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