|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "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 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "MemSpyEngineHelperSysMemTrackerEntryHandleGeneric.h" |
|
19 |
|
20 // System includes |
|
21 #include <e32base.h> |
|
22 #include <badesca.h> |
|
23 |
|
24 // Driver includes |
|
25 #include <memspy/driver/memspydriverclient.h> |
|
26 #include <memspy/driver/memspydriverconstants.h> |
|
27 #include <memspy/driver/memspydriverenumerationsshared.h> |
|
28 |
|
29 // User includes |
|
30 #include <memspy/engine/memspyengine.h> |
|
31 #include <memspy/engine/memspyengineutils.h> |
|
32 #include <memspy/engine/memspyengineoutputsink.h> |
|
33 #include <memspy/engine/memspyengineoutputlist.h> |
|
34 #include <memspy/engine/memspyenginehelperheap.h> |
|
35 #include <memspy/engine/memspyenginehelperchunk.h> |
|
36 #include <memspy/engine/memspyengineobjectthread.h> |
|
37 #include <memspy/engine/memspyengineobjectprocess.h> |
|
38 #include <memspy/engine/memspyengineobjectcontainer.h> |
|
39 #include <memspy/engine/memspyenginehelpercodesegment.h> |
|
40 #include "MemSpyEngineHelperSysMemTrackerImp.h" |
|
41 #include <memspy/engine/memspyenginehelperkernelcontainers.h> |
|
42 #include <memspy/engine/memspyenginehelpersysmemtrackercycle.h> |
|
43 #include <memspy/engine/memspyenginehelpersysmemtrackerconfig.h> |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 CMemSpyEngineHelperSysMemTrackerEntryHandleGeneric::CMemSpyEngineHelperSysMemTrackerEntryHandleGeneric( CMemSpyEngineHelperSysMemTrackerImp& aTracker, TMemSpyDriverContainerType aType ) |
|
49 : CMemSpyEngineHelperSysMemTrackerEntry( aTracker, EMemSpyEngineSysMemTrackerTypeHandleGeneric ), iHandleType( aType ) |
|
50 { |
|
51 } |
|
52 |
|
53 |
|
54 CMemSpyEngineHelperSysMemTrackerEntryHandleGeneric::~CMemSpyEngineHelperSysMemTrackerEntryHandleGeneric() |
|
55 { |
|
56 delete iName; |
|
57 } |
|
58 |
|
59 |
|
60 void CMemSpyEngineHelperSysMemTrackerEntryHandleGeneric::ConstructL( TAny* aHandle ) |
|
61 { |
|
62 SetHandle( aHandle ); |
|
63 } |
|
64 |
|
65 |
|
66 CMemSpyEngineHelperSysMemTrackerEntryHandleGeneric* CMemSpyEngineHelperSysMemTrackerEntryHandleGeneric::NewLC( CMemSpyEngineHelperSysMemTrackerImp& aTracker, TAny* aHandle, TMemSpyDriverContainerType aType ) |
|
67 { |
|
68 CMemSpyEngineHelperSysMemTrackerEntryHandleGeneric* self = new(ELeave) CMemSpyEngineHelperSysMemTrackerEntryHandleGeneric( aTracker, aType ); |
|
69 CleanupStack::PushL( self ); |
|
70 self->ConstructL( aHandle ); |
|
71 return self; |
|
72 } |
|
73 |
|
74 |
|
75 TUint64 CMemSpyEngineHelperSysMemTrackerEntryHandleGeneric::Key() const |
|
76 { |
|
77 const TUint32 val = ( Type() << 28 ) + iHandleType; |
|
78 TUint64 ret = val; |
|
79 ret <<= 32; |
|
80 ret += Handle(); |
|
81 return ret; |
|
82 } |
|
83 |
|
84 |
|
85 void CMemSpyEngineHelperSysMemTrackerEntryHandleGeneric::CreateChangeDescriptorL( CMemSpyEngineHelperSysMemTrackerCycle& aCycle ) |
|
86 { |
|
87 // We lazy fetch the name to avoid having to get info for every single handle whenever a change cycle occurs... |
|
88 if ( iName == NULL ) |
|
89 { |
|
90 TMemSpyDriverHandleInfoGeneric info; |
|
91 const TInt err = Engine().Driver().GetGenericHandleInfo( KMemSpyDriverEnumerateContainerHandles, iHandleType, (TAny*) Handle(), info ); |
|
92 if ( err == KErrNone ) |
|
93 { |
|
94 // Save name |
|
95 iName = HBufC::NewL( info.iName.Length() ); |
|
96 iName->Des().Copy( info.iName ); |
|
97 } |
|
98 else |
|
99 { |
|
100 iName = KNullDesC().AllocL(); |
|
101 } |
|
102 } |
|
103 |
|
104 CMemSpyEngineHelperSysMemTrackerCycleChangeHandleGeneric* changeDescriptor = CMemSpyEngineHelperSysMemTrackerCycleChangeHandleGeneric::NewLC( Attributes(), *iName, Handle(), iHandleType ); |
|
105 aCycle.AddAndPopL( changeDescriptor ); |
|
106 } |
|
107 |
|
108 |
|
109 |
|
110 |
|
111 |
|
112 |
|
113 |
|
114 |
|
115 |
|
116 |
|
117 |
|
118 |
|
119 |
|
120 |
|
121 |
|
122 |
|
123 |
|
124 CMemSpyEngineHelperSysMemTrackerCycleChangeHandleGeneric::CMemSpyEngineHelperSysMemTrackerCycleChangeHandleGeneric( TUint8 aAttribs, TUint32 aHandle, TMemSpyDriverContainerType aType ) |
|
125 : CMemSpyEngineHelperSysMemTrackerCycleChange( aAttribs ), iHandle( aHandle ), iType( aType ) |
|
126 { |
|
127 } |
|
128 |
|
129 |
|
130 CMemSpyEngineHelperSysMemTrackerCycleChangeHandleGeneric::~CMemSpyEngineHelperSysMemTrackerCycleChangeHandleGeneric() |
|
131 { |
|
132 delete iName; |
|
133 } |
|
134 |
|
135 |
|
136 void CMemSpyEngineHelperSysMemTrackerCycleChangeHandleGeneric::ConstructL( const TDesC& aName ) |
|
137 { |
|
138 BaseConstructL(); |
|
139 |
|
140 // Save the thread name |
|
141 iName = aName.AllocL(); |
|
142 } |
|
143 |
|
144 |
|
145 CMemSpyEngineHelperSysMemTrackerCycleChangeHandleGeneric* CMemSpyEngineHelperSysMemTrackerCycleChangeHandleGeneric::NewLC( TUint8 aAttribs, const TDesC& aName, TUint32 aHandle, TMemSpyDriverContainerType aType ) |
|
146 { |
|
147 CMemSpyEngineHelperSysMemTrackerCycleChangeHandleGeneric* self = new(ELeave) CMemSpyEngineHelperSysMemTrackerCycleChangeHandleGeneric( aAttribs, aHandle, aType ); |
|
148 CleanupStack::PushL( self ); |
|
149 self->ConstructL( aName ); |
|
150 return self; |
|
151 } |
|
152 |
|
153 |
|
154 TMemSpyEngineSysMemTrackerType CMemSpyEngineHelperSysMemTrackerCycleChangeHandleGeneric::Type() const |
|
155 { |
|
156 return EMemSpyEngineSysMemTrackerTypeHandleGeneric; |
|
157 } |
|
158 |
|
159 |
|
160 void CMemSpyEngineHelperSysMemTrackerCycleChangeHandleGeneric::OutputHeaderL( CMemSpyEngineOutputSink& aSink, CMemSpyEngineHelperSysMemTrackerCycle& /*aCycle*/ ) |
|
161 { |
|
162 _LIT( KHeaderLine, "Type, Name, Handle, Handle Type, Attribs"); |
|
163 aSink.OutputLineL( KHeaderLine ); |
|
164 } |
|
165 |
|
166 |
|
167 void CMemSpyEngineHelperSysMemTrackerCycleChangeHandleGeneric::OutputContentL( CMemSpyEngineOutputSink& aSink, CMemSpyEngineHelperSysMemTrackerCycle& /*aCycle*/ ) |
|
168 { |
|
169 _LIT( KFormat, "%S,%S,0x%08x,%S,%S" ); |
|
170 // |
|
171 TMemSpySWMTTypeName type; |
|
172 FormatType( type ); |
|
173 // |
|
174 TBuf<20> attribs; |
|
175 FormatAttributes( attribs ); |
|
176 // |
|
177 HBufC* buf = HBufC::NewLC( 1024 ); |
|
178 TPtr pBuf(buf->Des()); |
|
179 // |
|
180 const TPtrC pType( CMemSpyEngineGenericKernelObjectList::TypeAsString( iType ) ); |
|
181 |
|
182 // Now output line |
|
183 pBuf.Format( KFormat, |
|
184 &type, |
|
185 iName, |
|
186 iHandle, |
|
187 &pType, |
|
188 &attribs |
|
189 ); |
|
190 |
|
191 aSink.OutputLineL( pBuf ); |
|
192 CleanupStack::PopAndDestroy( buf ); |
|
193 } |
|
194 |
|
195 |
|
196 |