author | Matti Laitinen <matti.t.laitinen@nokia.com> |
Thu, 11 Feb 2010 15:52:57 +0200 | |
changeset 1 | 3ff3fecb12fe |
permissions | -rw-r--r-- |
1
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
1 |
/* |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
3 |
* All rights reserved. |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
4 |
* This component and the accompanying materials are made available |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
5 |
* under the terms of "Eclipse Public License v1.0" |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
6 |
* which accompanies this distribution, and is available |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
8 |
* |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
9 |
* Initial Contributors: |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
10 |
* Nokia Corporation - initial contribution. |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
11 |
* |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
12 |
* Contributors: |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
13 |
* |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
14 |
* Description: |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
15 |
* |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
16 |
*/ |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
17 |
|
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
18 |
#include <f32file.h> |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
19 |
#include <e32cons.h> |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
20 |
|
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
21 |
#include "ProfilerEshell.h" |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
22 |
#include <piprofiler/ProfilerSession.h> |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
23 |
|
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
24 |
|
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
25 |
|
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
26 |
_LIT(KProfilerEngineExe, "PIProfilerEngine.exe"); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
27 |
|
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
28 |
/* |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
29 |
* |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
30 |
* Static methods for controlling the profiler |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
31 |
* through command line |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
32 |
* |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
33 |
*/ |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
34 |
// -------------------------------------------------------------------------------------------- |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
35 |
static void PrintUsageInfo(const TDesC& aAdditionalInfo) |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
36 |
{ |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
37 |
_LIT(KConsoleName, "Console"); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
38 |
_LIT(KLegalNote, "PIProfiler Version 2.00.0 Copyright @ 2009 Nokia\n"); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
39 |
_LIT(KUsageNote, "Usage: PIProfiler [start/end/timed] settingsfile [time to run]\n"); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
40 |
_LIT(KExample, "Example: PIProfiler timed C:\\data\\piprofilersettings.txt 60\n"); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
41 |
|
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
42 |
TRAP_IGNORE(CConsoleBase* console = Console::NewL(KConsoleName,TSize(KConsFullScreen,KConsFullScreen)); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
43 |
console->Printf(KLegalNote); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
44 |
console->Printf(KUsageNote); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
45 |
console->Printf(KExample); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
46 |
console->Write(aAdditionalInfo); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
47 |
|
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
48 |
console->Printf(_L("\n[Press any key]")); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
49 |
console->Getch(); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
50 |
delete console;); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
51 |
} |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
52 |
|
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
53 |
// -------------------------------------------------------------------------------------------- |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
54 |
static TInt FindProcess() |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
55 |
{ |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
56 |
TFindProcess procName; |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
57 |
procName.Find(_L("PIProfilerEngine.exe*")); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
58 |
TFullName aResult; |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
59 |
|
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
60 |
// find the first appearance, i.e. "myself"... |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
61 |
TInt err(procName.Next(aResult)); // the first appearance |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
62 |
if(err == KErrNotFound) |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
63 |
{ |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
64 |
// now check if old Profiler is still running on |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
65 |
procName.Find(_L("BappeaProf.exe*")); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
66 |
err = procName.Next(aResult); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
67 |
// check if old profiler process found |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
68 |
if(err == KErrNone) |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
69 |
{ |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
70 |
// return error for error handling |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
71 |
return KErrAlreadyExists; |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
72 |
} |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
73 |
// return KErrNotFound and a new profiler engine process can be started |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
74 |
return KErrNotFound; |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
75 |
} |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
76 |
return err; |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
77 |
} |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
78 |
|
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
79 |
/** |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
80 |
* Function for starting profiler engine in the background, |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
81 |
* call profiler to load settings |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
82 |
* and start sampling process |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
83 |
* |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
84 |
* @param configFile name and location of settings file |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
85 |
*/ |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
86 |
// -------------------------------------------------------------------------------------------- |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
87 |
static TInt StartProfilerProcess(const TDesC& configFile, TInt aRunTimeInSeconds) |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
88 |
{ |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
89 |
TInt err(KErrNone); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
90 |
RProcess proc; |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
91 |
TRequestStatus status = KRequestPending; |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
92 |
|
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
93 |
// check if process exists |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
94 |
err = FindProcess(); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
95 |
LOGSTRING2(_L("PIProfiler: tried to find process, response %d"), err); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
96 |
|
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
97 |
// check if already exists and don't start a new eshell profiling |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
98 |
if( err == KErrNotFound ) |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
99 |
{ |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
100 |
// try create new process |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
101 |
err = proc.Create(KProfilerEngineExe, configFile); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
102 |
|
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
103 |
LOGSTRING2(_L("PIProfiler: created process, response %d"), err); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
104 |
|
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
105 |
// check if RProcess::Create() succeeded |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
106 |
if( err == KErrNone ) |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
107 |
{ |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
108 |
// kick off the engine process |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
109 |
proc.Resume(); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
110 |
|
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
111 |
// wait for the constructor to complete |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
112 |
proc.Rendezvous(status); // Trigger rendezvous on the supplied TRequestStatus object |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
113 |
User::WaitForRequest(status); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
114 |
|
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
115 |
// just lose the handle |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
116 |
proc.Close(); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
117 |
|
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
118 |
// check if command succesfull |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
119 |
if( err != KErrNone ) |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
120 |
{ |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
121 |
LOGTEXT(_L("Profiler: could not connect engine")); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
122 |
return err; |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
123 |
} |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
124 |
|
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
125 |
// start sampling, using settings found in settings file or if not found the default settings |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
126 |
err = RProfiler::StartSampling(); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
127 |
// check if command succesful |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
128 |
if( err != KErrNone ) |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
129 |
{ |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
130 |
_LIT(KNoteProfilerCannotStart, "PI Profiler: cannot start PI Profiler, check settings!"); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
131 |
PrintUsageInfo(KNoteProfilerCannotStart); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
132 |
// check if process still alive |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
133 |
if(err != KErrNotFound) |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
134 |
{ |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
135 |
// exit the profiler process since process was started |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
136 |
RProfiler::ExitProfiler(); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
137 |
} |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
138 |
return err; |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
139 |
} |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
140 |
|
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
141 |
if(aRunTimeInSeconds > 0) |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
142 |
{ |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
143 |
RDebug::Print(_L("Profiler running for %d s... "), aRunTimeInSeconds); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
144 |
User::After(aRunTimeInSeconds*1000000); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
145 |
RDebug::Print(_L("************* Profiler process closing *********")); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
146 |
|
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
147 |
// stop sampling process |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
148 |
err = RProfiler::StopSampling(); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
149 |
// check if command succesfull |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
150 |
if( err != KErrNone ) |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
151 |
{ |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
152 |
LOGTEXT(_L("Profiler: could not connect engine, stop failed")); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
153 |
return err; |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
154 |
} |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
155 |
|
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
156 |
// exit the profiler process |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
157 |
err = RProfiler::ExitProfiler(); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
158 |
// check if command succesfull |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
159 |
if( err != KErrNone ) |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
160 |
{ |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
161 |
LOGTEXT(_L("Profiler: could not connect engine, exit failed")); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
162 |
return err; |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
163 |
} |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
164 |
} |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
165 |
} |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
166 |
else |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
167 |
{ |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
168 |
_LIT(KNoteCannotFindProfiler, "PI Profiler: could not find PIProfilerEngine.exe"); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
169 |
PrintUsageInfo(KNoteCannotFindProfiler); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
170 |
} |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
171 |
} |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
172 |
// check if old Profiler is already running |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
173 |
else if( err == KErrAlreadyExists ) |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
174 |
{ |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
175 |
_LIT(KNoteAlreadyRunning, "PI Profiler: old Profiler process already running, close it down before launching the new!"); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
176 |
PrintUsageInfo(KNoteAlreadyRunning); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
177 |
} |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
178 |
// otherwise show error note |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
179 |
else |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
180 |
{ |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
181 |
_LIT(KNoteAlreadyRunning, "PI Profiler: already running, not able to launch new one. NOTE: check if UI running!"); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
182 |
PrintUsageInfo(KNoteAlreadyRunning); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
183 |
} |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
184 |
return KErrNone; |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
185 |
} |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
186 |
|
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
187 |
// -------------------------------------------------------------------------------------------- |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
188 |
static TInt EndProfilerProcess() |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
189 |
{ |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
190 |
LOGTEXT(_L("EndProfilerProcess() ...")); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
191 |
|
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
192 |
// call profiler to stop sampling |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
193 |
TInt err = RProfiler::StopSampling(); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
194 |
|
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
195 |
// check if command succesfull |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
196 |
if( err != KErrNone ) |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
197 |
{ |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
198 |
LOGTEXT(_L("Profiler: could not connect engine, stop failed")); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
199 |
return err; |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
200 |
} |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
201 |
|
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
202 |
// exit the profiler process |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
203 |
err = RProfiler::ExitProfiler(); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
204 |
// check if command succesfull |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
205 |
if( err != KErrNone ) |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
206 |
{ |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
207 |
LOGTEXT(_L("Profiler: could not connect engine, exit failed")); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
208 |
return err; |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
209 |
} |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
210 |
|
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
211 |
return KErrNone; |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
212 |
} |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
213 |
|
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
214 |
// -------------------------------------------------------------------------------------------- |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
215 |
static TInt TestSettingsFile(const TDesC& configFile) |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
216 |
{ |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
217 |
RFs fs; |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
218 |
RFile file; |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
219 |
TInt err(KErrNone); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
220 |
|
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
221 |
// check if file server can be connected |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
222 |
if (fs.Connect() != KErrNone) |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
223 |
{ |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
224 |
// file server couldn't be connected, return false |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
225 |
return KErrNotFound; |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
226 |
} |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
227 |
|
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
228 |
// check if config file name length is > 0 |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
229 |
if (configFile.Length() > 0) |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
230 |
{ |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
231 |
// open the file with the given path and name |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
232 |
err = file.Open(fs,configFile,EFileRead); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
233 |
// check if file open was succesfull |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
234 |
if(err != KErrNone) |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
235 |
{ |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
236 |
// return false if failed |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
237 |
fs.Close(); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
238 |
return err; |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
239 |
} |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
240 |
|
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
241 |
} |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
242 |
else |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
243 |
{ |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
244 |
// configFile length 0, return false |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
245 |
fs.Close(); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
246 |
return KErrNotFound; |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
247 |
} |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
248 |
// return true if tests passed |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
249 |
file.Close(); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
250 |
fs.Close(); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
251 |
return KErrNone; |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
252 |
} |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
253 |
|
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
254 |
// -------------------------------------------------------------------------------------------- |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
255 |
static TInt ParseCommandAndExecute() |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
256 |
{ |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
257 |
// commands literals for finding the right keyword |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
258 |
_LIT(KAutomatedTestStart,"start*"); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
259 |
_LIT(KAutomatedTestEnd,"end*"); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
260 |
_LIT(KAutomatedTestTimed,"timed*"); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
261 |
|
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
262 |
TBuf<256> c; |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
263 |
TInt match(KErrNotFound); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
264 |
|
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
265 |
// copy the full command line with arguments into a buffer |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
266 |
User::CommandLine(c); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
267 |
|
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
268 |
// try to match with each of the literals defined above |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
269 |
// (commands in atf format) |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
270 |
|
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
271 |
// check if command is "start" |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
272 |
match = c.Match(KAutomatedTestStart); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
273 |
if (match != KErrNotFound) |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
274 |
{ |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
275 |
LOGTEXT(_L("Found keyword start")); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
276 |
|
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
277 |
TBuf<256> fileName; |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
278 |
fileName.Append(c.Right(c.Length()-6)); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
279 |
LOGSTRING2(_L("Filename is %S"), &fileName); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
280 |
if(TestSettingsFile(fileName) != KErrNone) |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
281 |
{ |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
282 |
_LIT(KSettingsFileFailed, "False settings file"); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
283 |
PrintUsageInfo(KSettingsFileFailed); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
284 |
return -2; |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
285 |
} |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
286 |
// execute Profile process |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
287 |
if( StartProfilerProcess(fileName, 0) == KErrNone ) |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
288 |
{ |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
289 |
return -10; |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
290 |
} |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
291 |
return -2; |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
292 |
} |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
293 |
|
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
294 |
// check if command is "end" |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
295 |
match = c.Match(KAutomatedTestEnd); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
296 |
if (match != KErrNotFound) |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
297 |
{ |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
298 |
LOGTEXT(_L("Found keyword end")); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
299 |
|
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
300 |
// stop the profiling process |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
301 |
EndProfilerProcess(); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
302 |
return -10; |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
303 |
} |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
304 |
|
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
305 |
// check if command is "timed" |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
306 |
match = c.Match(KAutomatedTestTimed); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
307 |
if (match != KErrNotFound) |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
308 |
{ |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
309 |
// command "timed" found, need for finding settings file and run time next |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
310 |
LOGTEXT(_L("Found keyword timed")); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
311 |
TBuf<256> temp; |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
312 |
temp.Append(c); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
313 |
TLex lex(temp); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
314 |
|
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
315 |
TBuf<256> fileName; |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
316 |
TInt seconds; |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
317 |
|
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
318 |
// parse the first command line argument, the command itself |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
319 |
lex.Mark(); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
320 |
lex.SkipCharacters(); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
321 |
if(lex.TokenLength() != 0) |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
322 |
{ |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
323 |
#ifdef PIPROFILER_PRINTS |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
324 |
TPtrC token = lex.MarkedToken(); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
325 |
LOGSTRING2("Token 1 %S",&token); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
326 |
#endif |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
327 |
} |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
328 |
else |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
329 |
{ |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
330 |
LOGTEXT(_L("Problem 1 in parsing command line")); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
331 |
_LIT(KSettingsFileFailed, "Failure: False argument"); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
332 |
PrintUsageInfo(KSettingsFileFailed); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
333 |
return -2; |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
334 |
} |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
335 |
|
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
336 |
// parse the second command line argument, the settings file name |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
337 |
lex.SkipSpace(); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
338 |
lex.Mark(); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
339 |
lex.SkipCharacters(); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
340 |
if(lex.TokenLength() != 0) |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
341 |
{ |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
342 |
TPtrC token2 = lex.MarkedToken(); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
343 |
LOGSTRING2(_L("Token 2 %S"),&token2); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
344 |
fileName.Append(token2); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
345 |
LOGSTRING2(_L("Value of fileName is %S"),&fileName); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
346 |
// if(TestSettingsFile(fileName) != KErrNone) |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
347 |
// { |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
348 |
// _LIT(KSettingsFileFailed, "Failure: False settings file"); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
349 |
// PrintUsageInfo(KSettingsFileFailed); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
350 |
// return -2; |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
351 |
// } |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
352 |
} |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
353 |
else |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
354 |
{ |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
355 |
LOGTEXT(_L("Problem 2 in parsing command line")); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
356 |
_LIT(KSettingsFileFailed, "Failure: No settings file specified"); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
357 |
PrintUsageInfo(KSettingsFileFailed); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
358 |
return -2; |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
359 |
} |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
360 |
|
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
361 |
// parse the third command line argument, the run time in seconds |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
362 |
lex.SkipSpace(); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
363 |
lex.Mark(); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
364 |
lex.SkipCharacters(); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
365 |
if(lex.TokenLength() != 0) |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
366 |
{ |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
367 |
// third token ok, try to convert into TInt value |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
368 |
TPtrC token3 = lex.MarkedToken(); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
369 |
LOGSTRING2(_L("Token 3 %S"),&token3); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
370 |
TLex num(token3); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
371 |
TInt err = num.Val(seconds); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
372 |
// check if given time value acceptable |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
373 |
if (err != KErrNone) |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
374 |
{ |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
375 |
// value parsing failed, show info note to user |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
376 |
_LIT(KSecondsFailed, "Failure: False time value"); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
377 |
PrintUsageInfo(KSecondsFailed); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
378 |
return -2; |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
379 |
} |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
380 |
} |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
381 |
else |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
382 |
{ |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
383 |
LOGTEXT(_L("Problem 3 in parsing command line")); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
384 |
_LIT(KSecondsFailed, "Failure: False time value"); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
385 |
PrintUsageInfo(KSecondsFailed); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
386 |
return -2; |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
387 |
} |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
388 |
|
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
389 |
LOGSTRING3(_L("Filename is %S, seconds is %d"), &fileName, seconds); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
390 |
// execute Profile process |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
391 |
if( StartProfilerProcess(fileName, seconds) == KErrNone ) |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
392 |
{ |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
393 |
return -10; |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
394 |
} |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
395 |
return -2; |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
396 |
} |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
397 |
|
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
398 |
// check if space character in the middle of command line string |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
399 |
if( c.LocateReverse(' ') != KErrNotFound) |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
400 |
{ |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
401 |
_LIT(KWrongParameters, "Failure: Check command line parameters"); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
402 |
PrintUsageInfo(KWrongParameters); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
403 |
return -2; |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
404 |
} |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
405 |
|
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
406 |
// return -1 if no command found |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
407 |
LOGTEXT(_L("No keyword found")); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
408 |
return -1; |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
409 |
} |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
410 |
|
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
411 |
// -------------------------------------------------------------------------------------------- |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
412 |
GLDEF_C TInt E32Main() |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
413 |
{ |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
414 |
// parse command line arguments |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
415 |
ParseCommandAndExecute(); |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
416 |
|
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
417 |
return KErrNone; |
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
418 |
|
3ff3fecb12fe
Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff
changeset
|
419 |
} |