19 |
19 |
20 // System includes |
20 // System includes |
21 #include <bacline.h> |
21 #include <bacline.h> |
22 #include <bautils.h> |
22 #include <bautils.h> |
23 #include <memspyengineclientinterface.h> |
23 #include <memspyengineclientinterface.h> |
24 #include <memspysession.h> |
|
25 #include <memspy/engine/memspyenginehelpersysmemtrackerconfig.h> |
24 #include <memspy/engine/memspyenginehelpersysmemtrackerconfig.h> |
26 |
25 |
27 // User includes |
26 // User includes |
28 #include "MemSpyCommands.h" |
27 #include "MemSpyCommands.h" |
29 |
28 |
30 /* |
29 |
31 CMemSpyCommandLine::CMemSpyCommandLine() |
30 CMemSpyCommandLine::CMemSpyCommandLine() |
32 { |
31 { |
33 } |
32 } |
34 */ |
33 |
35 |
|
36 CMemSpyCommandLine::CMemSpyCommandLine( CConsoleBase& aConsole ) |
|
37 : CActive( EPriorityHigh ), iConsole( aConsole ) |
|
38 { |
|
39 CActiveScheduler::Add( this ); |
|
40 } |
|
41 |
34 |
42 CMemSpyCommandLine::~CMemSpyCommandLine() |
35 CMemSpyCommandLine::~CMemSpyCommandLine() |
43 { |
36 { |
44 Cancel(); |
37 if ( iMemSpy ) |
45 |
38 { |
46 if ( iMemSpySession ) |
39 iMemSpy->Close(); |
47 { |
40 } |
48 iMemSpySession->Close(); |
41 delete iMemSpy; |
49 } |
|
50 delete iMemSpySession; |
|
51 iFsSession.Close(); |
42 iFsSession.Close(); |
52 } |
43 } |
53 |
44 |
54 |
45 |
55 void CMemSpyCommandLine::ConstructL() |
46 void CMemSpyCommandLine::ConstructL() |
56 { |
47 { |
57 User::LeaveIfError( iFsSession.Connect() ); |
48 User::LeaveIfError( iFsSession.Connect() ); |
58 iMemSpySession = new(ELeave) RMemSpySession(); |
49 iMemSpy = new(ELeave) RMemSpyEngineClientInterface(); |
59 ConnectToMemSpyL(); |
50 ConnectToMemSpyL(); |
60 } |
51 } |
61 |
52 |
62 CMemSpyCommandLine* CMemSpyCommandLine::NewLC( CConsoleBase& aConsole ) |
53 |
63 { |
54 CMemSpyCommandLine* CMemSpyCommandLine::NewLC() |
64 CMemSpyCommandLine* self = new(ELeave) CMemSpyCommandLine( aConsole ); |
55 { |
|
56 CMemSpyCommandLine* self = new(ELeave) CMemSpyCommandLine(); |
65 CleanupStack::PushL( self ); |
57 CleanupStack::PushL( self ); |
66 self->ConstructL(); |
58 self->ConstructL(); |
67 return self; |
59 return self; |
68 } |
60 } |
|
61 |
|
62 |
|
63 void CMemSpyCommandLine::PerformBatchL( const TDesC& aFileName ) |
|
64 { |
|
65 TInt err = KErrNone; |
|
66 RFile file; |
|
67 err = file.Open( iFsSession, aFileName, EFileRead ); |
|
68 TRACE( RDebug::Print( _L("[MemSpyCmdLine] CMemSpyCommandLine::PerformBatchL() - START - this: 0x%08x, openErr: %d, fileName: %S"), this, err, &aFileName ) ); |
|
69 User::LeaveIfError( err ); |
|
70 |
|
71 CleanupClosePushL( file ); |
|
72 CDesCArray* lines = ReadLinesL( file ); |
|
73 CleanupStack::PopAndDestroy( &file ); |
|
74 CleanupStack::PushL( lines ); |
|
75 |
|
76 const TInt count = lines->Count(); |
|
77 TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::PerformOpL() - got %d lines", count ) ); |
|
78 iIsBatch = ETrue; |
|
79 for( TInt i=0; i<count; i++ ) |
|
80 { |
|
81 const TPtrC pLine( (*lines)[ i ] ); |
|
82 TRACE( RDebug::Print( _L("[MemSpyCmdLine] CMemSpyCommandLine::PerformOpL() - processing line[%03d] \"%S\""), i, &pLine ) ); |
|
83 |
|
84 // Must be at least 3 chars big, i.e. '[' and <command> and then ']' |
|
85 if ( pLine.Length() <= 2 || pLine[ 0 ] != '[' ) |
|
86 { |
|
87 TRACE( RDebug::Print( _L("[MemSpyCmdLine] CMemSpyCommandLine::PerformOpL() - ignoring line: \"%S\""), &pLine ) ); |
|
88 } |
|
89 else if ( pLine[0] == '[' ) |
|
90 { |
|
91 // Try to find end of command... |
|
92 const TInt posOfClosingArgChar = pLine.Locate( ']' ); |
|
93 if ( posOfClosingArgChar >= 2 ) |
|
94 { |
|
95 // Get command |
|
96 const TPtrC pCommand( pLine.Mid( 1, posOfClosingArgChar - 1 ) ); |
|
97 TRACE( RDebug::Print( _L("[MemSpyCmdLine] CMemSpyCommandLine::PerformOpL() - got command: %S"), &pCommand ) ); |
|
98 |
|
99 // Next, try to get any args |
|
100 CDesCArrayFlat* args = new(ELeave) CDesCArrayFlat( 2 ); |
|
101 CleanupStack::PushL( args ); |
|
102 |
|
103 // There must be a mandatory space between closing ] and start of args... |
|
104 // E.g.: |
|
105 // |
|
106 // [CMD] ARG |
|
107 // |
|
108 const TInt remainderLength = pLine.Length() - posOfClosingArgChar; |
|
109 if ( remainderLength > 1 ) |
|
110 { |
|
111 const TPtrC remainder( pLine.Mid( posOfClosingArgChar + 1 ) ); |
|
112 TRACE( RDebug::Print( _L("[MemSpyCmdLine] CMemSpyCommandLine::PerformOpL() - got remainder: %S"), &pLine ) ); |
|
113 |
|
114 // Extract arguments separated by tabs or space characters |
|
115 // and store in arguments array |
|
116 HBufC* argText = HBufC::NewLC( pLine.Length() + 1 ); |
|
117 TPtr pArgText( argText->Des() ); |
|
118 for( TInt j=0; j<remainder.Length(); j++ ) |
|
119 { |
|
120 const TChar c( remainder[ j ] ); |
|
121 // |
|
122 if ( c == '\t' || c == ' ' ) |
|
123 { |
|
124 pArgText.Trim(); |
|
125 if ( pArgText.Length() ) |
|
126 { |
|
127 TRACE( RDebug::Print( _L("[MemSpyCmdLine] CMemSpyCommandLine::PerformOpL() - arg[%02d] %S"), args->Count(), &pArgText ) ); |
|
128 args->AppendL( pArgText ); |
|
129 pArgText.Zero(); |
|
130 } |
|
131 } |
|
132 else |
|
133 { |
|
134 pArgText.Append( c ); |
|
135 } |
|
136 } |
|
137 |
|
138 // Save leftovers... |
|
139 pArgText.Trim(); |
|
140 if ( pArgText.Length() ) |
|
141 { |
|
142 TRACE( RDebug::Print( _L("[MemSpyCmdLine] CMemSpyCommandLine::PerformOpL() - arg[%02d] %S"), args->Count(), &pArgText ) ); |
|
143 args->AppendL( pArgText ); |
|
144 } |
|
145 |
|
146 CleanupStack::PopAndDestroy( argText ); |
|
147 } |
|
148 |
|
149 // Now we can perform the operation! |
|
150 PerformSingleOpL( pCommand, *args ); |
|
151 |
|
152 CleanupStack::PopAndDestroy( args ); |
|
153 } |
|
154 } |
|
155 |
|
156 TRACE( RDebug::Print( _L("[MemSpyCmdLine] CMemSpyCommandLine::PerformOpL() - processing line: \"%S\""), &pLine ) ); |
|
157 } |
|
158 |
|
159 iIsBatch = EFalse; |
|
160 |
|
161 CleanupStack::PopAndDestroy( lines ); |
|
162 TRACE( RDebug::Print( _L("[MemSpyCmdLine] CMemSpyCommandLine::PerformBatchL() - END - this: 0x%08x, fileName: %S"), this, &aFileName ) ); |
|
163 } |
|
164 |
69 |
165 |
70 void CMemSpyCommandLine::PerformOpL( const CCommandLineArguments& aCommandLine ) |
166 void CMemSpyCommandLine::PerformOpL( const CCommandLineArguments& aCommandLine ) |
71 { |
167 { |
72 const TInt count = aCommandLine.Count(); |
168 const TInt count = aCommandLine.Count(); |
73 TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::PerformOpL() - START - arg count: %d, this: 0x%08x", count, this ) ); |
169 TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::PerformOpL() - START - arg count: %d, this: 0x%08x", count, this ) ); |
120 |
216 |
121 TFileName batchFile; |
217 TFileName batchFile; |
122 batchFile.Append( aCommand ); |
218 batchFile.Append( aCommand ); |
123 |
219 |
124 TInt err = KErrNotSupported; |
220 TInt err = KErrNotSupported; |
125 TInt error = KErrNotSupported; |
221 if ( aCommand.CompareF( KMemSpyCmdSWMTForceUpdate ) == 0 ) |
126 |
222 { |
127 // --- HELP |
223 TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::PerformSingleOpL() - this: 0x%08x - SWMT_ForceUpdate", this ) ); |
128 if ( aCommand.CompareF( KMemSpyCmdHelp1) == 0 || |
224 if ( paramCount > 0 ) |
129 aCommand.CompareF( KMemSpyCmdHelp2) == 0 || |
225 { |
130 aCommand.CompareF( KMemSpyCmdHelp3) == 0 || |
226 TInt categories( 0 ); |
131 aCommand.CompareF( KMemSpyCmdHelp4) == 0 ) |
227 TName threadNameFilter; |
132 { |
228 TRAP( err, ParseSWMTParametersL( aParameters, categories, threadNameFilter ) ); |
133 iConsole.Write( KHelpMessage ); |
229 if ( !err ) |
134 iConsole.Write( KMemSpyCLINewLine ); |
230 { |
135 iConsole.Write( KHelpOutputCommand ); |
231 err = iMemSpy->SystemWideMemoryTrackerCategoriesSet( categories ); |
136 iConsole.Write( KHelpOutputToFileCommand ); |
232 if ( !err && threadNameFilter.Length() > 0 ) |
137 iConsole.Write( KHelpHeapDumpCommand ); |
233 { |
138 iConsole.Write( KHelpSwmtCommand ); |
234 err = iMemSpy->SystemWideMemoryTrackerThreadFilterSet( threadNameFilter ); |
139 iConsole.Write( KHelpKillServerCommand ); |
235 } |
140 iConsole.Write( KMemSpyCLINewLine ); |
236 } |
141 iConsole.Write( KHelpCommand ); |
237 } |
142 |
238 if ( !err ) |
143 // Show input prompt. |
239 { |
144 iCommandPromptPos = iConsole.CursorPos(); |
240 err = iMemSpy->PerformOperation( EMemSpyClientServerOpSystemWideMemoryTrackingForceUpdate ); |
145 RedrawInputPrompt(); |
241 } |
146 WaitForInput(); |
242 } |
147 |
243 else if ( aCommand.CompareF( KMemSpyCmdSWMTReset ) == 0 ) |
148 CActiveScheduler::Start(); |
244 { |
149 } |
245 TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::PerformSingleOpL() - this: 0x%08x - SWMT_Reset", this ) ); |
150 // --- OUTPUT |
246 err = iMemSpy->PerformOperation( EMemSpyClientServerOpSystemWideMemoryTrackingReset ); |
151 //TODO: directory option to be added |
247 } |
152 else if ( aCommand.CompareF( KMemSpyCmdOutput ) == 0 ) //change output mode |
248 else if ( aCommand.CompareF( KMemSpyCmdHeapDumpKernel ) == 0 ) |
153 { |
249 { |
154 if( paramCount >= 1 ) |
250 TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::PerformSingleOpL() - this: 0x%08x - Heap_DumpKernel", this ) ); |
155 { |
251 err = iMemSpy->PerformOperation( EMemSpyClientServerOpHeapData, KMemSpyClientServerThreadIdKernel ); |
156 if( aParameters[0].CompareF( KMemSpyCmdOutputParameterFile ) == 0 ) |
252 } |
157 { |
253 else if ( aCommand.CompareF( KMemSpyCmdHeapCompact ) == 0 ) |
158 if( paramCount == 2 ) |
254 { |
159 { |
255 TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::PerformSingleOpL() - this: 0x%08x - Heap_Compact", this ) ); |
160 TBuf<KMaxFileName> directory; |
256 err = iMemSpy->PerformOperation( EMemSpyClientServerOpHeapInfoCompact ); |
161 directory.Copy( aParameters[1] ); |
257 } |
162 iMemSpySession->SwitchOutputToFileL( directory ); |
258 else if ( aCommand.CompareF( KMemSpyCmdContainer ) == 0 ) |
163 } |
259 { |
164 else |
260 TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::PerformSingleOpL() - this: 0x%08x - Container", this ) ); |
165 { |
261 err = iMemSpy->PerformOperation( EMemSpyClientServerOpEnumerateKernelContainerAll ); |
166 iMemSpySession->SwitchOutputToFileL( KNullDesC ); |
262 } |
167 } |
263 else if ( aCommand.CompareF( KMemSpyCmdBitmapsSave ) == 0 ) |
168 } |
264 { |
169 else if( aParameters[0].CompareF( KMemSpyCmdOutputParameterTrace ) == 0) |
265 TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::PerformSingleOpL() - this: 0x%08x - Bitmaps_Save", this ) ); |
170 { |
266 err = iMemSpy->SaveAllBitmaps(); |
171 TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::PerformSingleOpL() - this: 0x%08x - Output Trace", this ) ); |
267 } |
172 iMemSpySession->SwitchOutputToTraceL(); |
268 else if ( aCommand.CompareF( KMemSpyCmdRamDisableAknIconCache ) == 0 ) |
173 } |
269 { |
174 } |
270 TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::PerformSingleOpL() - this: 0x%08x - Ram_DisableAknIconCache", this ) ); |
175 } |
271 err = iMemSpy->DisableAknIconCache(); |
176 // --- HEAP DUMP |
272 } |
177 else if ( aCommand.CompareF( KMemSpyCmdHeapDump) == 0 ) |
273 else if ( aCommand.CompareF( KMemSpyCmdOutputToFile ) == 0 ) |
178 { |
274 { |
179 RedrawStatusMessage( KHeapDumpMessage ); |
275 TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::PerformSingleOpL() - this: 0x%08x - Output_ToFile", this ) ); |
180 |
276 err = iMemSpy->SwitchOutputModeFile(); |
181 if( paramCount == 0 ) // no parameter - dump all heap data + kernel heap at the end |
277 } |
182 { |
278 else if ( aCommand.CompareF( KMemSpyCmdOutputToTrace ) == 0 ) |
183 |
279 { |
184 TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::PerformSingleOpL() - this: 0x%08x - Heap_Dump (all threads)", this ) ); |
280 TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::PerformSingleOpL() - this: 0x%08x - Output_ToTrace", this ) ); |
185 // Dump heap data for all threads - Thread agnostic operation |
281 err = iMemSpy->SwitchOutputModeTrace(); |
186 iMemSpySession->OutputHeapData(); |
282 } |
187 // Dump kernel heap data |
283 else if ( aCommand.CompareF( KMemSpyCmdUiSendToBackground ) == 0 ) |
188 iMemSpySession->OutputThreadHeapDataL( KMemSpyClientServerThreadIdKernel ); |
284 { |
189 } |
285 TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::PerformSingleOpL() - this: 0x%08x - UI_Background", this ) ); |
190 else if( paramCount >= 1) |
286 err = iMemSpy->SendToBackground(); |
191 { |
287 } |
192 if( aParameters[0].CompareF( KMemSpyCmdHeapDumpParameterAll ) == 0 ) |
288 else if ( aCommand.CompareF( KMemSpyCmdUiBringToForeground ) == 0 ) |
193 { |
289 { |
194 iMemSpySession->OutputHeapData(); |
290 TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::PerformSingleOpL() - this: 0x%08x - UI_Foreground", this ) ); |
195 iMemSpySession->OutputThreadHeapDataL( KMemSpyClientServerThreadIdKernel ); |
291 err = iMemSpy->BringToForeground(); |
196 } |
292 } |
197 else if( aParameters[0].CompareF( KMemSpyCmdHeapDumpParameterKernel ) == 0 ) |
293 else if ( aCommand.CompareF( KMemSpyCmdUiExit ) == 0 ) |
198 { |
294 { |
199 TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::PerformSingleOpL() - this: 0x%08x - Heap_DumpKernel", this ) ); |
295 TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::PerformSingleOpL() - this: 0x%08x - UI_Exit", this ) ); |
200 iMemSpySession->OutputThreadHeapDataL( KMemSpyClientServerThreadIdKernel ); |
296 err = iMemSpy->Exit(); |
201 } |
297 } |
202 else |
298 else if ( aCommand.CompareF( KMemSpyCmdHeapDump ) == 0 ) |
203 { |
299 { |
204 // Dump heap data for named thread - filter |
300 if ( paramCount == 0 ) |
205 const TPtrC pThreadName( aParameters[0] ); |
301 { |
206 TRACE( RDebug::Print( _L("[MemSpyCmdLine] CMemSpyCommandLine::PerformSingleOpL() - this: 0x%08x - Heap_Dump (%S)"), this, &pThreadName ) ); |
302 // Dump heap data for all threads |
207 iMemSpySession->OutputThreadHeapDataL( pThreadName ); |
303 TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::PerformSingleOpL() - this: 0x%08x - Heap_Dump (all threads)", this ) ); |
208 } |
304 err = iMemSpy->PerformOperation( EMemSpyClientServerOpHeapData ); |
209 } |
305 } |
210 } |
306 else if ( paramCount >= 1 ) |
211 |
307 { |
212 // --- SYSTEM WIDE MEMORY TRACKING |
308 // Dump heap data for named thread |
213 else if( aCommand.CompareF( KMemSpyCmdSwmt ) == 0 ) |
309 const TPtrC pThreadName( aParameters[ 0 ] ); |
214 { |
310 TRACE( RDebug::Print( _L("[MemSpyCmdLine] CMemSpyCommandLine::PerformSingleOpL() - this: 0x%08x - Heap_Dump (%S)"), this, &pThreadName ) ); |
215 RedrawStatusMessage( KSWMTMessage ); |
311 err = iMemSpy->PerformOperation( EMemSpyClientServerOpHeapData, pThreadName ); |
216 |
312 } |
217 TInt categories( 0 ); |
313 } |
218 TName threadNameFilter; |
314 else if ( aCommand.CompareF( KMemSpyCmdOpenFile ) == 0 ) |
219 |
315 { |
220 if( paramCount == 0 ) //default state -> "dumpnow" command with "all" categories |
316 if ( paramCount == 0 ) |
221 { |
317 { |
222 TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::PerformSingleOpL() - this: 0x%08x - dumpnow command", this ) ); |
318 // Dump heap data for all threads |
223 TInt category = TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryAll; |
319 TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::PerformSingleOpL() - this: 0x%08x - OpenFile (all threads)", this ) ); |
224 iMemSpySession->SetSwmtCategoriesL( category ); |
320 err = iMemSpy->PerformOperation( EMemSpyClientServerOpOpenFiles ); |
225 iMemSpySession->ForceSwmtUpdateL(); |
321 } |
226 } |
322 else if ( paramCount >= 1 ) |
227 else if( paramCount >= 1) |
323 { |
228 { |
324 // Dump heap data for named thread |
229 const TPtrC pParam( aParameters[0] ); |
325 const TPtrC pThreadName( aParameters[ 0 ] ); |
230 if( pParam.CompareF( KMemSpyCmdSwmtParameterStarttimer) == 0 ) // "starttimer" - start tracking |
326 TRACE( RDebug::Print( _L("[MemSpyCmdLine] CMemSpyCommandLine::PerformSingleOpL() - this: 0x%08x - OpenFile (%S)"), this, &pThreadName ) ); |
231 { |
327 err = iMemSpy->PerformOperation( EMemSpyClientServerOpOpenFiles, pThreadName ); |
232 TInt result(0); |
328 } |
233 categories = TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryAll; |
329 } |
234 iMemSpySession->SetSwmtTimerIntervalL( KMemSpySysMemTrackerConfigMinTimerPeriod ); |
330 else if ( !iIsBatch && FindBatchFile( batchFile ) == KErrNone ) |
235 |
331 { |
236 if( paramCount >= 2 ) // user gave some optional parameters - <categories> or <value in seconds> |
332 TRACE( RDebug::Print( _L("[MemSpyCmdLine] CMemSpyCommandLine::PerformSingleOpL() - this: 0x%08x - Batch file: %S"), this, &batchFile ) ); |
237 { |
333 PerformBatchL( batchFile ); |
238 TLex lex( aParameters[1] ); |
334 } |
239 if ( lex.Val( result ) == KErrNone ) //if 2nd parameter is not number, then parse parameters |
335 else |
240 { |
336 { |
241 if( result >= KMemSpySysMemTrackerConfigMinTimerPeriod && result <= KMemSpySysMemTrackerConfigMaxTimerPeriod ) |
337 TRACE( RDebug::Print( _L("[MemSpyCmdLine] CMemSpyCommandLine::PerformSingleOpL() - this: 0x%08x - Unsupported Command: %S"), this, &aCommand ) ); |
242 { |
338 } |
243 iMemSpySession->SetSwmtTimerIntervalL( result ); ; |
339 |
244 } |
|
245 } |
|
246 TRAP( err, ParseSWMTParametersL( aParameters, categories, threadNameFilter) ); |
|
247 } |
|
248 |
|
249 //if( !err ) |
|
250 // { |
|
251 /* |
|
252 _LIT( KPressS, "Press 's' to stop the timer " ); |
|
253 iConsole.Write( KPressS ); |
|
254 |
|
255 iCommandPromptPos = iConsole.CursorPos(); |
|
256 RedrawInputPrompt(); |
|
257 WaitForInput(); |
|
258 */ |
|
259 |
|
260 iMemSpySession->StartSwmtTimerL(); |
|
261 |
|
262 //CActiveScheduler::Start(); |
|
263 // } |
|
264 } |
|
265 else if( pParam.CompareF( KMemSpyCmdSwmtParameterStoptimer) == 0 ) // "stoptime" - stop tracking |
|
266 { |
|
267 iMemSpySession->StopSwmtTimerL(); |
|
268 } |
|
269 else if( pParam.CompareF( KMemSpyCmdSwmtParameterDumpnow ) == 0 ) // "dumpnow" - runs one tracking cycle (CmdSWMT_ForceUpdate before) |
|
270 { |
|
271 categories = TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryAll; |
|
272 if( paramCount >= 2 ) // user gave some optional parameters - <categories> |
|
273 { |
|
274 TRAP( err, ParseSWMTParametersL( aParameters, categories, threadNameFilter) ); |
|
275 } |
|
276 |
|
277 if( !err ) |
|
278 { |
|
279 iMemSpySession->SetSwmtCategoriesL( categories ); |
|
280 iMemSpySession->ForceSwmtUpdateL(); |
|
281 } |
|
282 } |
|
283 else //no parameters ("starttimer / stoptimer / dumpnow"), just categories / thread filter |
|
284 //so dumpnow is used as default with category / thread specified |
|
285 { |
|
286 TRAP( err, ParseSWMTParametersL( aParameters, categories, threadNameFilter) ); |
|
287 if( !err ) |
|
288 { |
|
289 iMemSpySession->SetSwmtCategoriesL( categories ); |
|
290 if( threadNameFilter.Length() > 0 ) |
|
291 { |
|
292 iMemSpySession->SetSwmtFilter( threadNameFilter ); |
|
293 } |
|
294 } |
|
295 iMemSpySession->ForceSwmtUpdateL(); |
|
296 } |
|
297 } |
|
298 } |
|
299 // --- KILL SERVER |
|
300 else if ( aCommand.CompareF( KMemSpyCmdKillServer ) == 0 ) |
|
301 { |
|
302 } |
|
303 |
|
304 // RedrawStatusMessage(); |
|
305 |
|
306 TRACE( RDebug::Print( _L("[MemSpyCmdLine] CMemSpyCommandLine::PerformSingleOpL() - END - err: %d, this: 0x%08x, cmd: %S" ), err, this, &aCommand ) ); |
340 TRACE( RDebug::Print( _L("[MemSpyCmdLine] CMemSpyCommandLine::PerformSingleOpL() - END - err: %d, this: 0x%08x, cmd: %S" ), err, this, &aCommand ) ); |
307 |
341 |
308 // Calculate duration |
342 // Calculate duration |
309 TTime timeEnd; |
343 TTime timeEnd; |
310 timeEnd.HomeTime(); |
344 timeEnd.HomeTime(); |
354 { |
388 { |
355 TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::LaunchMemSpyL() - START - this: 0x%08x", this ) ); |
389 TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::LaunchMemSpyL() - START - this: 0x%08x", this ) ); |
356 |
390 |
357 TInt err = KErrGeneral; |
391 TInt err = KErrGeneral; |
358 RProcess proc; |
392 RProcess proc; |
359 |
393 |
360 // Try to run server first |
394 // First try with s60 UI |
361 err = proc.Create( KMemSpyProcessName0, KNullDesC ); |
395 err = proc.Create( KMemSpyProcessName1, KNullDesC ); |
362 if ( err == KErrNone ) |
396 if ( err == KErrNone ) |
363 { |
397 { |
364 TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::LaunchMemSpyL() - Create server process successfully... - this: 0x%08x", this ) ); |
398 TFullName fullName; |
365 |
399 proc.FullName( fullName ); |
366 TRequestStatus status; |
400 TRACE( RDebug::Print( _L("[MemSpyCmdLine] CMemSpyCommandLine::LaunchMemSpyL() - Create S60 UI process successfully... - this: 0x%08x, name: %S"), this, &fullName ) ); |
367 proc.Rendezvous( status ); |
401 |
368 proc.Resume(); |
402 TRequestStatus status; |
369 |
403 proc.Rendezvous( status ); |
370 TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::LaunchMemSpyL() - MemSpy resumed, waiting for Rendezvous... - this: 0x%08x", this ) ); |
404 proc.Resume(); |
371 |
405 |
372 User::WaitForRequest( status ); |
406 TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::LaunchMemSpyL() - MemSpy resumed, waiting for Rendezvous... - this: 0x%08x", this ) ); |
373 err = status.Int(); |
407 User::WaitForRequest( status ); |
374 proc.Close(); |
408 err = status.Int(); |
375 |
409 proc.Close(); |
376 TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::LaunchMemSpyL() - Rendezvous complete: %d, this: 0x%08x", err, this ) ); |
410 |
377 } |
411 TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::LaunchMemSpyL() - Rendezvous complete: %d, this: 0x%08x", err, this ) ); |
378 |
412 } |
379 // If server is not available, try with s60 UI |
413 if ( err != KErrNone ) |
380 if ( err != KErrNone ) |
414 { |
381 { |
415 // Try console UI |
382 err = proc.Create( KMemSpyProcessName1, KNullDesC ); |
416 err = proc.Create( KMemSpyProcessName2, KNullDesC ); |
383 if ( err == KErrNone ) |
417 if ( err == KErrNone ) |
384 { |
418 { |
385 TFullName fullName; |
419 TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::LaunchMemSpyL() - Create Console UI process successfully... - this: 0x%08x", this ) ); |
386 proc.FullName( fullName ); |
420 |
387 TRACE( RDebug::Print( _L("[MemSpyCmdLine] CMemSpyCommandLine::LaunchMemSpyL() - Create S60 UI process successfully... - this: 0x%08x, name: %S"), this, &fullName ) ); |
421 TRequestStatus status; |
388 |
422 proc.Rendezvous( status ); |
389 TRequestStatus status; |
423 proc.Resume(); |
390 proc.Rendezvous( status ); |
424 |
391 proc.Resume(); |
425 TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::LaunchMemSpyL() - MemSpy resumed, waiting for Rendezvous... - this: 0x%08x", this ) ); |
392 |
426 |
393 TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::LaunchMemSpyL() - MemSpy resumed, waiting for Rendezvous... - this: 0x%08x", this ) ); |
427 User::WaitForRequest( status ); |
394 User::WaitForRequest( status ); |
428 err = status.Int(); |
395 err = status.Int(); |
429 proc.Close(); |
396 proc.Close(); |
430 |
397 |
431 TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::LaunchMemSpyL() - Rendezvous complete: %d, this: 0x%08x", err, this ) ); |
398 TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::LaunchMemSpyL() - Rendezvous complete: %d, this: 0x%08x", err, this ) ); |
432 } |
399 } |
433 } |
400 } |
|
401 |
434 |
402 TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::LaunchMemSpyL() - final error: %d, this: 0x%08x", err, this ) ); |
435 TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::LaunchMemSpyL() - final error: %d, this: 0x%08x", err, this ) ); |
403 User::LeaveIfError( err ); |
436 User::LeaveIfError( err ); |
404 User::After( 10 * 1000000 ); |
437 User::After( 10 * 1000000 ); |
405 |
438 |