diff -r 3ff3fecb12fe -r 6a82cd05fb1e sysanadatacapture/piprofiler/piprofiler/plugins/GeneralsPlugin/inc/IttSamplerImpl.h --- a/sysanadatacapture/piprofiler/piprofiler/plugins/GeneralsPlugin/inc/IttSamplerImpl.h Thu Feb 11 15:52:57 2010 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,188 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - - -#ifndef PROFILER_ITT_SAMPLER_H -#define PROFILER_ITT_SAMPLER_H - -#include "GeneralsConfig.h" - -#include - -#include -#include -#include "GppSamplerImpl.h" - -/* - * - * ITT sampler definition - * - */ - -class IttSamplerImpl -{ -public: - IttSamplerImpl(); - ~IttSamplerImpl(); - - TInt SampleImpl(TUint32 pc,TUint32 sampleNum); - TBool SampleNeeded(TUint32 sampleNum); - TInt CreateFirstSample(); - void Reset(); - - TUint8* itt_sample; - TBool iSampleProcesses; -private: - - TUint8 internalData[256]; - TPtr8* ptrToData; - TInt currentLibCount; - TInt currentProcCount; - - TBuf8<64> iVersionData; - SDblQue* codeSegList; -}; - -template -class DProfilerIttSampler : public DProfilerGenericSampler -{ -public: - DProfilerIttSampler(struct TProfilerGppSamplerData* gppSamplerDataIn); - ~DProfilerIttSampler(); - - void Sample(); - TInt Reset(DProfilerSampleStream* aStream, TUint32 aSyncOffset); - TInt PostSample(); - TBool PostSampleNeeded(); - -private: - struct TProfilerGppSamplerData* gppSamplerData; - IttSamplerImpl ittSampler; - TBool sampleInProgress; - TBool sampleNeeded; -}; - -/* - * - * ITT sampler implementation - * - */ - -template -DProfilerIttSampler::DProfilerIttSampler(struct TProfilerGppSamplerData* gppSamplerDataIn) : - DProfilerGenericSampler(PROFILER_ITT_SAMPLER_ID) -{ - this->gppSamplerData = (struct TProfilerGppSamplerData*)gppSamplerDataIn; - this->sampleInProgress = false; - LOGSTRING2("CProfilerIttSampler<%d>::CProfilerIttSampler",BufferSize); -} - -template -TInt DProfilerIttSampler::Reset(DProfilerSampleStream* aStream, TUint32 aSyncOffset) -{ - LOGSTRING2("CProfilerIttSampler<%d>::Reset - calling superclass reset",BufferSize); - DProfilerGenericSampler::Reset(aStream); - LOGSTRING2("CProfilerIttSampler<%d>::Reset - called superclass reset",BufferSize); - TInt length = this->ittSampler.CreateFirstSample(); - this->iSampleBuffer->AddSample((TUint8*)&length,1); - this->iSampleBuffer->AddSample(ittSampler.itt_sample,length); - this->sampleInProgress = false; - this->sampleNeeded = false; - - this->ittSampler.Reset(); - - return KErrNone; -} - -template -TInt DProfilerIttSampler::PostSample() -{ - if(sampleNeeded) - { - this->sampleNeeded = false; - - LOGSTRING3("CProfilerIttSampler<%d>::PostSample - state %d",BufferSize,this->sampleBuffer->GetBufferStatus()); - - - TInt length = this->ittSampler.SampleImpl(this->gppSamplerData->lastPcValue, - this->gppSamplerData->sampleNumber); - if(length != 0) - { - LOGSTRING("ITT sampler PostSample - starting to sample"); - - while(length > 0) - { - this->iSampleBuffer->AddSample(ittSampler.itt_sample,length); - length = this->ittSampler.SampleImpl( this->gppSamplerData->lastPcValue, - this->gppSamplerData->sampleNumber ); - if(length == 0) - { - LOGSTRING("MEM sampler PostSample - all samples generated!"); - } - } - LOGSTRING("ITT sampler PostSample - finished sampling"); - } - this->sampleInProgress = false; - } - - // finally perform superclass postsample - TInt i = this->DProfilerGenericSampler::PostSample(); - return i; -} - -template -TBool DProfilerIttSampler::PostSampleNeeded() -{ - LOGSTRING3("CProfilerMemSampler<%d>::PostSampleNeeded - state %d",BufferSize,this->sampleBuffer->GetBufferStatus()); - - TUint32 status = this->iSampleBuffer->iBufferStatus; - - if(status == DProfilerSampleBuffer::BufferCopyAsap || status == DProfilerSampleBuffer::BufferFull || this->sampleNeeded == true) - { - return true; - } - - return false; -} - -template -void DProfilerIttSampler::Sample() -{ - LOGSTRING2("CProfilerIttSampler<%d>::Sample",BufferSize); - - //#ifdef ITT_TEST - LOGSTRING2("CProfilerIttSampler<%d>::Sample",BufferSize); - - if(ittSampler.SampleNeeded(this->gppSamplerData->sampleNumber) && this->sampleInProgress == false) - { - this->sampleInProgress = true; - this->sampleNeeded = true; - - LOGSTRING2("CProfilerIttSampler<%d>::Sample - sample needed",BufferSize); - } - - LOGSTRING2("CProfilerIttSampler<%d>::Sample",BufferSize); - - return; -} - -template -DProfilerIttSampler::~DProfilerIttSampler() -{ - LOGSTRING2("CProfilerIttSampler<%d>::~CProfilerIttSampler",BufferSize); -} -#endif