|
1 // heaptrace.cpp |
|
2 // |
|
3 // Copyright (c) 2009 - 2010 Accenture. All rights reserved. |
|
4 // This component and the accompanying materials are made available |
|
5 // under the terms of the "Eclipse Public License v1.0" |
|
6 // which accompanies this distribution, and is available |
|
7 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 // |
|
9 // Initial Contributors: |
|
10 // Accenture - Initial contribution |
|
11 // |
|
12 |
|
13 #include <fshell/memoryaccesscmd.h> |
|
14 #include <fshell/common.mmh> |
|
15 |
|
16 using namespace IoUtils; |
|
17 |
|
18 class CCmdHeapTrace : public CMemoryAccessCommandBase |
|
19 { |
|
20 public: |
|
21 static CCommandBase* NewLC(); |
|
22 ~CCmdHeapTrace(); |
|
23 private: |
|
24 CCmdHeapTrace(); |
|
25 private: // From CCommandBase. |
|
26 virtual const TDesC& Name() const; |
|
27 virtual void DoRunL(); |
|
28 virtual void ArgumentsL(RCommandArgumentList& aArguments); |
|
29 private: |
|
30 enum TCmd |
|
31 { |
|
32 EEnable, |
|
33 EDisable, |
|
34 //EDump |
|
35 }; |
|
36 TCmd iCommand; |
|
37 TUint iThreadId; |
|
38 }; |
|
39 |
|
40 EXE_BOILER_PLATE(CCmdHeapTrace) |
|
41 |
|
42 CCommandBase* CCmdHeapTrace::NewLC() |
|
43 { |
|
44 CCmdHeapTrace* self = new(ELeave) CCmdHeapTrace(); |
|
45 CleanupStack::PushL(self); |
|
46 self->BaseConstructL(); |
|
47 return self; |
|
48 } |
|
49 |
|
50 CCmdHeapTrace::~CCmdHeapTrace() |
|
51 { |
|
52 } |
|
53 |
|
54 CCmdHeapTrace::CCmdHeapTrace() |
|
55 { |
|
56 } |
|
57 |
|
58 const TDesC& CCmdHeapTrace::Name() const |
|
59 { |
|
60 _LIT(KName, "heaptrace"); |
|
61 return KName; |
|
62 } |
|
63 |
|
64 void CCmdHeapTrace::ArgumentsL(RCommandArgumentList& aArguments) |
|
65 { |
|
66 aArguments.AppendEnumL((TInt&)iCommand, _L("command")); |
|
67 aArguments.AppendUintL(iThreadId, _L("thread_id")); |
|
68 } |
|
69 |
|
70 void CCmdHeapTrace::DoRunL() |
|
71 { |
|
72 LoadMemoryAccessL(); |
|
73 TInt err; |
|
74 switch (iCommand) |
|
75 { |
|
76 case EEnable: |
|
77 err = iMemAccess.EnableHeapTracing(iThreadId, ETrue); |
|
78 LeaveIfErr(err, _L("Couldn't enable tracing.")); |
|
79 break; |
|
80 case EDisable: |
|
81 err = iMemAccess.EnableHeapTracing(iThreadId, EFalse); |
|
82 LeaveIfErr(err, _L("Couldn't disable tracing.")); |
|
83 break; |
|
84 } |
|
85 } |