sysanadatacapture/piprofiler/piprofiler/plugins/GeneralsPlugin/src/GppSamplerImpl.cpp
author Matti Laitinen <matti.t.laitinen@nokia.com>
Thu, 11 Feb 2010 15:52:57 +0200
changeset 1 3ff3fecb12fe
permissions -rw-r--r--
Add initial version of PI Profiler under EPL
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
     1
/*
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
     3
* All rights reserved.
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
     8
*
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
     9
* Initial Contributors:
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    11
*
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    12
* Contributors:
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    13
*
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    14
* Description:  
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    15
*
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    16
*/
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    17
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    18
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    19
#include <piprofiler/ProfilerVersion.h>
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    20
#include <piprofiler/ProfilerTraces.h>
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    21
#include <kern_priv.h>
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    22
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    23
#include "GppSamplerImpl.h"
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    24
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    25
extern TUint*		IntStackPtr();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    26
#define	TAG(obj)	(*(TUint32*)&(obj.iAsyncDeleteNext))
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    27
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    28
// properties for ISA task parsing
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    29
const TUid KIsaPropertyCat={0x2001E5AD};
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    30
enum TIsaPropertyKeys
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    31
	{
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    32
	EIsaPropertyIsaTaskParserStatus = 1,
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    33
	EIsaPropertyIsaTaskAddressStart,
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    34
	EIsaPropertyIsaTaskAddressEnd,
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    35
	EIsaPropertyIsaTaskAddress,
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    36
	EIsaPropertyIsaOsTaskRunningAddress,
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    37
	EIsaPropertyIsaTaskParsedName
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    38
	};
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    39
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    40
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    41
GppSamplerImpl::GppSamplerImpl()
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    42
	{
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    43
	LOGTEXT("GppSamplerImpl::GppSamplerImpl");
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    44
	iInterruptStack = (TUint*)IntStackPtr();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    45
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    46
	LOGTEXT("GppSamplerImpl::GppSamplerImpl - attaching to properties");
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    47
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    48
	TInt err = iIsaStartAddr.Attach(KIsaPropertyCat, EIsaPropertyIsaTaskAddressStart);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    49
	if(err != KErrNone)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    50
		LOGTEXT("GppSamplerImpl::GppSamplerImpl() - Property EIsaPropertyIsaTaskAddressStart not available"); 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    51
	err = iIsaEndAddr.Attach(KIsaPropertyCat, EIsaPropertyIsaTaskAddressEnd);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    52
	if(err != KErrNone)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    53
		LOGTEXT("GppSamplerImpl::GppSamplerImpl() - Property EIsaPropertyIsaTaskAddressEnd not available"); 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    54
	err = iIsaPluginStatus.Attach(KIsaPropertyCat, EIsaPropertyIsaTaskParserStatus);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    55
	if(err != KErrNone)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    56
		LOGTEXT("GppSamplerImpl::GppSamplerImpl() - Property EIsaPropertyIsaTaskParserStatus not available"); 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    57
	err = iIsaOsTaskRunning.Attach(KIsaPropertyCat, EIsaPropertyIsaOsTaskRunningAddress);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    58
	if(err != KErrNone)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    59
		LOGTEXT("GppSamplerImpl::GppSamplerImpl() - Property EIsaPropertyIsaOsTaskRunningAddress not available"); 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    60
	
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    61
	PROFILER_ISA_TASK_NAMES
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    62
	
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    63
	Reset();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    64
	}
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    65
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    66
GppSamplerImpl::~GppSamplerImpl() 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    67
	{
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    68
	iIsaStartAddr.Close();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    69
	iIsaEndAddr.Close();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    70
	iIsaPluginStatus.Close();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    71
	iIsaOsTaskRunning.Close();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    72
	}
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    73
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    74
void GppSamplerImpl::Reset()
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    75
	{
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    76
	LOGTEXT("GppSamplerImpl::Reset");
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    77
	iLastPc = 0;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    78
	iLastThread = 0;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    79
	iRepeat = 0;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    80
	iIsaStatus = 0;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    81
	iIsaStart = 0;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    82
	iIsaEnd = 0;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    83
//	isaOsTaskRunningAddr = 0;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    84
	iStartTime=( NKern::TickCount() & 0xfffffffc );
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    85
	
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    86
	TPropertyStatus status;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    87
	TInt osAddr = 0;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    88
	
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    89
	LOGTEXT("GppSamplerImpl::Reset - getting status");
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    90
	
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    91
	// get status of ISA plug-in
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    92
	if(iIsaPluginStatus.GetStatus(status))
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    93
		{
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    94
		iIsaPluginStatus.Get(iIsaStatus);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    95
		LOGSTRING2("GppSamplerImpl::Reset - ISA plug-in status %d", iIsaStatus);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    96
		}
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    97
	
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    98
	if(iIsaStatus > 0)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
    99
		{
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   100
		LOGTEXT("GppSamplerImpl::Reset - get isa start address");
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   101
		iIsaStartAddr.Get(iIsaStart);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   102
		LOGTEXT("GppSamplerImpl::Reset - get isa end address");
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   103
		iIsaEndAddr.Get(iIsaEnd);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   104
		LOGTEXT("GppSamplerImpl::Reset - get isa os_task_running address");
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   105
		iIsaOsTaskRunning.Get(osAddr);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   106
		isaOsTaskRunningAddr = reinterpret_cast<TInt*>(osAddr);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   107
		LOGSTRING2("GppSamplerImpl::Reset - got isa os_task_running address 0x%X", osAddr);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   108
		}
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   109
	
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   110
	LOGTEXT("GppSamplerImpl::Reset - initializing isa task list");
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   111
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   112
	iIsaSample = false;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   113
	
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   114
	for(TInt i=0;i<256;i++)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   115
		knownIsaTasks[i] = -1;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   116
	
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   117
	knownIsaTaskCount = 0;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   118
	
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   119
	}
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   120
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   121
TUint8* GppSamplerImpl::EncodeTag(TUint8* aPtr)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   122
//
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   123
// Encode a tag and version to the trace data. This allows the offline analyser to 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   124
// identify the sample data.
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   125
//
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   126
{	
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   127
	_LIT(KGppSamplerVersion,"Bappea_GPP_V");
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   128
	_LIT(KProfilerVersion,"#Prof#");
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   129
	_LIT(KSamplerVersion,"#Samp#");
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   130
	
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   131
	TBuf<64> buf;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   132
	buf.Zero();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   133
	buf.Append(KGppSamplerVersion);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   134
	buf.Append(PROFILER_GPP_SAMPLER_VERSION);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   135
	buf.Append(KProfilerVersion);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   136
	buf.Append(PROFILER_VERSION_SHORT);	
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   137
	buf.Append(KSamplerVersion);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   138
	buf.Append(PROFILER_SAMPLER_VERSION);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   139
	aPtr = EncodeText(aPtr, buf);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   140
	return aPtr;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   141
}
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   142
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   143
TUint8* GppSamplerImpl::EncodeInt(TUint8* aPtr,TInt aValue)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   144
{
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   145
	LOGSTRING2("Encoding int 0x%x",aPtr);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   146
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   147
	LOGSTRING2("TIint = 0x%x",aValue);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   148
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   149
	TUint byte;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   150
	for (;;)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   151
		{
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   152
		byte = aValue & 0x7f;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   153
		if ((aValue >> 6) == (aValue >> 7))
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   154
			break;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   155
		aValue >>= 7;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   156
		*aPtr++ = byte;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   157
		}
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   158
	*aPtr++ = byte | 0x80;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   159
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   160
	LOGSTRING2("Encoded int 0x%x",aPtr);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   161
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   162
	return aPtr;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   163
}
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   164
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   165
TUint8* GppSamplerImpl::EncodeUint(TUint8* aPtr,TUint aValue)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   166
{
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   167
	LOGSTRING2("Encoding Uint 0x%x",aPtr);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   168
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   169
	LOGSTRING2("TUint = 0x%x",aValue);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   170
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   171
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   172
	TUint byte;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   173
	for (;;)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   174
		{
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   175
		byte = aValue & 0x7f;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   176
		aValue >>= 7;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   177
		if (aValue == 0)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   178
			break;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   179
		*aPtr++ = byte;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   180
		}
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   181
	*aPtr++ = byte | 0x80;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   182
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   183
	LOGSTRING2("Encoded Uint 0x%x",aPtr);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   184
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   185
	return aPtr;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   186
}
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   187
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   188
TUint8* GppSamplerImpl::EncodeText(TUint8* aPtr, const TDesC& aDes)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   189
//
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   190
// Encode a descriptor into the data stream
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   191
// This is currently limited to a descriptor that is up to 255 characters in length,
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   192
// and Unicode characters are truncated to 8 bits
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   193
//
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   194
{
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   195
	LOGSTRING2("Encoding text 0x%x",aPtr);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   196
	TInt len=aDes.Length();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   197
	*aPtr++ = TUint8(len);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   198
	const TText* p = aDes.Ptr();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   199
	while (--len >= 0)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   200
		{
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   201
		*aPtr++ = TUint8(*p++);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   202
		}
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   203
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   204
	LOGSTRING2("Encoded text 0x%x",aPtr);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   205
	return aPtr;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   206
}
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   207
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   208
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   209
TUint8* GppSamplerImpl::EncodeName(TUint8* aPtr, DObject& aObject,TUint32 id)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   210
//
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   211
// Encode the name of a kernel object
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   212
//
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   213
{
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   214
	LOGSTRING2("Encoding name 0x%x",aPtr);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   215
	TBuf8<0x5f> name;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   216
	aObject.TraceAppendName(name,false);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   217
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   218
	if(id != 0xffffffff)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   219
	{
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   220
		name.Append('[');
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   221
		name.AppendNum(id,EHex);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   222
		name.Append(']');
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   223
	}
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   224
	else
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   225
	{
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   226
		name.Append('[');
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   227
		name.AppendNum((TUint32)((void*)&(((DThread*)&aObject)->iNThread)),EHex);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   228
		name.Append(']');
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   229
	}
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   230
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   231
	aPtr = EncodeText(aPtr,name);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   232
	LOGSTRING2("Encoded name 0x%x",aPtr);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   233
	return aPtr;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   234
}
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   235
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   236
TUint8* GppSamplerImpl::EncodeThread(TUint8* aPtr, DThread& aThread)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   237
//
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   238
// Encode a thread name in the data stream.
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   239
// The thread is identified by its name, and the identity of its owning process.
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   240
// If the process has not been identified in the data stream already, it's name is
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   241
// also encoded.
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   242
//
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   243
{
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   244
	LOGSTRING2("Encoding thread 0x%x",aPtr);	
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   245
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   246
	DProcess& p = *aThread.iOwningProcess;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   247
	
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   248
	aPtr = EncodeUint(aPtr, p.iId);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   249
	if (TAG(p) != iStartTime)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   250
	{
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   251
		TAG(p) = iStartTime;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   252
		// Provide the name matching this process ID
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   253
		aPtr = EncodeName(aPtr, p, p.iId);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   254
	}
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   255
	aPtr = EncodeName(aPtr, aThread,0xffffffff);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   256
	
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   257
	LOGSTRING2("Encoded thread 0x%x",aPtr);	
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   258
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   259
	return aPtr;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   260
}
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   261
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   262
TUint8* GppSamplerImpl::EncodeRepeat(TUint8* aPtr)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   263
//
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   264
// Encode a repeated sequence of samples
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   265
//
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   266
{
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   267
	LOGSTRING2("Encoding repeat, 0x%x",iRepeat);	
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   268
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   269
	aPtr = EncodeInt(aPtr, 0);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   270
	aPtr = EncodeUint(aPtr, iRepeat);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   271
	iRepeat = 0;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   272
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   273
	LOGSTRING2("Encoded repeat, 0x%x",iRepeat);	
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   274
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   275
	return aPtr;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   276
}
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   277
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   278
TInt GppSamplerImpl::CreateFirstSample()
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   279
{
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   280
	LOGTEXT("GppSamplerImpl::CreateFirstSample");
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   281
	Reset();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   282
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   283
	TUint8* w = this->tempBuf;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   284
	w = EncodeTag(w);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   285
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   286
	TInt length = w-tempBuf;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   287
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   288
	LOGSTRING2("TAG encoded, length %d",length);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   289
	return length;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   290
}
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   291
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   292
TBool GppSamplerImpl::IsaTaskKnown(TUint8 task)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   293
{
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   294
	for(TInt i=0;i<256;i++)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   295
	{
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   296
		if(knownIsaTasks[i] == -1)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   297
		{
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   298
			knownIsaTasks[i] = task;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   299
			knownIsaTaskCount++;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   300
			return false;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   301
		}
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   302
		else if(knownIsaTasks[i] == task)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   303
		{
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   304
			return true;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   305
		}
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   306
	}
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   307
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   308
	return false;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   309
}
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   310
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   311
TUint8* GppSamplerImpl::EncodeIsaTask(TUint8* aPtr, TUint task)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   312
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   313
{
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   314
	LOGSTRING2("Encoding ISA task 0x%x",aPtr);	
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   315
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   316
	aPtr = EncodeUint(aPtr,task);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   317
	// use the task name as the process name
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   318
	aPtr = EncodeIsaName(aPtr,task,true);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   319
	// then encode the task name
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   320
	aPtr = EncodeIsaName(aPtr,task,false);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   321
	
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   322
	LOGSTRING2("Encoded ISA task 0x%x",aPtr);	
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   323
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   324
	return aPtr;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   325
}
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   326
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   327
TUint8* GppSamplerImpl::EncodeIsaName(TUint8* aPtr, TUint task,TBool process)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   328
//
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   329
// Encode a descriptor into the data stream
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   330
// This is currently limited to a descriptor that is up to 255 characters in length,
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   331
// and Unicode characters are truncated to 8 bits
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   332
//
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   333
{
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   334
	TBuf8<256> aDes;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   335
	
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   336
//	#ifdef NCP_COMMON_PROFILER_ISA_TASKS 
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   337
	if(iIsaStatus > 0)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   338
		{
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   339
		// resolve the isa task name from the task name array
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   340
		if((task-100000) < PROFILER_ISA_OS_TASK_AMOUNT && process == false)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   341
			{
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   342
			aDes.Append(isaTaskNames[(task-100000)]);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   343
			}
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   344
		else
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   345
			{
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   346
			aDes.Append(_L8("NativeOS_Task"));
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   347
			}
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   348
		}
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   349
	else
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   350
		{
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   351
		aDes.Append(_L8("NativeOS_Task"));
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   352
		}
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   353
	
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   354
	aDes.Append('[');
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   355
	aDes.AppendNum((task-100000),EHex);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   356
	aDes.Append(']');
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   357
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   358
	LOGSTRING2("Encoding ISA name 0x%x",aPtr);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   359
	TInt len=aDes.Length();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   360
	*aPtr++ = TUint8(len);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   361
	const TText* p = aDes.Ptr();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   362
	while (--len >= 0)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   363
		{
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   364
		*aPtr++ = TUint8(*p++);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   365
		}
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   366
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   367
	LOGSTRING2("Encoded ISA name 0x%x",aPtr);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   368
	return aPtr;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   369
}
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   370
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   371
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   372
TInt GppSamplerImpl::SampleImpl()
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   373
//
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   374
// ISR for the profile timer
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   375
// This extracts the thread and PC that was current when the interrupt went off and
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   376
// encodes it into the sample data buffer. If enough data has been generated, the
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   377
// DFC is triggered to complete a read request
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   378
//
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   379
{
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   380
	TUint8* w = this->tempBuf;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   381
	
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   382
	TUint32 pc = iInterruptStack[-1];
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   383
	LOGSTRING3("pc value 0x%x sp 0x%x",pc,iInterruptStack);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   384
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   385
	// ignore the low bit being set for THUMB mode - we use for something else
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   386
	pc &= ~1;			
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   387
	TInt diff = pc - iLastPc;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   388
	iLastPc = pc;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   389
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   390
	if(iIsaStatus > 0)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   391
		{
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   392
		if((TUint32)pc > (TUint32)iIsaStart && (TUint32)pc < (TUint32)iIsaEnd)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   393
			{
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   394
			LOGSTRING2("Identified ISA execution at 0x%x",pc);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   395
			iIsaSample = true;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   396
			}
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   397
		else
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   398
			{
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   399
			LOGSTRING2("Normal sample at 0x%x",pc);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   400
			iIsaSample = false;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   401
			}
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   402
		}
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   403
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   404
	DThread& t = Kern::CurrentThread();
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   405
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   406
	TUint tid;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   407
	TUint8 isaTask = 0;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   408
	if(iIsaSample)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   409
	{
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   410
		LOGSTRING2("Reading ISA task number from 0x%x",isaOsTaskRunningAddr);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   411
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   412
		// if we don't get reasonable ISA address to read, skip ISA task handling
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   413
		if(isaOsTaskRunningAddr == 0)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   414
			{
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   415
			tid = 100000; // to tell the difference from SOS threads
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   416
			iIsaSample = false;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   417
			}
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   418
		else	// normal ISA task parsing process
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   419
			{
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   420
			isaTask = *isaOsTaskRunningAddr;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   421
			LOGSTRING2("ISA task = %d",isaTask);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   422
			tid = isaTask;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   423
			// this will make sure we don't mix ISA tasks and normal tasks
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   424
			tid += 100000;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   425
			}
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   426
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   427
	}
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   428
	else
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   429
	{
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   430
		tid = t.iId;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   431
	}
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   432
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   433
	if (tid != iLastThread)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   434
	{
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   435
		// Change of thread is marked in the low bit of the PC difference
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   436
		diff |= 1;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   437
	}
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   438
	TUint rp = iRepeat;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   439
	if (diff == 0)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   440
	{
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   441
		// Identical sample, bump up the repeat count
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   442
		iRepeat = rp + 1;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   443
	}
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   444
	else
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   445
	{
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   446
		if (rp)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   447
		{
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   448
			// Encode the repeat data
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   449
			w = EncodeRepeat(w);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   450
		}
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   451
		// Encode the PC difference
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   452
		w = EncodeInt(w, diff);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   453
		if (diff & 1)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   454
		{
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   455
			// Encode the new thread ID
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   456
			if(iIsaSample)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   457
			{
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   458
				iLastThread = tid;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   459
				w = EncodeUint(w,tid);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   460
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   461
				if(!this->IsaTaskKnown(isaTask))
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   462
				{
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   463
					w = EncodeIsaTask(w,iLastThread);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   464
				}
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   465
				//LOGSTRING2("Sample total length: %d",w-tempBuf);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   466
				TInt length = w-tempBuf;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   467
				// encoded isa task, return here
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   468
				return length;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   469
			}
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   470
		
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   471
			iLastThread = tid;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   472
			w = EncodeUint(w, tid);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   473
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   474
			if ((TAG(t) & 0xfffffffc) != iStartTime)
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   475
			{
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   476
			
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   477
				TAG(t) = ((TAG(t) & 0x3) | iStartTime);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   478
				// The thread is 'unknown' to this sample, so encode the thread name
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   479
				w = EncodeThread(w, t);		
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   480
			}
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   481
		}
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   482
	}
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   483
	LOGSTRING2("Sample total length: %d",w-tempBuf);
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   484
	TInt length = w-tempBuf;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   485
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   486
	return length;
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   487
}
3ff3fecb12fe Add initial version of PI Profiler under EPL
Matti Laitinen <matti.t.laitinen@nokia.com>
parents:
diff changeset
   488