perfsrv/piprofiler/engine/src/ProfilerEshell.cpp
changeset 62 1c2bb2fc7c87
parent 51 98307c651589
equal deleted inserted replaced
56:aa2539c91954 62:1c2bb2fc7c87
    33  */
    33  */
    34 // --------------------------------------------------------------------------------------------
    34 // --------------------------------------------------------------------------------------------
    35 static void PrintUsageInfo(const TDesC& aAdditionalInfo)
    35 static void PrintUsageInfo(const TDesC& aAdditionalInfo)
    36     {
    36     {
    37     _LIT(KConsoleName, "Console");
    37     _LIT(KConsoleName, "Console");
    38     _LIT(KLegalNote, "PIProfiler Version 2.2.2 Copyright @ 2009 Nokia\n");
    38     _LIT(KLegalNote, "PIProfiler Version 2.2.0.3 Copyright @ 2009 Nokia\n");
    39     _LIT(KUsageNote, "Usage: PIProfiler [start/end/timed] settingsfile [time to run]\n");
    39     _LIT(KUsageNote, "Usage: PIProfiler [start/end/timed] settingsfile [time to run]\n");
    40     _LIT(KExample, "Example: PIProfiler timed C:\\data\\piprofilersettings.txt 60\n");
    40     _LIT(KExample, "Example: PIProfiler timed C:\\data\\piprofilersettings.txt 60\n");
    41 
    41 
    42     TRAP_IGNORE(CConsoleBase* console = Console::NewL(KConsoleName,TSize(KConsFullScreen,KConsFullScreen));
    42     TRAP_IGNORE(CConsoleBase* console = Console::NewL(KConsoleName,TSize(KConsFullScreen,KConsFullScreen));
    43         console->Printf(KLegalNote);
    43         console->Printf(KLegalNote);
    94     TBuf<256> conf;
    94     TBuf<256> conf;
    95     conf.Zero();
    95     conf.Zero();
    96     conf.Append(configFile);
    96     conf.Append(configFile);
    97     if(aBootTime)
    97     if(aBootTime)
    98         {
    98         {
    99         RDebug::Printf("boot time measurement");
    99         RDebug::Printf("PIProfiler: StartProfilerProcess: boot time measurement");
   100         conf.Append(_L(" "));
   100         conf.Append(_L(" "));
   101         conf.Append(_L("boot"));
   101         conf.Append(_L("boot"));
   102         }
   102         }
   103     RDebug::RawPrint(conf);
   103     RDebug::RawPrint(conf);
       
   104     RDebug::Printf("PIProfiler: StartProfilerProcess run time is %d", aRunTimeInSeconds);
   104     // check if process exists
   105     // check if process exists
   105     err = FindProcess();
   106     err = FindProcess();
   106     LOGSTRING2("PIProfiler: tried to find process, response %d", err); 
   107     LOGSTRING2("PIProfiler: tried to find process, response %d", err); 
   107 
   108 
   108     // check if already exists and don't start a new eshell profiling
   109     // check if already exists and don't start a new eshell profiling
   114         LOGSTRING2("PIProfiler: created process, response %d", err); 
   115         LOGSTRING2("PIProfiler: created process, response %d", err); 
   115 
   116 
   116         // check if RProcess::Create() succeeded
   117         // check if RProcess::Create() succeeded
   117         if( err == KErrNone )
   118         if( err == KErrNone )
   118             {
   119             {
       
   120             LOGSTRING("PI Profiler start rendezvous ");
   119             // Trigger rendezvous on the supplied TRequestStatus object
   121             // Trigger rendezvous on the supplied TRequestStatus object
   120             proc.Rendezvous(status); 
   122             proc.Rendezvous(status); 
   121 
   123             LOGSTRING("PI Profiler start resume ");
   122             // kick off the engine process
   124             // kick off the engine process
   123             proc.Resume();
   125             proc.Resume();
   124             
   126             LOGSTRING("PI Profiler start waitforrequest ");
   125             // wait for the constructor to complete 
   127             // wait for the constructor to complete 
   126             User::WaitForRequest(status); 
   128             User::WaitForRequest(status); 
   127             
   129             LOGSTRING("PI Profiler start close ");
   128             // just lose the handle
   130             // just lose the handle
   129             proc.Close();
   131             proc.Close();
   130             
   132             LOGSTRING("PI Profiler start: closed");
   131             // start sampling, using settings found in settings file or if not found the default settings
   133             // start sampling, using settings found in settings file or if not found the default settings
   132             err = RProfiler::StartSampling();
   134             err = RProfiler::StartSampling();
       
   135             LOGSTRING2("PI Profiler start: err %d", err);
   133             // check if command succesful
   136             // check if command succesful
   134             if( err != KErrNone )
   137             if( err != KErrNone )
   135                 {
   138                 {
   136                 LOGSTRING2("PI Profiler start: err %d", err);
   139                 LOGSTRING2("PI Profiler start: err %d", err);
   137                 _LIT(KNoteProfilerCannotStart, "PI Profiler: cannot start PI Profiler, check settings!");
   140                 _LIT(KNoteProfilerCannotStart, "PI Profiler: cannot start PI Profiler, check settings!");
   271     TInt match(KErrNotFound);
   274     TInt match(KErrNotFound);
   272     TInt bootmatch(KErrNotFound);
   275     TInt bootmatch(KErrNotFound);
   273     TBool myBoot=false;
   276     TBool myBoot=false;
   274     // copy the full command line with arguments into a buffer
   277     // copy the full command line with arguments into a buffer
   275     User::CommandLine(c);
   278     User::CommandLine(c);
   276     LOGSTRING2("command: %S", &c);
   279     LOGSTRING2("ParseCommandAndExecute command: %S", &c);
   277 
   280 
   278     // try to match with each of the literals defined above
   281     // try to match with each of the literals defined above
   279     // (commands in atf format)
   282     // (commands in atf format)
   280     
   283     
   281     // check if command is "start"
   284     // check if command is "start"
   282     match = c.Match(KAutomatedTestStart);
   285     match = c.Match(KAutomatedTestStart);
   283     if (match != KErrNotFound)
   286     if (match != KErrNotFound)
   284         {
   287         {
   285         LOGTEXT(_L("Found keyword start"));
   288         LOGTEXT(_L("ParseCommandAndExecute Found keyword start"));
   286 
   289 
   287         TBuf<256> fileName;
   290         TBuf<256> fileName;
   288         fileName.Append(c.Right(c.Length()-6));
   291         fileName.Append(c.Right(c.Length()-6));
   289         LOGSTRING2("Filename is %S", &fileName);
   292         LOGSTRING2("ParseCommandAndExecute Filename is %S", &fileName);
   290         if(TestSettingsFile(fileName) != KErrNone)
   293         if(TestSettingsFile(fileName) != KErrNone)
   291             {
   294             {
   292             _LIT(KSettingsFileFailed, "False settings file");
   295             _LIT(KSettingsFileFailed, "False settings file");
   293             PrintUsageInfo(KSettingsFileFailed);
   296             PrintUsageInfo(KSettingsFileFailed);
   294             return -2;
   297             return -2;
   319     if ((match!= KErrNotFound) || (bootmatch != KErrNotFound))
   322     if ((match!= KErrNotFound) || (bootmatch != KErrNotFound))
   320         {
   323         {
   321         // command "timed" or " boot" found, need for finding settings file and run time next
   324         // command "timed" or " boot" found, need for finding settings file and run time next
   322         if(bootmatch != KErrNotFound)
   325         if(bootmatch != KErrNotFound)
   323             {
   326             {
   324             LOGTEXT(_L("Found keyword boot"));
   327             LOGTEXT(_L("ParseCommandAndExecute Found keyword boot"));
   325             myBoot = TRUE;
   328             myBoot = TRUE;
   326             }
   329             }
   327         if(match != KErrNotFound)
   330         if(match != KErrNotFound)
   328             {
   331             {
   329             LOGTEXT(_L("Found keyword timed"));
   332             LOGTEXT(_L("ParseCommandAndExecute Found keyword timed"));
   330             }
   333             }
   331         
   334         
   332         TBuf<256> temp;
   335         TBuf<256> temp;
   333         temp.Append(c);
   336         temp.Append(c);
   334         TLex lex(temp);
   337         TLex lex(temp);