commands/showdebug/showdebug.cpp
author Tom Sutcliffe <thomas.sutcliffe@accenture.com>
Thu, 21 Oct 2010 22:32:59 +0100
changeset 90 dc41da2f70a4
permissions -rw-r--r--
Added showdebug command. Also: * Added an exported constructor to RChildProcess so the iProcess handle was set to zero on construction. * Fixed bug in fshell_builddocs script that created HTML relative links with backslashes instead of forward slashes.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
90
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
     1
// showdebug.cpp
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
     2
// 
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
     3
// Copyright (c) 2010 Accenture. All rights reserved.
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
     4
// This component and the accompanying materials are made available
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
     5
// under the terms of the "Eclipse Public License v1.0"
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
     6
// which accompanies this distribution, and is available
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
     7
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
     8
// 
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
     9
// Initial Contributors:
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    10
// Accenture - Initial contribution
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    11
//
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    12
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    13
#include <fshell/ioutils.h>
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    14
#include <fshell/common.mmh>
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    15
#include <fshell/debugrouter.h>
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    16
#include <HAL.h>
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    17
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    18
using namespace IoUtils;
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    19
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    20
class CCmdShowDebug : public CCommandBase, public MCommandExtensionsV2
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    21
	{
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    22
public:
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    23
	static CCommandBase* NewLC();
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    24
	~CCmdShowDebug();
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    25
private:
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    26
	CCmdShowDebug();
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    27
	void Log(TUint8 aWhere, TUint32 aTickCount, TUint aThreadId, const TDesC8& aMsg);
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    28
	inline TTime TickCountToTime(TUint32 aTickCount) const;
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    29
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    30
private: // From CCommandBase.
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    31
	virtual const TDesC& Name() const;
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    32
	virtual void DoRunL();
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    33
	virtual void ArgumentsL(RCommandArgumentList& aArguments);
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    34
	virtual void OptionsL(RCommandOptionList& aOptions);
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    35
	virtual void DoCancel();
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    36
	virtual void RunL();
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    37
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    38
private: // From MCommandExtensionsV2
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    39
	virtual void CtrlCPressed();
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    40
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    41
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    42
	class CLogonCompleter : public CActive
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    43
		{
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    44
	public:
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    45
		CLogonCompleter(CCmdShowDebug* aCommand) : CActive(CActive::EPriorityStandard), iCommand(aCommand)
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    46
			{
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    47
			CActiveScheduler::Add(this);
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    48
			iCommand->iProcess.Process().Logon(iStatus);
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    49
			SetActive();
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    50
			}
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    51
		void RunL() { iCommand->Complete(iStatus.Int()); }
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    52
		void DoCancel() { iCommand->iProcess.Process().LogonCancel(iStatus); }
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    53
		~CLogonCompleter() { Cancel(); }
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    54
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    55
	private:
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    56
		CCmdShowDebug* iCommand;
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    57
		};
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    58
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    59
private:
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    60
	RCloggerDebugRouter iRouter;
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    61
	RChunk iChunk;
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    62
	TBuf8<2048> iTempBuf;
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    63
	TBuf<2048> iTempWideBuf;
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    64
	RChildProcess iProcess;
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    65
	CLogonCompleter* iCompleter;
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    66
	TInt64 iStartupTickInMicroseconds;
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    67
	TTime iTimeAtStartup;
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    68
	TInt iTickFreq;
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    69
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    70
	HBufC* iProcessName;
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    71
	HBufC* iArgs;
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    72
	RArray<TBool> iVerbose;
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    73
	TBool iFilter;
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    74
	};
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    75
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    76
EXE_BOILER_PLATE(CCmdShowDebug)
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    77
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    78
CCommandBase* CCmdShowDebug::NewLC()
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    79
	{
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    80
	CCmdShowDebug* self = new(ELeave) CCmdShowDebug();
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    81
	CleanupStack::PushL(self);
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    82
	self->BaseConstructL();
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    83
	return self;
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    84
	}
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    85
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    86
CCmdShowDebug::~CCmdShowDebug()
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    87
	{
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    88
	Cancel();
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    89
	if (iRouter.Handle())
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    90
		{
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    91
		iRouter.EnableDebugRouting(RCloggerDebugRouter::EDisable);
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    92
		}
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    93
	iRouter.Close();
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    94
	iChunk.Close();
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    95
	delete iCompleter;
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    96
	if (iProcess.Process().Handle() && iProcess.Process().ExitType() == EExitPending)
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    97
		{
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    98
		iProcess.Process().Kill(KErrAbort);
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    99
		}
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   100
	iProcess.Close();
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   101
	delete iProcessName;
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   102
	delete iArgs;
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   103
	}
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   104
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   105
CCmdShowDebug::CCmdShowDebug()
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   106
	: CCommandBase(EManualComplete | ECaptureCtrlC)
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   107
	{
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   108
	SetExtension(this);
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   109
	}
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   110
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   111
const TDesC& CCmdShowDebug::Name() const
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   112
	{
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   113
	_LIT(KName, "showdebug");	
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   114
	return KName;
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   115
	}
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   116
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   117
void CCmdShowDebug::ArgumentsL(RCommandArgumentList& aArguments)
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   118
	{
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   119
	aArguments.AppendStringL(iProcessName, _L("process"));
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   120
	aArguments.AppendStringL(iArgs, _L("arguments"));
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   121
	}
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   122
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   123
void CCmdShowDebug::OptionsL(RCommandOptionList& aOptions)
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   124
	{
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   125
	aOptions.AppendBoolL(iVerbose, _L("verbose"));
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   126
	aOptions.AppendBoolL(iFilter, _L("filter"));
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   127
	}
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   128
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   129
void CCmdShowDebug::DoRunL()
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   130
	{
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   131
	TInt err = RCloggerDebugRouter::LoadDriver();
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   132
	if (err != KErrAlreadyExists) LeaveIfErr(err, _L("Couldn't load clogger debug router"));
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   133
	LeaveIfErr(iRouter.Open(), _L("Couldn't open debug router"));
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   134
	LeaveIfErr(iRouter.OpenChunk(iChunk), _L("Couldn't open debug router shared chunk"));
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   135
	LeaveIfErr(iRouter.EnableDebugRouting(RCloggerDebugRouter::EEnableRouting), _L("Couldn't enable routing"));
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   136
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   137
	iRouter.ReceiveData(iStatus);
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   138
	SetActive();
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   139
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   140
	if (iProcessName)
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   141
		{
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   142
		TRAPL(iProcess.CreateL(*iProcessName, iArgs ? *iArgs : KNullDesC(), IoSession(), Stdin(), Stdout(), Stderr(), Env()), _L("Failed to execute %S"), iProcessName);
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   143
		iCompleter = new(ELeave) CLogonCompleter(this);
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   144
		SetErrorReported(ETrue); // So that if iProcess completes with an error it doesn't cause a strange printout when we complete with its error code
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   145
		iProcess.Process().Resume();
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   146
		}
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   147
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   148
	if (iVerbose.Count())
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   149
		{
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   150
		// Need to do some maths to figure out how to translate tick counts to time
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   151
		TUint32 tickCount = User::NTickCount();
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   152
		iTimeAtStartup.UniversalTime();
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   153
		TInt tickPeriod;
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   154
		User::LeaveIfError(HAL::Get(HAL::ENanoTickPeriod, tickPeriod));
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   155
		iTickFreq = 1000000 / tickPeriod; // We work in frequencies because they are the round numbers when using the fast counter, and at some point we might want to again
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   156
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   157
		iStartupTickInMicroseconds = ((TInt64)tickCount * 1000000) / (TInt64)iTickFreq; // Just making damn sure we're using 64bit math
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   158
		}
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   159
	}
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   160
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   161
void CCmdShowDebug::DoCancel()
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   162
	{
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   163
	iRouter.CancelReceive();
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   164
	}
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   165
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   166
TPtrC8 Read(TDes8& aTempBuf, TPtrC8& aData, TInt aLength, TPtrC8& aOverflowData)
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   167
	{
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   168
	if (aLength <= aData.Length())
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   169
		{
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   170
		// Can read it from this buffer
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   171
		TPtrC8 res(aData.Left(aLength));
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   172
		aData.Set(aData.Mid(aLength));
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   173
		return res;
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   174
		}
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   175
	else /*if (aLength > aData.Length())*/
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   176
		{
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   177
		// Descriptor spans wrap point, so need to copy into temp buf
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   178
		aTempBuf.Copy(aData.Left(aTempBuf.MaxLength())); // If anyone's crazy enough to write a platsec diagnostic string longer than 2k, it gets truncated
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   179
		TInt overflowLen = aLength - aData.Length();
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   180
		aData.Set(aOverflowData); // Wrap aData
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   181
		aOverflowData.Set(TPtrC8());
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   182
		if (overflowLen > aData.Length())
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   183
			{
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   184
			ASSERT(EFalse); // Shouldn't happen
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   185
			// in urel, return everything we've got
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   186
			return aData;
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   187
			}
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   188
		aTempBuf.Append(aData.Left(overflowLen));
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   189
		aData.Set(aData.Mid(overflowLen));
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   190
		return TPtrC8(aTempBuf);
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   191
		}
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   192
	}
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   193
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   194
void CCmdShowDebug::RunL()
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   195
	{
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   196
	TUint chunkSize = iChunk.Size();
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   197
	const TUint KDataStartOffset = sizeof(SDebugChunkHeader);
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   198
	SDebugChunkHeader* chunkHeader = (SDebugChunkHeader*)iChunk.Base();
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   199
	TUint start = chunkHeader->iStartOffset;
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   200
	TUint end = chunkHeader->iEndOffset;
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   201
	TUint overflows = chunkHeader->iOverflows;
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   202
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   203
	TBool wrap = (start > end);
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   204
	TUint endLen = wrap ? chunkSize - start : end - start;
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   205
	TUint startLen = wrap ? end - KDataStartOffset : 0;
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   206
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   207
	TPtrC8 endData(iChunk.Base() + start, endLen);
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   208
	TPtrC8 startData;
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   209
	if (wrap) startData.Set(iChunk.Base() + KDataStartOffset, startLen);
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   210
	TPtrC8 data(endData);
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   211
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   212
	while (data.Length())
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   213
		{
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   214
		TPtrC8 header = Read(iTempBuf, data, sizeof(SCloggerTraceInfo), startData);
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   215
		if (header.Length() < (TInt)sizeof(SCloggerTraceInfo))
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   216
			{
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   217
			ASSERT(EFalse); // for udeb
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   218
			break; // Something's broken
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   219
			}
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   220
		SCloggerTraceInfo info;
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   221
		Mem::Copy(&info, header.Ptr(), sizeof(SCloggerTraceInfo));
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   222
		ASSERT(info.iTraceType == 'K' || info.iTraceType == 'U' || info.iTraceType == 'P');
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   223
		TPtrC8 msg = Read(iTempBuf, data, info.iLength, startData);
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   224
		Log(info.iTraceType, info.iTickCount, info.iThreadId, msg);
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   225
		}
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   226
	if (overflows)
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   227
		{
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   228
		_LIT(KErr, "RDebug::Print buffer overflowed, %u calls not logged");
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   229
		PrintWarning(KErr, overflows);
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   230
		}
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   231
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   232
	iRouter.ReceiveData(iStatus);
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   233
	SetActive();
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   234
	}
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   235
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   236
void CCmdShowDebug::Log(TUint8 /*aWhere*/, TUint32 aTickCount, TUint aThreadId, const TDesC8& aMsg)
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   237
	{
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   238
	RThread thread; thread.SetHandle(0);
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   239
	if (iVerbose.Count() > 1 || iFilter)
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   240
		{
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   241
		// Need to open the thread in those cases
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   242
		thread.Open(aThreadId);
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   243
		}
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   244
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   245
	if (iFilter && thread.Handle())
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   246
		{
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   247
		RProcess proc;
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   248
		TInt err = thread.Process(proc);
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   249
		if (!err)
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   250
			{
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   251
			if (proc.Id() != iProcess.Process().Id())
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   252
				{
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   253
				// Trace definitely doesn't belong to our process, skip it
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   254
				proc.Close();
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   255
				thread.Close();
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   256
				return;
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   257
				}
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   258
			}
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   259
		}
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   260
	
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   261
	if (iVerbose.Count())
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   262
		{
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   263
		TDateTime dt = TickCountToTime(aTickCount).DateTime();
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   264
		_LIT(KFormat, "%i-%02i-%02i %02i:%02i:%02i.%03i: ");
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   265
		// Have to add 1 to Month and Day, as these are zero-based
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   266
		iTempWideBuf.Format(KFormat, dt.Year(), dt.Month()+1, dt.Day()+1, dt.Hour(), dt.Minute(), dt.Second(), dt.MicroSecond()/1000);
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   267
		if (iVerbose.Count() > 1 && thread.Handle())
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   268
			{
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   269
			TFullName name = thread.FullName();
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   270
			iTempWideBuf.AppendFormat(_L("%S "), &name);
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   271
			}
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   272
		else
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   273
			{
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   274
			// Just use thread id
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   275
			iTempWideBuf.AppendFormat(_L("[%d] "), aThreadId);
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   276
			}
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   277
		Write(iTempWideBuf);
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   278
		}
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   279
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   280
	thread.Close();
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   281
	
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   282
	iTempWideBuf.Copy(aMsg);
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   283
	Write(iTempWideBuf);
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   284
	Write(_L("\r\n"));
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   285
	}
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   286
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   287
void CCmdShowDebug::CtrlCPressed()
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   288
	{
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   289
	// TODO clean up iProcess
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   290
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   291
	Printf(_L("CTRL-C received, exiting.\r\n"));
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   292
	Complete();
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   293
	}
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   294
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   295
inline TTime CCmdShowDebug::TickCountToTime(TUint32 aTickCount) const
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   296
	{
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   297
	return TTime(iTimeAtStartup.Int64() + (((TInt64)aTickCount*1000000) / (TInt64)iTickFreq) - iStartupTickInMicroseconds);
dc41da2f70a4 Added showdebug command.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   298
	}