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