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