author | hgs |
Tue, 26 Oct 2010 16:20:32 +0300 | |
changeset 62 | 1c2bb2fc7c87 |
parent 54 | a151135b0cf9 |
permissions | -rw-r--r-- |
0
a03f92240627
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1 |
/* |
52 | 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 |
*/ |
|
0
a03f92240627
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
17 |
|
a03f92240627
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
18 |
#include "MemSpyCommandLine.h" |
a03f92240627
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
19 |
|
a03f92240627
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
20 |
// System includes |
a03f92240627
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
21 |
#include <bacline.h> |
a03f92240627
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
22 |
#include <bautils.h> |
a03f92240627
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
23 |
#include <memspyengineclientinterface.h> |
30 | 24 |
#include <memspysession.h> |
0
a03f92240627
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
25 |
#include <memspy/engine/memspyenginehelpersysmemtrackerconfig.h> |
a03f92240627
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
26 |
|
a03f92240627
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
27 |
// User includes |
a03f92240627
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
28 |
#include "MemSpyCommands.h" |
a03f92240627
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
29 |
|
30 | 30 |
/* |
52 | 31 |
CMemSpyCommandLine::CMemSpyCommandLine() |
32 |
{ |
|
33 |
} |
|
34 |
*/ |
|
0
a03f92240627
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
35 |
|
30 | 36 |
CMemSpyCommandLine::CMemSpyCommandLine( CConsoleBase& aConsole ) |
52 | 37 |
:CActive(EPriorityHigh), iConsole(aConsole) |
38 |
{ |
|
39 |
CActiveScheduler::Add(this); |
|
40 |
} |
|
0
a03f92240627
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
41 |
|
a03f92240627
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
42 |
CMemSpyCommandLine::~CMemSpyCommandLine() |
52 | 43 |
{ |
30 | 44 |
Cancel(); |
0
a03f92240627
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
45 |
|
52 | 46 |
if (iMemSpySession) |
47 |
{ |
|
48 |
iMemSpySession->Close(); |
|
49 |
} |
|
50 |
delete iMemSpySession; |
|
51 |
iFsSession.Close(); |
|
52 |
} |
|
0
a03f92240627
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
53 |
|
a03f92240627
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
54 |
void CMemSpyCommandLine::ConstructL() |
52 | 55 |
{ |
56 |
User::LeaveIfError(iFsSession.Connect()); |
|
57 |
iMemSpySession = new (ELeave) RMemSpySession(); |
|
58 |
ConnectToMemSpyL(); |
|
59 |
} |
|
0
a03f92240627
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
60 |
|
52 | 61 |
CMemSpyCommandLine* CMemSpyCommandLine::NewLC(CConsoleBase& aConsole) |
62 |
{ |
|
63 |
CMemSpyCommandLine* self = new (ELeave) CMemSpyCommandLine(aConsole); |
|
64 |
CleanupStack::PushL(self); |
|
65 |
self->ConstructL(); |
|
66 |
return self; |
|
67 |
} |
|
0
a03f92240627
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
68 |
|
52 | 69 |
void CMemSpyCommandLine::PerformOpL(const CCommandLineArguments& aCommandLine) |
70 |
{ |
|
71 |
const TInt count = aCommandLine.Count(); |
|
72 |
TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::PerformOpL() - START - arg count: %d, this: 0x%08x", count, this ) ); |
|
0
a03f92240627
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
73 |
|
54 | 74 |
if (count > 1) |
52 | 75 |
{ |
76 |
// Get main command |
|
77 |
TBuf<KMemSpyCommandLineMaxLength> command; |
|
78 |
command.Copy(aCommandLine.Arg(1)); |
|
79 |
command.UpperCase(); |
|
0
a03f92240627
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
80 |
|
52 | 81 |
// Extract arguments into array |
82 |
CDesCArrayFlat* args = new (ELeave) CDesCArrayFlat(4); |
|
83 |
CleanupStack::PushL(args); |
|
84 |
for (TInt i = 2; i < count; i++) |
|
85 |
{ |
|
86 |
args->AppendL(aCommandLine.Arg(i)); |
|
87 |
} |
|
0
a03f92240627
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
88 |
|
52 | 89 |
// Perform op |
90 |
PerformSingleOpL(command, *args); |
|
0
a03f92240627
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
91 |
|
52 | 92 |
// Tidy up |
93 |
CleanupStack::PopAndDestroy(args); |
|
94 |
} |
|
54 | 95 |
else if ( count == 1 ) |
96 |
{ |
|
62 | 97 |
PrintHelp(); |
54 | 98 |
} |
52 | 99 |
else |
100 |
{ |
|
101 |
User::Leave(KErrUnderflow); |
|
102 |
} |
|
103 |
} |
|
0
a03f92240627
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
104 |
|
52 | 105 |
void CMemSpyCommandLine::PerformSingleOpL(const TDesC& aCommand, const CDesCArray& aParameters) |
106 |
{ |
|
107 |
// Record duration |
|
108 |
TTime timeStart; |
|
109 |
timeStart.HomeTime(); |
|
110 |
const TInt paramCount = aParameters.Count(); |
|
0
a03f92240627
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
111 |
|
a03f92240627
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
112 |
#ifdef _DEBUG |
52 | 113 |
TRACE( RDebug::Print( _L("[MemSpyCmdLine] CMemSpyCommandLine::PerformSingleOpL() - START - command: %S, paramCount: %d, this: 0x%08x"), &aCommand, paramCount, this ) ); |
114 |
for (TInt i = 0; i < paramCount; i++) |
|
115 |
{ |
|
116 |
const TPtrC pParam(aParameters[i]); |
|
117 |
TRACE( RDebug::Print( _L("[MemSpyCmdLine] CMemSpyCommandLine::PerformSingleOpL() - param[%02d] = [%S]"), i, &pParam ) ); |
|
118 |
} |
|
0
a03f92240627
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
119 |
#else |
52 | 120 |
RDebug::Print( _L("[MemSpyCmdLine] COMMAND: [%S] {%02d}..."), &aCommand, paramCount ); |
0
a03f92240627
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
121 |
#endif |
a03f92240627
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
122 |
|
52 | 123 |
TFileName batchFile; |
124 |
batchFile.Append(aCommand); |
|
125 |
||
126 |
TInt err = KErrNotSupported; |
|
127 |
TInt error = KErrNotSupported; |
|
0
a03f92240627
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
128 |
|
52 | 129 |
// --- HELP |
130 |
if ( aCommand.CompareF( KMemSpyCmdHelp1) == 0 || |
|
131 |
aCommand.CompareF(KMemSpyCmdHelp2) == 0 || |
|
132 |
aCommand.CompareF(KMemSpyCmdHelp3) == 0 || |
|
133 |
aCommand.CompareF(KMemSpyCmdHelp4) == 0) |
|
134 |
{ |
|
62 | 135 |
PrintHelp(); |
52 | 136 |
} |
137 |
// --- OUTPUT |
|
138 |
//TODO: directory option to be added |
|
139 |
else if (aCommand.CompareF(KMemSpyCmdOutput) == 0) //change output mode |
|
140 |
{ |
|
141 |
if (paramCount >= 1) |
|
30 | 142 |
{ |
52 | 143 |
if (aParameters[0].CompareF(KMemSpyCmdOutputParameterFile) == 0) |
30 | 144 |
{ |
52 | 145 |
if (paramCount == 2) |
30 | 146 |
{ |
147 |
TBuf<KMaxFileName> directory; |
|
52 | 148 |
directory.Copy(aParameters[1]); |
149 |
iMemSpySession->SwitchOutputToFileL(directory); |
|
30 | 150 |
} |
151 |
else |
|
152 |
{ |
|
52 | 153 |
iMemSpySession->SwitchOutputToFileL(KNullDesC); |
30 | 154 |
} |
155 |
} |
|
156 |
else if( aParameters[0].CompareF( KMemSpyCmdOutputParameterTrace ) == 0) |
|
157 |
{ |
|
158 |
TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::PerformSingleOpL() - this: 0x%08x - Output Trace", this ) ); |
|
159 |
iMemSpySession->SwitchOutputToTraceL(); |
|
160 |
} |
|
52 | 161 |
} |
162 |
} |
|
163 |
// --- HEAP DUMP |
|
164 |
else if (aCommand.CompareF(KMemSpyCmdHeapDump) == 0) |
|
165 |
{ |
|
166 |
RedrawStatusMessage(KHeapDumpMessage); |
|
167 |
||
168 |
if (paramCount == 0) // no parameter - dump all heap data + kernel heap at the end |
|
169 |
{ |
|
170 |
||
171 |
TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::PerformSingleOpL() - this: 0x%08x - Heap_Dump (all threads)", this ) ); |
|
30 | 172 |
// Dump heap data for all threads - Thread agnostic operation |
173 |
iMemSpySession->OutputHeapData(); |
|
174 |
// Dump kernel heap data |
|
175 |
iMemSpySession->OutputThreadHeapDataL( KMemSpyClientServerThreadIdKernel ); |
|
176 |
} |
|
52 | 177 |
else if (paramCount >= 1) |
30 | 178 |
{ |
52 | 179 |
if (aParameters[0].CompareF(KMemSpyCmdHeapDumpParameterAll) == 0) |
30 | 180 |
{ |
52 | 181 |
iMemSpySession->OutputHeapData(); |
30 | 182 |
iMemSpySession->OutputThreadHeapDataL( KMemSpyClientServerThreadIdKernel ); |
183 |
} |
|
184 |
else if( aParameters[0].CompareF( KMemSpyCmdHeapDumpParameterKernel ) == 0 ) |
|
185 |
{ |
|
186 |
TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::PerformSingleOpL() - this: 0x%08x - Heap_DumpKernel", this ) ); |
|
187 |
iMemSpySession->OutputThreadHeapDataL( KMemSpyClientServerThreadIdKernel ); |
|
188 |
} |
|
189 |
else |
|
52 | 190 |
{ |
30 | 191 |
// Dump heap data for named thread - filter |
52 | 192 |
const TPtrC pThreadName(aParameters[0]); |
193 |
TRACE( RDebug::Print( _L("[MemSpyCmdLine] CMemSpyCommandLine::PerformSingleOpL() - this: 0x%08x - Heap_Dump (%S)"), this, &pThreadName ) ); |
|
194 |
iMemSpySession->OutputThreadHeapDataL(pThreadName); |
|
30 | 195 |
} |
52 | 196 |
} |
30 | 197 |
} |
52 | 198 |
|
199 |
// --- SYSTEM WIDE MEMORY TRACKING |
|
200 |
else if (aCommand.CompareF(KMemSpyCmdSwmt) == 0) |
|
201 |
{ |
|
202 |
RedrawStatusMessage(KSWMTMessage); |
|
203 |
||
204 |
TInt categories(0); |
|
30 | 205 |
TName threadNameFilter; |
52 | 206 |
|
207 |
if (paramCount == 0) //default state -> "dumpnow" command with "all" categories |
|
30 | 208 |
{ |
209 |
TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::PerformSingleOpL() - this: 0x%08x - dumpnow command", this ) ); |
|
210 |
TInt category = TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryAll; |
|
52 | 211 |
iMemSpySession->SetSwmtCategoriesL(category); |
212 |
iMemSpySession->ForceSwmtUpdateL(); |
|
30 | 213 |
} |
52 | 214 |
else if (paramCount >= 1) |
30 | 215 |
{ |
52 | 216 |
const TPtrC pParam(aParameters[0]); |
217 |
if (pParam.CompareF(KMemSpyCmdSwmtParameterStarttimer) == 0) // "starttimer" - start tracking |
|
30 | 218 |
{ |
219 |
TInt result(0); |
|
220 |
categories = TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryAll; |
|
52 | 221 |
iMemSpySession->SetSwmtTimerIntervalL(KMemSpySysMemTrackerConfigMinTimerPeriod); |
222 |
||
223 |
if (paramCount >= 2) // user gave some optional parameters - <categories> or <value in seconds> |
|
224 |
{ |
|
225 |
TLex lex(aParameters[1]); |
|
226 |
if (lex.Val(result) == KErrNone) //if 2nd parameter is not number, then parse parameters |
|
227 |
{ |
|
30 | 228 |
if( result >= KMemSpySysMemTrackerConfigMinTimerPeriod && result <= KMemSpySysMemTrackerConfigMaxTimerPeriod ) |
229 |
{ |
|
52 | 230 |
iMemSpySession->SetSwmtTimerIntervalL( result ); |
231 |
} |
|
232 |
} |
|
233 |
TRAP( err, ParseSWMTParametersL( aParameters, categories, threadNameFilter) ); |
|
234 |
} |
|
235 |
||
30 | 236 |
//if( !err ) |
237 |
// { |
|
52 | 238 |
/* |
239 |
_LIT( KPressS, "Press 's' to stop the timer " ); |
|
240 |
iConsole.Write( KPressS ); |
|
241 |
||
242 |
iCommandPromptPos = iConsole.CursorPos(); |
|
243 |
RedrawInputPrompt(); |
|
244 |
WaitForInput(); |
|
245 |
*/ |
|
246 |
||
247 |
iMemSpySession->StartSwmtTimerL(); |
|
248 |
||
249 |
//CActiveScheduler::Start(); |
|
30 | 250 |
// } |
251 |
} |
|
52 | 252 |
else if (pParam.CompareF(KMemSpyCmdSwmtParameterStoptimer) == 0) // "stoptime" - stop tracking |
30 | 253 |
{ |
254 |
iMemSpySession->StopSwmtTimerL(); |
|
255 |
} |
|
52 | 256 |
else if (pParam.CompareF(KMemSpyCmdSwmtParameterDumpnow) == 0) // "dumpnow" - runs one tracking cycle (CmdSWMT_ForceUpdate before) |
30 | 257 |
{ |
258 |
categories = TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryAll; |
|
52 | 259 |
if (paramCount >= 2) // user gave some optional parameters - <categories> |
30 | 260 |
{ |
261 |
TRAP( err, ParseSWMTParametersL( aParameters, categories, threadNameFilter) ); |
|
52 | 262 |
} |
263 |
||
264 |
if (!err) |
|
30 | 265 |
{ |
52 | 266 |
iMemSpySession->SetSwmtCategoriesL(categories); |
30 | 267 |
iMemSpySession->ForceSwmtUpdateL(); |
52 | 268 |
} |
269 |
} |
|
30 | 270 |
else //no parameters ("starttimer / stoptimer / dumpnow"), just categories / thread filter |
52 | 271 |
//so dumpnow is used as default with category / thread specified |
30 | 272 |
{ |
273 |
TRAP( err, ParseSWMTParametersL( aParameters, categories, threadNameFilter) ); |
|
52 | 274 |
if (!err) |
30 | 275 |
{ |
52 | 276 |
iMemSpySession->SetSwmtCategoriesL(categories); |
277 |
if (threadNameFilter.Length() > 0) |
|
30 | 278 |
{ |
52 | 279 |
iMemSpySession->SetSwmtFilter(threadNameFilter); |
30 | 280 |
} |
52 | 281 |
} |
282 |
iMemSpySession->ForceSwmtUpdateL(); |
|
30 | 283 |
} |
284 |
} |
|
52 | 285 |
} |
286 |
// --- KILL SERVER |
|
287 |
else if (aCommand.CompareF(KMemSpyCmdKillServer) == 0) |
|
288 |
{ |
|
289 |
} |
|
290 |
||
291 |
// RedrawStatusMessage(); |
|
292 |
||
293 |
TRACE( RDebug::Print( _L("[MemSpyCmdLine] CMemSpyCommandLine::PerformSingleOpL() - END - err: %d, this: 0x%08x, cmd: %S" ), err, this, &aCommand ) ); |
|
0
a03f92240627
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
294 |
|
52 | 295 |
// Calculate duration |
296 |
TTime timeEnd; |
|
297 |
timeEnd.HomeTime(); |
|
298 |
TTimeIntervalSeconds interval(0); |
|
299 |
timeEnd.SecondsFrom(timeStart, interval); |
|
0
a03f92240627
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
300 |
|
52 | 301 |
// Print some info |
302 |
if (err != KErrNone) |
|
303 |
{ |
|
304 |
RDebug::Print( _L("[MemSpyCmdLine] COMMAND: [%S] {%02d} {%08d sec} => ERROR: %d"), &aCommand, paramCount, interval.Int(), err ); |
|
305 |
} |
|
306 |
else |
|
307 |
{ |
|
308 |
RDebug::Print( _L("[MemSpyCmdLine] COMMAND: [%S] {%02d} {%08d sec} => OK"), &aCommand, paramCount, interval.Int() ); |
|
309 |
} |
|
0
a03f92240627
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
310 |
|
52 | 311 |
// Spacer |
312 |
RDebug::Printf(" "); |
|
313 |
} |
|
0
a03f92240627
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
314 |
|
a03f92240627
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
315 |
void CMemSpyCommandLine::ConnectToMemSpyL() |
52 | 316 |
{ |
317 |
TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::ConnectToMemSpyL() - START - this: 0x%08x", this ) ); |
|
0
a03f92240627
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
318 |
|
52 | 319 |
TInt err = iMemSpySession->Connect(); |
320 |
TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::ConnectToMemSpyL() - connect #1 err: %d, this: 0x%08x", err, this ) ); |
|
0
a03f92240627
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
321 |
|
52 | 322 |
if (err == KErrNotFound) |
323 |
{ |
|
324 |
TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::ConnectToMemSpyL() - launching MemSpy... - this: 0x%08x", this ) ); |
|
325 |
LaunchMemSpyL(); |
|
0
a03f92240627
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
326 |
|
52 | 327 |
TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::ConnectToMemSpyL() - launched MemSpy - this: 0x%08x", this ) ); |
328 |
err = iMemSpy->Connect(); |
|
0
a03f92240627
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
329 |
|
52 | 330 |
TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::ConnectToMemSpyL() - connect #2 err: %d, this: 0x%08x", err, this ) ); |
331 |
} |
|
0
a03f92240627
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
332 |
|
52 | 333 |
User::LeaveIfError(err); |
0
a03f92240627
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
334 |
|
52 | 335 |
TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::ConnectToMemSpyL() - END - ok - this: 0x%08x", this ) ); |
336 |
} |
|
0
a03f92240627
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
337 |
|
a03f92240627
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
338 |
void CMemSpyCommandLine::LaunchMemSpyL() |
52 | 339 |
{ |
340 |
TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::LaunchMemSpyL() - START - this: 0x%08x", this ) ); |
|
0
a03f92240627
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
341 |
|
52 | 342 |
TInt err = KErrGeneral; |
343 |
RProcess proc; |
|
344 |
||
345 |
// Try to run server first |
|
346 |
err = proc.Create(KMemSpyProcessName0, KNullDesC); |
|
347 |
if (err == KErrNone) |
|
348 |
{ |
|
20 | 349 |
TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::LaunchMemSpyL() - Create server process successfully... - this: 0x%08x", this ) ); |
0
a03f92240627
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
350 |
|
20 | 351 |
TRequestStatus status; |
52 | 352 |
proc.Rendezvous(status); |
20 | 353 |
proc.Resume(); |
354 |
||
355 |
TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::LaunchMemSpyL() - MemSpy resumed, waiting for Rendezvous... - this: 0x%08x", this ) ); |
|
356 |
||
52 | 357 |
User::WaitForRequest(status); |
20 | 358 |
err = status.Int(); |
359 |
proc.Close(); |
|
360 |
||
361 |
TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::LaunchMemSpyL() - Rendezvous complete: %d, this: 0x%08x", err, this ) ); |
|
52 | 362 |
} |
0
a03f92240627
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
363 |
|
52 | 364 |
// If server is not available, try with s60 UI |
365 |
if (err != KErrNone) |
|
366 |
{ |
|
367 |
err = proc.Create(KMemSpyProcessName1, KNullDesC); |
|
368 |
if (err == KErrNone) |
|
20 | 369 |
{ |
370 |
TFullName fullName; |
|
52 | 371 |
proc.FullName(fullName); |
20 | 372 |
TRACE( RDebug::Print( _L("[MemSpyCmdLine] CMemSpyCommandLine::LaunchMemSpyL() - Create S60 UI process successfully... - this: 0x%08x, name: %S"), this, &fullName ) ); |
52 | 373 |
|
20 | 374 |
TRequestStatus status; |
52 | 375 |
proc.Rendezvous(status); |
20 | 376 |
proc.Resume(); |
52 | 377 |
|
20 | 378 |
TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::LaunchMemSpyL() - MemSpy resumed, waiting for Rendezvous... - this: 0x%08x", this ) ); |
52 | 379 |
User::WaitForRequest(status); |
20 | 380 |
err = status.Int(); |
381 |
proc.Close(); |
|
52 | 382 |
|
20 | 383 |
TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::LaunchMemSpyL() - Rendezvous complete: %d, this: 0x%08x", err, this ) ); |
384 |
} |
|
52 | 385 |
} |
386 |
||
387 |
TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::LaunchMemSpyL() - final error: %d, this: 0x%08x", err, this ) ); |
|
388 |
User::LeaveIfError(err); |
|
389 |
User::After(10 * 1000000); |
|
0
a03f92240627
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
390 |
|
52 | 391 |
TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::LaunchMemSpyL() - END - ok - this: 0x%08x", this ) ); |
392 |
} |
|
0
a03f92240627
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
393 |
|
52 | 394 |
CDesCArray* CMemSpyCommandLine::ReadLinesL(RFile& aFile) |
395 |
{ |
|
396 |
TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::ReadLinesL() - START - this: 0x%08x", this ) ); |
|
397 |
CDesCArrayFlat* lines = new (ELeave) CDesCArrayFlat(10); |
|
398 |
CleanupStack::PushL(lines); |
|
0
a03f92240627
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
399 |
|
52 | 400 |
TInt size = 0; |
401 |
User::LeaveIfError(aFile.Size(size)); |
|
402 |
TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::ReadLinesL() - this: 0x%08x, file size: %d", this, size ) ); |
|
0
a03f92240627
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
403 |
|
52 | 404 |
// Read file |
405 |
HBufC8* narrowBuf = HBufC8::NewLC(size); |
|
406 |
TPtr8 pBufNarrow(narrowBuf->Des()); |
|
407 |
TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::ReadLinesL() - this: 0x%08x, reading file..." ) ); |
|
408 |
User::LeaveIfError(aFile.Read(pBufNarrow)); |
|
409 |
if (pBufNarrow.Length() <= 2) |
|
410 |
{ |
|
411 |
TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::ReadLinesL() - this: 0x%08x - BAD FILE LENGTH", this ) ); |
|
412 |
User::Leave(KErrCorrupt); |
|
413 |
} |
|
0
a03f92240627
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
414 |
|
52 | 415 |
// Look for BOM and convert to unicode |
416 |
HBufC* unicodeText = HBufC::NewL(size); |
|
417 |
TPtr pUnicodeText(unicodeText->Des()); |
|
418 |
if (pBufNarrow[0] == 0xFF && pBufNarrow[1] == 0xFE) |
|
419 |
{ |
|
420 |
// It's unicode... and we don't want the BOM, hence -2 |
|
421 |
const TInt textLength = size - 2; |
|
422 |
TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::ReadLinesL() - this: 0x%08x - UNICODE TEXT - textLength: %d", this, textLength / 2 ) ); |
|
423 |
Mem::Copy( (TUint8 *)pUnicodeText.Ptr(), pBufNarrow.Ptr() + 2, textLength ); |
|
424 |
pUnicodeText.SetLength(textLength / 2); |
|
425 |
} |
|
426 |
else |
|
427 |
{ |
|
428 |
// It's ASCII, convert it to unicode... |
|
429 |
TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::ReadLinesL() - this: 0x%08x - ASCII TEXT - textLength: %d", this, size ) ); |
|
430 |
for (TInt i = 0; i < size; i++) |
|
431 |
{ |
|
432 |
pUnicodeText.Append(pBufNarrow[i]); |
|
433 |
} |
|
434 |
} |
|
0
a03f92240627
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
435 |
|
52 | 436 |
// Discard old narrow text |
437 |
CleanupStack::PopAndDestroy(narrowBuf); |
|
438 |
CleanupStack::PushL(unicodeText); |
|
0
a03f92240627
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
439 |
|
52 | 440 |
// Try to extract lines of text... |
441 |
HBufC* line = HBufC::NewLC(1024); |
|
442 |
TPtr pLine(line->Des()); |
|
443 |
const TInt length = unicodeText->Length(); |
|
444 |
for (TInt i = 0; i < length; i++) |
|
445 |
{ |
|
446 |
const TChar c(pUnicodeText[i]); |
|
447 |
// |
|
448 |
if (c == '\r' || c == '\n') |
|
449 |
{ |
|
450 |
pLine.Trim(); |
|
451 |
if (pLine.Length()) |
|
452 |
{ |
|
453 |
TRACE( RDebug::Print( _L("[MemSpyCmdLine] CMemSpyCommandLine::ReadLinesL() - this: 0x%08x - LINE[%03d] %S"), this, lines->Count(), line ) ); |
|
454 |
lines->AppendL(pLine); |
|
455 |
} |
|
0
a03f92240627
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
456 |
|
52 | 457 |
pLine.Zero(); |
458 |
} |
|
459 |
else |
|
460 |
{ |
|
461 |
pLine.Append(c); |
|
462 |
} |
|
463 |
} |
|
0
a03f92240627
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
464 |
|
52 | 465 |
// Save last line, just in cae it didn't end with a CR/LF |
466 |
pLine.Trim(); |
|
467 |
if (pLine.Length()) |
|
468 |
{ |
|
469 |
TRACE( RDebug::Print( _L("[MemSpyCmdLine] CMemSpyCommandLine::ReadLinesL() - this: 0x%08x - LINE[%03d] %S"), this, lines->Count(), line ) ); |
|
470 |
lines->AppendL(pLine); |
|
471 |
} |
|
0
a03f92240627
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
472 |
|
52 | 473 |
CleanupStack::PopAndDestroy(2, unicodeText); // line & unicodeText |
474 |
CleanupStack::Pop(lines); |
|
475 |
TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine::ReadLinesL() - END - this: 0x%08x", this ) ); |
|
0
a03f92240627
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
476 |
|
52 | 477 |
return lines; |
478 |
} |
|
0
a03f92240627
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
479 |
|
52 | 480 |
void CMemSpyCommandLine::ParseSWMTParametersL(const CDesCArray& aParameters,TInt& aCategories, TDes& aFilter) |
481 |
{ |
|
482 |
TInt result(0); |
|
483 |
// Check if the first parameter is a number. |
|
484 |
// In that case other parameters are ignored. |
|
485 |
TLex lex(aParameters[0]); |
|
486 |
if (lex.Val(result) != KErrNone) |
|
487 |
{ |
|
488 |
// Parameters were given in text form: |
|
489 |
const TInt count(aParameters.Count()); |
|
490 |
for (TInt i = 0; i < count; i++) |
|
491 |
{ |
|
492 |
lex = aParameters[i]; //check if num. |
|
493 |
if (aParameters[i].CompareF(KMemSpyCmdSWMTTypeHeap) == 0) |
|
494 |
result |
|
495 |
|= TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryUserHeap; |
|
496 |
//| TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryKernelHeap; |
|
497 |
else if (aParameters[i].CompareF(KMemSpyCmdSWMTTypeChunk) == 0) |
|
498 |
result |
|
499 |
|= TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryLocalChunks |
|
500 |
| TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryGlobalChunks; |
|
501 |
else if (aParameters[i].CompareF(KMemSpyCmdSWMTTypeCode) == 0) |
|
502 |
result |
|
503 |
|= TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryRAMLoadedCode; |
|
504 |
//else if (aParameters[i].CompareF(KMemSpyCmdSWMTTypeStack) == 0) |
|
505 |
// result |
|
506 |
// |= TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryUserStacks; |
|
507 |
//else if ( aParameters[i].CompareF( KMemSpyCmdSWMTTypeGlobalData ) == 0 ) |
|
508 |
// result |= TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryGlobalData; |
|
509 |
else if (aParameters[i].CompareF(KMemSpyCmdSWMTTypeRamDrive) == 0) |
|
510 |
result |
|
511 |
|= TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryRAMDrive; |
|
512 |
else if (aParameters[i].CompareF(KMemSpyCmdSWMTTypeOpenFile) == 0) |
|
513 |
result |
|
514 |
|= TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryOpenFiles; |
|
515 |
else if (aParameters[i].CompareF(KMemSpyCmdSWMTTypeDiskSpace) == 0) |
|
516 |
result |
|
517 |
|= TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryDiskusage; |
|
518 |
//else if ( aParameters[i].CompareF( KMemSpyCmdSWMTTypeFbserv ) == 0 ) // enables both FABS and BITM |
|
519 |
// result |= TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryBitmapHandles; |
|
520 |
else if (aParameters[i].CompareF(KMemSpyCmdSWMTTypeHandleGeneric) |
|
521 |
== 0) // enables both HGEN and HPAS |
|
522 |
result |
|
523 |
|= TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryKernelHandles; |
|
524 |
else if (aParameters[i].CompareF(KMemSpyCmdSWMTTypeFileServerCache) |
|
525 |
== 0) |
|
526 |
result |
|
527 |
|= TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryFileServerCache; |
|
528 |
else if (aParameters[i].CompareF(KMemSpyCmdSWMTTypeSystemMemory) |
|
529 |
== 0) |
|
530 |
result |
|
531 |
|= TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategorySystemMemory; |
|
532 |
else if (aParameters[i].CompareF(KMemSpyCmdSWMTTypeWindowGroup) |
|
533 |
== 0) |
|
534 |
result |
|
535 |
|= TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryWindowGroups; |
|
536 |
else if (aParameters[i].CompareF(KMemSpyCmdSWMTTypeAll) == 0) //"all" category added |
|
537 |
result |
|
538 |
= TMemSpyEngineHelperSysMemTrackerConfig::EMemSpyEngineSysMemTrackerCategoryAll; |
|
539 |
else if (aParameters[i].CompareF(KMemSpyCmdSwmtParameterDumpnow) |
|
540 |
== 0 || aParameters[i].CompareF( |
|
541 |
KMemSpyCmdSwmtParameterStarttimer) == 0 |
|
542 |
|| aParameters[i].CompareF(KMemSpyCmdSwmtParameterStoptimer) |
|
543 |
== 0) |
|
544 |
{ |
|
545 |
TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine:: command parameter") ); |
|
546 |
} |
|
547 |
else if (lex.Val(result) == KErrNone) |
|
548 |
{ |
|
549 |
TRACE( RDebug::Printf( "[MemSpyCmdLine] CMemSpyCommandLine:: number - timer period") ); |
|
550 |
} |
|
551 |
else// if ( aParameters[i].Find( KMemSpyCmdSWMTTypeHeapFilter ) == 0 ) |
|
552 |
{ |
|
553 |
aFilter.Copy(aParameters[i].Right(aParameters[i].Length() - 11)); |
|
554 |
} |
|
555 |
/* else |
|
556 |
{ |
|
557 |
//User::Leave( KErrNotSupported ); |
|
558 |
}*/ |
|
559 |
} |
|
560 |
} |
|
561 |
else if (aParameters.Count() > 1)//&& aParameters[1].Find( KMemSpyCmdSWMTTypeHeapFilter ) == 0 ) |
|
562 |
{ |
|
563 |
aFilter.Copy(aParameters[1].Right(aParameters[1].Length() - 11)); |
|
564 |
} |
|
565 |
aCategories = result; |
|
566 |
} |
|
0
a03f92240627
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
567 |
|
52 | 568 |
TInt CMemSpyCommandLine::FindBatchFile(TDes &aFileName) |
569 |
{ |
|
570 |
if ( BaflUtils::FileExists( iFsSession, aFileName )) return KErrNone; |
|
571 |
if ( !FindFile( aFileName, _L("\\") ) ) return KErrNone; |
|
572 |
if ( !FindFile( aFileName, _L("\\data\\") ) ) return KErrNone; |
|
573 |
if (!FindFile(aFileName, _L("\\documents\\"))) return KErrNone; |
|
574 |
if (!FindFile(aFileName, _L("\\temp\\"))) return KErrNone; |
|
575 |
if (!FindFile(aFileName, _L("\\system\\temp\\"))) return KErrNone; |
|
576 |
// if ( !FindFile( aFileName, _L("\\private\\1000484b\\") ) ) return KErrNone; // Mail folder KErrPermissionDenied |
|
577 |
return KErrNotFound; |
|
578 |
} |
|
0
a03f92240627
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
579 |
|
52 | 580 |
TInt CMemSpyCommandLine::FindFile(TDes &aFileName, const TDesC &aDirPath) |
581 |
{ |
|
582 |
TFindFile fileFinder(iFsSession); |
|
583 |
TInt err = fileFinder.FindByDir(aFileName, aDirPath); |
|
584 |
if (!err) |
|
585 |
{ |
|
586 |
aFileName.Copy(fileFinder.File()); |
|
587 |
} |
|
588 |
return err; |
|
589 |
} |
|
30 | 590 |
|
591 |
//CLI status messages methods |
|
592 |
void CMemSpyCommandLine::RedrawInputPrompt() |
|
52 | 593 |
{ |
594 |
iConsole.SetCursorPosAbs(iCommandPromptPos); |
|
595 |
iConsole.ClearToEndOfLine(); |
|
596 |
iConsole.Printf(KMemSpyCLIInputPrompt, &iCommandBuffer); |
|
597 |
} |
|
30 | 598 |
|
599 |
void CMemSpyCommandLine::RedrawStatusMessage() |
|
52 | 600 |
{ |
601 |
RedrawStatusMessage(KNullDesC); |
|
602 |
} |
|
30 | 603 |
|
52 | 604 |
void CMemSpyCommandLine::RedrawStatusMessage(const TDesC& aMessage) |
605 |
{ |
|
606 |
iConsole.SetCursorPosAbs(iStatusMessagePos); |
|
607 |
iConsole.ClearToEndOfLine(); |
|
608 |
iConsole.Write(aMessage); |
|
609 |
iConsole.Write(KMemSpyCLINewLine); |
|
610 |
} |
|
30 | 611 |
|
612 |
void CMemSpyCommandLine::WaitForInput() |
|
52 | 613 |
{ |
614 |
ASSERT( !IsActive() ); |
|
615 |
iConsole.Read(iStatus); |
|
616 |
SetActive(); |
|
617 |
} |
|
30 | 618 |
|
619 |
void CMemSpyCommandLine::DoCancel() |
|
52 | 620 |
{ |
621 |
iConsole.ReadCancel(); |
|
622 |
} |
|
30 | 623 |
|
624 |
void CMemSpyCommandLine::RunL() |
|
52 | 625 |
{ |
626 |
TKeyCode key = iConsole.KeyCode(); |
|
627 |
// |
|
628 |
if ( key == EKeyEnter || key == KMemSpyUiS60KeyCodeButtonOk || key == KMemSpyUiS60KeyCodeRockerEnter ) |
|
629 |
{ |
|
630 |
TRAP_IGNORE( ProcessCommandBufferL() ); |
|
631 |
} |
|
632 |
else |
|
633 |
{ |
|
634 |
TChar character(key); |
|
635 |
if (character.IsPrint()) |
|
636 |
{ |
|
637 |
if (iCommandBuffer.Length() < iCommandBuffer.MaxLength()) |
|
638 |
{ |
|
639 |
iCommandBuffer.Append(TChar(key)); |
|
640 |
} |
|
30 | 641 |
|
52 | 642 |
RedrawInputPrompt(); |
643 |
} |
|
644 |
} |
|
30 | 645 |
|
52 | 646 |
WaitForInput(); |
647 |
} |
|
30 | 648 |
|
52 | 649 |
TInt CMemSpyCommandLine::RunError(TInt aError) |
650 |
{ |
|
30 | 651 |
return KErrNone; |
652 |
} |
|
653 |
||
654 |
void CMemSpyCommandLine::ProcessCommandBufferL() |
|
52 | 655 |
{ |
656 |
iCommandBuffer.Trim(); |
|
657 |
// |
|
30 | 658 |
#ifdef _DEBUG |
52 | 659 |
RDebug::Print( _L("[MCon] CMemSpyConsoleMenu::ProcessCommandBufferL() - cmd: [%S]"), &iCommandBuffer ); |
30 | 660 |
#endif |
52 | 661 |
// |
662 |
TBool validCommand = EFalse; |
|
663 |
if (iCommandBuffer.Length() == 1) |
|
664 |
{ |
|
665 |
// Reset if not recognised... |
|
666 |
validCommand = ETrue; |
|
30 | 667 |
|
52 | 668 |
const TChar cmd = iCommandBuffer[0]; |
669 |
switch (cmd) |
|
670 |
{ |
|
671 |
case 's': |
|
672 |
case 'S': |
|
673 |
{ |
|
674 |
iMemSpy->PerformOperation( EMemSpyClientServerOpSystemWideMemoryTrackingTimerStop ); |
|
675 |
||
676 |
CActiveScheduler::Stop(); |
|
677 |
return; |
|
678 |
} |
|
679 |
case 'c': |
|
680 |
case 'C': |
|
681 |
CActiveScheduler::Stop(); |
|
682 |
return; |
|
683 |
default: |
|
684 |
validCommand = EFalse; |
|
685 |
break; |
|
686 |
} |
|
687 |
} |
|
688 |
if (!validCommand) |
|
689 |
{ |
|
690 |
_LIT( KInvalidEntry, "*** ERROR - Invalid Command ***" ); |
|
691 |
RedrawStatusMessage(KInvalidEntry); |
|
692 |
RedrawInputPrompt(); |
|
693 |
} |
|
694 |
} |
|
62 | 695 |
|
696 |
||
697 |
void CMemSpyCommandLine::PrintHelp() |
|
698 |
{ |
|
699 |
iConsole.Write(KHelpMessage); |
|
700 |
iConsole.Write(KMemSpyCLINewLine); |
|
701 |
iConsole.Write(KHelpOutputCommand); |
|
702 |
iConsole.Write(KHelpOutputToFileCommand); |
|
703 |
iConsole.Write(KHelpHeapDumpCommand); |
|
704 |
iConsole.Write(KHelpSwmtCommand); |
|
705 |
iConsole.Write(KHelpKillServerCommand); |
|
706 |
iConsole.Write(KMemSpyCLINewLine); |
|
707 |
iConsole.Write(KHelpCommand); |
|
708 |
||
709 |
// Show input prompt. |
|
710 |
iCommandPromptPos = iConsole.CursorPos(); |
|
711 |
RedrawInputPrompt(); |
|
712 |
WaitForInput(); |
|
713 |
||
714 |
CActiveScheduler::Start(); |
|
715 |
} |