|
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 "MemSpyEngineHelperSysMemTrackerEntryStack.h" |
|
19 |
|
20 // System includes |
|
21 #include <e32base.h> |
|
22 #include <badesca.h> |
|
23 |
|
24 // Driver includes |
|
25 #include <memspy/driver/memspydriverclient.h> |
|
26 |
|
27 // User includes |
|
28 #include <memspy/engine/memspyengine.h> |
|
29 #include <memspy/engine/memspyengineutils.h> |
|
30 #include <memspy/engine/memspyengineoutputsink.h> |
|
31 #include <memspy/engine/memspyengineoutputlist.h> |
|
32 #include <memspy/engine/memspyenginehelperheap.h> |
|
33 #include <memspy/engine/memspyenginehelperchunk.h> |
|
34 #include <memspy/engine/memspyengineobjectthread.h> |
|
35 #include <memspy/engine/memspyengineobjectprocess.h> |
|
36 #include <memspy/engine/memspyengineobjectcontainer.h> |
|
37 #include <memspy/engine/memspyenginehelpercodesegment.h> |
|
38 #include "MemSpyEngineHelperSysMemTrackerImp.h" |
|
39 #include <memspy/engine/memspyenginehelpersysmemtrackercycle.h> |
|
40 #include <memspy/engine/memspyenginehelpersysmemtrackerconfig.h> |
|
41 |
|
42 |
|
43 CMemSpyEngineHelperSysMemTrackerEntryStack::CMemSpyEngineHelperSysMemTrackerEntryStack( CMemSpyEngineHelperSysMemTrackerImp& aTracker, const TMemSpyDriverChunkInfo& aChunkInfo, const TThreadStackInfo& aStackInfo ) |
|
44 : CMemSpyEngineHelperSysMemTrackerEntry( aTracker, EMemSpyEngineSysMemTrackerTypeStack ), iChunkInfo( aChunkInfo ), iStackInfo( aStackInfo ) |
|
45 { |
|
46 SetHandle( aChunkInfo.iHandle ); |
|
47 } |
|
48 |
|
49 |
|
50 CMemSpyEngineHelperSysMemTrackerEntryStack::~CMemSpyEngineHelperSysMemTrackerEntryStack() |
|
51 { |
|
52 delete iThreadName; |
|
53 } |
|
54 |
|
55 |
|
56 void CMemSpyEngineHelperSysMemTrackerEntryStack::ConstructL( CMemSpyThread& aThread ) |
|
57 { |
|
58 TFullName* name = new(ELeave) TFullName(); |
|
59 CleanupStack::PushL( name ); |
|
60 aThread.FullName( *name ); |
|
61 iThreadName = name->AllocL(); |
|
62 CleanupStack::PopAndDestroy( name ); |
|
63 // |
|
64 SetThread( aThread.Id() ); |
|
65 SetProcess( aThread.Process().Id() ); |
|
66 } |
|
67 |
|
68 |
|
69 CMemSpyEngineHelperSysMemTrackerEntryStack* CMemSpyEngineHelperSysMemTrackerEntryStack::NewLC( CMemSpyEngineHelperSysMemTrackerImp& aTracker, CMemSpyThread& aThread, const TMemSpyDriverChunkInfo& aChunkInfo, const TThreadStackInfo& aStackInfo ) |
|
70 { |
|
71 CMemSpyEngineHelperSysMemTrackerEntryStack* self = new(ELeave) CMemSpyEngineHelperSysMemTrackerEntryStack( aTracker, aChunkInfo, aStackInfo ); |
|
72 CleanupStack::PushL( self ); |
|
73 self->ConstructL( aThread ); |
|
74 return self; |
|
75 } |
|
76 |
|
77 |
|
78 TUint64 CMemSpyEngineHelperSysMemTrackerEntryStack::Key() const |
|
79 { |
|
80 const TUint32 val = ( Type() << 28 ) + ThreadId(); |
|
81 TUint64 ret = val; |
|
82 ret <<= 32; |
|
83 ret += Handle(); |
|
84 return ret; |
|
85 } |
|
86 |
|
87 |
|
88 void CMemSpyEngineHelperSysMemTrackerEntryStack::CreateChangeDescriptorL( CMemSpyEngineHelperSysMemTrackerCycle& aCycle ) |
|
89 { |
|
90 CMemSpyEngineHelperSysMemTrackerCycleChangeStack* changeDescriptor = CMemSpyEngineHelperSysMemTrackerCycleChangeStack::NewLC( Attributes(), *iThreadName, iChunkInfo, iStackInfo ); |
|
91 aCycle.AddAndPopL( changeDescriptor ); |
|
92 } |
|
93 |
|
94 |
|
95 void CMemSpyEngineHelperSysMemTrackerEntryStack::UpdateCycleStatistics( CMemSpyEngineHelperSysMemTrackerCycle& aCycle ) |
|
96 { |
|
97 const TInt size = StackSize(); |
|
98 aCycle.AddToMemoryUsed( size ); |
|
99 } |
|
100 |
|
101 |
|
102 TInt CMemSpyEngineHelperSysMemTrackerEntryStack::StackSize() const |
|
103 { |
|
104 const TInt size = iStackInfo.iBase - iStackInfo.iLimit; |
|
105 return size; |
|
106 } |
|
107 |
|
108 |
|
109 |
|
110 |
|
111 |
|
112 |
|
113 |
|
114 |
|
115 |
|
116 |
|
117 |
|
118 |
|
119 |
|
120 |
|
121 |
|
122 |
|
123 |
|
124 |
|
125 |
|
126 |
|
127 |
|
128 |
|
129 |
|
130 |
|
131 |
|
132 |
|
133 |
|
134 |
|
135 |
|
136 |
|
137 |
|
138 |
|
139 |
|
140 |
|
141 |
|
142 |
|
143 |
|
144 |
|
145 |
|
146 |
|
147 CMemSpyEngineHelperSysMemTrackerCycleChangeStack::CMemSpyEngineHelperSysMemTrackerCycleChangeStack( TUint8 aAttribs, const TMemSpyDriverChunkInfo& aChunkInfo, const TThreadStackInfo& aStackInfo ) |
|
148 : CMemSpyEngineHelperSysMemTrackerCycleChange( aAttribs ), iChunkInfo( aChunkInfo ), iStackInfo( aStackInfo ) |
|
149 { |
|
150 } |
|
151 |
|
152 |
|
153 CMemSpyEngineHelperSysMemTrackerCycleChangeStack::~CMemSpyEngineHelperSysMemTrackerCycleChangeStack() |
|
154 { |
|
155 delete iThreadName; |
|
156 } |
|
157 |
|
158 |
|
159 void CMemSpyEngineHelperSysMemTrackerCycleChangeStack::ConstructL( const TDesC& aThreadName ) |
|
160 { |
|
161 BaseConstructL(); |
|
162 |
|
163 // Save the thread name |
|
164 iThreadName = aThreadName.AllocL(); |
|
165 } |
|
166 |
|
167 |
|
168 CMemSpyEngineHelperSysMemTrackerCycleChangeStack* CMemSpyEngineHelperSysMemTrackerCycleChangeStack::NewLC( TUint8 aAttribs, const TDesC& aThreadName, const TMemSpyDriverChunkInfo& aChunkInfo, const TThreadStackInfo& aStackInfo ) |
|
169 { |
|
170 CMemSpyEngineHelperSysMemTrackerCycleChangeStack* self = new(ELeave) CMemSpyEngineHelperSysMemTrackerCycleChangeStack( aAttribs, aChunkInfo, aStackInfo ); |
|
171 CleanupStack::PushL( self ); |
|
172 self->ConstructL( aThreadName ); |
|
173 return self; |
|
174 } |
|
175 |
|
176 |
|
177 TMemSpyEngineSysMemTrackerType CMemSpyEngineHelperSysMemTrackerCycleChangeStack::Type() const |
|
178 { |
|
179 return EMemSpyEngineSysMemTrackerTypeStack; |
|
180 } |
|
181 |
|
182 |
|
183 void CMemSpyEngineHelperSysMemTrackerCycleChangeStack::OutputHeaderL( CMemSpyEngineOutputSink& aSink, CMemSpyEngineHelperSysMemTrackerCycle& /*aCycle*/ ) |
|
184 { |
|
185 _LIT( KHeaderStack, "Type, Thread, Chunk, Handle, Size, Attribs"); |
|
186 aSink.OutputLineL( KHeaderStack ); |
|
187 } |
|
188 |
|
189 |
|
190 void CMemSpyEngineHelperSysMemTrackerCycleChangeStack::OutputContentL( CMemSpyEngineOutputSink& aSink, CMemSpyEngineHelperSysMemTrackerCycle& /*aCycle*/ ) |
|
191 { |
|
192 _LIT( KFormat, "%S,%S,%S,0x%08x,%d,%S" ); |
|
193 // |
|
194 TMemSpySWMTTypeName type;; |
|
195 FormatType( type ); |
|
196 // |
|
197 TBuf<20> attribs; |
|
198 FormatAttributes( attribs ); |
|
199 // |
|
200 HBufC* buf = HBufC::NewLC( 1024 ); |
|
201 TPtr pBuf(buf->Des()); |
|
202 |
|
203 pBuf.Format( KFormat, |
|
204 &type, |
|
205 iThreadName, |
|
206 &iChunkInfo.iName, |
|
207 iChunkInfo.iHandle, |
|
208 StackSize(), |
|
209 &attribs |
|
210 ); |
|
211 |
|
212 aSink.OutputLineL( pBuf ); |
|
213 CleanupStack::PopAndDestroy( buf ); |
|
214 } |
|
215 |
|
216 |
|
217 void CMemSpyEngineHelperSysMemTrackerCycleChangeStack::OutputDataL( CMemSpyEngineOutputSink& aSink, CMemSpyEngineHelperSysMemTrackerCycle& /*aCycle*/ ) |
|
218 { |
|
219 CMemSpyEngine& engine = aSink.Engine(); |
|
220 } |
|
221 |
|
222 |
|
223 TInt CMemSpyEngineHelperSysMemTrackerCycleChangeStack::StackSize() const |
|
224 { |
|
225 const TInt size = iStackInfo.iBase - iStackInfo.iLimit; |
|
226 return size; |
|
227 } |
|
228 |
|
229 |