# HG changeset patch # User Matti Laitinen # Date 1265896377 -7200 # Node ID 3ff3fecb12fefbd6c2fc62e746ac69b8629ac769 # Parent f0f2b8682603a0e99e72c9f8fa45087837b40fdc Add initial version of PI Profiler under EPL diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/group/ReleaseNotes_PIProfiler.txt Binary file sysanadatacapture/piprofiler/group/ReleaseNotes_PIProfiler.txt has changed diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/group/bld.inf Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,21 @@ +/* +* 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: PI Profiler engine and UI +* +*/ + +#include "../piprofiler_api/group/bld.inf" +#include "../piprofiler/group/bld.inf" +#include "../piprofilerui/group/bld.inf" + diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler/engine/group/ProfilerEngine.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler/engine/group/ProfilerEngine.mmp Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,56 @@ +/* +* 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: +* +*/ + + +#include + + +TARGET PIProfilerEngine.exe +TARGETTYPE EXE +UID 0x100039CE 0x2001E5AD +VENDORID VID_DEFAULT +CAPABILITY ALL -TCB + +EPOCSTACKSIZE 0x10000 +EPOCHEAPSIZE 0x100000 0x2000000 // Min 1MB, Max 32MB + +OS_LAYER_SYSTEMINCLUDE +USERINCLUDE ../inc +SOURCEPATH ../src + + +SOURCE ProfilerErrorChecker.cpp +SOURCE ProfilerEngine.cpp +SOURCE SamplerController.cpp +SOURCE SamplerPluginLoader.cpp +SOURCE WriterController.cpp +SOURCE WriterPluginLoader.cpp + +LIBRARY sysutil.lib +LIBRARY EFSRV.LIB +LIBRARY C32.LIB +LIBRARY EUSER.LIB +LIBRARY estor.lib +LIBRARY fbscli.lib +LIBRARY eikcore.lib +LIBRARY apparc.lib +LIBRARY cone.lib +LIBRARY ws32.lib +LIBRARY bafl.lib +LIBRARY charconv.lib +LIBRARY ecom.lib +LIBRARY PlatformEnv.lib diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler/engine/group/ProfilerEshell.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler/engine/group/ProfilerEshell.mmp Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,40 @@ +/* +* 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: +* +*/ + + +#include + + +TARGET PIProfiler.exe +TARGETTYPE EXE +UID 0x100039CE 0x2021E5AD // test UID, get an official +VENDORID VID_DEFAULT +CAPABILITY ALL -TCB + +EPOCSTACKSIZE 0x10000 + +OS_LAYER_SYSTEMINCLUDE +USERINCLUDE ../inc +SOURCEPATH ../src + + +SOURCE ProfilerEshell.cpp + +LIBRARY C32.LIB +LIBRARY EUSER.LIB +LIBRARY bafl.lib +LIBRARY efsrv.lib diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler/engine/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler/engine/group/bld.inf Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,21 @@ +/* +* Copyright (c) 2007 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: +* +*/ + + +PRJ_MMPFILES +ProfilerEngine.mmp +ProfilerEshell.mmp \ No newline at end of file diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler/engine/inc/ProfilerEngine.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler/engine/inc/ProfilerEngine.h Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,252 @@ +/* +* 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 __PROFILERENGINE__ +#define __PROFILERENGINE__ + +#include +#include +#include +#include + +#include +#include +#include +#include // internal settings format presentations + +#include "SamplerController.h" +#include "WriterController.h" +#include "ProfilerErrorChecker.h" + +// CONSTANTS +const TInt KProfilerPrefixMaxLength = 32; +const TInt KSettingsFileSize = 4096; + +/* + * This is an internal interface to the profiling engine which allows + * an additional control DLL to be loaded, replacing the profiler's + * default console UI + */ + +/** + * Implementation class providing access to the profiler engine + */ + +class MProfilerEngine +{ +public: + virtual TInt ControlL(TInt aCommand) =0; + virtual TInt ControlDataL(TInt aCommand, TAny* data1 = 0, TAny* data2 = 0) = 0; + + virtual TInt GetSamplerAttributesL(const RMessage2& aMessage) = 0; + virtual TInt GetSamplerAttributeCountL(const RMessage2& aMessage) = 0; + virtual TInt SetSamplerAttributesL(const RMessage2& aMessage) = 0; + virtual TInt GetGeneralAttributesL(const RMessage2& aMessage) = 0; + virtual TInt SetGeneralAttributesL(const RMessage2& aMessage) = 0; + virtual TInt RefreshStatus(const RMessage2& aMessage) = 0; + virtual RProfiler::TSamplerState State() const =0; +}; + +/** + * The interface that the extra controller must implement to access + * the profiler. + */ +class MProfilerController +{ + public: + /** Release the controller from the profiler. This is invoked when the profiler is unloading. */ + virtual void Release() = 0; + /** Ask the profiler to change state */ + inline TInt ControlL(TInt aCommand) const; + /** Ask the profiler to change state */ + inline TInt ControlDataL(TInt aCommand, TAny* data1 = 0, TAny* data2 = 0) const; + + inline TInt GetSamplerAttributesL(const RMessage2& aMessage) const; + inline TInt SetSamplerAttributesL(const RMessage2& aMessage) const; + inline TInt GetGeneralAttributesL(const RMessage2& aMessage) const; + inline TInt SetGeneralAttributesL(const RMessage2& aMessage) const; + inline TInt GetSamplerAttributeCountL(const RMessage2& aMessage) const; + inline TInt RefreshStatus(const RMessage2& aMessage) const; + /* Query the profiler state */ + inline RProfiler::TSamplerState GeTComand() const; + protected: + inline MProfilerController(MProfilerEngine& aEngine); + private: + MProfilerEngine& iEngine; +}; + +/** The signature of ordinal 1 in the controller DLL */ +typedef MProfilerController* (*TProfilerControllerFactoryL)(TInt aPriority, MProfilerEngine& aEngine); +/** The second UID required by the controller DLL */ +const TUid KUidProfilerKeys={0x1000945c}; + +inline MProfilerController::MProfilerController(MProfilerEngine& aEngine) + :iEngine(aEngine) +{ + +} + +inline TInt MProfilerController::ControlL(TInt aCommand) const +{ + return iEngine.ControlL(aCommand); +} + +inline TInt MProfilerController::ControlDataL(TInt aCommand,TAny* data1, TAny* data2) const +{ + return iEngine.ControlDataL(aCommand,data1,data2); +} + +inline TInt MProfilerController::GetSamplerAttributesL(const RMessage2& aMessage) const +{ + return iEngine.GetSamplerAttributesL(aMessage); +} + +inline TInt MProfilerController::SetSamplerAttributesL(const RMessage2& aMessage) const +{ + return iEngine.SetSamplerAttributesL(aMessage); +} + +inline TInt MProfilerController::GetGeneralAttributesL(const RMessage2& aMessage) const +{ + return iEngine.GetGeneralAttributesL(aMessage); +} + +inline TInt MProfilerController::GetSamplerAttributeCountL(const RMessage2& aMessage) const +{ + return iEngine.GetSamplerAttributeCountL(aMessage); +} + +inline TInt MProfilerController::SetGeneralAttributesL(const RMessage2& aMessage) const +{ + return iEngine.SetGeneralAttributesL(aMessage); +} + +inline TInt MProfilerController::RefreshStatus(const RMessage2& aMessage) const +{ + return iEngine.RefreshStatus(aMessage); +} + +inline RProfiler::TSamplerState MProfilerController::GeTComand() const +{ + return iEngine.State(); +} + +class CSamplerController; +class CWriterController; +class MSamplerControllerObserver; +class MProfilerErrorObserver; + +class CProfiler : public CBase, private MProfilerEngine, + MSamplerControllerObserver, + MProfilerErrorObserver +{ + public: + + static CProfiler* NewLC(const TDesC& aSettingsFile); + + /** + * Method for control commands, i.e. start, stop and exit + * + * @param aCommand command to be parsed and executed + * @return TInt KErrNone if succeed, else error code + */ + TInt ControlL(TInt aCommand); + + /** + * Method for control data, e.g. settings + * + * @param aCommand command to be parsed and executed + * @param value1 can contain any value, integer or string, depends on use case + * @param value2 can contain any value, integer or string, depends on use case + * @return TInt KErrNone if succeed, else error code + */ + TInt ControlDataL(TInt aCommand, TAny* value1 = 0, TAny* value2 = 0); + + // setting attributes manipulation + TInt GetGeneralAttributesL(const RMessage2& aMessage); + TInt GetSamplerAttributesL(const RMessage2& aMessage); + TInt SetGeneralAttributesL(const RMessage2& aMessage); + TInt SetSamplerAttributesL(const RMessage2& aMessage); + TInt GetSamplerAttributeCountL(const RMessage2& aMessage); + TInt RefreshStatus(const RMessage2& /*aMessage*/); + + // from CProfilerErrorChecker + void HandleSamplerControllerReadyL(); + void NotifyRequesterForSettingsUpdate(); + void HandleProfilerErrorChangeL( TInt aError ); + + void Finalise(); + CProfilerSampleStream* GetSamplerStream(); + void HandleError(TInt aErr); + static TBool CheckLocationSanity(RFs& fs, const TDesC8& aLocation); +private: + CProfiler(const TDesC& aSettingsFile); + ~CProfiler(); + void ConstructL(); + TInt LoadSettingsL(/*const TDesC& configFile*/); + void DoGetValueFromSettingsArray(CDesC8ArrayFlat* aLineArray, const TDesC8& aAttribute, TDes8& aValue); + void UpdateSavedGeneralAttributes(CDesC8ArrayFlat* aSavedAttributes); + template CBufFlat* ExternalizeLC(const T& aElements); + + RProfiler::TSamplerState State() const; + + void DrainSampleStream(); + void InstallStreamForActiveTraces(CSamplerPluginInterface& aSampler, CWriterPluginInterface& aWriter, TDesC& totalPrefix); + void SaveSettingsL(); + + TInt HandleGeneralSettingsChange(); + TInt CheckOldProfilerRunning(); +public: + // trace file settings + TBuf8 iFilePrefix; + TBuf8 iDriveLetter; + TBuf8 iTotalPrefix; + + TBuf<256> iSettingsFileLocation; + + MProfilerController* iServer; + RProfiler::TSamplerState iState; + + CProfilerSampleStream* iUserStream; + + // plug-in controllers + CWriterController* iWriterHandler; + CSamplerController* iSamplerHandler; + + // setting attribute containers + TGeneralAttributes iGeneralAttributes; + CArrayFixFlat* iDefaultSamplerAttributesArray; + + // temporary settings file array container + CDesC8ArrayFlat* iSavedLineArray; + TInt iSavedLinesCount; + // saved settings, add extra 1 byte space to end buffer with a '\n' + TBuf8 iSettingsBuffer; + + // P&S status properties + RProperty iEngineStatus; + RProperty iUpdateStatus; + TBuf<128> iFileNameStream; +private: + TBool iSettingsFileLoaded; + CProfilerErrorChecker* iErrorChecker; +}; + +#include +#endif // __PROFILERENGINE__ + diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler/engine/inc/ProfilerErrorChecker.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler/engine/inc/ProfilerErrorChecker.h Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,47 @@ +/* +* 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 PROFILERERRORCHECKER_H_ +#define PROFILERERRORCHECKER_H_ + +// CLASS DECLARATIONS +class MProfilerErrorObserver + { + public: // New + virtual void HandleProfilerErrorChangeL( TInt aError ) = 0; + }; + + +class CProfilerErrorChecker : public CActive + { +public: + static CProfilerErrorChecker* CProfilerErrorChecker::NewL(); + ~CProfilerErrorChecker(); + void SetObserver(MProfilerErrorObserver* aObserver); +private: + CProfilerErrorChecker(); + void ConstructL(); + void RunL(); + TInt RunError(TInt aError); + void DoCancel(); +private: + MProfilerErrorObserver* iObserver; + RProperty iErrorStatus; + }; + +#endif /* PROFILERERRORCHECKER_H_ */ diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler/engine/inc/ProfilerEshell.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler/engine/inc/ProfilerEshell.h Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,36 @@ +/* +* 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 PROFILERESHELL_H_ +#define PROFILERESHELL_H_ + +#include +#include +#include // CCommandLineArguments + +class CProfilerEShell : public CBase + { +public: + static CProfilerEShell* NewL(); + ~CProfilerEShell(); + + void ConstructL(); +private: + CProfilerEShell(); + + }; + +#endif /* PROFILERESHELL_H_ */ diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler/engine/inc/SamplerController.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler/engine/inc/SamplerController.h Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,154 @@ +/* +* 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 __SAMPLERCONTROLLER_H__ +#define __SAMPLERCONTROLLER_H__ + +// system includes +#include +#include + + +// The user-interface to the sampling device driver sued by the profiling engine +// user includes +#include +#include +#include + +#include "SamplerPluginLoader.h" + +/* + * Forward declarations + */ +class TBapBuf; +class CProfilerSampleStream; +class CSamplerPluginLoader; +class CSamplerPluginInterface; +class MSamplerControllerObserver; +/** + * The sampler controller for handling the actual sampler plugins. + */ + +class CSamplerController : public CBase, MSamplerPluginLoadObserver + { + +public: + static CSamplerController* NewL(CProfilerSampleStream& aStream); + void ConstructL(); + + CSamplerController(CProfilerSampleStream& aStream); + ~CSamplerController(); + + /** + * + * Methods for user mode sampling + * + **/ + + /** Initialise the user mode samplers **/ + void InitialiseSamplerListL(); + + /* Overrider of MSamplerPluginLoaderObserver class **/ + void HandlePluginLoaded( KSamplerPluginLoaderStatus aStatus ); + + /* returns the name matching plugin Uid */ + TUid GetPluginUID(TDesC8& name); + + /** Start enabled samplers **/ + void StartSamplerPluginsL(); + + /** Stop enabled samplers **/ + TInt StopSamplerPlugins(); + +public: + + CSamplerPluginInterface* GetPlugin(TUid aUid); + + TInt GetPluginList(TDes* aList); + + TInt SetSamplerSettingsL(TInt aUid, TSamplerAttributes aAttributes); + + void GetSamplerAttributesL(CArrayFixFlat* aAttributes); + + TInt UpdateSavedSamplerAttributesL(CDesC8ArrayFlat* aSavedLineArray, CArrayFixFlat* aAttributes); + + /* + * Compose all sampler (sampler or sub-sampler) attributes as text array for saving to settings file, + * called by CSamplerController (and Profiler Engine) + * + * @param aFile settings file where to write the settings + */ + void ComposeAttributesToSettingsFileFormat(RFile& aFile, CArrayFixFlat* aAttributes); + + /* + * Compose all sampler (sampler or sub-sampler) attributes as text array for saving to settings file, + * called by CSamplerController (and Profiler Engine) + * + * @param aFile settings file where to write the settings + * @param aAttrArray is container for saving the text to + */ + void ComposeSettingsText(RFile& aFile, CArrayFixFlat* aAttrArray); + + void SetObserver(MSamplerControllerObserver* aObserver); + + void Str2Bool(const TDesC8& aBuf, TBool& aValue); + + void Str2Int(const TDesC8& aBuf, TInt& aValue); + + void Str2Int(const TDesC8& aBuf, TUint32& aValue); + + TBuf8<16> Bool2Str(const TBool& aValue); + + TBuf8<16> Int2Str(const TInt& aValue); +public: + + CArrayPtrFlat* iPluginArray; + + // Asynchronous loader for the sampler plug-ins. + CSamplerPluginLoader* iPluginLoader; + + // UID of the selected plugin in the container's lbx. + TUid iSelectedPluginUid; + + // shared sample stream for all plugin samplers + CProfilerSampleStream& iStream; + +private: + MSamplerControllerObserver* iObserver; +}; + +/** +* Interface for SamplerPluginLoader observer. MSamplerPluginLoadObserver gets +* notifications when plugins are loaded. +* +* @lib ProfilerEngine.exe/.lib +* @since Series60_30.1 +*/ + +class MSamplerControllerObserver + { + public: // New + + //CSamplerController calls this function when each plug-in is loaded or + //loading is finished.. + + virtual void HandleSamplerControllerReadyL() = 0; + virtual void HandleError(TInt aError) = 0; + }; + +#endif // __SAMPLERCONTROLLER_H__ diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler/engine/inc/SamplerPluginLoader.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler/engine/inc/SamplerPluginLoader.h Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,297 @@ +/* +* 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 SAMPLERPLUGINLOADER_H +#define SAMPLERPLUGINLOADER_H + +// INCLUDES +#include +#include +#include +#include + +// CONSTANTS +// Value for a to b comparison result when logically a == b. +const TInt KSamplerComparisonEqual = 0; + +// Value for a to b comparison result when logically a < b. +const TInt KSamplerComparisonBefore = -1; + +// Value for a to b comparison result when logically a > b. +const TInt KSamplerComparisonAfter = 1; + +// CLASS DEFINITIONS +class CSamplerPluginInterface; +class MSamplerPluginLoadObserver; +class REComSession; + +/** +* CSamplerPluginLoader. Mechanism used to load plugins asynchronously. Uses +* MSamplerPluginLoadObserver as a callback. +* +* @lib ProfilerEngine.exe/.lib??????????? +* @since Series60_30.1 +*/ +class CSamplerPluginLoader : public CActive + { + public: // Constructor and destructor + + /** + * Two-phased constructor. + * + * @param aAppUi Pointer to application UI. Does not take ownership. + */ + static CSamplerPluginLoader* NewL(); + + /** + * Destructor + */ + ~CSamplerPluginLoader(); + + private: // Internal construction + + /** + * Default C++ contructor + */ + CSamplerPluginLoader(); + + /** + * Symbian OS default constructor + * @return void + */ + void ConstructL(); + + public: // API + + /** + * Starts loading GS plug-ins asynchronously. Will call + * MSamplerPluginLoadObserver::HandlePluginLoaded() each time a plug-in is + * loaded and when all plugins are loaded. + * + * CSamplerPluginLoader transfers the ownership of each loaded plugin view to + * CAknViewAppUi. It is client's responsibility to remove the views from + * CAknViewAppUi and delete the plugins if necessary. + * + * @param aInterfaceUid Uid ofthe interfaces to be loaded. + * @param aParentUid Uid of the parent. Only children of this parent + * will be loaded. + * @param aPluginArray An array for the loaded GS plug-ins. + * CSamplerPluginLoader does not take the ownership of this array. + */ + void LoadAsyncL( CArrayPtrFlat* aPluginArray ); + + /** + * Load a specific plugin instance synchronously. + * + * @param aInterfaceUid Uid ofthe interfaces to be loaded. + * @param aImplementationUid Uid of the implementation to load + */ + void LoadSyncL( CArrayPtrFlat* aPluginArray ); + + /** + * Sets observer for this loader. Only one observer per loader in one + * time is possible. + */ + void SetObserver(MSamplerPluginLoadObserver* aObserver); + + /** + * Aborts asynchronous loading of the GS plug-ins. + */ + void AbortAsyncLoad(); + + + /** + * Sorts the plugin array. + * + * Sorting criterias: + * + * 1. Order number if provider category is Internal. + * 2. Provider category. Precedence as follows: + * 1. KGSPluginProviderInternal + * 2. EGSPluginProviderOEM + * 3. EGSPluginProviderOperator + * 4. EGSPluginProvider3rdParty + * 3. Alphabetical + * + * @param aPlugins The array which will be sorted. + */ + void SortPluginsL( CArrayPtrFlat* aPlugins ); + + private: // Internal methods + + /** + * Starts loading next plugin. + */ + void LoadNextPluginL(); + + /** + * Creates a plugin instance from given UID. Ownership is transferred. + */ + CSamplerPluginInterface& CreatePluginInstanceL( + const CImplementationInformation& aImpInfo ); + + /** + * Notifies MPluginLoadObserver. + */ + void NotifyProgress(); + + /** + * Notifies MPluginLoadObserver. + */ + void NotifyFinished(); + + /** + * Wait for the next round of CActive execution. + */ + void CompleteOwnRequest(); + + // Insertion function used by sorting: + + /** + * Inserts plugin in the correct position in the array using sorting + * criterias. Assumes aPlugins is ordered. + * + * @param aPlugin The plugin to be inserted. + * @param aPlugins Array in which the plugin is inserted into the + * corresponding location. + */ + void InsertPluginInOrderL( + CSamplerPluginInterface* aPlugin, + CArrayPtrFlat* aPlugins ); + + // Comparison functions: + + /** + * Compares plugins according to comparison criterias. + * + * Note: GS internal comparison constants such as KGSComparisonEqual are + * different from the ones outputted by this function. This is because + * this function is also usable by RArray sort -functionality but BC + * cannot be broken in GS. + * + * @return Negative value: If aFirst before aSecond. + * 0: If equal. + * Positive value: If aSecond before aFirst. + */ + static TInt Compare( const CSamplerPluginInterface& aFirst, + const CSamplerPluginInterface& aSecond ); + + /** + * + * @return KGSComparisonEqual = equal indexes + * KGSComparisonBefore = aFirst is before aSecond + * KGSComparisonAfter = aFirst is after aSecond + */ + + static TInt CompareIndex( + const CSamplerPluginInterface& aFirst, + const CSamplerPluginInterface& aSecond ); + + private: // Utility methods + + /** + * Parses descriptor to UID. + */ + static TInt ParseToUid( const TDesC8& aSource, TUid& aTarget ); + + /** + * Parsers plugin's order number + */ + static TInt ParseOrderNumber( const TDesC8& aSource, TInt& aOrderNumber ); + + /** + * Print ordering debug data. + */ + void CSamplerPluginLoader::PrintOrderTraces( + CArrayPtrFlat* aPlugins ); + + private: // From CActive + + /** + * See base class. + */ + void RunL(); + + /** + * See base class. + */ + TInt RunError( TInt aError ); + + /** + * See base class. + */ + void DoCancel(); + + private: // Data + // Pluginloader goes through this array and loads the plugins into + // iPluginArray if they fulfill the criterias. + RImplInfoPtrArray iImplInfoArray; + + // Used as an iterator to maintain location in iImplInfoArray. + TInt iImplInfoArrayIterator; + + // Array of loaded plugins.Plugins are owned by iAppUi. Only the array + // pointers are owned by this class and therefore only reset array. + CArrayPtrFlat* iPluginArray; + + // Pointer to observer. Not owned. + MSamplerPluginLoadObserver* iObserver; + + // Number of RunL calls. + TInt iRunLDebugCount; + + }; + + +/** +* Interface for SamplerPluginLoader observer. MSamplerPluginLoadObserver gets +* notifications when plugins are loaded. +* +* @lib ProfilerEngine.exe/.lib??????????? +* @since Series60_30.1 +*/ + +class MSamplerPluginLoadObserver + { + public: // Enums + enum KSamplerPluginLoaderStatus + { + // One plugin loaded successfully, continue to next. + ESamplerSuccess, + // Loading one plugin failed, contiue to next. + ESamplerFail, + // Client called AbortAsyncLoad(), finished loading. + ESamplerAborted, + // All plugins loaded successfully, finished loading. + ESamplerFinished, + // Severe error with loader, finished loading. + ESamplerError + }; + + public: // New + + //CSamplerPluginLoader calls this function when each plug-in is loaded or + //loading is finished.. + + IMPORT_C virtual void HandlePluginLoaded( + KSamplerPluginLoaderStatus aStatus ) = 0; + }; + + +#endif // SAMPLERPLUGINLOADER_H +// End of File diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler/engine/inc/WriterController.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler/engine/inc/WriterController.h Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,115 @@ +/* +* 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 __WRITERCONTROLLER_H__ +#define __WRITERCONTROLLER_H__ + +// system includes +#include +#include + + +// The user-interface to the sampling device driver sued by the profiling engine +// user includes +#include +#include +#include + +#include "WriterPluginLoader.h" + +/* + * Forward declarations + */ +class TBapBuf; +class CWriterPluginLoader; +class CWriterPluginInterface; + +/** + * The writer controller for handling the available Data writer plugins. + */ + +class CWriterController : public CBase, MWriterPluginLoadObserver + { + +public: + static CWriterController* NewL(CProfilerSampleStream& aStream); + void ConstructL(); + + CWriterController(CProfilerSampleStream& aStream); + ~CWriterController(); + + /** + * + * Methods for user mode sampling + * + **/ + + /** Initialise the user mode samplers **/ + void InitialiseWriterListL(); + + /* Overrider of MSamplerPluginLoaderObserver class **/ + void HandlePluginLoaded( KWriterPluginLoaderStatus /*aStatus*/ ); + + /* returns the matching plugin Uid */ + TUid GetPluginUID(TInt traceId); + + CWriterPluginInterface* GetActiveWriter(); + + /** Returns the sampler type (kernel/user) **/ + TUint32 GetWriterType(TUint32 samplerId); + + /** Set additional settings for a trace **/ + TInt AdditionalUserTraceSettings(TInt traceId, TInt settings); + + /** Set data stream for samplers **/ + //void SetSampleStream(RProfilerSampleStream* iStream); + + TInt StartSelectedPlugin(); + + void StopSelectedPlugin(); + + /** Set selected plugin active **/ + void SetPluginActive(TUid uid, const TWriterPluginValueKeys aKey); + + TInt SetPluginSettings(TUid aUid, TDes& aDes); + + /** Get settings for a specific plugin **/ + void GetPluginSettings(TUid uid, TDes& aVal); + + /** Request stream read **/ + //void FillThisStreamBuffer(TBapBuf* aBuffer, TRequestStatus& aStatus); + + CWriterPluginInterface* GetPlugin(TUid aUid); + + CArrayPtrFlat* GetPluginList(); + + void InitialisePluginStream(); +public: + CArrayPtrFlat* iPluginArray; + + // Asynchronous loader for the writer plug-ins. + CWriterPluginLoader* iPluginLoader; + + // UID of the selected plugin in the container's lbx. + TUid iSelectedPluginUid; + + CProfilerSampleStream& iStream; +}; + + +#endif // __WRITERCONTROLLER_H__ diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler/engine/inc/WriterPluginLoader.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler/engine/inc/WriterPluginLoader.h Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,307 @@ +/* +* 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 WRITERPLUGINLOADER_H +#define WRITERPLUGINLOADER_H + +// INCLUDES +#include +#include +#include +#include +#include + +// CONSTANTS + +// Value for a to b comparison result when logically a == b. +const TInt KWriterComparisonEqual = 0; + +// Value for a to b comparison result when logically a < b. +const TInt KWriterComparisonBefore = -1; + +// Value for a to b comparison result when logically a > b. +const TInt KWriterComparisonAfter = 1; + +// CLASS DEFINITIONS +class CWriterPluginInterface; +class MWriterPluginLoadObserver; +class REComSession; + +/** +* CWriterPluginLoader. Mechanism used to load plugins asynchronously. Uses +* MWriterPluginLoadObserver as a callback. +* +* @lib ProfilerEngine.exe/.lib??????????? +* @since Series60_30.1 +*/ +class CWriterPluginLoader : public CActive + { + public: // Constructor and destructor + + /** + * Two-phased constructor. + * + * @param aAppUi Pointer to application UI. Does not take ownership. + */ + static CWriterPluginLoader* NewL(); + + /** + * Destructor + */ + ~CWriterPluginLoader(); + + private: // Internal construction + + /** + * Default C++ contructor + */ + CWriterPluginLoader(); + + /** + * Symbian OS default constructor + * @return void + */ + void ConstructL(); + + public: // API + + /** + * Starts loading GS plug-ins asynchronously. Will call + * MWriterPluginLoadObserver::HandlePluginLoaded() each time a plug-in is + * loaded and when all plugins are loaded. + * + * CWriterPluginLoader transfers the ownership of each loaded plugin view to + * CAknViewAppUi. It is client's responsibility to remove the views from + * CAknViewAppUi and delete the plugins if necessary. + * + * @param aInterfaceUid Uid ofthe interfaces to be loaded. + * @param aParentUid Uid of the parent. Only children of this parent + * will be loaded. + * @param aPluginArray An array for the loaded GS plug-ins. + * CWriterPluginLoader does not take the ownership of this array. + */ + void LoadAsyncL( CArrayPtrFlat* aPluginArray ); + + /** + * Load a specific plugin instance synchronously. + * + * @param aInterfaceUid Uid ofthe interfaces to be loaded. + * @param aImplementationUid Uid of the implementation to load + */ + CWriterPluginInterface& LoadSyncL( TUid aImplementationUid ); + + /** + * Sets observer for this loader. Only one observer per loader in one + * time is possible. + */ + void SetObserver(MWriterPluginLoadObserver* aObserver); + + /** + * Aborts asynchronous loading of the GS plug-ins. + */ + void AbortAsyncLoad(); + + /** + * Sorts the plugin array. + * + * Sorting criterias: + * + * 1. Order number if provider category is Internal. + * 2. Provider category. Precedence as follows: + * 3. Alphabetical + * + * @param aPlugins The array which will be sorted. + */ + void SortPluginsL( CArrayPtrFlat* aPlugins ); + + private: // Internal methods + + /** + * Starts loading next plugin. + */ + void LoadNextPluginL(); + + /** + * Creates a plugin instance from given UID. Ownership is transferred. + */ + CWriterPluginInterface& CreatePluginInstanceL( + const CImplementationInformation& aImpInfo ); + + /** + * Notifies MGSPluginLoadObserver. + */ + void NotifyProgress(); + + /** + * Notifies MGSPluginLoadObserver. + */ + void NotifyFinished(); + + /** + * Wait for the next round of CActive execution. + */ + void CompleteOwnRequest(); + + // Insertion function used by sorting: + + /** + * Inserts plugin in the correct position in the array using sorting + * criterias. Assumes aPlugins is ordered. + * + * @param aPlugin The plugin to be inserted. + * @param aPlugins Array in which the plugin is inserted into the + * corresponding location. + */ + void InsertPluginInOrderL( + CWriterPluginInterface* aPlugin, + CArrayPtrFlat* aPlugins ); + + // Comparison functions: + + /** + * Compares plugins according to comparison criterias. + * + * Note: GS internal comparison constants such as KGSComparisonEqual are + * different from the ones outputted by this function. This is because + * this function is also usable by RArray sort -functionality but BC + * cannot be broken in GS. + * + * @return Negative value: If aFirst before aSecond. + * 0: If equal. + * Positive value: If aSecond before aFirst. + */ + static TInt Compare( const CWriterPluginInterface& aFirst, + const CWriterPluginInterface& aSecond ); + + /** + * + * @return KGSComparisonEqual = equal indexes + * KGSComparisonBefore = aFirst is before aSecond + * KGSComparisonAfter = aFirst is after aSecond + */ + + static TInt CompareIndex( + const CWriterPluginInterface& aFirst, + const CWriterPluginInterface& aSecond ); + + private: // Utility methods + + /** + * Parses descriptor to UID. + */ + static TInt ParseToUid( const TDesC8& aSource, TUid& aTarget ); + + /** + * Parsers plugin's order number + */ + static TInt ParseOrderNumber( const TDesC8& aSource, TInt& aOrderNumber ); + + /** + * Print debug information. + */ + static void PrintInfoDebug( const CImplementationInformation& aInfo, + TInt aIterator, + TInt aPluginCount ); + /** + * Print ordering debug data. + */ + void CWriterPluginLoader::PrintOrderTraces( + CArrayPtrFlat* aPlugins ); + + /** + * Display loading error popup message. + */ + void DisplayErrorPopupL( TInt aError, + const CImplementationInformation* aInfo ); + + private: // From CActive + + /** + * See base class. + */ + void RunL(); + + /** + * See base class. + */ + TInt RunError( TInt aError ); + + /** + * See base class. + */ + void DoCancel(); + + private: // Data + + + // Pluginloader goes through this array and loads the plugins into + // iPluginArray if they fulfill the criterias. + RImplInfoPtrArray iImplInfoArray; + + // Used as an iterator to maintain location in iImplInfoArray. + TInt iImplInfoArrayIterator; + + // Array of loaded plugins.Plugins are owned by iAppUi. Only the array + // pointers are owned by this class and therefore only reset array. + CArrayPtrFlat* iPluginArray; + + // Pointer to observer. Not owned. + MWriterPluginLoadObserver* iObserver; + + // Number of RunL calls. + TInt iRunLDebugCount; + }; + + +/** +* Interface for WriterPluginLoader observer. MWriterPluginLoadObserver gets +* notifications when plugins are loaded. +* +* @lib ProfilerEngine.exe/.lib??????????? +* @since Series60_30.1 +*/ + +class MWriterPluginLoadObserver + { + public: // Enums + enum KWriterPluginLoaderStatus + { + // One plugin loaded successfully, continue to next. + EWriterSuccess, + // Loading one plugin failed, contiue to next. + EWriterFail, + // Client called AbortAsyncLoad(), finished loading. + EWriterAborted, + // All plugins loaded successfully, finished loading. + EWriterFinished, + // Severe error with loader, finished loading. + EWriterError + }; + + public: // New + + //CWriterPluginLoader calls this function when each plug-in is loaded or + //loading is finished.. + + IMPORT_C virtual void HandlePluginLoaded( + KWriterPluginLoaderStatus aStatus ) = 0; + }; + + +#endif // WRITERPLUGINLOADER_H +// End of File diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler/engine/src/ProfilerEngine.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler/engine/src/ProfilerEngine.cpp Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,1433 @@ +/* +* 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: +* +*/ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "ProfilerEngine.h" +#include +#include + +// properties +const TUid KEngineStatusPropertyCat={0x2001E5AD}; +enum TEnginePropertyKeys + { + EProfilerEngineStatus = 8, + EProfilerErrorStatus + }; + +static _LIT_SECURITY_POLICY_PASS( KAllowAllPolicy ); + +// CONSTANTS +const TInt KStreamBufferSize = 32768; +const TInt KSavedLineCount = 64; +const TInt KFileNameBufSize = 128; + +// LITERALS +_LIT8(KGenericTraceOutput, "output_type"); +_LIT8(KGenericTraceFilePrefix, "file_prefix"); +_LIT8(KGenericTraceFileSaveDrive, "save_file_location"); +_LIT8(KEquals, "="); +_LIT8(KNewLineSeparator, "\n"); +_LIT8(KProfilerVersionTag, "version"); +_LIT8(KEndMark, "[end]"); +_LIT8(KOutputToDebugOutput, "debug_output"); + +/** + * + * The controller class used to provide the Profiler functions. + * This runs as a server in the engine thread + * + */ +class CPServer : public CServer2, public MProfilerController + { +public: + static MProfilerController* NewL(TInt aPriority, MProfilerEngine& aEngine); + +private: + CPServer(TInt aPriority, MProfilerEngine& aEngine); + void Release(); + CSession2* NewSessionL(const TVersion& aVersion,const RMessage2& aMessage) const; + }; + +// The session class used by the server controller +class CPSession : public CSession2 + { +private: + inline const CPServer& Server() const; + void ServiceL(const RMessage2& aMessage); + }; + +/* + * + * CProfiler class implementation + * + */ +// -------------------------------------------------------------------------------------------- +CProfiler* CProfiler::NewLC(const TDesC& aSettingsFile) + { + CProfiler* self = new(ELeave) CProfiler(aSettingsFile); + CleanupStack::PushL(self); + self->ConstructL(); + return self; + } + +// -------------------------------------------------------------------------------------------- +CProfiler::CProfiler(const TDesC& aSettingsFile) : + iSettingsFileLocation(aSettingsFile) + { + // define property for Profiler Engine status, UI may read it for control purposes + if ( RProperty::Define(KEngineStatusPropertyCat, + EProfilerEngineStatus, + RProperty::EInt, + KAllowAllPolicy, + KAllowAllPolicy, + 0) != KErrAlreadyExists ) + { + LOGTEXT(_L("CProfiler::CProfiler - status property already defined")); + } + + if ( RProperty::Define(KEngineStatusPropertyCat, + EProfilerErrorStatus, + RProperty::EInt, + KAllowAllPolicy, + KAllowAllPolicy, + 0) != KErrAlreadyExists ) + { + LOGTEXT(_L("CProfiler::CProfiler - status property already defined")); + } + + // attach to own property + iEngineStatus.Attach(KEngineStatusPropertyCat, EProfilerEngineStatus); + // set status idle + iEngineStatus.Set(KEngineStatusPropertyCat, EProfilerEngineStatus, RProfiler::EIdle); + + // attach to own property + iUpdateStatus.Attach(KEngineStatusPropertyCat, EProfilerErrorStatus); + // set status idle + iUpdateStatus.Set(KEngineStatusPropertyCat, EProfilerErrorStatus, EFalse); + } + +// -------------------------------------------------------------------------------------------- +CProfiler::~CProfiler() + { + LOGTEXT(_L("CProfiler::~CProfiler - Enter")); + + // delete error checker + if(iErrorChecker) + { + iErrorChecker->Cancel(); + delete iErrorChecker; + iErrorChecker = NULL; + } + + // delete settings array + if(iDefaultSamplerAttributesArray) + { + iDefaultSamplerAttributesArray->Reset(); + delete iDefaultSamplerAttributesArray; + iDefaultSamplerAttributesArray = NULL; + } + + // delete settings file raw line array + if(iSavedLineArray) + { + iSavedLineArray->Reset(); + delete iSavedLineArray; + iSavedLineArray = NULL; + } + + // delete sampler controller, cleans up the sampler plugin instances + if(iSamplerHandler) + { + delete iSamplerHandler; + iSamplerHandler = NULL; + } + // delete writer controller, cleans up the writer plugin instances + if(iWriterHandler) + { + delete iWriterHandler; + iWriterHandler = NULL; + } + + // delete user side sampler stream + if(iUserStream) + { + delete iUserStream; + iUserStream = NULL; + } + + // close engine status property + iEngineStatus.Close(); + if (RProperty::Delete(KEngineStatusPropertyCat, EProfilerEngineStatus) != KErrNotFound) + { + LOGTEXT(_L("CProfiler::~CProfiler - cannot close status property")); + } + // close engine update property + iUpdateStatus.Close(); + if (RProperty::Delete(KEngineStatusPropertyCat, EProfilerErrorStatus) != KErrNotFound) + { + LOGTEXT(_L("CProfiler::~CProfiler - cannot close update property")); + } + + // close server process + if (iServer) + { + LOGTEXT(_L("CProfiler::~CProfiler - Releasing server")); + iServer->Release(); + } + + LOGTEXT(_L("CProfiler::~CProfiler - Finished")); + } + +// -------------------------------------------------------------------------------------------- +void CProfiler::ConstructL() + { + LOGTEXT(_L("CProfiler::ConstructL - Enter")); + TInt err(0); + + // create new sampler stream instance + iUserStream = CProfilerSampleStream::NewL(KStreamBufferSize); + if(!iUserStream) + { + LOGTEXT(_L("Profiler engine cannot reserve memory")); + User::Leave(KErrCancel); // operation cancelled + } + + // engine status checker + iErrorChecker = CProfilerErrorChecker::NewL(); + iErrorChecker->SetObserver(this); + + // create and initiate plug-in controller instances + iSamplerHandler = CSamplerController::NewL(*iUserStream); + iWriterHandler = CWriterController::NewL(*iUserStream); + + iWriterHandler->InitialiseWriterListL(); + + // set engine as an observer to sampler controller to get the notification of plugin load has ended + iSamplerHandler->SetObserver(this); + + // default settings from sampler plugins, maximum 20 sampler plugins + iDefaultSamplerAttributesArray = new(ELeave) CArrayFixFlat(20); + + // set profiler status to initializing + iState = RProfiler::EInitializing; + iEngineStatus.Set(RProfiler::EInitializing); + + // set default general settings, will be overdriven if changed in settings file + iGeneralAttributes.iTraceOutput.Copy(KDefaultTraceOutput); + iGeneralAttributes.iTraceFilePrefix.Copy(KDefaultTraceFilePrefix); + iGeneralAttributes.iSaveFileDrive.Copy(KDefaultTraceFileSaveDrive); + + RThread me; + + me.SetPriority(EPriorityRealTime); + + err = KErrGeneral; + TInt count = 0; + + while(err != KErrNone && count < 30) + { + err = User::RenameThread(KProfilerName); + if(err != KErrNone) + { + User::Leave(err); + } + else break; + } + + if(err != KErrNone) + { + User::Leave(err); + } + + // set settings file loading preferences + iSettingsFileLoaded = EFalse; + + // change status property to idle since initialization successfull + iState = RProfiler::EIdle; + if( iEngineStatus.Set((TInt)RProfiler::EIdle) != KErrNone ) + { + LOGTEXT(_L("CProfiler::ConstructL - engine status property change failed")); + } + + if( iUpdateStatus.Set(EFalse) != KErrNone ) + { + LOGTEXT(_L("CProfiler::ConstructL - engine status property change failed")); + } + + // create a server instance for clients to communicate with + iServer = CPServer::NewL(10,*this); + + // close the handle + me.Close(); + + LOGTEXT(_L("CProfiler::ConstructL - Exit")); + + } + +CProfilerSampleStream* CProfiler::GetSamplerStream() + { + return iUserStream; + } + +void CProfiler::HandleSamplerControllerReadyL() + { + // load settings + // check if settings file already loaded + if(!iSettingsFileLoaded) + { + // load default settings file + LoadSettingsL(); + + iSettingsFileLoaded = ETrue; + } + + // notify engine's launcher(UI or PIProfilerLauncher) to continue launch + RProcess::Rendezvous(KErrNone); + } + +void CProfiler::NotifyRequesterForSettingsUpdate() + { + // set update status P&S property true => update needed on UI side + iUpdateStatus.Set(ETrue); + } + +void CProfiler::HandleProfilerErrorChangeL(TInt aError) + { + LOGSTRING2("CProfiler::HandleProfilerErrorChangeL() - error received, %d", aError); + + // check if profiler running + if(iState == RProfiler::ERunning) + { + // stop profiler if error occurred during the trace + iEngineStatus.Set(aError); + + // stop samplers, NOTE! Writer plugins not stopped since + iSamplerHandler->StopSamplerPlugins(); + + // stop debug output plugin and write the rest of the trace data to output + if(iGeneralAttributes.iTraceOutput.CompareF(KOutputToDebugOutput) == 0) + { + // write the rest of trace data only if debug output selected + iWriterHandler->StopSelectedPlugin(); + } + LOGSTRING2("CProfiler::HandleProfilerErrorChangeL - sampling stopped, going to state %d", RProfiler::EIdle); + } + } + +// ---------------------------------------------------------------------------- +// Gets a value from settings file for certain attribute. +// ---------------------------------------------------------------------------- +void CProfiler::DoGetValueFromSettingsArray(CDesC8ArrayFlat* aLineArray, const TDesC8& aAttribute, TDes8& aValue) + { + LOGTEXT(_L("CProfiler::DoGetValueFromSettingsFile()")); + _LIT8(KSettingItemSeparator, "="); + + // read a line of given array + for (TInt i=0; iMdcaCount(); i++) + { + // check if this line has a separator + TInt sepPos = aLineArray->MdcaPoint(i).Find(KSettingItemSeparator); + if (sepPos > 0) + { + // check that the element matches + if (aLineArray->MdcaPoint(i).Left(sepPos).CompareF(aAttribute) == 0) + { + // get the value + aValue.Copy(aLineArray->MdcaPoint(i).Right(aLineArray->MdcaPoint(i).Length()-sepPos-1)); + break; + } + } + } + } + +// -------------------------------------------------------------------------------------------- +TInt CProfiler::GetSamplerAttributesL(const RMessage2& aMessage) + { + TInt err(KErrNone); + TInt pos(0); + + // get sampler count + TInt count(iDefaultSamplerAttributesArray->Count()); + + // write each of the default sampler plugin setting attributes over client-server session + for (TInt i(0); iAt(i); + TPckgC attrPckg(attr); + + // write a TSamplerAttributes container at a time + aMessage.WriteL(0, attrPckg, pos); + pos += attrPckg.Length(); + } + + aMessage.Complete(err); + return err; + } + +// -------------------------------------------------------------------------------------------- +TInt CProfiler::SetSamplerAttributesL(const RMessage2& aMessage) + { + TSamplerAttributes attr; + TPckg inAttr(attr); + + TInt err = aMessage.Read(0, inAttr, 0); + + // apply the changes directly to a plugin + iSamplerHandler->SetSamplerSettingsL(attr.iUid, attr); + + aMessage.Complete(err); + return err; + } + +// -------------------------------------------------------------------------------------------- +TInt CProfiler::GetGeneralAttributesL(const RMessage2& aMessage) + { + TPckgBuf generalSettings( iGeneralAttributes ); + + // write general attributes over client-server session + TInt err = aMessage.Write(0, generalSettings); + + aMessage.Complete(err); + return err; + } + +// -------------------------------------------------------------------------------------------- +TInt CProfiler::SetGeneralAttributesL(const RMessage2& aMessage) + { + // read the general settings from message + TGeneralAttributes attr; + TPckg inPckg(attr); + TInt err = aMessage.Read(0, inPckg, 0); + + // copy to the general attributes + iGeneralAttributes.iSaveFileDrive.Copy(attr.iSaveFileDrive); + iGeneralAttributes.iTraceFilePrefix.Copy(attr.iTraceFilePrefix); + iGeneralAttributes.iTraceOutput.Copy(attr.iTraceOutput); + + aMessage.Complete(err); + return err; + } + +TInt CProfiler::GetSamplerAttributeCountL(const RMessage2& aMessage) + { + // get the plugin array count and wrap it to TPckgBuf<> + TPckgBuf attributeCount(iDefaultSamplerAttributesArray->Count()); + + // write general attributes over client-server session + TInt err = aMessage.Write(0, attributeCount); + + aMessage.Complete(err); + return err; + } + +TInt CProfiler::RefreshStatus(const RMessage2& aMessage) + { + TInt err(KErrNone); + + // update profiler status for requester + iEngineStatus.Set(iState); + + aMessage.Complete(err); + return err; + } + +// -------------------------------------------------------------------------------------------- +TInt CProfiler::LoadSettingsL(/*const TDesC& configFile*/) + { + RFs fileServer; + RFile file; + TInt err(KErrNone); + + // connect to file server + err = fileServer.Connect(); + + // check if file server can be connected + if (err != KErrNone) + { + // file server couldn't be connected + return KErrGeneral; + } + + // check if settings file location length reasonable + if ( iSettingsFileLocation.CompareF(KNullDesC) == 0 ) + { + // open the file with the default path and name + TBuf<256> pathAndName; + pathAndName.Append(PathInfo::PhoneMemoryRootPath()); + pathAndName.Append(KProfilerSettingsFileName); + iSettingsFileLocation.Copy(pathAndName); + LOGTEXT(_L("CProfiler::LoadSettings - Opening settings file with name (with the default path)")); + LOGTEXT(pathAndName); + } + + // open the file with the given path and name + err = file.Open(fileServer,iSettingsFileLocation,EFileRead); + + + // check if RFile::Open() returned error + if (err != KErrNone) + { + // file couldn't be opened + LOGTEXT(_L("CProfiler::LoadSettings - Failed to open settings, using default")); + + // check if settings already loaded + if(iDefaultSamplerAttributesArray->Count() > 0) + { + // reset default settings array + iDefaultSamplerAttributesArray->Reset(); + } + + // load default settings, instead of settings file ones + iSamplerHandler->GetSamplerAttributesL(iDefaultSamplerAttributesArray); + + fileServer.Close(); + return KErrNone; + } + + // initialize iSavedLineArray, initial settings file lines 64 + if(iSavedLineArray) + { + iSavedLineArray->Reset(); + } + else + { + iSavedLineArray = new (ELeave) CDesC8ArrayFlat(KSavedLineCount); + } + + iSavedLinesCount = KSavedLineCount; + + // get size of the file + TInt fileSize(0); + err = file.Size(fileSize); + // check if an error occurred reading the file size + if(err != KErrNone) + { + return KErrGeneral; // could not find the size + } + + // sanity check for the file size + if (fileSize < 3 || fileSize > 20000) + { + fileSize = KSettingsFileSize; + return KErrNotSupported; + } + + // read the contents of the file to buffer. + iSettingsBuffer.Zero(); + file.Read(iSettingsBuffer, fileSize); + file.Close(); + fileServer.Close(); + LOGSTRING2("CProfiler::LoadSettings: read %d bytes",iSettingsBuffer.Length()); + + // append end mark "[end]" + iSettingsBuffer.Append(KEndMark); + // force an ending newline + iSettingsBuffer.Append('\n'); + + // next fill the saved settings array (CDesC8ArrayFlat) for further comparison with changes and default values + TBuf8<384> tmpBuf; + TInt lineCount(0); + TBool commentFound(EFalse); + for (TInt i(0); i 0) + { + // remove extra spaces + tmpBuf.TrimAll(); + // check if the size of the array too small + if(lineCount >= iSavedLinesCount) + { + iSavedLineArray->ExpandL(20); // expand by 20 lines + iSavedLinesCount += 20; + } + iSavedLineArray->AppendL(tmpBuf); + tmpBuf.Copy(KNullDesC8); + lineCount++; + } + commentFound = EFalse; + } + // check if comment mark ';' is found on the line, skip the rest of the line + else if(iSettingsBuffer[i]==';') + { + commentFound = ETrue; + } + // otherwise append a char to the temp line buffer if it is a wanted ASCII char + else if (iSettingsBuffer[i]>=32 && iSettingsBuffer[i]<=127 && !commentFound) + { + tmpBuf.Append(iSettingsBuffer[i]); + } + } + + // empty tmpBuf + tmpBuf.Copy(KNullDesC8); + // check settings file version + DoGetValueFromSettingsArray(iSavedLineArray, KProfilerVersionTag, tmpBuf); + + TBuf8<32> version; + version.Copy(PROFILER_VERSION_SHORT); + + // check if settings file version is + if(tmpBuf.CompareF(version) >= 0) + { + // update general attributes + UpdateSavedGeneralAttributes(iSavedLineArray); + + // update settings to sampler plugins and save the attributes to default array + iSamplerHandler->UpdateSavedSamplerAttributesL(iSavedLineArray, iDefaultSamplerAttributesArray); + } + else + { + // check if settings already loaded + if(iDefaultSamplerAttributesArray) + { + // reset default settings array + iDefaultSamplerAttributesArray->Reset(); + } + // get the default settings if settings file version too old + iSamplerHandler->GetSamplerAttributesL(iDefaultSamplerAttributesArray); + } + + return err; + } + +// -------------------------------------------------------------------------------------------- +void CProfiler::UpdateSavedGeneralAttributes(CDesC8ArrayFlat* aSavedAttributes) + { + // get saved general settings + DoGetValueFromSettingsArray(aSavedAttributes, KGenericTraceOutput, iGeneralAttributes.iTraceOutput); + DoGetValueFromSettingsArray(aSavedAttributes, KGenericTraceFilePrefix, iGeneralAttributes.iTraceFilePrefix); + DoGetValueFromSettingsArray(aSavedAttributes, KGenericTraceFileSaveDrive, iGeneralAttributes.iSaveFileDrive); + + } + +TBool CProfiler::CheckLocationSanity(RFs& fs, const TDesC8& aLocation) + { + TBool ret(EFalse); + + TBuf<32> drive; + + CnvUtfConverter::ConvertToUnicodeFromUtf8(drive, aLocation); + + // check that aLocation contains some of reasonable drives + if(aLocation.Find(_L8("C:\\")) != KErrNotFound) + { + if(BaflUtils::CheckFolder(fs, drive) == KErrNone && + !SysUtil::DiskSpaceBelowCriticalLevelL(&fs, 0, EDriveC)) + ret = ETrue; + } + else if(aLocation.Find(_L8("D:\\")) != KErrNotFound) + { + if(BaflUtils::CheckFolder(fs, drive) == KErrNone && + !SysUtil::DiskSpaceBelowCriticalLevelL(&fs, 0, EDriveD)) + ret = ETrue; + } + else if(aLocation.Find(_L8("E:\\")) != KErrNotFound) + { + if(BaflUtils::CheckFolder(fs, drive) == KErrNone && + !SysUtil::DiskSpaceBelowCriticalLevelL(&fs, 0, EDriveE)) + ret = ETrue; + } + else if(aLocation.Find(_L8("F:\\")) != KErrNotFound) + { + if(BaflUtils::CheckFolder(fs, drive) == KErrNone && + !SysUtil::DiskSpaceBelowCriticalLevelL(&fs, 0, EDriveF)) + ret = ETrue; + } + else if(aLocation.Find(_L8("G:\\")) != KErrNotFound) + { + if(BaflUtils::CheckFolder(fs, drive) == KErrNone && + !SysUtil::DiskSpaceBelowCriticalLevelL(&fs, 0, EDriveG)) + ret = ETrue; + } + else if(aLocation.Find(_L8("H:\\")) != KErrNotFound ) + { + if(BaflUtils::CheckFolder(fs, drive) == KErrNone && + !SysUtil::DiskSpaceBelowCriticalLevelL(&fs, 0, EDriveH)) + ret = ETrue; + } + else if(aLocation.Find(_L8("I:\\")) != KErrNotFound) + { + if(BaflUtils::CheckFolder(fs, drive) == KErrNone && + !SysUtil::DiskSpaceBelowCriticalLevelL(&fs, 0, EDriveI)) + ret = ETrue; + } + else + { + // otherwise return false + ret = EFalse; + } + + return ret; + } + +TInt CProfiler::HandleGeneralSettingsChange() + { + // local literals + _LIT8(KBackSlash, "\\"); + _LIT8(KTraceFileExtension, ".dat"); + + TBuf8 fileNameBuf; + TBuf8<10> number; + TInt result(0); + TInt index(1); + TInt hashLocation(0); + TParse parse; + + // check if plugin writer changed + if(iGeneralAttributes.iTraceOutput.CompareF(KOutputToDebugOutput) == 0) + { + iWriterHandler->SetPluginActive( KDebOutWriterPluginUid, EWriterPluginEnabled ); + } + else + { + RFs fileServer; + RFile file; + + // connect to the file server + result = fileServer.Connect(); + if(result == KErrNone) + { + // disk writer plugin will be activated + iWriterHandler->SetPluginActive( KDiskWriterPluginUid, EWriterPluginEnabled ); + + // fix the trace data file location as well + iTotalPrefix.Zero(); + iTotalPrefix.Append(iGeneralAttributes.iSaveFileDrive); + + // check that trace file location sane + if(!CProfiler::CheckLocationSanity(fileServer, iTotalPrefix)) + { +// // empty location data +// iTotalPrefix.Zero(); +// // use default location instead +// iTotalPrefix.Append(KProfilerDefaultDrive); + fileServer.Close(); + return KErrPathNotFound; + } + + // remove extra spaces + iTotalPrefix.TrimAll(); + + // check if trace data location directory => string ends with '\' + if(iTotalPrefix.LocateReverse('\\') != iTotalPrefix.Length()-1 && + iTotalPrefix.LocateReverse('/') != iTotalPrefix.Length()-1) + { + // append backslash to end + iTotalPrefix.Append(KBackSlash); + } + + // append trace file name prefix e.g. PIProfiler_# + iTotalPrefix.Append(iGeneralAttributes.iTraceFilePrefix); + + // locate '#' mark for finding the next free trace file name, e.g. E:\data\PIProfiler_4.dat + hashLocation = iTotalPrefix.Locate('#'); + if( hashLocation == KErrNotFound ) + { + // append simply at the end of the trace file prefix, no need to inform user + iTotalPrefix.Append('#'); + // get new hash mark location + hashLocation = iTotalPrefix.Locate('#'); + } + + // add the file extension + iTotalPrefix.Append(KTraceFileExtension); + + // search for files with different indices + // until a free filename is found + while(result != KErrNotFound) + { + fileNameBuf.Zero(); + // start with the original prefix + fileNameBuf.Append(iTotalPrefix); + // convert the number to a descriptor + number.Num(index); + // replace the hashmark with the real number + fileNameBuf.Replace(hashLocation,1,number); + + // make a copy to the iFileNameStream descriptor + iFileNameStream.Zero(); + CnvUtfConverter::ConvertToUnicodeFromUtf8(iFileNameStream, fileNameBuf); + + LOGSTRING2("CProfiler::HandleGeneralSettingsChange() - trying to open files %S ",&iFileNameStream); + + if((result = parse.Set(iFileNameStream, NULL, NULL)) != KErrNone) + { + // break loop if fails, problems in file name => change to log into debug output + break; + } + + // create directory for trace files if not exists + result = fileServer.MkDirAll(parse.FullName()); + + // check that file server responded with KErrNone or KErrAlreadyExists + if( result != KErrNone && result != KErrAlreadyExists) + { + // if some other result, e.g. memory full => break + break; + } + + // attempt opening the file + result = file.Open(fileServer,parse.FullName(),EFileShareReadersOnly); + if(result != KErrNotFound) + { + if( result != KErrNotReady && + result != KErrServerBusy ) + { + // close the file if it could be opened + LOGSTRING2("Found STREAM file with index %d",index); + index++; + } + else + { + // in boot measurements the file system might not be ready yet. + LOGSTRING2("Problem in opening STREAM file %d",index); + } + file.Close(); + } + } // while + } + else + { + // return error code + return result; + } + + TUint32 id(iWriterHandler->GetActiveWriter()->GetWriterType()); + + // check if a file name is one that does not exist and selected plugin is disk writer + if(result == KErrNotFound && id == KDiskWriterPluginUid.iUid) + { + // write right trace data file name to disk writer plugin + iWriterHandler->SetPluginSettings( KDiskWriterPluginUid, iFileNameStream ); + } + else + { + // return error if could not create trace log file + return result; + } + // close file server + fileServer.Close(); + } // if output == KOutputToDebugOutput + return KErrNone; + } + +// -------------------------------------------------------------------------------------------- +void CProfiler::SaveSettingsL() + { + LOGTEXT(_L("CProfiler::SaveSettings()")); + + // local literal + _LIT(KGeneralHeader, "[general]"); + _LIT(KVersionHeader, "version"); + _LIT8(KPIProfilerSettingsHeader, "; PI Profiler Settings File"); + _LIT8(KGeneralSettingsHeader, "; general settings"); + _LIT8(KOutputFileDescription,"; \"output_type=file_system\" writes *.dat file to external memory"); + _LIT8(KOutputDebugDescription,"; \"output_type=debug_output\" writes *.dat file to debug port"); + _LIT8(KOutputFilePrefixDescription,"; if writing to file, prefix of the *.dat file\r\n; first '#' in the prefix is replaced with an integer"); + _LIT8(KOutputSaveDriveDescription,"; if writing to file, the location to store the *.dat file"); + + RFs fs; + RFile settingsFile; + TInt err(KErrNone); + TBuf8<384> line; + + // connect to file server + err = fs.Connect(); + if( err != KErrNone ) + { + // failed to write settings to settings file + return; + } + + // create and set the private path + fs.CreatePrivatePath(EDriveC); + fs.SetSessionToPrivate(EDriveC); + + // create the new settings file + err = settingsFile.Replace(fs, iSettingsFileLocation, EFileWrite); + if(err != KErrNone) + return; + + CleanupClosePushL(settingsFile); + + // write the header + line.Copy(KPIProfilerSettingsHeader); + line.Append(KNewLineSeparator); + line.Append(KNewLineSeparator); + settingsFile.Write(line); + + // write the header + line.Copy(KGeneralSettingsHeader); + line.Append(KNewLineSeparator); + settingsFile.Write(line); + + // write all generic settings + line.Copy(KGeneralHeader); + line.Append(KNewLineSeparator); + settingsFile.Write(line); + + // write version info + line.Copy(KVersionHeader); + line.Append(KEquals); + line.Append(PROFILER_VERSION_SHORT); + line.Append(KNewLineSeparator); + settingsFile.Write(line); + + // output explanation + line.Copy(KOutputFileDescription); + line.Append(KNewLineSeparator); + line.Append(KOutputDebugDescription); + line.Append(KNewLineSeparator); + settingsFile.Write(line); + + // write trace output + line.Copy(KGenericTraceOutput); + line.Append(KEquals); + line.Append(iGeneralAttributes.iTraceOutput); + line.Append(KNewLineSeparator); + settingsFile.Write(line); + + // file prefix explanation + line.Copy(KOutputFilePrefixDescription); + line.Append(KNewLineSeparator); + settingsFile.Write(line); + + // write trace file prefix + line.Copy(KGenericTraceFilePrefix); + line.Append(KEquals); + line.Append(iGeneralAttributes.iTraceFilePrefix); + line.Append(KNewLineSeparator); + settingsFile.Write(line); + + // file prefix explanation + line.Copy(KOutputSaveDriveDescription); + line.Append(KNewLineSeparator); + settingsFile.Write(line); + + // write trace file location + line.Copy(KGenericTraceFileSaveDrive); + line.Append(KEquals); + line.Append(iGeneralAttributes.iSaveFileDrive); + line.Append(KNewLineSeparator); + settingsFile.Write(line); + + // reset the default attributes array + iDefaultSamplerAttributesArray->Reset(); + + // update the latest changes from plugins + iSamplerHandler->GetSamplerAttributesL(iDefaultSamplerAttributesArray); + + // call CSamplerController to write all sampler settings + iSamplerHandler->ComposeAttributesToSettingsFileFormat(settingsFile, iDefaultSamplerAttributesArray); + + CleanupStack::PopAndDestroy(); //settingsFile + // close file + fs.Close(); + } + +TInt CProfiler::CheckOldProfilerRunning() + { + TFindProcess procName; + procName.Find(_L("BappeaProf.exe*")); + TFullName aResult; + TInt err(KErrNone); + RProcess proc; + + // now check if old Profiler is still running on + err = procName.Next(aResult); + // check if old profiler process found + if(err == KErrNone) + { + // other process found, i.e. right process to communicate with, in case started from eshell + err = proc.Open(procName); + if(err == KErrNone) + { + if(proc.ExitCategory().Length() > 0) + { + proc.Close(); + // process already exited => create a new one + return KErrNotFound; + } + proc.Close(); + } + // return error for error handling + return KErrAlreadyExists; + } + return err; + } + +// -------------------------------------------------------------------------------------------- +void CProfiler::HandleError(TInt aErr) + { + // write error to status property to inform requester + TInt err(iEngineStatus.Set(KEngineStatusPropertyCat, EProfilerEngineStatus, aErr)); + if(err != KErrNone) + RDebug::Print(_L("CProfiler::HandleError() - error setting status: %d"), err); + } + +// -------------------------------------------------------------------------------------------- +TInt CProfiler::ControlDataL(TInt aCommand,TAny* value1,TAny* /*value2*/) + { + LOGSTRING3("CProfiler::ControlData %d, 0x%x",aCommand,value1); + + _LIT(KDebugOutput, "debug_output"); + _LIT(KFileOutput, "file_system"); + _LIT8(KOutputToDebugOutput, "debug_output"); + + TDes* desc; + TPtrC ptrDesc; + + switch(aCommand) + { + // new controls + case RProfiler::EGetFileName: + { + LOGTEXT(_L("Profiler::EGetFileName - start")); + LOGSTRING2(_L("Profiler::EGetFileName - total file name is: %S"),(TDes*)value1); + desc = (TDes*)value1; + desc->Zero(); + desc->Append(iFileNameStream); + LOGSTRING2(_L("Profiler::EGetFileName - now total file name is: %S"),(TDes*)value1); + return KErrNone; + } + case RProfiler::EGetActiveWriter: + { + LOGTEXT(_L("Profiler::EGetActiveWriter - start")); + desc = (TDes*)value1; + desc->Zero(); + if(iGeneralAttributes.iTraceOutput.CompareF(KOutputToDebugOutput) == 0) + { + desc->Append(KDebugOutput); + } + else + { + desc->Append(KFileOutput); + } + return KErrNone; + } + } + + return KErrNone; + } + +// -------------------------------------------------------------------------------------------- +TInt CProfiler::ControlL(TInt aCommand) + { + LOGSTRING2("CProfiler::Control - Controlling ProfilerEngine %d",aCommand); + TInt err(KErrNone); + + switch (aCommand) + { + case RProfiler::EStartSampling: + { + // check first if old Profiler already running + err = CheckOldProfilerRunning(); + if(err == KErrAlreadyExists) + { + // if exists do not start a profiling process since corrupts the collected trace data + HandleError(err); + err = KErrNone; + return err; + } + + // save settings before launching the profiler + // reason: the profiling may have set to the background => need for get right settings + SaveSettingsL(); + + // set the general settings to writer plugins to reflect the latest changes + err = HandleGeneralSettingsChange(); + if(err == KErrNone) + { + // reset the buffers before new profiling + iUserStream->ResetBuffers(); + + // give the CProfilerSampleStream a handle to current writer + iUserStream->SetWriter(*iWriterHandler->GetActiveWriter()); + + // set initially debug output writer active + err = iWriterHandler->StartSelectedPlugin(); + + // check that writer plugin started + if(err != KErrNone) + { + // if not started handle error + HandleError(err); + } + else + { + // start activated sampler plug-in, NOTE: plugins check if errors occur in startup for some reason + iSamplerHandler->StartSamplerPluginsL(); + + // set engine state P&S property to running, e.g. for PIProfiler UI to read + iState = RProfiler::ERunning; + + // set the engine into running mode + iEngineStatus.Set(iState); + } + } + else + { + // handle error and notify requester + HandleError(err); + } + + LOGTEXT(_L("CProfiler::Control - Finished processing EStartSampling!")); + + return err; + } + case RProfiler::EStopSampling: + LOGTEXT(_L("CProfiler::Control - Starting to stop sampling...")); + // stop sampler plugins + if(iState == RProfiler::ERunning) + { + iState = RProfiler::EStopping; + iEngineStatus.Set(RProfiler::EStopping); + + iSamplerHandler->StopSamplerPlugins(); + + // finalize the filled buffer writing + iUserStream->Finalise(); + + // stop output plugin and write the rest of the trace data to output + LOGTEXT(_L("CProfiler::Control - stopping writer")); + iWriterHandler->StopSelectedPlugin(); + + // set engine state P&S property idle + iState = RProfiler::EIdle; + iEngineStatus.Set(RProfiler::EIdle); + + LOGSTRING2("CProfiler::Control - sampling stopped, going to state %d", RProfiler::EIdle); + } + return KErrNone; + + case RProfiler::EExitProfiler: + { + // save settings into settings file when exiting + SaveSettingsL(); + + if(iUserStream) + { + delete iUserStream; + iUserStream = NULL; + } + + // set engine state P&S property idle + iState = RProfiler::EIdle; + iEngineStatus.Set(RProfiler::EIdle); + + LOGTEXT(_L("Stopping Activer Scheduler")); + CActiveScheduler::Stop(); + LOGTEXT(_L("Stopped Activer Scheduler")); + + return KErrNone; + } + } + + LOGTEXT(_L("CProfiler::Control - returning")); + + return err; + } + +// -------------------------------------------------------------------------------------------- +void CProfiler::Finalise() + { + LOGTEXT(_L("CProfiler::Finalise - Finished processing EStopSampling!")); + } + +// -------------------------------------------------------------------------------------------- +RProfiler::TSamplerState CProfiler::State() const + { + return iState; + } + +/* + * + * Class CPServer definition + * + */ +// -------------------------------------------------------------------------------------------- +inline const CPServer& CPSession::Server() const + { + return *static_cast(CSession2::Server()); + } + +// -------------------------------------------------------------------------------------------- +void CPSession::ServiceL(const RMessage2& aMessage) + { + LOGTEXT(_L("CPSession::ServiceL - Starting to process message")); + TInt err(KErrNone); + + if(aMessage.Function() == RProfiler::EGetGeneralAttributes) + { + Server().GetGeneralAttributesL(aMessage); + } + else if(aMessage.Function() == RProfiler::ESetGeneralAttributes) + { + Server().SetGeneralAttributesL(aMessage); + } + else if(aMessage.Function() == RProfiler::EGetSamplerAttributes) + { + Server().GetSamplerAttributesL(aMessage); + } + else if(aMessage.Function() == RProfiler::EGetSamplerAttributeCount) + { + Server().GetSamplerAttributeCountL(aMessage); + } + else if(aMessage.Function() == RProfiler::ESetSamplerAttributes) + { + Server().SetSamplerAttributesL(aMessage); + } + else if(aMessage.Function() == RProfiler::ERefreshProfilerStatus) + { + Server().RefreshStatus(aMessage); + } + else if(aMessage.Ptr0() == 0 && aMessage.Ptr1() == 0 && aMessage.Ptr2() == 0) + { + LOGTEXT(_L("Ptr0 && Ptr1 == 0 && Ptr2 == 0")); + aMessage.Complete(Server().ControlL(RProfiler::TCommand(aMessage.Function()))); + LOGTEXT(_L("CPSession::ServiceL - Message completed")); + } + else if(aMessage.Ptr0() != 0 && aMessage.Ptr1() != 0 && aMessage.Ptr2() != 0) + { + LOGTEXT(_L("Error with message, all pointers contain data!")); + } + + else if (aMessage.Ptr0() != 0) + { + if(aMessage.Ptr1() == 0) + { + LOGTEXT(_L("ServiceL: Ptr0 != 0 && Ptr1 == 0")); + // provided value is a descriptor + TBuf<64>* dst = new TBuf<64>; + aMessage.ReadL(0,*dst,0); + + err = Server().ControlDataL(aMessage.Function(),(TAny*)dst); + delete dst; + aMessage.Complete(err); + LOGTEXT(_L("CPSession::ServiceL - Message completed")); + } + else + { + LOGTEXT(_L("ServiceL: Ptr0 != 0 && Ptr1 != 0")); + // provided value is a descriptor + TBuf<64>* dst = new TBuf<64>; + aMessage.ReadL(0,*dst,0); + + TUint32 num1 = (TUint32)aMessage.Ptr1(); + + err = Server().ControlDataL(aMessage.Function(),(TAny*)dst, (TAny*)num1); + delete dst; + aMessage.Complete(err); + LOGTEXT(_L("CPSession::ServiceL - Message completed")); + } + } + else if (aMessage.Ptr1() != 0) + { + LOGTEXT(_L("ServiceL: Ptr1 != 0")); + // provided value is a TUint32 + if( ((TUint32)aMessage.Ptr3()) == 0xffffffff) + { + TUint32 num = (TUint32)aMessage.Ptr1(); + err = Server().ControlDataL(aMessage.Function(),(TAny*)num); + aMessage.Complete(err); + LOGTEXT(_L("CPSession::ServiceL - Message completed")); + } + else + { + LOGTEXT(_L("ServiceL: Ptr3 != 0xffffffff")); + TUint32 num1 = (TUint32)aMessage.Ptr1(); + TUint32 num2 = (TUint32)aMessage.Ptr3(); + err = Server().ControlDataL(aMessage.Function(),(TAny*)num1,(TAny*)num2); + aMessage.Complete(err); + LOGTEXT(_L("CPSession::ServiceL - Message completed")); + } + } + else if (aMessage.Ptr2() != 0) + { + // command requests for data, provided + // value should be a descriptor + if( ((TUint32)aMessage.Ptr3()) == 0xffffffff) + { + LOGTEXT(_L("ServiceL: Ptr2 != 0 && Ptr3 == 0xffffffff")); + + TBuf<256>* src = new TBuf<256>; + src->Zero(); + err = Server().ControlDataL(aMessage.Function(),(TAny*)src); + + LOGSTRING2("Got sampler data %S",src); + + aMessage.WriteL(2, *src, 0); + + delete src; + aMessage.Complete(err); + LOGTEXT(_L("CPSession::ServiceL - Message completed")); + } + else + { + LOGTEXT(_L("ServiceL: Ptr2 != 0 && Ptr3 != 0xffffffff")); + + TUint32 num1 = (TUint32)aMessage.Ptr2(); // containing id + TBuf<256>* buffer = new TBuf<256>; // Text data, e.g. plug-in name or description + + LOGSTRING3("Getting data for sampler: 0x%X, buffer max len %d",num1, aMessage.GetDesMaxLength(3)); + + err = Server().ControlDataL(aMessage.Function(), (TAny*)num1, (TAny*)buffer); + + LOGSTRING2("Got sampler data %S",&buffer); + + // write back to same parameter + aMessage.WriteL(3, *buffer, 0); + aMessage.Complete(err); + LOGTEXT(_L("CPSession::ServiceL - Message completed")); + } + } + LOGTEXT(_L("CPSession::ServiceL - Message processed")); + } + +// -------------------------------------------------------------------------------------------- +MProfilerController* CPServer::NewL(TInt aPriority, MProfilerEngine& aEngine) + { + LOGTEXT(_L("CPServer::NewL - Enter")); + CPServer* self = new(ELeave) CPServer(aPriority, aEngine); + CleanupStack::PushL(self); + self->StartL(KProfilerName); + CleanupStack::Pop(); + LOGTEXT(_L("CPSession::NewL - Exit")); + return self; + } + +// -------------------------------------------------------------------------------------------- +CPServer::CPServer(TInt aPriority, MProfilerEngine& aEngine) + : CServer2(aPriority), MProfilerController(aEngine) + { + + } + +// -------------------------------------------------------------------------------------------- +void CPServer::Release() + { + delete this; + } + +// -------------------------------------------------------------------------------------------- +CSession2* CPServer::NewSessionL(const TVersion&,const RMessage2&) const + { + return new(ELeave) CPSession(); + } + +/* + * + * Static methods for controlling the profiler + * through command line + * + */ +// -------------------------------------------------------------------------------------------- +static void RunEngineServerL(const TDesC& aSettingsFile) + { + RDebug::Print(_L("Profiler: RunEngineServerL() - Install active scheduler")); + CActiveScheduler* pS = new CActiveScheduler; + CActiveScheduler::Install(pS); + CProfiler* p = CProfiler::NewLC(aSettingsFile); + CActiveScheduler::Start(); + p->Finalise(); + CleanupStack::PopAndDestroy(p); + delete pS; + } + +// -------------------------------------------------------------------------------------------- +static TInt TestSettingsFile(const TDesC& configFile) + { + RFs fs; + TBuf8<256> configFile8; + + // check if file server can be connected + if (fs.Connect() != KErrNone) + { + // file server couldn't be connected, return false + return KErrNotFound; + } + + // check if config file name length is > 0 + if (configFile.Length() > 0) + { + // check sanity of settings file location + CnvUtfConverter::ConvertFromUnicodeToUtf8(configFile8, configFile); + if(!CProfiler::CheckLocationSanity(fs, configFile8)) + { + fs.Close(); + return KErrGeneral; + } + } + else + { + // configFile length 0, return false + fs.Close(); + return KErrNotFound; + } + // return true if tests passed + fs.Close(); + return KErrNone; + } + +// -------------------------------------------------------------------------------------------- +GLDEF_C TInt E32Main() + { + // parse command line arguments + TBuf<256> c; + + // copy the full command line with arguments into a buffer + User::CommandLine(c); + + TBuf<256> fileName; + fileName.Append(c); // only one settings param should be + LOGSTRING2("Filename is %S", &fileName); + if(TestSettingsFile(fileName) != KErrNone) + { + // settings file does not exist, copy null desc to file name + fileName.Copy(KNullDesC); + } + + // if no command line arguments found just start the profiler process + __UHEAP_MARK; + CTrapCleanup* cleanup = CTrapCleanup::New(); + TInt ret(KErrNoMemory); + if( cleanup ) + { + TRAPD( ret, RunEngineServerL(fileName) ); + RDebug::Print(_L("Profiler: E32Main() - ret %d"), ret); + delete cleanup; + } + __UHEAP_MARKEND; + + return ret; + } + + diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler/engine/src/ProfilerErrorChecker.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler/engine/src/ProfilerErrorChecker.cpp Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,115 @@ +/* +* 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: +* +*/ + + +#include +#include +#include + +#include + +#include "ProfilerErrorChecker.h" + +// properties +const TUid KEngineStatusPropertyCat={0x2001E5AD}; +enum TEnginePropertyKeys + { + EProfilerEngineStatus = 8, + EProfilerErrorStatus + }; + +/* + * + * CProfilerErrorChecker class implementation + * + */ +CProfilerErrorChecker* CProfilerErrorChecker::NewL() + { + CProfilerErrorChecker* self = new(ELeave) CProfilerErrorChecker; + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + +// -------------------------------------------------------------------------------------------- +CProfilerErrorChecker::CProfilerErrorChecker() : + CActive(EPriorityStandard) + { + } + +CProfilerErrorChecker::~CProfilerErrorChecker() + { + Cancel(); + iErrorStatus.Close(); + } + +// -------------------------------------------------------------------------------------------- +void CProfilerErrorChecker::ConstructL() + { + + LOGTEXT(_L("Trying to attach to profiler engine error status property")); + User::LeaveIfError(iErrorStatus.Attach(KEngineStatusPropertyCat, EProfilerErrorStatus)); + CActiveScheduler::Add(this); + + // subscribe to P&S status property + iErrorStatus.Subscribe(iStatus); + SetActive(); + } + +// -------------------------------------------------------------------------------------------- +void CProfilerErrorChecker::SetObserver(MProfilerErrorObserver* aObserver) + { + iObserver = aObserver; + } + +// -------------------------------------------------------------------------------------------- +TInt CProfilerErrorChecker::RunError(TInt aError) + { + iErrorStatus.Close(); + return aError; + } +// -------------------------------------------------------------------------------------------- +void CProfilerErrorChecker::RunL() + { + // resubscribe before processing new value to prevent missing updates + iErrorStatus.Subscribe(iStatus); + SetActive(); + + TInt stat(0); + if(iErrorStatus.Get(stat) != KErrNone) + { + // check if error status != KErrNone + if(stat != 0) + { + iObserver->HandleProfilerErrorChangeL(stat); + } + + // reset error code + iErrorStatus.Set(KErrNone); + } + } + +// -------------------------------------------------------------------------------------------- + +void CProfilerErrorChecker::DoCancel() + { + iErrorStatus.Cancel(); + } + +// end of file + diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler/engine/src/ProfilerEshell.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler/engine/src/ProfilerEshell.cpp Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,419 @@ +/* +* 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: +* +*/ + +#include +#include + +#include "ProfilerEshell.h" +#include + + + +_LIT(KProfilerEngineExe, "PIProfilerEngine.exe"); + +/* + * + * Static methods for controlling the profiler + * through command line + * + */ +// -------------------------------------------------------------------------------------------- +static void PrintUsageInfo(const TDesC& aAdditionalInfo) + { + _LIT(KConsoleName, "Console"); + _LIT(KLegalNote, "PIProfiler Version 2.00.0 Copyright @ 2009 Nokia\n"); + _LIT(KUsageNote, "Usage: PIProfiler [start/end/timed] settingsfile [time to run]\n"); + _LIT(KExample, "Example: PIProfiler timed C:\\data\\piprofilersettings.txt 60\n"); + + TRAP_IGNORE(CConsoleBase* console = Console::NewL(KConsoleName,TSize(KConsFullScreen,KConsFullScreen)); + console->Printf(KLegalNote); + console->Printf(KUsageNote); + console->Printf(KExample); + console->Write(aAdditionalInfo); + + console->Printf(_L("\n[Press any key]")); + console->Getch(); + delete console;); + } + +// -------------------------------------------------------------------------------------------- +static TInt FindProcess() + { + TFindProcess procName; + procName.Find(_L("PIProfilerEngine.exe*")); + TFullName aResult; + + // find the first appearance, i.e. "myself"... + TInt err(procName.Next(aResult)); // the first appearance + if(err == KErrNotFound) + { + // now check if old Profiler is still running on + procName.Find(_L("BappeaProf.exe*")); + err = procName.Next(aResult); + // check if old profiler process found + if(err == KErrNone) + { + // return error for error handling + return KErrAlreadyExists; + } + // return KErrNotFound and a new profiler engine process can be started + return KErrNotFound; + } + return err; + } + +/** + * Function for starting profiler engine in the background, + * call profiler to load settings + * and start sampling process + * + * @param configFile name and location of settings file + */ +// -------------------------------------------------------------------------------------------- +static TInt StartProfilerProcess(const TDesC& configFile, TInt aRunTimeInSeconds) + { + TInt err(KErrNone); + RProcess proc; + TRequestStatus status = KRequestPending; + + // check if process exists + err = FindProcess(); + LOGSTRING2(_L("PIProfiler: tried to find process, response %d"), err); + + // check if already exists and don't start a new eshell profiling + if( err == KErrNotFound ) + { + // try create new process + err = proc.Create(KProfilerEngineExe, configFile); + + LOGSTRING2(_L("PIProfiler: created process, response %d"), err); + + // check if RProcess::Create() succeeded + if( err == KErrNone ) + { + // kick off the engine process + proc.Resume(); + + // wait for the constructor to complete + proc.Rendezvous(status); // Trigger rendezvous on the supplied TRequestStatus object + User::WaitForRequest(status); + + // just lose the handle + proc.Close(); + + // check if command succesfull + if( err != KErrNone ) + { + LOGTEXT(_L("Profiler: could not connect engine")); + return err; + } + + // start sampling, using settings found in settings file or if not found the default settings + err = RProfiler::StartSampling(); + // check if command succesful + if( err != KErrNone ) + { + _LIT(KNoteProfilerCannotStart, "PI Profiler: cannot start PI Profiler, check settings!"); + PrintUsageInfo(KNoteProfilerCannotStart); + // check if process still alive + if(err != KErrNotFound) + { + // exit the profiler process since process was started + RProfiler::ExitProfiler(); + } + return err; + } + + if(aRunTimeInSeconds > 0) + { + RDebug::Print(_L("Profiler running for %d s... "), aRunTimeInSeconds); + User::After(aRunTimeInSeconds*1000000); + RDebug::Print(_L("************* Profiler process closing *********")); + + // stop sampling process + err = RProfiler::StopSampling(); + // check if command succesfull + if( err != KErrNone ) + { + LOGTEXT(_L("Profiler: could not connect engine, stop failed")); + return err; + } + + // exit the profiler process + err = RProfiler::ExitProfiler(); + // check if command succesfull + if( err != KErrNone ) + { + LOGTEXT(_L("Profiler: could not connect engine, exit failed")); + return err; + } + } + } + else + { + _LIT(KNoteCannotFindProfiler, "PI Profiler: could not find PIProfilerEngine.exe"); + PrintUsageInfo(KNoteCannotFindProfiler); + } + } + // check if old Profiler is already running + else if( err == KErrAlreadyExists ) + { + _LIT(KNoteAlreadyRunning, "PI Profiler: old Profiler process already running, close it down before launching the new!"); + PrintUsageInfo(KNoteAlreadyRunning); + } + // otherwise show error note + else + { + _LIT(KNoteAlreadyRunning, "PI Profiler: already running, not able to launch new one. NOTE: check if UI running!"); + PrintUsageInfo(KNoteAlreadyRunning); + } + return KErrNone; + } + +// -------------------------------------------------------------------------------------------- +static TInt EndProfilerProcess() + { + LOGTEXT(_L("EndProfilerProcess() ...")); + + // call profiler to stop sampling + TInt err = RProfiler::StopSampling(); + + // check if command succesfull + if( err != KErrNone ) + { + LOGTEXT(_L("Profiler: could not connect engine, stop failed")); + return err; + } + + // exit the profiler process + err = RProfiler::ExitProfiler(); + // check if command succesfull + if( err != KErrNone ) + { + LOGTEXT(_L("Profiler: could not connect engine, exit failed")); + return err; + } + + return KErrNone; + } + +// -------------------------------------------------------------------------------------------- +static TInt TestSettingsFile(const TDesC& configFile) + { + RFs fs; + RFile file; + TInt err(KErrNone); + + // check if file server can be connected + if (fs.Connect() != KErrNone) + { + // file server couldn't be connected, return false + return KErrNotFound; + } + + // check if config file name length is > 0 + if (configFile.Length() > 0) + { + // open the file with the given path and name + err = file.Open(fs,configFile,EFileRead); + // check if file open was succesfull + if(err != KErrNone) + { + // return false if failed + fs.Close(); + return err; + } + + } + else + { + // configFile length 0, return false + fs.Close(); + return KErrNotFound; + } + // return true if tests passed + file.Close(); + fs.Close(); + return KErrNone; + } + +// -------------------------------------------------------------------------------------------- +static TInt ParseCommandAndExecute() + { + // commands literals for finding the right keyword + _LIT(KAutomatedTestStart,"start*"); + _LIT(KAutomatedTestEnd,"end*"); + _LIT(KAutomatedTestTimed,"timed*"); + + TBuf<256> c; + TInt match(KErrNotFound); + + // copy the full command line with arguments into a buffer + User::CommandLine(c); + + // try to match with each of the literals defined above + // (commands in atf format) + + // check if command is "start" + match = c.Match(KAutomatedTestStart); + if (match != KErrNotFound) + { + LOGTEXT(_L("Found keyword start")); + + TBuf<256> fileName; + fileName.Append(c.Right(c.Length()-6)); + LOGSTRING2(_L("Filename is %S"), &fileName); + if(TestSettingsFile(fileName) != KErrNone) + { + _LIT(KSettingsFileFailed, "False settings file"); + PrintUsageInfo(KSettingsFileFailed); + return -2; + } + // execute Profile process + if( StartProfilerProcess(fileName, 0) == KErrNone ) + { + return -10; + } + return -2; + } + + // check if command is "end" + match = c.Match(KAutomatedTestEnd); + if (match != KErrNotFound) + { + LOGTEXT(_L("Found keyword end")); + + // stop the profiling process + EndProfilerProcess(); + return -10; + } + + // check if command is "timed" + match = c.Match(KAutomatedTestTimed); + if (match != KErrNotFound) + { + // command "timed" found, need for finding settings file and run time next + LOGTEXT(_L("Found keyword timed")); + TBuf<256> temp; + temp.Append(c); + TLex lex(temp); + + TBuf<256> fileName; + TInt seconds; + + // parse the first command line argument, the command itself + lex.Mark(); + lex.SkipCharacters(); + if(lex.TokenLength() != 0) + { + #ifdef PIPROFILER_PRINTS + TPtrC token = lex.MarkedToken(); + LOGSTRING2("Token 1 %S",&token); + #endif + } + else + { + LOGTEXT(_L("Problem 1 in parsing command line")); + _LIT(KSettingsFileFailed, "Failure: False argument"); + PrintUsageInfo(KSettingsFileFailed); + return -2; + } + + // parse the second command line argument, the settings file name + lex.SkipSpace(); + lex.Mark(); + lex.SkipCharacters(); + if(lex.TokenLength() != 0) + { + TPtrC token2 = lex.MarkedToken(); + LOGSTRING2(_L("Token 2 %S"),&token2); + fileName.Append(token2); + LOGSTRING2(_L("Value of fileName is %S"),&fileName); +// if(TestSettingsFile(fileName) != KErrNone) +// { +// _LIT(KSettingsFileFailed, "Failure: False settings file"); +// PrintUsageInfo(KSettingsFileFailed); +// return -2; +// } + } + else + { + LOGTEXT(_L("Problem 2 in parsing command line")); + _LIT(KSettingsFileFailed, "Failure: No settings file specified"); + PrintUsageInfo(KSettingsFileFailed); + return -2; + } + + // parse the third command line argument, the run time in seconds + lex.SkipSpace(); + lex.Mark(); + lex.SkipCharacters(); + if(lex.TokenLength() != 0) + { + // third token ok, try to convert into TInt value + TPtrC token3 = lex.MarkedToken(); + LOGSTRING2(_L("Token 3 %S"),&token3); + TLex num(token3); + TInt err = num.Val(seconds); + // check if given time value acceptable + if (err != KErrNone) + { + // value parsing failed, show info note to user + _LIT(KSecondsFailed, "Failure: False time value"); + PrintUsageInfo(KSecondsFailed); + return -2; + } + } + else + { + LOGTEXT(_L("Problem 3 in parsing command line")); + _LIT(KSecondsFailed, "Failure: False time value"); + PrintUsageInfo(KSecondsFailed); + return -2; + } + + LOGSTRING3(_L("Filename is %S, seconds is %d"), &fileName, seconds); + // execute Profile process + if( StartProfilerProcess(fileName, seconds) == KErrNone ) + { + return -10; + } + return -2; + } + + // check if space character in the middle of command line string + if( c.LocateReverse(' ') != KErrNotFound) + { + _LIT(KWrongParameters, "Failure: Check command line parameters"); + PrintUsageInfo(KWrongParameters); + return -2; + } + + // return -1 if no command found + LOGTEXT(_L("No keyword found")); + return -1; + } + +// -------------------------------------------------------------------------------------------- +GLDEF_C TInt E32Main() + { + // parse command line arguments + ParseCommandAndExecute(); + + return KErrNone; + + } diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler/engine/src/SamplerController.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler/engine/src/SamplerController.cpp Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,526 @@ +/* +* 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: +* +*/ + + +#include "SamplerController.h" +#include + +// CONSTANTS +const TInt KMaxSamplerPluginCount = 20; +const TInt KMaxExtraSettingsItemCount = 6; + +// LITERALS +_LIT8(KEnabled, "enabled"); +_LIT8(KSamplingPeriod, "sampling_period_ms"); +_LIT8(KBracketOpen, "["); +_LIT8(KBracketClose, "]"); +_LIT8(KNewLine8, "\n"); +_LIT8(KEquals8, "="); +_LIT8(KSettingsText, " settings"); +_LIT(KNewLine, "\n"); +_LIT(KEquals, "="); +_LIT(KCommentSeparator, " ; "); + +CSamplerController* CSamplerController::NewL(CProfilerSampleStream& aStream) + { + CSamplerController* self = new( ELeave ) CSamplerController(aStream); + CleanupStack::PushL( self ); + self->ConstructL( ); + CleanupStack::Pop( self ); + return self; + } + +void CSamplerController::ConstructL() + { + // initiate sampler plugin list + InitialiseSamplerListL(); + } + + +CSamplerController::CSamplerController(CProfilerSampleStream& aStream) : + iStream(aStream) + { + } + +void CSamplerController::InitialiseSamplerListL() + { + // create new sampler plugin array + iPluginArray = new (ELeave) CArrayPtrFlat( KMaxSamplerPluginCount ); + + // create plugin loader instance + iPluginLoader = CSamplerPluginLoader::NewL(); + + // register sampler controller to get notifications of succesfull plugin load + iPluginLoader->SetObserver( this ); + + // load sampler plugins asynchronously + iPluginLoader->LoadAsyncL( iPluginArray ); + + LOGTEXT(_L(" RSamplerController::InitialiseUserSideSamplerList - exit")); + } + +CSamplerController::~CSamplerController() + { + LOGTEXT(_L("CSamplerController::~CSamplerController - entry" )); + + if ( iPluginArray ) + { + // destroy the plugin instances + // empty loaded plugins from array + for(TInt i(0);iCount();i++) + { + if(iPluginArray->At(i)) + { + delete iPluginArray->At(i); + iPluginArray->At(i) = NULL; + } + } + iPluginArray->Reset(); + delete iPluginArray; + iPluginArray = NULL; + } + + if ( iPluginLoader ) + { + iPluginLoader->AbortAsyncLoad(); + delete iPluginLoader; + iPluginLoader = NULL; + } + + LOGTEXT(_L("CSamplerController::~CSamplerController - exit" )); + } + +void CSamplerController::SetObserver(MSamplerControllerObserver* aObserver) + { + iObserver = aObserver; + } + +TInt CSamplerController::UpdateSavedSamplerAttributesL(CDesC8ArrayFlat* aSavedLineArray, CArrayFixFlat* aAttributes) + { + TInt err(KErrNone); + TInt count(iPluginArray->Count()); + // all plugins get their own settings among whole lump of setting strings + CSamplerPluginInterface* plugin = NULL; + + // loop through the plugin array + for(TInt i(0);iAt(i); + + // call each plugin to sort out its own settings + err = plugin->ConvertRawSettingsToAttributes(aSavedLineArray); + + // get plugin specific attributes, array may contain attributes of several sub samplers + plugin->GetAttributesL(aAttributes); + } + + return err; + } + +TInt CSamplerController::SetSamplerSettingsL(TInt aUid, TSamplerAttributes aAttributes) + { + // parse right plugin based on UID + CSamplerPluginInterface* plugin = GetPlugin(TUid::Uid(aUid)); + + // set the sampler attributes of a sampler plugin + plugin->SetAttributesL(aAttributes); + + return KErrNone; + } + +void CSamplerController::GetSamplerAttributesL(CArrayFixFlat* aAttributes) + { + CSamplerPluginInterface* plugin = NULL; + + TInt count(iPluginArray->Count()); + + // get first all the attributes from all the sampler plugins listed in iPluginArray + for(TInt i(0);iAt(i); + + // get plugin specific attributes, array may contain attributes of several sub samplers + plugin->GetAttributesL(aAttributes); + } + } + +void CSamplerController::ComposeAttributesToSettingsFileFormat(RFile& aFile, CArrayFixFlat* aAttributes) + { + // write immediately to settings file + ComposeSettingsText(aFile, aAttributes); + } + +void CSamplerController::ComposeSettingsText(RFile& aFile, CArrayFixFlat* aAttrArray) + { + // temporary buffer for a setting line + TBuf<384> settingLine; + TBuf8<384> settingLine8; + TInt itemCount(0); + TBuf<266> tBuf; + + TSamplerAttributes attr; + + for(TInt i(0);iCount();i++) + { + // get the attribute container + attr = aAttrArray->At(i); + + // add the name and description of the sampler in brackets first + settingLine8.Copy(KBracketOpen); + settingLine8.Append(attr.iShortName); + settingLine8.Append(KBracketClose); + settingLine8.Append(KCommentSeparator()); + settingLine8.Append(attr.iName); + settingLine8.Append(KSettingsText); + settingLine8.Append(KNewLine8); + aFile.Write(settingLine8); + + // enabled + settingLine8.Copy(KEnabled); + settingLine8.Append(KEquals8); + settingLine8.Append(Bool2Str(attr.iEnabled)); + settingLine8.Append(KNewLine8); + aFile.Write(settingLine8); + + // sampling rate (if set) + if( attr.iSampleRate != -1 ) + { + settingLine8.Copy(KSamplingPeriod); + settingLine8.Append(KEquals8); + settingLine8.Append(Int2Str(attr.iSampleRate)); + settingLine8.Append(KNewLine8); + aFile.Write(settingLine8); + } + + itemCount = attr.iItemCount; + + // check if item count set is sane, max extra settings item count 6 + if(itemCount > KMaxExtraSettingsItemCount) + { + // probably forgot to set the item count value in plugin => safe to set it 0 + itemCount = 0; + } + + // setting items + for (TInt j(0);j CSamplerController::Bool2Str(const TBool& aValue) + { + TBuf8<16> buf; + + if (aValue) + buf.Copy(KTrue); + else + buf.Copy(KFalse); + + return buf; + } + +// ---------------------------------------------------------------------------- +// Converts given integer into a descriptor. +// ---------------------------------------------------------------------------- +// +inline TBuf8<16> CSamplerController::Int2Str(const TInt& aValue) + { + TBuf8<16> buf; + buf.AppendNum(aValue); + + return buf; + } + + +void CSamplerController::HandlePluginLoaded( KSamplerPluginLoaderStatus aStatus ) + { + + // process status value + switch(aStatus) + { + case 0: + LOGSTRING2("RSamplerController - one plugin loaded, status: %d", aStatus); + break; + case 1: + LOGSTRING2("RSamplerController - a plugin load failed: %d", aStatus); + break; + case 2: + LOGSTRING2("RSamplerController - plugin loading aborted: %d", aStatus); + break; + case 3: + LOGSTRING2("RSamplerController - all plugins loaded: %d", aStatus); + TRAPD(err, iPluginLoader->SortPluginsL(iPluginArray)); + if(err != KErrNone) + { + LOGTEXT(_L("Sampler controller unable to sort plugins")); + } + + // call engine to finalize the startup + TRAPD(result, iObserver->HandleSamplerControllerReadyL();); + if(result != KErrNone) + { + LOGTEXT(_L("Failed to notify engine")); + } + break; + case 4: + LOGSTRING2("RSamplerController - error in loading plugins: %d", aStatus); + break; + default: + break; + } +} + +TUid CSamplerController::GetPluginUID(TDesC8& aName) + { + TUid uid; + TInt id; + + // check if plugin array contains loaded samplers + if( iPluginArray && iPluginArray->Count() > 0 ) + { + for(TInt i=0;iCount();i++) + { + CSamplerPluginInterface* plugin = iPluginArray->At(i); + id = (TUint32)plugin->GetSamplerUidByName(aName); + if(id != KErrNotFound) + { + return TUid::Uid(id); + } + } + } + + LOGSTRING2(" RSamplerController::GetPluginUID - KErrNotFound! traceId = %d", id ); + uid = TUid::Uid(0); + return uid; + } + + +CSamplerPluginInterface* CSamplerController::GetPlugin(TUid aUid) + { + LOGTEXT(_L("RSamplerController::GetPlugin - entry")); + // check that plugin array contains samplers + if( iPluginArray && iPluginArray->Count() > 0 ) + { + for(TInt i=0;iCount();i++) + { + CSamplerPluginInterface* plugin = iPluginArray->At(i); + TUid uid = plugin->Id(-1); // get parent uid first + if(uid == aUid) + { + LOGTEXT(_L("CSamplerController::GetPlugin() - main plug-in found!")); + return plugin; + } + + if(plugin->SubId(aUid) != KErrNotFound) + { + LOGTEXT(_L("CSamplerController::GetPlugin() - subsampler found!")); + return plugin; + } + } + } + LOGTEXT(_L("CSamplerController::GetPlugin() - No plug-in found for UID")); + + return (CSamplerPluginInterface*)0; + } + +// start user mode samplers +void CSamplerController::StartSamplerPluginsL() + { + CSamplerPluginInterface* plugin = NULL; + TInt count(iPluginArray->Count()); + TInt err(KErrNone); + + LOGSTRING2(" RSamplerController::StartSamplerPlugin - plugins loaded, amount = %d", count); + if( iPluginArray && count > 0 ) + { + for(TInt i(0);iAt(i); + // check if some error received when starting profiling + err = plugin->ResetAndActivateL(iStream); + if( err != KErrNone) + { + // handle received error, need to update UI! + iObserver->HandleError(err); + } + } + } + } + +// stop user mode samplers +TInt CSamplerController::StopSamplerPlugins() + { + TInt count(0); + + if( iPluginArray && iPluginArray->Count() > 0 ) + { + TInt i(0); + CSamplerPluginInterface* plugin = NULL; + // stop kernel mode samplers + for(;iCount();i++) + { + plugin = iPluginArray->At(i); + TUint32 id = plugin->Id(-1).iUid; + LOGSTRING2(" CSamplerController::StopSamplerPlugins - traceId = %d", + id); + // stop only started samplers + if(plugin->Enabled()) + { + // stop selected plugin + plugin->StopSampling(); + // check if user mode sampler, special flush needed to direct data to stream + if(plugin->GetSamplerType() == PROFILER_USER_MODE_SAMPLER) + { + LOGTEXT(_L(" CSamplerController::StopSamplerPlugins - flushing user mode sampler stream")); + plugin->Flush(); + } + } + count++; + } + } + return count; + } + +// end of file + + + + diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler/engine/src/SamplerPluginLoader.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler/engine/src/SamplerPluginLoader.cpp Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,568 @@ +/* +* 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: +* +*/ + + +// INCLUDE FILES +#include "SamplerPluginLoader.h" +#include +#include // CnvUtfConverter +#include + +// CONSTANTS +const TInt KSamplerCaptionSize = 256; + +// ---------------------------------------------------------------------------- +// CSamplerPluginLoader::NewL +// +// EPOC two-phased constructor +// ---------------------------------------------------------------------------- +// +CSamplerPluginLoader* CSamplerPluginLoader::NewL() + { + CSamplerPluginLoader* self = new( ELeave ) CSamplerPluginLoader; + CleanupStack::PushL( self ); + self->ConstructL( ); + CleanupStack::Pop( self ); + return self; + } + + +// ---------------------------------------------------------------------------- +// CSamplerPluginLoader::CSamplerPluginLoader +// +// C++ default constructor can NOT contain any code, that +// might leave. +// ---------------------------------------------------------------------------- +// +CSamplerPluginLoader::CSamplerPluginLoader() : CActive( EPriorityStandard ) + { + LOGSTRING( "CSamplerPluginLoader()::CSamplerPluginLoader()" ); + } + + +// ---------------------------------------------------------------------------- +// CSamplerPluginLoader::ConstructL +// +// EPOC default constructor can leave. +// ---------------------------------------------------------------------------- +// +void CSamplerPluginLoader::ConstructL( ) + { + LOGSTRING( "CSamplerPluginLoader()::ConstructL()" ); + + // get list of implementations + CSamplerPluginInterface::ListAllImplementationsL( iImplInfoArray ); + + CActiveScheduler::Add( this ); + } + +// ---------------------------------------------------------------------------- +// CSamplerPluginLoader::~CSamplerPluginLoader +// +// Destructor +// ---------------------------------------------------------------------------- +// +CSamplerPluginLoader::~CSamplerPluginLoader() + { + LOGSTRING( "CSamplerPluginLoader()::~CSamplerPluginLoader()" ); + + AbortAsyncLoad(); + + Cancel(); + + // reset ECOM implementation info array + iImplInfoArray.ResetAndDestroy(); // This is needed + iImplInfoArray.Close(); + } + + +// ---------------------------------------------------------------------------- +// CSamplerPluginLoader::LoadAsync +// ---------------------------------------------------------------------------- +// +void CSamplerPluginLoader::LoadAsyncL(CArrayPtrFlat* aPluginArray ) + { + iPluginArray = aPluginArray; + + // Reset iterator + iImplInfoArrayIterator = 0; + + LOGSTRING2( "CSamplerPluginLoader()::Implementation info count: %d", + iImplInfoArray.Count() ); + + NotifyProgress(); + + //Begin CActive asynchronous loop. + CompleteOwnRequest(); + } + + +// ---------------------------------------------------------------------------- +// CSamplerPluginLoader::LoadSyncL +// ---------------------------------------------------------------------------- +// +void CSamplerPluginLoader::LoadSyncL(CArrayPtrFlat* aPluginArray) + { + // cancel first active object from loading samplers dynamically + Cancel(); + CSamplerPluginInterface* plugin = NULL; + + iPluginArray = aPluginArray; + + // Get a list of all implementations, even though we only want one specific + // one. There appears to be no way to otherwise extract a specific implementation + // info object :( + // Search for the implementation that matches aImplementationUid + const TInt impCount = iImplInfoArray.Count(); + for( TInt i=0; iiDisplayName(), ret); + } + break; + } + } + + if ( plugin == NULL ) + { + User::Leave( KErrNotFound ); + } + } + + +// ---------------------------------------------------------------------------- +// CSamplerPluginLoader::AbortAsyncLoad +// ---------------------------------------------------------------------------- +// +void CSamplerPluginLoader::AbortAsyncLoad() + { + LOGSTRING( "CSamplerPluginLoader()::AbortAsyncLoad()" ); + Cancel(); + } + + +// ---------------------------------------------------------------------------- +// CSamplerPluginLoader::RunL +// ---------------------------------------------------------------------------- +// +void CSamplerPluginLoader::RunL() + { + iRunLDebugCount++; + LoadNextPluginL(); + + // Check if there are still more plugins to be loaded: + if ( iImplInfoArrayIterator < iImplInfoArray.Count() ) + { + NotifyProgress(); + // Continue CActive asynchronous loop. + CompleteOwnRequest(); + } + else + { + // All plugins loaded: + LOGSTRING( "CSamplerPluginLoader()::Loading plugins finished." ); + NotifyFinished(); + } + } + + +// --------------------------------------------------------------------------- +// CScGenreItemConstructionConductor::CompleteOwnRequest +// +// Issue request complete notification. +// --------------------------------------------------------------------------- +void CSamplerPluginLoader::CompleteOwnRequest() + { + TRequestStatus* status = &iStatus; + User::RequestComplete( status, KErrNone ); + SetActive(); + } + + +// ---------------------------------------------------------------------------- +// CSamplerPluginLoader::RunError +// ---------------------------------------------------------------------------- +// +TInt CSamplerPluginLoader::RunError( TInt aError ) + { + // This method is called when a plugin loading fails. + // Always "fake" the return value so that ActiveSchedule + // keeps running and later plugins are continued to be loaded. + // Check if still plugins to be loaded: + LOGTEXT(_L("CSamplerPluginLoader::RunError() - error in loading plugin")); + if( iImplInfoArrayIterator < iImplInfoArray.Count() ) + { + NotifyProgress(); + + //Continue CActive asynchronous loop. + CompleteOwnRequest(); + } + else // All plugins loaded: + { + NotifyFinished(); + } + + if ( aError == KLeaveExit ) + { + return KLeaveExit; + } + + return KErrNone; + } + + +// ---------------------------------------------------------------------------- +// CSamplerPluginLoader::DoCancel +// ---------------------------------------------------------------------------- +// +void CSamplerPluginLoader::DoCancel() + { + + } + + +// ---------------------------------------------------------------------------- +// CSamplerPluginLoader::NotifyProgress +// ---------------------------------------------------------------------------- +// +void CSamplerPluginLoader::NotifyProgress() + { + if( iObserver ) + { + iObserver->HandlePluginLoaded( MSamplerPluginLoadObserver::ESamplerSuccess); + } + } + + +// ---------------------------------------------------------------------------- +// CSamplerPluginLoader::NotifyFinished +// ---------------------------------------------------------------------------- +// +void CSamplerPluginLoader::NotifyFinished() + { + if( iObserver ) + { + iObserver->HandlePluginLoaded( MSamplerPluginLoadObserver::ESamplerFinished ); + } + } + + +// ---------------------------------------------------------------------------- +// CSamplerPluginLoader::SetObserver +// ---------------------------------------------------------------------------- +// +void CSamplerPluginLoader::SetObserver(MSamplerPluginLoadObserver* aObserver) + { + LOGSTRING2("CSamplerPluginLoader()::Observer set:0x%X", aObserver); + iObserver = aObserver; + } + + +// ---------------------------------------------------------------------------- +// CSamplerPluginLoader::ParseToUid +// Parses a UID from descriptor of form '0xNNNNNNNN' where N is hexadecimal. +// +// ---------------------------------------------------------------------------- +// +TInt CSamplerPluginLoader::ParseToUid( const TDesC8& aSource, TUid& aTarget ) + { + // Remove "0x" from the descriptor if it exists + _LIT8(KHexPrefix, "0x"); + + TPtrC8 pSource( aSource ); + const TInt prefixPosition = pSource.Find( KHexPrefix ); + if ( prefixPosition != KErrNotFound ) + { + pSource.Set( aSource.Mid( prefixPosition + KHexPrefix().Length() ) ); + } + + // Parse to integer + TLex8 lex( pSource ); + TUint integer = 0; + + // Parse using TRadix::EHex as radix: + const TInt err = lex.Val( integer, EHex ); + aTarget.iUid = integer; + + if( err != KErrNone ) + { + // If parsing parent UID failed, do not load plugin: + LOGSTRING2( + "CSamplerPluginLoader()::Parsing parent UID failed. Error code:%d", + err ); + } + return err; + } + + +// ---------------------------------------------------------------------------- +// CSamplerPluginLoader::ParseOrderNumber +// +// +// ---------------------------------------------------------------------------- +// +TInt CSamplerPluginLoader::ParseOrderNumber( const TDesC8& aSource, TInt& aOrderNumber ) + { + // Parse plugin's order number from opaque_data: + TLex8 lex( aSource ); + const TInt orderErr = lex.Val( aOrderNumber ); + return orderErr; + } + +// ---------------------------------------------------------------------------- +// CSamplerPluginLoader::LoadNextPluginL +// Iterate through iImplInfoArray. Load the plugin if it is eligible for +// loading. Loaded plugin is added to iPluginArray. Each time a plugin is +// loaded, iObserver is notified. +// +// ---------------------------------------------------------------------------- +// +void CSamplerPluginLoader::LoadNextPluginL() + { + // Iterate through iImplInfoArray. This loop continues between function + // calls. Therefore member variable iImplInfoArrayIterator is used as a + // counter. Loop will break when match is found and continues on next RunL. + for( ; iImplInfoArrayIterator < iImplInfoArray.Count(); ) + { + const CImplementationInformation* info = + iImplInfoArray[ iImplInfoArrayIterator ]; + + iImplInfoArrayIterator++; + +// PrintInfoDebug( *info, iImplInfoArrayIterator, iImplInfoArray.Count() ); + LOGSTRING3("CSamplerPluginLoader() - iImplInfoArrayIterator %d, iImplInfoArray.Count() %d", + iImplInfoArrayIterator, + iImplInfoArray.Count() ); + + // If this plugin is OK -> load it: + LOGSTRING2( "CSamplerPluginLoader() %S eligible for parent", + &info->DisplayName()); + CSamplerPluginInterface* plugin = NULL; + TInt error(KErrNone); + // Create plugin. Trap leave for debugging purposes. + TRAP( error, plugin = &CreatePluginInstanceL( *info ); ); + + if( error == KErrNone ) + { + // Plugin ownership is transfered to iPluginArray + InsertPluginInOrderL( plugin, iPluginArray ); + } + else + { + // Error note is displayed even if plugin is not loaded + LOGSTRING3("CSamplerPluginLoader::LoadNextPluginL() - plugin %S load failed, error %d", &info->iDisplayName(), error); + } + // Wait for next round + break; + } + } + +// ---------------------------------------------------------------------------- +// CSamplerPluginLoader::CreatePluginInstanceL +// +// +// ---------------------------------------------------------------------------- +// + +CSamplerPluginInterface& CSamplerPluginLoader::CreatePluginInstanceL( + const CImplementationInformation& aImpInfo ) + { + // Now we can load the plugin + const TUid implUid = aImpInfo.ImplementationUid(); + + CSamplerPluginInterface* plugin = CSamplerPluginInterface::NewL( implUid , (TAny*)&aImpInfo.DisplayName() ); + CleanupStack::PushL ( plugin ); + + // Parse plugin's order number from opaque_data: + TInt orderNumber(0); + const TInt orderErr = ParseOrderNumber( aImpInfo.OpaqueData(), orderNumber ); + + if ( orderErr == KErrNone && orderNumber >= 0 ) + { + plugin->iOrder = orderNumber; + } + CleanupStack::Pop( plugin ); // CSamplerController is now responsible for this memory. + + return *plugin; + } + +// ---------------------------------------------------------------------------- +// CSamplerPluginLoader::SortPluginsL +// +// ---------------------------------------------------------------------------- +// +void CSamplerPluginLoader::SortPluginsL( + CArrayPtrFlat* aPlugins ) + { + RPointerArray plugins; + TLinearOrder order( CSamplerPluginLoader::Compare ); + + // Insertion will also order + for( TInt i = 0; i < aPlugins->Count(); i++ ) + { + plugins.InsertInOrderL( (*aPlugins)[i], order ); + } + + // Replace original array content with sorted items + aPlugins->Reset(); + for( TInt i = 0; i < plugins.Count(); i++ ) + { + aPlugins->AppendL( plugins[i] ); + } + } + + +// ---------------------------------------------------------------------------- +// CSamplerPluginLoader::Compare +// +// Compare two plugins. +// Precedence: +// [1. plugin provider category] +// 2. plugin order number +// 3. plugin caption +// Plugin provider gategory is currently disabled (not supported yet). +// ---------------------------------------------------------------------------- +// +TInt CSamplerPluginLoader::Compare( const CSamplerPluginInterface& aFirst, + const CSamplerPluginInterface& aSecond ) + { + // compare indexes and sort + return CompareIndex( aFirst, aSecond ); + } + + +// ---------------------------------------------------------------------------- +// CSamplerPluginLoader::InsertPluginInOrderL +// +// ---------------------------------------------------------------------------- +// +void CSamplerPluginLoader::InsertPluginInOrderL( + CSamplerPluginInterface* aPlugin, + CArrayPtrFlat* aPlugins ) + { + CSamplerPluginInterface* comparedPlugin; + TInt comparison = 0; + TBool inserted = EFalse; + + for( TInt i = 0; i < aPlugins->Count(); i++ ) + { + comparedPlugin = (*aPlugins)[i]; + // Optimization: do not call time consuming Compare() multiple times! + comparison = Compare( *aPlugin, *comparedPlugin ); + if( comparison < 0 ) + { + aPlugins->InsertL( i, aPlugin ); + inserted = ETrue; + break; + } + else if( comparison == 0 ) + { + aPlugins->InsertL( i+1, aPlugin ); + inserted = ETrue; + break; + } + } + // Plugin was not before any other plugin - make sure it's appended + if( !inserted ) + { + aPlugins->AppendL( aPlugin ); + } + + #ifdef _GS_PLUGINLOADER_SORTING_TRACES + PrintOrderTraces( aPlugins ); + #endif // _GS_PLUGINLOADER_SORTING_TRACES + + } + +// ---------------------------------------------------------------------------- +// CSamplerPluginLoader::CompareCategory +// +// ---------------------------------------------------------------------------- +// +void CSamplerPluginLoader::PrintOrderTraces( + CArrayPtrFlat* aPlugins ) + { + LOGSTRING( "---[CSamplerPluginLoader] Sorted list---" ); + HBufC* name = HBufC::New( KSamplerCaptionSize ); + TRAPD(err, CleanupStack::PushL( name )); + + if(err != KErrNone) + return; // no memory + + TPtr ptr = name->Des(); + CSamplerPluginInterface* plg; + + for( TInt i = 0; i < aPlugins->Count(); i++ ) + { + plg = aPlugins->At(i); + plg->GetCaption( ptr, ECaptionLengthShort, -1 ); + + } + CleanupStack::PopAndDestroy( name ); + + } + +// ---------------------------------------------------------------------------- +// CSamplerPluginLoader::CompareIndex +// ---------------------------------------------------------------------------- +// +TInt CSamplerPluginLoader::CompareIndex( const CSamplerPluginInterface& aFirst, + const CSamplerPluginInterface& aSecond ) + { + TInt comparison = KSamplerComparisonEqual; + // The plugin having index is before the one not having one + + if( aFirst.iOrder == KSamplerPluginNotIndexed && + aSecond.iOrder == KSamplerPluginNotIndexed ) + { + // Neither have index -> equal + comparison = KSamplerComparisonEqual; + } + else if( aFirst.iOrder == KSamplerPluginNotIndexed ) + { + // The plugin having index is before the one not having one + comparison = KSamplerComparisonAfter; + } + else if( aSecond.iOrder == KSamplerPluginNotIndexed ) + { + // The plugin having index is before the one not having one + comparison = KSamplerComparisonBefore; + } + else if( aFirst.iOrder < aSecond.iOrder ) + { + // Compare actual index values + comparison = KSamplerComparisonBefore; + } + else if( aFirst.iOrder > aSecond.iOrder ) + { + // Compare actual index values + comparison = KSamplerComparisonAfter; + } + return comparison; + } + +// End of File diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler/engine/src/WriterController.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler/engine/src/WriterController.cpp Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,280 @@ +/* +* 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: +* +*/ + + +#include +#include + +#include "WriterController.h" + +const TInt KMaxWriterPluginCount = 10; + + +CWriterController* CWriterController::NewL(CProfilerSampleStream& aStream) + { + CWriterController* self = new( ELeave ) CWriterController(aStream); + CleanupStack::PushL( self ); + self->ConstructL( ); + CleanupStack::Pop( self ); + return self; + } + +CWriterController::CWriterController(CProfilerSampleStream& aStream) : + iStream(aStream) + { + } + +void CWriterController::ConstructL() + { + // initiate writer plugin list + + } + + +void CWriterController::InitialiseWriterListL() + { + // create new writer plugin array + iPluginArray = new(ELeave) CArrayPtrFlat( KMaxWriterPluginCount ); + + // create new writer plugin loader + iPluginLoader = CWriterPluginLoader::NewL(); + iPluginLoader->SetObserver( this ); + iPluginLoader->LoadAsyncL( iPluginArray ); + + LOGTEXT(_L(" RWriterController::InitialiseWriterList - exit")); + } + +CWriterController::~CWriterController() + { + LOGTEXT(_L("RWriterController::~RWriterController" )); + if ( iPluginArray ) + { + // destroy the plugin instances + // empty loaded plugins from array + for(TInt i(0);iCount();i++) + { + if(iPluginArray->At(i)) + { + delete iPluginArray->At(i); + iPluginArray->At(i) = NULL; + } + } + iPluginArray->Reset(); + delete iPluginArray; + iPluginArray = NULL; + } + + if ( iPluginLoader ) + { + iPluginLoader->AbortAsyncLoad(); + delete iPluginLoader; + iPluginLoader = NULL; + } + + } + + +void CWriterController::InitialisePluginStream() + { + LOGTEXT(_L("RWriterController::InitialisePluginStream - entry")); + TInt pluginCount(iPluginArray->Count()); + + if( iPluginArray && pluginCount > 0 ) + { + LOGSTRING2("RWriterController::InitialisePluginStream - plugin count %d, searching through", pluginCount); + for(TInt i=0;iAt(i); + LOGSTRING2("RWriterController::InitialisePluginStream - writer found, 0x%x, initializing stream...", plugin->Id()); + plugin->SetStream(iStream); + LOGTEXT(_L("RSamplerController::InitialisePluginStream - succeeded!")); + } + } + LOGTEXT(_L("RSamplerController::InitialisePluginStream - exit")); + + } + +CArrayPtrFlat* CWriterController::GetPluginList() + { + return iPluginArray; + } + +void CWriterController::HandlePluginLoaded( KWriterPluginLoaderStatus aStatus ) + { + + switch(aStatus) + { + case 0: + LOGSTRING2("RWriterController - one plugin loaded, status: %d", aStatus); + break; + case 1: + LOGSTRING2("RWriterController - a plugin load failed: %d", aStatus); + break; + case 2: + LOGSTRING2("RWriterController - plugin loading aborted: %d", aStatus); + break; + case 3: + LOGSTRING2("RWriterController - all plugins loaded: %d", aStatus); + // set stream after all loaded writer plugins + InitialisePluginStream(); + break; + case 4: + LOGSTRING2("RWriterController - error in loading plugins: %d", aStatus); + break; + default: + break; + } + } + + + +TUid CWriterController::GetPluginUID(TInt traceId) + { + LOGSTRING2(" RWriterController::GetPluginUID - checking UID for traceId = %d",traceId); + // this part has to be changed for each new writer + + if( iPluginArray && iPluginArray->Count() > 0 ) + { + for(TInt i=0;iCount();i++) + { + CWriterPluginInterface* plugin = iPluginArray->At(i); + if(plugin->Id().iUid == traceId) + { + LOGSTRING2(" RWriterController::GetPluginUID - got: 0x%X",plugin->Id()); + return plugin->Id(); + } + } + } + return KWriterNoneSelected; + + } + +CWriterPluginInterface* CWriterController::GetActiveWriter() + { + CWriterPluginInterface* plugin = NULL; + TInt count(iPluginArray->Count()); + if( iPluginArray && count > 0 ) + { + for(TInt i=0;iAt(i); + if(plugin->GetEnabled()) + { + return plugin; + } + } + } + return (CWriterPluginInterface*)0; + } + +TUint32 CWriterController::GetWriterType(TUint32 writerId) + { + TUid id; + + id = this->GetPluginUID(writerId); + + if(id != KWriterNoneSelected) + return GetPlugin(id)->GetWriterType(); + else + return 0; + } + +CWriterPluginInterface* CWriterController::GetPlugin(TUid aUid) + { + if( iPluginArray && iPluginArray->Count() > 0 ) + { + for(TInt i=0;iCount();i++) + { + CWriterPluginInterface* plugin = iPluginArray->At(i); + // check if searched uid found + if(plugin->Id().iUid == aUid.iUid) + { + // return pointer to found plugin + return plugin; + } + } + } + // return null plugin + return (CWriterPluginInterface*)0; + } + +TInt CWriterController::StartSelectedPlugin() + { + LOGTEXT(_L("RWriterController::StartSelectedPlugin - entry")); + + CWriterPluginInterface* plugin = GetActiveWriter(); + + if(plugin) + { + return plugin->Start(); + } + + LOGTEXT(_L("RWriterController::StartSelectedPlugin - exit")); + return KErrNotFound; + } + +void CWriterController::StopSelectedPlugin() + { + LOGTEXT(_L("RWriterController::StopSelectedPlugin - entry")); + + CWriterPluginInterface* plugin = GetActiveWriter(); + + if(plugin) + { + plugin->Stop(); + } + LOGTEXT(_L("RWriterController::StopSelectedPlugin - exit")); + } + +/** Set selected plugin active **/ +void CWriterController::SetPluginActive(TUid uid, const TWriterPluginValueKeys aKey) + { + CWriterPluginInterface* plugin = NULL; + _LIT(KDummy, ""); + TBuf<1> buf; + buf.Append(KDummy); + + for(TInt i(0);iCount();i++) + { + plugin = iPluginArray->At(i); + if(plugin->Id().iUid == uid.iUid) + { + plugin->SetValue(aKey, buf); + } + else + { + plugin->SetValue(EWriterPluginDisabled, buf); + } + } + } + +TInt CWriterController::SetPluginSettings(TUid aUid, TDes& aDes) + { + LOGSTRING2(" CWriterController::SetPluginSettings, traceId = 0x%X", aUid.iUid); + GetPlugin(aUid)->SetValue(EWriterPluginSettings, aDes); + return KErrNone; + } + +/** Get settings for a specific plugin **/ +void CWriterController::GetPluginSettings(TUid uid, TDes& aVal) + { + GetPlugin(uid)->GetValue(EWriterPluginSettings, aVal); + } + + +// end of file diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler/engine/src/WriterPluginLoader.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler/engine/src/WriterPluginLoader.cpp Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,597 @@ +/* +* 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: +* +*/ + + +// INCLUDE FILES +#include "WriterPluginLoader.h" +#include +#include // CnvUtfConverter +#include + +// constants +const TInt KWriterCaptionSize = 256; + +// ---------------------------------------------------------------------------- +// CWriterPluginLoader::NewL +// +// EPOC two-phased constructor +// ---------------------------------------------------------------------------- +// +CWriterPluginLoader* CWriterPluginLoader::NewL() + { + CWriterPluginLoader* self = new( ELeave ) CWriterPluginLoader; + CleanupStack::PushL( self ); + self->ConstructL( ); + CleanupStack::Pop( self ); + return self; + } + + +// ---------------------------------------------------------------------------- +// CWriterPluginLoader::CWriterPluginLoader +// +// C++ default constructor can NOT contain any code, that +// might leave. +// ---------------------------------------------------------------------------- +// +CWriterPluginLoader::CWriterPluginLoader() : CActive( EPriorityStandard ) + { + LOGTEXT(_L("CWriterPluginLoader()::CWriterPluginLoader()" )); + } + + +// ---------------------------------------------------------------------------- +// CWriterPluginLoader::ConstructL +// +// EPOC default constructor can leave. +// ---------------------------------------------------------------------------- +// +void CWriterPluginLoader::ConstructL( ) + { + LOGTEXT(_L("CWriterPluginLoader()::ConstructL()" )); + + // get list of implementations + CWriterPluginInterface::ListAllImplementationsL( iImplInfoArray ); + + CActiveScheduler::Add( this ); + } + +// ---------------------------------------------------------------------------- +// CWriterPluginLoader::~CWriterPluginLoader +// +// Destructor +// ---------------------------------------------------------------------------- +// +CWriterPluginLoader::~CWriterPluginLoader() + { + LOGTEXT(_L("CWriterPluginLoader()::~CWriterPluginLoader()") ); + + AbortAsyncLoad(); + + Cancel(); + + // reset ECOM implementation info array + iImplInfoArray.ResetAndDestroy(); // This is needed + iImplInfoArray.Close(); + } + + +// ---------------------------------------------------------------------------- +// CWriterPluginLoader::LoadAsync +// +// +// ---------------------------------------------------------------------------- +// +void CWriterPluginLoader::LoadAsyncL( CArrayPtrFlat* aPluginArray ) + { + iPluginArray = aPluginArray; + + // Reset iterator: + iImplInfoArrayIterator = 0; + + LOGSTRING2( "CWriterPluginLoader()::Implementation info count: %d", + iImplInfoArray.Count() ); + + NotifyProgress(); + + //Begin CActive asynchronous loop. + CompleteOwnRequest(); + } + + +// ---------------------------------------------------------------------------- +// CWriterPluginLoader::LoadSyncL +// +// +// ---------------------------------------------------------------------------- +// +CWriterPluginInterface& CWriterPluginLoader::LoadSyncL( TUid aImplementationUid ) + { + Cancel(); + CWriterPluginInterface* plugin = NULL; + + // Get a list of all implementations, even though we only want one specific + // one. There appears to be no way to otherwise extract a specific implementation + // info object :( + // Search for the implementation that matches aImplementationUid + const TInt impCount = iImplInfoArray.Count(); + for( TInt i=0; iImplementationUid() == aImplementationUid ) + { + TRAPD(ret, plugin = &CreatePluginInstanceL( *info ); ); + if( ret == KErrNone ) + { + // Plugin ownership is transfered to iPluginArray + InsertPluginInOrderL( plugin, iPluginArray ); + } + else + { + // Error note is displayed even if plugin is not loaded + LOGSTRING3("CWriterPluginLoader::LoadSyncL() - plugin %S load failed, error %d", &info->iDisplayName(), ret); + } + break; + } + } + + if ( plugin == NULL ) + { + User::Leave( KErrNotFound ); + } + return *plugin; + } + + +// ---------------------------------------------------------------------------- +// CWriterPluginLoader::AbortAsyncLoad +// +// +// ---------------------------------------------------------------------------- +// +void CWriterPluginLoader::AbortAsyncLoad() + { + LOGTEXT(_L("CWriterPluginLoader()::AbortAsyncLoad()" )); + Cancel(); + } + + +// ---------------------------------------------------------------------------- +// CWriterPluginLoader::RunL +// +// +// ---------------------------------------------------------------------------- +// +void CWriterPluginLoader::RunL() + { + iRunLDebugCount++; + LoadNextPluginL(); + + // Check if there are still more plugins to be loaded: + if ( iImplInfoArrayIterator < iImplInfoArray.Count() ) + { + NotifyProgress(); + // Continue CActive asynchronous loop. + CompleteOwnRequest(); + } + else + { + // All plugins loaded: + LOGTEXT(_L("CWriterPluginLoader()::Loading plugins finished." )); + NotifyFinished(); + } + } + + +// --------------------------------------------------------------------------- +// CScGenreItemConstructionConductor::CompleteOwnRequest +// +// Issue request complete notification. +// --------------------------------------------------------------------------- +void CWriterPluginLoader::CompleteOwnRequest() + { + TRequestStatus* status = &iStatus; + User::RequestComplete( status, KErrNone ); + SetActive(); + } + + +// ---------------------------------------------------------------------------- +// CWriterPluginLoader::RunError +// +// +// ---------------------------------------------------------------------------- +// +TInt CWriterPluginLoader::RunError( TInt aError ) + { + // This method is called when a plugin loading fails. + // Always "fake" the return value so that ActiveSchedule + // keeps running and later plugins are continued to be loaded. + // Check if still plugins to be loaded: + if( iImplInfoArrayIterator < iImplInfoArray.Count() ) + { + NotifyProgress(); + + //Continue CActive asynchronous loop. + CompleteOwnRequest(); + } + else // All plugins loaded: + { + NotifyFinished(); + } + + if ( aError == KLeaveExit ) + { + return KLeaveExit; + } + + return KErrNone; + } + + +// ---------------------------------------------------------------------------- +// CWriterPluginLoader::DoCancel +// +// +// ---------------------------------------------------------------------------- +// +void CWriterPluginLoader::DoCancel() + { + + } + + +// ---------------------------------------------------------------------------- +// CWriterPluginLoader::NotifyProgress +// +// +// ---------------------------------------------------------------------------- +// +void CWriterPluginLoader::NotifyProgress() + { + if( iObserver ) + { + iObserver->HandlePluginLoaded( MWriterPluginLoadObserver::EWriterSuccess); + } + } + + +// ---------------------------------------------------------------------------- +// CWriterPluginLoader::NotifyFinished +// +// +// ---------------------------------------------------------------------------- +// +void CWriterPluginLoader::NotifyFinished() + { + if( iObserver ) + { + iObserver->HandlePluginLoaded( MWriterPluginLoadObserver::EWriterFinished ); + } + } + + +// ---------------------------------------------------------------------------- +// CWriterPluginLoader::SetObserver +// +// +// ---------------------------------------------------------------------------- +// +void CWriterPluginLoader::SetObserver(MWriterPluginLoadObserver* aObserver) + { + LOGSTRING2("CWriterPluginLoader()::Observer set:0x%X", aObserver); + iObserver = aObserver; + } + + +// ---------------------------------------------------------------------------- +// CWriterPluginLoader::ParseToUid +// Parses a UID from descriptor of form '0xNNNNNNNN' where N is hexadecimal. +// +// ---------------------------------------------------------------------------- +// +TInt CWriterPluginLoader::ParseToUid( const TDesC8& aSource, TUid& aTarget ) + { + // Remove "0x" from the descriptor if it exists + _LIT8(KHexPrefix, "0x"); + + TPtrC8 pSource( aSource ); + const TInt prefixPosition = pSource.Find( KHexPrefix ); + if ( prefixPosition != KErrNotFound ) + { + pSource.Set( aSource.Mid( prefixPosition + KHexPrefix().Length() ) ); + } + + // Parse to integer + TLex8 lex( pSource ); + TUint integer = 0; + + // Parse using TRadix::EHex as radix: + const TInt err = lex.Val( integer, EHex ); + aTarget.iUid = integer; + + if( err != KErrNone ) + { + // If parsing parent UID failed, do not load plugin: + LOGSTRING2( + "CWriterPluginLoader()::Parsing parent UID failed. Error code:%d", + err ); + } + return err; + } + + +// ---------------------------------------------------------------------------- +// CWriterPluginLoader::ParseOrderNumber +// +// +// ---------------------------------------------------------------------------- +// +TInt CWriterPluginLoader::ParseOrderNumber( const TDesC8& aSource, TInt& aOrderNumber ) + { + // Parse plugin's order number from opaque_data: + TLex8 lex( aSource ); + const TInt orderErr = lex.Val( aOrderNumber ); + return orderErr; + } + +// ---------------------------------------------------------------------------- +// CWriterPluginLoader::LoadNextPluginL +// Iterate through iImplInfoArray. Load the plugin if it is eligible for +// loading. Loaded plugin is added to iPluginArray. Each time a plugin is +// loaded, iObserver is notified. +// +// ---------------------------------------------------------------------------- +// +void CWriterPluginLoader::LoadNextPluginL() + { + // Iterate through iImplInfoArray. This loop continues between function + // calls. Therefore member variable iImplInfoArrayIterator is used as a + // counter. Loop will break when match is found and continues on next RunL. + for( ; iImplInfoArrayIterator < iImplInfoArray.Count(); ) + { + const CImplementationInformation* info = + iImplInfoArray[ iImplInfoArrayIterator ]; + + iImplInfoArrayIterator++; + + // If this plugin is OK -> load it: + LOGSTRING2( "CWriterPluginLoader() %S eligible for parent", + &info->DisplayName() ); + CWriterPluginInterface* plugin = NULL; + TInt error(KErrNone); + // Create plugin. Trap leave for debugging purposes. + TRAP( error, plugin = &CreatePluginInstanceL( *info ); ); + if( error == KErrNone ) + { + // Plugin ownership is transfered to iPluginArray + InsertPluginInOrderL( plugin, iPluginArray ); + } + else + { + LOGSTRING3("CWriterPluginLoader::LoadNextPluginL() - plugin %S load failed, error %d", &info->iDisplayName(), error); + } + // Wait for next round + break; + } + } + +// ---------------------------------------------------------------------------- +// CWriterPluginLoader::CreatePluginInstanceL +// +// +// ---------------------------------------------------------------------------- +// + +CWriterPluginInterface& CWriterPluginLoader::CreatePluginInstanceL( + const CImplementationInformation& aImpInfo ) + { + // Now we can load the plugin + const TUid implUid = aImpInfo.ImplementationUid(); + + CWriterPluginInterface* plugin = CWriterPluginInterface::NewL( implUid , (TAny*)&aImpInfo.DisplayName() ); + CleanupStack::PushL ( plugin ); + + TInt orderNumber(0); + const TInt orderErr = ParseOrderNumber( aImpInfo.OpaqueData(), orderNumber ); + + if ( orderErr == KErrNone && orderNumber >= 0 ) + { + plugin->iOrder = orderNumber; + } + + CleanupStack::Pop( plugin ); // CWriterController is now responsible for this memory. + + return *plugin; + } + +// ---------------------------------------------------------------------------- +// CWriterPluginLoader::SortPluginsL +// +// ---------------------------------------------------------------------------- +// +void CWriterPluginLoader::SortPluginsL( + CArrayPtrFlat* aPlugins ) + { + RPointerArray plugins; + TLinearOrder order( CWriterPluginLoader::Compare ); + + // Insertion will also order + for( TInt i = 0; i < aPlugins->Count(); i++ ) + { + plugins.InsertInOrderL( (*aPlugins)[i], order ); + } + + // Replace original array content with sorted items + aPlugins->Reset(); + for( TInt i = 0; i < plugins.Count(); i++ ) + { + aPlugins->AppendL( plugins[i] ); + } + } + + +// ---------------------------------------------------------------------------- +// CWriterPluginLoader::Compare +// +// Compare two plugins. +// Precedence: +// [1. plugin provider category] +// 2. plugin order number +// 3. plugin caption +// Plugin provider gategory is currently disabled (not supported yet). +// ---------------------------------------------------------------------------- +// +TInt CWriterPluginLoader::Compare( const CWriterPluginInterface& aFirst, + const CWriterPluginInterface& aSecond ) + { + return CompareIndex( aFirst, aSecond ); + } + + +// ---------------------------------------------------------------------------- +// CWriterPluginLoader::InsertPluginInOrderL +// +// ---------------------------------------------------------------------------- +// +void CWriterPluginLoader::InsertPluginInOrderL( + CWriterPluginInterface* aPlugin, + CArrayPtrFlat* aPlugins ) + { + CWriterPluginInterface* comparedPlugin; + TInt comparison = 0; + TBool inserted = EFalse; + + for( TInt i = 0; i < aPlugins->Count(); i++ ) + { + comparedPlugin = (*aPlugins)[i]; + // Optimization: do not call time consuming Compare() multiple times! + comparison = Compare( *aPlugin, *comparedPlugin ); + if( comparison < 0 ) + { + aPlugins->InsertL( i, aPlugin ); + inserted = ETrue; + break; + } + else if( comparison == 0 ) + { + aPlugins->InsertL( i+1, aPlugin ); + inserted = ETrue; + break; + } + } + // Plugin was not before any other plugin - make sure it's appended + if( !inserted ) + { + aPlugins->AppendL( aPlugin ); + } + + #ifdef _GS_PLUGINLOADER_SORTING_TRACES + PrintOrderTraces( aPlugins ); + #endif // _GS_PLUGINLOADER_SORTING_TRACES + + } + +// ---------------------------------------------------------------------------- +// CWriterPluginLoader::CompareCategory +// +// ---------------------------------------------------------------------------- +// +void CWriterPluginLoader::PrintOrderTraces( + CArrayPtrFlat* aPlugins ) + { + LOGTEXT(_L("---[CWriterPluginLoader] Sorted list---") ); + HBufC* name = HBufC::New( KWriterCaptionSize ); + TRAPD(err, CleanupStack::PushL( name )); + if(err != KErrNone) + { + LOGTEXT(_L("Writer plugin loader unable to sort plugins")); + return; + } + + TPtr ptr = name->Des(); + CWriterPluginInterface* plg; + + for( TInt i = 0; i < aPlugins->Count(); i++ ) + { + plg = (*aPlugins)[i]; + plg->GetCaption( ptr ); + + } + CleanupStack::PopAndDestroy( name ); + + } + + +// ---------------------------------------------------------------------------- +// CWriterPluginLoader::CompareIndex +// +// +// ---------------------------------------------------------------------------- +// + +TInt CWriterPluginLoader::CompareIndex( const CWriterPluginInterface& aFirst, + const CWriterPluginInterface& aSecond ) + { + TInt comparison = KWriterComparisonEqual; + // The plugin having index is before the one not having one + + if( aFirst.iOrder == KWriterPluginNotIndexed && + aSecond.iOrder == KWriterPluginNotIndexed ) + { + // Neither have index -> equal + comparison = KWriterComparisonEqual; + } + else if( aFirst.iOrder == KWriterPluginNotIndexed ) + { + // The plugin having index is before the one not having one + comparison = KWriterComparisonAfter; + } + else if( aSecond.iOrder == KWriterPluginNotIndexed ) + { + // The plugin having index is before the one not having one + comparison = KWriterComparisonBefore; + } + else if( aFirst.iOrder < aSecond.iOrder ) + { + // Compare actual index values + comparison = KWriterComparisonBefore; + } + else if( aFirst.iOrder > aSecond.iOrder ) + { + // Compare actual index values + comparison = KWriterComparisonAfter; + } + return comparison; + } + + +// ---------------------------------------------------------------------------- +// CWriterPluginLoader::GetDocument +// +// +// ---------------------------------------------------------------------------- +// +/* +CWriterBaseDocument* CWriterPluginLoader::GetDocument() + { + CWriterBaseDocument* document = static_cast( iAppUi->Document() ); + return document; + } +*/ + +// End of File diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler/group/bld.inf Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,35 @@ +/* +* 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: +* +*/ + + +#include + +#include "../engine/group/bld.inf" +#include "../plugins/GeneralsPlugin/group/bld.inf" +#include "../plugins/BUPPlugin/group/bld.inf" +#include "../plugins/DebugOutputWriterPlugin/group/bld.inf" +#include "../plugins/DiskWriterPlugin/group/bld.inf" + + +PRJ_EXPORTS +../rom/piprofiler.iby CORE_IBY_EXPORT_PATH(tools,piprofiler.iby) + + +PRJ_MMPFILES +#ifdef MARM + gnumakefile piprofiler_stub_sis.mk +#endif diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler/group/piprofiler_stub_sis.mk --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler/group/piprofiler_stub_sis.mk Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,55 @@ +# +# 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: +# + +TARGETDIR=$(EPOCROOT)EPOC32\Data\Z\System\Install + +SISNAME=PIProfiler_stub +PKGNAME=PIProfiler_stub + +$(TARGETDIR) : + @perl -S emkdir.pl "$(TARGETDIR)" + +do_nothing : + rem do_nothing + +SISFILE=$(TARGETDIR)\$(SISNAME).sis + +$(SISFILE) : ..\sis\$(PKGNAME).pkg + makesis -s $? $@ + + + +MAKMAKE : do_nothing + +RESOURCE : do_nothing + +SAVESPACE : do_nothing + +BLD : do_nothing + +FREEZE : do_nothing + +LIB : do_nothing + +CLEANLIB : do_nothing + +FINAL : $(TARGETDIR) $(SISFILE) + +CLEAN : + @if exist $(SISFILE) erase $(SISFILE) + +RELEASABLES : + @echo $(SISFILE) diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler/plugins/BUPplugin/data/2001E5B6.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler/plugins/BUPplugin/data/2001E5B6.rss Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,51 @@ +/* +* 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: +* +*/ + + +#include + +// Declares info for two implementations +RESOURCE REGISTRY_INFO theInfo + { + // UID for the DLL. See mmp files + //__SERIES60_3X__ can't be used in resource files + dll_uid = 0x2001E5B6; + + // Declare array of interface info. This dll contains implementations for + // only one interface (CSamplerInterfaceDefinition). + interfaces = + { + INTERFACE_INFO + { + // UID of interface that is implemented + interface_uid = 0x2001E5BC; + + implementations = + { + IMPLEMENTATION_INFO + { + implementation_uid = 0x2001E5B6; + + version_no = 1; + display_name = "BUP Sampler"; + default_data = "bup"; + opaque_data = "6"; + } + }; + } + }; + } diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler/plugins/BUPplugin/group/BUPPlugin.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler/plugins/BUPplugin/group/BUPPlugin.mmp Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,50 @@ +/* +* 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: +* +*/ + + +#include + + +TARGET PIProfilerBUP.dll +TARGETTYPE PLUGIN +UID 0x10009D8D 0x2001E5B6 +VENDORID VID_DEFAULT +CAPABILITY ALL -TCB + +OS_LAYER_SYSTEMINCLUDE +USERINCLUDE ../inc +SOURCEPATH ../src + +START RESOURCE ../data/2001E5B6.rss +TARGET PIProfilerBUP.rsc +END + +SOURCE BupPluginImplementationTable.cpp +SOURCE BupPlugin.cpp +SOURCE TouchEventClientDll.cpp + +LIBRARY euser.lib +LIBRARY bafl.lib +LIBRARY ECom.lib +LIBRARY apparc.lib +LIBRARY cone.lib +LIBRARY gdi.lib +LIBRARY ws32.lib +LIBRARY EFSRV.LIB +LIBRARY charconv.lib +LIBRARY commonengine.lib +LIBRARY flogger.lib diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler/plugins/BUPplugin/group/TouchAnimDll.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler/plugins/BUPplugin/group/TouchAnimDll.mmp Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,35 @@ +/* +* 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: +* +*/ + + +#include + + +TARGET PIProfilerTouchEventAnim.DLL +UID 0x10003B22 0x2001E5B7 +TARGETTYPE ANI +EPOCSTACKSIZE 0x5000 +VENDORID VID_DEFAULT +CAPABILITY ALL -TCB // -AllFiles -NetworkControl -DiskAdmin -MultimediaDD -TCB -DRM + +OS_LAYER_SYSTEMINCLUDE +USERINCLUDE ../inc +SOURCEPATH ../src + +SOURCE TouchEventAnimDll.cpp + +LIBRARY euser.lib diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler/plugins/BUPplugin/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler/plugins/BUPplugin/group/bld.inf Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,21 @@ +/* +* 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: +* +*/ + + +PRJ_MMPFILES +TouchAnimDll.mmp +BUPPlugin.mmp diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler/plugins/BUPplugin/inc/BupPlugin.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler/plugins/BUPplugin/inc/BupPlugin.h Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,217 @@ +/* +* 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 PIPROFILER_BUPECOM_SAMPLER_H +#define PIPROFILER_BUPECOM_SAMPLER_H + +#include +#include +#include // RWsSession +#include // RAnim DLL +#include +#include // RProperty + +#include +#include +#include +#include +#include + +#include // for KDC_SHARED_LIB_DIR + +// Button press&touch event Anim DLL interface +#include "TouchEventClientDll.h" + +// caption definitions +_LIT8(KBUPShortName, "bup"); +_LIT8(KBUPLongName, "Button and touch event capture"); +_LIT8(KBUPDescription, "Button and touch event sampler\nTracing button and touch screen events\nHW dep: N/A\nSW dep: S60 3.0\n"); + +const TUid KProfilerKeyEventPropertyCat={0x2001E5AD}; +enum TProfilerKeyEventPropertyKeys + { + EProfilerKeyEventPropertySample = 7 + }; + +const TUid KGppPropertyCat={0x20201F70}; +enum TGppPropertyKeys + { + EGppPropertySyncSampleNumber + }; + + +static _LIT_SECURITY_POLICY_PASS(KAllowAllPolicy); +static _LIT_SECURITY_POLICY_C1(KCapabilityNone, ECapability_None); + +_LIT(KDllName, "PIProfilerTouchEventAnim.DLL"); // animation server dll on user disk + +/* + * + * BUP sampler definition + * + */ +class CProfilerButtonListener; +class CSamplerPluginInterface; + +class CBupPlugin : public CSamplerPluginInterface +{ +public: + static CBupPlugin* NewL(const TUid aImplementationUid, TAny* aInitParams); + ~CBupPlugin(); + + void GetCaption( TDes& aCaption, TInt aType, TInt aSubId ) const; + TInt ResetAndActivateL(CProfilerSampleStream& aStream); + TInt StopSampling(); + TBool Enabled() { return iEnabled; } + + TInt GetSamplerType(); + + TInt CreateFirstSample(); + + // no sub samplers, from CSamplerPluginInterface + TInt SubId(TUid /*aId*/) const {return KErrNotFound;} + TInt GetSubSamplers(TDes* /*aDes*/){return KErrNotFound;} + TInt GetSamplerUidByName(TDesC8& /*name*/){return KSamplerBupPluginUid.iUid;} + TInt GetSubCount(){return KErrNotFound;} + + void GetAttributesL(CArrayFixFlat* aAttributes); + TInt SetAttributesL(TSamplerAttributes aAttributes); + void InitiateSamplerAttributesL(); + + TInt ConvertRawSettingsToAttributes(CDesC8ArrayFlat* aSingleSettingArray); + + TInt DoSetSamplerSettings(CDesC8ArrayFlat* aAllSettings, TDesC8& aSamplerName, TInt aIndex); + void SaveSettingToAttributes(const TDesC8& aSetting, TInt aIndex); + + TUid Id(TInt aSubId) const; + + void FillThisStreamBuffer(TBapBuf* nextFree,TRequestStatus& aStatus); + +private: + CBupPlugin(); + void ConstructL(); + +private: + TUint8 iVersion[20]; + TPtr8 iVersionDescriptor; + + TInt iSamplerType; + + CProfilerButtonListener* iButtonListener; + CArrayFixFlat* iSamplerAttributes; +public: + TUint32* iSampleTime; +}; + + +/* +* +* Base class for all windows +* +*/ +class CWsClient : public CActive + { + protected: + //construct + CWsClient(); + CWsScreenDevice* iScreen; + RWsSession iWs; + public: + void ConstructL(); + // destruct + ~CWsClient(); + // main window + virtual void ConstructMainWindowL(); + // terminate cleanly + void Exit(); + // active object protocol + void IssueRequest(); // request an event + void DoCancel(); // cancel the request + virtual TInt RunError(TInt aError) = 0; + virtual void RunL() = 0; // handle completed request + virtual void HandleKeyEventL (TKeyEvent& aKeyEvent) = 0; + + RWindowGroup Group() {return iGroup;}; + + private: + RWindowGroup iGroup; + CWindowGc* iGc; + friend class CWindow; // needs to get at session + RProperty iProperty; + + }; + + + +class CWindow; + +class CProfilerButtonListener : public CWsClient +{ +public: + static CProfilerButtonListener* NewL(CBupPlugin* aSamplerm); + ~CProfilerButtonListener(); +private: + CProfilerButtonListener(CBupPlugin* aSampler); + + +public: + void ConstructMainWindowL(); + void HandleKeyEventL (TKeyEvent& aKeyEvent); + void RunL(); + TInt RunError(TInt aError); + TInt StartL(); + TInt Stop(); + +private: + TUint8 iSample[8]; + + CBupPlugin* iSampler; + RProfilerTouchEventAnim* iAnim; + RAnimDll* iAnimDll; + CWindow* iMainWindow; // main window + + TInt iSampleStartTime; +}; + + + +/* +* +* CWindow declaration +* +*/ +class CWindow : public CBase + { + protected: + RWindow iWindow; // window server window + TRect iRect; // rectangle re owning window + public: + CWindow(CWsClient* aClient); + void ConstructL (const TRect& aRect, CWindow* aParent=0); + ~CWindow(); + // access + RWindow& Window(); // our own window + CWindowGc* SystemGc(); // system graphics context + + CWsClient* Client() {return iClient;}; + private: + CWsClient* iClient; // client including session and group + }; + + +#endif diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler/plugins/BUPplugin/inc/TouchEventAnimDll.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler/plugins/BUPplugin/inc/TouchEventAnimDll.h Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,83 @@ +/* +* 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_TOUCH_EVENT_ANIM_DLL_ +#define _PROFILER_TOUCH_EVENT_ANIM_DLL_ + +/* +* +* TouchEventAnimDll.h +* +*/ + +// system includes +#include +#include + + + +/* +* +* Class definition of CProfilerTouchEventAnim +* +*/ +class CProfilerTouchEventAnim : public CWindowAnim +{ +public: + CProfilerTouchEventAnim(); + virtual ~CProfilerTouchEventAnim(); + + // from CWindowAnim + void ConstructL(TAny* aAny, TBool aHasFocus); + void Redraw(); + void FocusChanged(TBool aState); + // from MEventHandler + TBool OfferRawEvent(const TRawEvent& aRawEvent); + // from CAnim + void Animate(TDateTime* aDateTime); + void Command(TInt aOpcode, TAny* aArgs); + TInt CommandReplyL(TInt aOpcode, TAny* aArgs); + +private: + TBool HandlePointerDown(TPoint aPoint); + TBool HandlePointerUp(TPoint aPoint); + TBool HandleKeyDown(TInt aScanCode); + TBool HandleKeyUp(TInt aScanCode); +private: + TInt iState; +}; + + +/* +* +* Class definition of CProfilerTouchEventAnimDll +* +*/ + +class CProfilerTouchEventAnimDll : public CAnimDll +{ +public: + CProfilerTouchEventAnimDll(); + +public: + IMPORT_C CAnim* CreateInstanceL(TInt aType); + +}; + + +#endif diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler/plugins/BUPplugin/inc/TouchEventClientDll.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler/plugins/BUPplugin/inc/TouchEventClientDll.h Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,50 @@ +/* +* 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_TOUCH_EVENT_CLIENT_DLL__ +#define _PROFILER_TOUCH_EVENT_CLIENT_DLL__ + +#include + +class CProfilerTouchEventControl; + +class RProfilerTouchEventAnim : public RAnim +{ + public: + RProfilerTouchEventAnim( RAnimDll& aAnimDll ); + void ConstructL( const RWindow& aParent ); + + void Activate(); + void Deactivate(); + + + enum KAnimCommands + { + KActivate = 70002, + KDeactivate = 70003 + }; + /** + * Closes the animation object + */ + void Close(); + + private: + CProfilerTouchEventControl* iTouchEventControl; +}; + +#endif diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler/plugins/BUPplugin/src/BupPlugin.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler/plugins/BUPplugin/src/BupPlugin.cpp Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,592 @@ +/* +* 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: +* +*/ + + +#include "BupPlugin.h" +#include + +#include // key eventtien kuunteluun +#include // for CApaWindowGroupName + +// LITERALS +_LIT8(KEnabled, "enabled"); +_LIT8(KBracketOpen, "["); +_LIT8(KBracketClose, "]"); +_LIT8(KSettingItemSeparator, "="); + +/* + * + * class CBupPlugin implementation + * + */ + +CBupPlugin* CBupPlugin::NewL(const TUid /*aImplementationUid*/, TAny* /*aInitParams*/) + { + LOGTEXT(_L("CBupPlugin::NewL() - entry")); + CBupPlugin* self = new (ELeave) CBupPlugin(); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(); + LOGTEXT(_L("CBupPlugin::NewL() - exit")); + return self; + } + +CBupPlugin::CBupPlugin() : + iVersionDescriptor(&(this->iVersion[1]),0,19), + iSamplerType(PROFILER_USER_MODE_SAMPLER) + { + iSamplerId = PROFILER_BUP_SAMPLER_ID; + iEnabled = EFalse; + LOGTEXT(_L("CBupPlugin::CBupPlugin() - konstruktori")); + } + +void CBupPlugin::ConstructL() + { + LOGTEXT(_L("CBupPlugin::ConstructL() - entry")); + + // initiate sampler attributes array + iSamplerAttributes = new(ELeave) CArrayFixFlat(1); // only one sampler + + // insert default attributes to array + InitiateSamplerAttributesL(); + + LOGTEXT(_L("CBupPlugin::ConstructL() - exit")); + } + + +CBupPlugin::~CBupPlugin() + { + LOGTEXT(_L("CBupPlugin::~CBupPlugin() - entry")); + if(iButtonListener) + { + // check if button listener still running + if(Enabled()) + { + // stop profiling + iButtonListener->Stop(); + } + delete iButtonListener; + } + + if(iSamplerAttributes) + { + iSamplerAttributes->Reset(); + } + delete iSamplerAttributes; + + LOGTEXT(_L("CBupPlugin::~CBupPlugin() - exit")); + } + +TUid CBupPlugin::Id(TInt /*aUid*/) const + { + LOGSTRING2("CBupPlugin::Id():0x%X", KSamplerBupPluginUid.iUid ); + return KSamplerBupPluginUid; + } + +void CBupPlugin::InitiateSamplerAttributesL() + { + // create sampler attribute container + TSamplerAttributes attr(KSamplerBupPluginUid.iUid, + KBUPShortName(), + KBUPLongName(), + KBUPDescription(), + -1, + ETrue, + EFalse, + 0); // default item count + this->iSamplerAttributes->AppendL(attr); + } + +// returns setting array +void CBupPlugin::GetAttributesL(CArrayFixFlat* aAttributes) + { + // append my own attributes to complete array, requested by profiler engine + aAttributes->AppendL(iSamplerAttributes->At(0)); + } + +TInt CBupPlugin::SetAttributesL(TSamplerAttributes aAttributes) + { + TSamplerAttributes attr; + + attr = iSamplerAttributes->At(0); + // if UIDs match replace the old + if(attr.iUid == aAttributes.iUid) + { + // replace the old attribute container + iSamplerAttributes->Delete(0); + iSamplerAttributes->InsertL(0, aAttributes); + return KErrNone; + } + return KErrNotFound; + } + +/* + * Method for parsing and transforming text array settings into TSamplerAttributes (per each sub sampler), + * called by CSamplerController class + * + * @param array of raw text setting lines, e.g. [gpp]\nenabled=true\nsampling_period_ms=1\n + */ +//void CGeneralsPlugin::ParseSettingsText(CDesC8ArrayFlat* aRawSettings) +TInt CBupPlugin::ConvertRawSettingsToAttributes(CDesC8ArrayFlat* aAllSettingsArray) + { + // local literals + _LIT8(KBUPShort, "bup"); + + TInt err(KErrNone); + TBuf8<16> samplerSearchName; + samplerSearchName.Copy(KBUPShort); + + // get sampler specific settings + err = DoSetSamplerSettings(aAllSettingsArray, samplerSearchName, 0); + + // returns KErrNone if settings found, otherwise KErrNotFound + return err; + } + +TInt CBupPlugin::DoSetSamplerSettings(CDesC8ArrayFlat* aAllSettings, TDesC8& aSamplerName, TInt aIndex) + { + // + TBuf8<16> samplerSearch; + samplerSearch.Copy(KBracketOpen); + samplerSearch.Append(aSamplerName); + samplerSearch.Append(KBracketClose); + + // read a line + for (TInt i(0); iMdcaCount(); i++) + { + // check if this line has a setting block start, i.e. contains [xxx] in it + if (aAllSettings->MdcaPoint(i).CompareF(samplerSearch) == 0) + { + // right settings block found, now loop until the next block is found + for(TInt j(i+1);jMdcaCount();j++) + { + // check if the next settings block was found + if(aAllSettings->MdcaPoint(j).Left(1).CompareF(KBracketOpen) != 0) + { + // save found setting value directly to its owners attributes + SaveSettingToAttributes(aAllSettings->MdcaPoint(j), aIndex); + } + else + { + // next block found, return KErrNone + return KErrNone; + } + } + } + } + + return KErrNotFound; + } + +/** + * Method for setting a specific descriptor (from settings file) to attribute structure + * + * @param aSetting + * @param aName + */ +void CBupPlugin::SaveSettingToAttributes(const TDesC8& aSetting, TInt aIndex) + { + // find the equal mark from the setting line + TInt sepPos = aSetting.Find(KSettingItemSeparator); + // check that '=' is found + if (sepPos > 0) + { + // check that the element matches + if (aSetting.Left(sepPos).CompareF(KEnabled) == 0) + { + TBool en; + CSamplerPluginInterface::Str2Bool(aSetting.Right(aSetting.Length()-sepPos-1), en); + if(iSamplerAttributes->At(aIndex).iEnabled != en) + { + iSamplerAttributes->At(aIndex).iEnabled = en; + } + } + } + } + +TInt CBupPlugin::GetSamplerType() + { + return iSamplerType; + } + +void CBupPlugin::GetCaption( TDes& aCaption, TInt /*aType*/, TInt /*aUid*/ ) const + { + aCaption.Copy(KBUPShortName); + aCaption.TrimRight(); + LOGSTRING2("CBupPlugin::GetCaptionL() - Plugin name: %S", &aCaption); + } + +TInt CBupPlugin::ResetAndActivateL(CProfilerSampleStream& aStream) + { + LOGTEXT(_L("CBupPlugin::ResetAndActivate() - entry")); + TInt ret(KErrNone); + + // check if sampler enabled + if(iSamplerAttributes->At(0).iEnabled) + { + // create first the listener instance + iButtonListener = CProfilerButtonListener::NewL(this); + + LOGTEXT(_L("CBupPlugin::ResetAndActivate() - listener created")); + + iStream = &aStream; + TInt length = this->CreateFirstSample(); + iVersion[0] = (TUint8)length; + LOGSTRING2("CBupPlugin::ResetAndActivate() - AddSample, length %d",length); + ret = AddSample(iVersion, length+1, 0); + if(ret != KErrNone) + return ret; + + // activate button listener + ret = iButtonListener->StartL(); + + iEnabled = ETrue; + + LOGTEXT(_L("CBupPlugin::ResetAndActivate() - exit")); + } + return ret; + + } + +TInt CBupPlugin::CreateFirstSample() + { + LOGTEXT(_L("CBupPlugin::CreateFirstSample - entry")); + this->iVersionDescriptor.Zero(); + this->iVersionDescriptor.Append(_L8("Bappea_BUP_V")); + this->iVersionDescriptor.Append(PROFILER_BUP_SAMPLER_VERSION); + LOGTEXT(_L("CBupPlugin::CreateFirstSample - exit")); + return (TInt)(this->iVersionDescriptor.Length()); + } + +TInt CBupPlugin::StopSampling() + { + if(iButtonListener) + { + iButtonListener->Stop(); + delete iButtonListener; // delete listener after every trace + iButtonListener = NULL; + } + + // set disabled + iEnabled = EFalse; + + return KErrNone; + } + +void CBupPlugin::FillThisStreamBuffer(TBapBuf* /*aBapBuf*/, TRequestStatus& /*aStatus*/) + { + } + +/* + * + * Implementation of class CProfilerButtonListener + * + */ +CProfilerButtonListener::CProfilerButtonListener(CBupPlugin* aSampler) + { + LOGTEXT(_L("CProfilerButtonListener::CProfilerButtonListener() - konstuktori")); + this->iSampler = aSampler; + iSampleStartTime = 0; + LOGTEXT(_L("CProfilerButtonListener::CProfilerButtonListener() - konstuktori exit")); + } + +CProfilerButtonListener* CProfilerButtonListener::NewL(CBupPlugin* aSampler) + { + LOGTEXT(_L("CProfilerButtonListener::NewL() - entry")); + CProfilerButtonListener* self = new (ELeave) CProfilerButtonListener(aSampler); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(); + LOGTEXT(_L("CProfilerButtonListener::NewL() - exit")); + return self; + } + +CProfilerButtonListener::~CProfilerButtonListener() + { + LOGTEXT(_L("CProfilerButtonListener::~CProfilerButtonListener() - entry af")); + + if(iMainWindow) + { + LOGTEXT(_L("CProfilerButtonListener::~CProfilerButtonListener(): flushing iWs")); + iWs.Flush(); + LOGTEXT(_L("CProfilerButtonListener::~CProfilerButtonListener(): finishing")); + } + delete iMainWindow; + LOGTEXT(_L("CProfilerButtonListener::~CProfilerButtonListener() - exit")); + } + +void CProfilerButtonListener::ConstructMainWindowL() + { + LOGTEXT(_L("CProfilerButtonListener::ConstructMainWindowL() - Entry")); + + CWindow* window = new (ELeave) CWindow(this); + CleanupStack::PushL( window ); + window->ConstructL(TRect(TPoint(0,0), TSize(0,0))); + delete iMainWindow; + iMainWindow = window; + CleanupStack::Pop( window ); + + LOGTEXT(_L("CProfilerButtonListener::ConstructMainWindowL() - Exit")); + } + +void CProfilerButtonListener::HandleKeyEventL (TKeyEvent& /*aKeyEvent*/) + { + LOGTEXT(_L("CProfilerButtonListener::HandleKeyEventL() - Start")); + LOGTEXT(_L("CProfilerButtonListener::HandleKeyEventL() - End")); + } + + +TInt CProfilerButtonListener::RunError(TInt aError) + { + // get rid of everything we allocated + // deactivate the anim dll before killing window, otherwise anim dll dies too early + iAnim->Deactivate(); + iAnim->Close(); + + iAnimDll->Close(); + + return aError; + } + +void CProfilerButtonListener::RunL() + { + // resubscribe before processing new value to prevent missing updates + IssueRequest(); + + TInt c = 0; + if(RProperty::Get(KProfilerKeyEventPropertyCat, EProfilerKeyEventPropertySample, c) == KErrNone) + { + // do something with event + LOGSTRING2("CProfilerButtonListener::RunL() - event [%d] received",c); + + iSample[0] = c; + iSample[1] = c >> 8; + iSample[2] = c >> 16; + iSample[3] = c >> 24; + + // Space for GPP sample time + TUint32 sampleTime = User::NTickCount() - iSampleStartTime; + LOGSTRING2("CProfilerButtonListener::RunL() - sample time is %d",sampleTime); + + iSample[4] = sampleTime; + iSample[5] = sampleTime >> 8; + iSample[6] = sampleTime >> 16; + iSample[7] = sampleTime >> 24; + + iSampler->AddSample(iSample, 8, 0xb0); + } + } + +TInt CProfilerButtonListener::StartL() + { + LOGTEXT(_L("CProfilerButtonListener::StartL() - Activate touch server dll")); + TInt err(KErrNone); + + // get the property value + TInt r = RProperty::Get(KGppPropertyCat, EGppPropertySyncSampleNumber, iSampleStartTime); + if(r != KErrNone) + { + LOGSTRING2("CProfilerButtonListener::StartL() - getting iSyncOffset failed, error %d", r); + } + + iAnimDll = new (ELeave) RAnimDll(iWs); + LOGTEXT(_L("CProfilerButtonListener::StartL() - #1")); + + TParse* fp = new (ELeave) TParse(); + CleanupStack::PushL(fp); + fp->Set( KDllName, &KDC_SHARED_LIB_DIR , NULL ); + LOGSTRING2("CProfilerButtonListener::StartL() - touch event server: %S" , &(fp->FullName())); + + err = iAnimDll->Load(fp->FullName()); + // check if anim dll load failed + if(err != KErrNone) + { + CleanupStack::PopAndDestroy(fp); + // stop plugin if failed + iAnimDll->Close(); + return KErrGeneral; + } + CleanupStack::PopAndDestroy(fp); + LOGTEXT(_L("CProfilerButtonListener::StartL() - #2")); + + iAnim = new (ELeave) RProfilerTouchEventAnim(*iAnimDll); + LOGTEXT(_L("CProfilerButtonListener::StartL() - #3")); + iAnim->ConstructL(iMainWindow->Window()); + + // activate the animation dll for collecting touch and key events + iAnim->Activate(); + + // wait for a new sample + IssueRequest(); + + // hide this window group from the app switcher + iMainWindow->Client()->Group().SetOrdinalPosition(-1); + iMainWindow->Client()->Group().EnableReceiptOfFocus(EFalse); + return KErrNone; + } + +TInt CProfilerButtonListener::Stop() + { + LOGTEXT(_L("CProfilerButtonListener::Stop() - enter")); + // deactivate the anim dll before killing window, otherwise anim dll dies too early + iAnim->Deactivate(); + iAnim->Close(); + + iAnimDll->Close(); + + Cancel(); + LOGTEXT(_L("CProfilerButtonListener::Stop() - exit")); + return KErrNone; + } + + +/////////////////////////////////////////////////////////////////////////////// +////////////////////////// CWindow implementation ///////////////////////////// +/////////////////////////////////////////////////////////////////////////////// + +CWindow::CWindow(CWsClient* aClient) +: iClient(aClient) + { + LOGTEXT(_L("CWindow::CWindow()")); + } + +void CWindow::ConstructL (const TRect& aRect, CWindow* aParent) + { + LOGTEXT(_L("CWindow::ConstructL(): Start")); + + // If a parent window was specified, use it; if not, use the window group + // (aParent defaults to 0). + RWindowTreeNode* parent= aParent ? (RWindowTreeNode*) &(aParent->Window()) : &(iClient->iGroup); + iWindow=RWindow(iClient->iWs); // use app's session to window server + User::LeaveIfError(iWindow.Construct(*parent,(TUint32)this)); + LOGSTRING2("CWindow::ConstructL(): Start - window handle is: 0x%08x", this); + iRect = aRect; + iWindow.SetExtent(iRect.iTl, iRect.Size()); // set extent relative to group coords + iWindow.Activate(); // window is now active + LOGTEXT(_L("CWindow::ConstructL(): End")); + } + + +CWindow::~CWindow() + { + LOGTEXT(_L("CWindow::~CWindow(): Start")); + iWindow.Close(); // close our window + LOGTEXT(_L("CWindow::~CWindow(): End")); + } + +RWindow& CWindow::Window() + { + LOGTEXT(_L("CWindow::Window()")); + return iWindow; + } + +CWindowGc* CWindow::SystemGc() + { + LOGTEXT(_L("CWindow::SystemGc()")); + return iClient->iGc; + } + +///////////////////////////////////////////////////////////////////////////////////// +/////////////////////////// CWsClient implementation //////////////////////////////// +///////////////////////////////////////////////////////////////////////////////////// +CWsClient::CWsClient() +: CActive(CActive::EPriorityStandard) + { + LOGTEXT(_L("CWsClient::CWsClient()")); + } + +void CWsClient::ConstructL() + { + LOGTEXT(_L("CWsClient::ConstructL() - Start")); + TInt r = RProperty::Define(EProfilerKeyEventPropertySample, RProperty::EInt, KAllowAllPolicy, KCapabilityNone); + if (r!=KErrAlreadyExists) + { + User::LeaveIfError(r); + } + + CActiveScheduler::Add(this); + + // attach to + User::LeaveIfError(iProperty.Attach(KProfilerKeyEventPropertyCat,EProfilerKeyEventPropertySample)); + + // get a session going + User::LeaveIfError(iWs.Connect()); + + // construct screen device and graphics context + iScreen=new (ELeave) CWsScreenDevice(iWs); // make device for this session + User::LeaveIfError(iScreen->Construct( 0 )); // and complete its construction + User::LeaveIfError(iScreen->CreateContext(iGc)); // create graphics context + + // construct our one and only window group + iGroup=RWindowGroup(iWs); + User::LeaveIfError(iGroup.Construct((TInt)this, EFalse)); // meaningless handle; enable focus + + // construct main window + ConstructMainWindowL(); + + LOGTEXT(_L("CWsClient::CWsClient() - End")); + } + +CWsClient::~CWsClient() + { + LOGTEXT(_L("CWsClient::~CWsClient() - Start")); + + // get rid of everything we allocated + delete iGc; + delete iScreen; + + iGroup.Close(); + // finish with window server + iWs.Close(); + + LOGTEXT(_L("CWsClient::~CWsClient() - Exit")); + } + +void CWsClient::Exit() + { + LOGTEXT(_L("CWsClient::Exit() - Start")); + + // destroy window group + iGroup.Close(); + // finish with window server + iProperty.Close(); + iWs.Close(); + LOGTEXT(_L("CWsClient::Exit() - Exit")); + } + +void CWsClient::IssueRequest() + { + LOGTEXT(_L("CWsClient::IssueRequest() - Start")); + iProperty.Subscribe( iStatus ); + SetActive(); // so we're now active + LOGTEXT(_L("CWsClient::IssueRequest() - Exit")); + } + +void CWsClient::DoCancel() + { + LOGTEXT(_L("CWsClient::DoCancel() - Start")); + // clean up the sample property + iProperty.Cancel(); + iProperty.Close(); + LOGTEXT(_L("CWsClient::DoCancel() - Exit")); + } + +void CWsClient::ConstructMainWindowL() + { + LOGTEXT(_L("CWsClient::ConstructMainWindowL()")); + } + diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler/plugins/BUPplugin/src/BupPluginImplementationTable.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler/plugins/BUPplugin/src/BupPluginImplementationTable.cpp Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,39 @@ +/* +* 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: +* +*/ + + +// INCLUDE FILES +#include +#include + +#include "BupPlugin.h" + + +// Provides a key value pair table, this is used to identify +// the correct construction function for the requested interface. +const TImplementationProxy ImplementationTable[] = +{ + IMPLEMENTATION_PROXY_ENTRY(0x2001E5B6, CBupPlugin::NewL) +}; + +// Function used to return an instance of the proxy table. +EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) +{ + aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); + return ImplementationTable; +} + diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler/plugins/BUPplugin/src/TouchEventAnimDll.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler/plugins/BUPplugin/src/TouchEventAnimDll.cpp Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,205 @@ +/* +* 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: +* +*/ + + + +#include +#include +#include +#include +#include +#include +#include + +// user includes +#include "TouchEventAnimDll.h" + +// control commands +static const TInt KActivate = 70002; +static const TInt KDeactivate = 70003; + +// touch events +static const TInt KTouchEventDown = 69999; +static const TInt KTouchEventUp = 70000; + +static const TInt KUpEventOffset = 70000; + +_LIT( KTouchEventServer, "PIProfilerTouchEvent server" ); +enum TAnimationPanics + { + EProfilerTouchEventServerPanic = 100 + }; + +const TUid KProfilerKeyEventPropertyCat={0x2001E5AD}; +enum TProfilerKeyEventPropertyKeys + { + EProfilerKeyEventPropertySample = 7 + }; + +/* +* +* Implementation of CProfilerTouchEventAnim +* +*/ +CProfilerTouchEventAnim::CProfilerTouchEventAnim() : iState(EFalse) + { + LOGTEXT(_L("CProfilerTouchEventAnim::CProfilerTouchEventAnim - entry")); + } + +CProfilerTouchEventAnim::~CProfilerTouchEventAnim() + { + LOGTEXT(_L("CProfilerTouchEventAnim::~CProfilerTouchEventAnim - entry")); + //iFunctions->GetRawEvents( EFalse ); // disable capture + LOGTEXT(_L("CProfilerTouchEventAnim::~CProfilerTouchEventAnim - exit")); + } + +void CProfilerTouchEventAnim::ConstructL(TAny* /*aArgs*/, TBool /*aHasFocus*/) + { + LOGTEXT(_L("CProfilerTouchEventAnim::ConstructL - entry")); + iFunctions->GetRawEvents( ETrue ); + LOGTEXT(_L("CProfilerTouchEventAnim::ConstructL - exit")); + } + +void CProfilerTouchEventAnim::Command(TInt /*aOpcode*/, TAny* /*aArgs*/) + { + + } + +TInt CProfilerTouchEventAnim::CommandReplyL(TInt aOpcode, TAny* /*aArgs*/) + { + LOGSTRING2("CProfilerTouchEventAnim::CommandReplyL - entry, aOpcode: %d", aOpcode); + switch(aOpcode) + { + case KActivate: // activate + iState = ETrue; + LOGTEXT(_L("CProfilerTouchEventAnim::CommandReplyL - activate")); + break; + case KDeactivate: // deactivate + iState = EFalse; + iFunctions->GetRawEvents( EFalse ); // disable capture + LOGTEXT(_L("CProfilerTouchEventAnim::CommandReplyL - deactivate")); + break; + default: + User::Panic( KTouchEventServer, EProfilerTouchEventServerPanic ); + LOGSTRING2("CProfilerTouchEventAnim::CommandReplyL - panic, code %d", EProfilerTouchEventServerPanic); + return EProfilerTouchEventServerPanic; + + } + return KErrNone; + } + + +TBool CProfilerTouchEventAnim::OfferRawEvent(const TRawEvent& aRawEvent) + { + LOGTEXT(_L("CProfilerTouchEventAnim::OfferRawEvent - entry")); + if(iState == EFalse) + return EFalse; // if not activated yet just pass through + + + switch(aRawEvent.Type()) + { + // handle the pointer events here + case TRawEvent::EButton1Down: + { + LOGTEXT(_L("CProfilerTouchEventAnim::OfferRawEvent - pointer down")); + return HandlePointerDown(aRawEvent.Pos()); + } + case TRawEvent::EButton1Up: + { + LOGTEXT(_L("CProfilerTouchEventAnim::OfferRawEvent - pointer up")); + return HandlePointerUp(aRawEvent.Pos()); + } + + // handle the key events here, replacing the BUP trace functionality + case TRawEvent::EKeyDown: + { + TInt scan = aRawEvent.ScanCode() & 0xFFFF; + return HandleKeyDown(scan); + } + case TRawEvent::EKeyUp: + { + TInt scan = (aRawEvent.ScanCode() & 0xFFFF)+KUpEventOffset; // + return HandleKeyUp(scan); + } + default: + return EFalse; // no action + } + } + +TBool CProfilerTouchEventAnim::HandlePointerDown( TPoint /*aPoint*/ ) + { + RProperty::Set(KProfilerKeyEventPropertyCat,EProfilerKeyEventPropertySample, KTouchEventDown); + return EFalse; + } + +TBool CProfilerTouchEventAnim::HandlePointerUp( TPoint /*aPoint*/ ) + { + RProperty::Set(KProfilerKeyEventPropertyCat,EProfilerKeyEventPropertySample, KTouchEventUp); + return EFalse; + } + +TBool CProfilerTouchEventAnim::HandleKeyDown( TInt aScanCode ) + { + LOGSTRING2("CProfilerTouchEventAnim::HandleKeyDown - scancode = %d", aScanCode); + RProperty::Set(KProfilerKeyEventPropertyCat,EProfilerKeyEventPropertySample, aScanCode); + return EFalse; + } + +TBool CProfilerTouchEventAnim::HandleKeyUp( TInt aScanCode ) + { + LOGSTRING2("CProfilerTouchEventAnim::HandleKeyUp - scancode = %d", aScanCode); + RProperty::Set(KProfilerKeyEventPropertyCat,EProfilerKeyEventPropertySample, aScanCode); + return EFalse; + } + + +void CProfilerTouchEventAnim::Animate(TDateTime* /*aDateTime*/) + { + } + +void CProfilerTouchEventAnim::Redraw() + { + } + +void CProfilerTouchEventAnim::FocusChanged(TBool /*aState*/) + { + } + + +/* +* +* Implementation of CProfilerTouchEventAnimDll +* +*/ +CProfilerTouchEventAnimDll::CProfilerTouchEventAnimDll() : CAnimDll() + { + } + +CAnim* CProfilerTouchEventAnimDll::CreateInstanceL(TInt /*aType*/) + { + LOGTEXT(_L("CProfilerTouchEventAnimDll::CreateInstanceL - entry")); + return (new (ELeave) CProfilerTouchEventAnim()); + } + + +// DLL entry +EXPORT_C CAnimDll* CreateCAnimDllL() + { + return (new (ELeave) CProfilerTouchEventAnimDll); + } + + diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler/plugins/BUPplugin/src/TouchEventClientDll.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler/plugins/BUPplugin/src/TouchEventClientDll.cpp Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,60 @@ +/* +* 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: +* +*/ + + +#include "TouchEventClientDll.h" +#include + +/* + * + * class RProfilerTouchEventAnim implementation + * + */ +void RProfilerTouchEventAnim::ConstructL( const RWindow& aParent) +{ + LOGTEXT(_L("RProfilerTouchEventAnim::ConstructL - entry")); + LOGTEXT(_L("RProfilerTouchEventAnim::ConstructL - calling RAnim::Construct...")); + RAnim::Construct(aParent, 0, TPtrC8()); +} + + +RProfilerTouchEventAnim::RProfilerTouchEventAnim( RAnimDll &aAnimDll ) : + RAnim( aAnimDll ) +{ +} + +void RProfilerTouchEventAnim::Activate() +{ + LOGTEXT(_L("RProfilerTouchEventAnim::Activate - entry")); + TInt err = RAnim::CommandReply(KActivate); + LOGSTRING2("RProfilerTouchEventAnim::Activate - error: %d", err); +} + +void RProfilerTouchEventAnim::Deactivate() +{ + LOGTEXT(_L("RProfilerTouchEventAnim::Deactivate - entry")); + TInt err = RAnim::CommandReply(KDeactivate); + LOGSTRING2("RProfilerTouchEventAnim::Deactivate - error: %d", err); +} + +void RProfilerTouchEventAnim::Close() + { + RAnim::Close(); + } + + + diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler/plugins/DebugOutputWriterPlugin/data/2001E5BA.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler/plugins/DebugOutputWriterPlugin/data/2001E5BA.rss Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,51 @@ +/* +* 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: +* +*/ + + +#include + +// Declares info for two implementations +RESOURCE REGISTRY_INFO theInfo + { + // UID for the DLL. See mmp files + //__SERIES60_3X__ can't be used in resource files + dll_uid = 0x2001E5BA; + + // Declare array of interface info. This dll contains implementations for + // only one interface (CSamplerInterfaceDefinition). + interfaces = + { + INTERFACE_INFO + { + // UID of interface that is implemented + interface_uid = 0x2001E5BD; + + implementations = + { + IMPLEMENTATION_INFO + { + implementation_uid = 0x2001E5BA; + + version_no = 1; + display_name = "Debug output writer implementation"; + default_data = "dow"; + opaque_data = "1"; + } + }; + } + }; + } diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler/plugins/DebugOutputWriterPlugin/group/DebOutWriterPlugin.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler/plugins/DebugOutputWriterPlugin/group/DebOutWriterPlugin.mmp Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,48 @@ +/* +* 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: +* +*/ + + +#include + + +TARGET PIProfilerDebugWriter.dll +TARGETTYPE PLUGIN +UID 0x10009D8D 0x2001E5BA +#ifdef WINSCW +VENDORID 0 +#else +VENDORID VID_DEFAULT +#endif +CAPABILITY ALL -TCB // AllFiles ReadDeviceData ReadUserData UserEnvironment WriteDeviceData WriteUserData + + +OS_LAYER_SYSTEMINCLUDE +USERINCLUDE ../inc ../traces +SOURCEPATH ../src + +START RESOURCE ../data/2001E5BA.rss +TARGET piprofilerdebugwriter.rsc +END + +SOURCE DebOutWriterPlugin.cpp +SOURCE DebOutWriterPluginImplementationTable.cpp + +LIBRARY euser.lib +LIBRARY ECom.lib +LIBRARY EFSRV.LIB +LIBRARY commonengine.lib +LIBRARY flogger.lib diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler/plugins/DebugOutputWriterPlugin/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler/plugins/DebugOutputWriterPlugin/group/bld.inf Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,20 @@ +/* +* 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: +* +*/ + + +PRJ_MMPFILES +DebOutWriterPlugin.mmp diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler/plugins/DebugOutputWriterPlugin/inc/DebOutWriterPlugin.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler/plugins/DebugOutputWriterPlugin/inc/DebOutWriterPlugin.h Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,130 @@ +/* +* 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: +* +*/ + + +// This file defines the API for DebOutWriterPlugin.dll + +#ifndef __DEBOUTWRITERPLUGIN_H__ +#define __DEBOUTWRITERPLUGIN_H__ + +// Include Files +#include +#include + +#include +#include +#include // CBase +#include // TBuf +#include + +_LIT(KDebOutShortName, "dow"); + +// forward declarations +class CDebOutWriterHandler; + +// Class Definitions + +class CDebOutWriterPlugin : public CWriterPluginInterface + { +public: + // new function + static CDebOutWriterPlugin* NewL(const TUid aImplementationUid, TAny* /*aInitParams*/); + ~CDebOutWriterPlugin(); + + void DoCancel(); + static void PrintDescriptorAsBase64(TDesC8& aDes, TRequestStatus* aStatus, TUint32 sampleTime, TBool aEmptying); + +public: // new functions + + TInt Start(); + + void Stop(); + + void GetCaption( TDes& aCaption ) const; + + void GetValue( const TWriterPluginValueKeys aKey, TDes& aValue ); + + void SetValue( const TWriterPluginValueKeys aKey, TDes& aValue ); + + TUid Id() const; + + void GetWriterVersion(TDes* aDes); + + TUint32 GetWriterType(); + + void SetStream(CProfilerSampleStream& aStream) { iStream = &aStream; } + + void HandleError(TInt aError); + + void WriteData(); +private: // new functions + CDebOutWriterPlugin(const TUid aImplementationUid); + void ConstructL(); + + void GetValueL( const TWriterPluginValueKeys aKey, TDes& aValue ); + void SetValueL( const TWriterPluginValueKeys aKey, TDes& aValue ); + TBool GetEnabled(); +public: + CProfilerSampleStream* iStream; +private: // data + TBapBuf* iBufferBeingWritten; + + TInt iWriterType; + TInt iWriterId; + CDebOutWriterHandler* iWriterHandler; + RProperty iErrorStatus; + }; + +/* + * + * Definition of class CDebOutWriterHandler + * + */ +class CDebOutWriterHandler : public CActive + { +public: + + + static CDebOutWriterHandler* NewL(CDebOutWriterPlugin* aWriter); + ~CDebOutWriterHandler(); + void DoCancel(); + void StartL(); + + void Stop(); + + void Reset(); +private: + CDebOutWriterHandler(CDebOutWriterPlugin* aWriter); + + void ConstructL(); + void RunL(); + + void WriteBufferToOutput(TBapBuf* aBuf); + void PrintBufferToOutput(TBapBuf* aBuffer, TRequestStatus& aStatus); + void HandleFullBuffers(); +private: + CDebOutWriterPlugin* iWriter; + RFile iFile; + RFs iFs; + TBuf<256> iFileName; +// CPeriodic* iTimer; + TBapBuf* iBufferBeingWritten; + TBool iStopping; + }; + +#endif // __DEBOUTWRITERPLUGIN_H__ + diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler/plugins/DebugOutputWriterPlugin/src/DebOutWriterPlugin.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler/plugins/DebugOutputWriterPlugin/src/DebOutWriterPlugin.cpp Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,508 @@ +/* +* 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: +* +*/ + + +// Include Files + +#include "DebOutWriterPlugin.h" +#include +#include +#include +#ifdef OST_TRACE_COMPILER_IN_USE +#include +#include "DebOutWriterPluginTraces.h" +#endif + +// engine properties +const TUid KEngineStatusPropertyCat={0x2001E5AD}; +enum TEnginePropertyKeys + { + EProfilerEngineStatus = 8, + EProfilerErrorStatus + }; +// Member Functions +/* + * + * Class CDebOutWriterPlugin implementation + * + */ + +CDebOutWriterPlugin* CDebOutWriterPlugin::NewL(const TUid /*aImplementationUid*/, TAny* /*aInitParams*/) +{ + LOGTEXT(_L("CDebOutWriterPlugin::NewL() - entry")); + CDebOutWriterPlugin* self = new (ELeave) CDebOutWriterPlugin(KDebOutWriterPluginUid); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(); + LOGTEXT(_L("CDebOutWriterPlugin::NewL() - exit")); + return self; +} + +CDebOutWriterPlugin::CDebOutWriterPlugin(const TUid aImplementationUid) : + iWriterType(aImplementationUid.iUid) + { + LOGTEXT(_L("CDebOutWriterPlugin::CDebOutWriterPlugin - entry")); + isEnabled = EFalse; + iWriterId = Id().iUid; + LOGTEXT(_L("CDebOutWriterPlugin::CDebOutWriterPlugin - exit")); + } + +CDebOutWriterPlugin::~CDebOutWriterPlugin() + { + LOGTEXT(_L("CDebOutWriterPlugin::~CDebOutWriterPlugin - entry")); + + iErrorStatus.Close(); + + if(iWriterHandler) + { + iWriterHandler->Cancel(); + delete iWriterHandler; + } + LOGTEXT(_L("CDebOutWriterPlugin::~CDebOutWriterPlugin - exit")); + } + +void CDebOutWriterPlugin::ConstructL() + { + // second phase constructor, anything that may leave must be constructed here + + LOGTEXT(_L("CDebOutWriterPlugin::ConstructL() - entry")); + iWriterHandler = CDebOutWriterHandler::NewL(this); + User::LeaveIfError(iErrorStatus.Attach(KEngineStatusPropertyCat, EProfilerErrorStatus)); + LOGTEXT(_L("CDebOutWriterPlugin::ConstructL() - exit")); + } + +TInt CDebOutWriterPlugin::Start() + { + LOGTEXT(_L("CDebOutWriterPlugin::Start() - entry")); +// if(isEnabled) +// { +// TRAPD(err,iWriterHandler->StartL()); +// if( err != KErrNone ) +// { +// LOGTEXT(_L("Could not start writer plugin")); +// return err; +// } +// } + LOGTEXT(_L("CDebOutWriterPlugin::Start() - exit")); + return KErrNone; + } + +void CDebOutWriterPlugin::Stop() + { + LOGTEXT(_L("CDebOutWriterPlugin::Stop() - entry")); + iWriterHandler->Stop(); + LOGTEXT(_L("CDebOutWriterPlugin::Stop() - exit")); + } + +void CDebOutWriterPlugin::GetCaption( TDes& aCaption ) const + { + aCaption.Copy(KDebOutShortName); + aCaption.TrimRight(); + LOGSTRING2("CDebOutWriterPlugin::GetCaptionL() - Plugin name: %S", &aCaption); + } + +TUid CDebOutWriterPlugin::Id() const + { + LOGSTRING2("CDebOutWriterPlugin::Id(): 0x%X", KDebOutWriterPluginUid.iUid ); + return KDebOutWriterPluginUid; + //return iDtor_ID_Key; + } + +TBool CDebOutWriterPlugin::GetEnabled() + { + return isEnabled; + } + +void CDebOutWriterPlugin::SetValue( const TWriterPluginValueKeys aKey, + TDes& aValue ) + { + TRAP_IGNORE( SetValueL( aKey, aValue ) ); + } + + +void CDebOutWriterPlugin::GetValue( const TWriterPluginValueKeys aKey, + TDes& aValue ) + { + TRAP_IGNORE( GetValueL( aKey, aValue ) ); + } + + + +void CDebOutWriterPlugin::SetValueL( const TWriterPluginValueKeys aKey, TDes& /*aValue*/ ) +{ + LOGTEXT(_L("CDebOutWriterPlugin::SetValueL - entry")); + + switch( aKey ) + { + case EWriterPluginEnabled: + isEnabled = ETrue; + LOGTEXT(_L("CDebOutWriterPlugin::SetValueL - plugin enabled")); + break; + case EWriterPluginDisabled: + isEnabled = EFalse; + LOGTEXT(_L("CDebOutWriterPlugin::SetValueL - plugin disabled")); + break; + case EWriterPluginSettings: + //result = StringLoader::LoadL(PROFILER_KERNEL_MODE_SAMPLER); + LOGTEXT(_L("CDebOutWriterPlugin::SetValueL - setting plugin settings")); + break; + default: + break; + } + LOGTEXT(_L("CDebOutWriterPlugin::SetValueL - exit")); + +} + +TUint32 CDebOutWriterPlugin::GetWriterType() + { + return iWriterType; + } + + +void CDebOutWriterPlugin::GetValueL( const TWriterPluginValueKeys aKey, TDes& aValue ) + { + switch( aKey ) + { + case EWriterPluginVersion: + + GetWriterVersion(&aValue); + break; + case EWriterPluginType: + break; + default: + break; + } + } + +void CDebOutWriterPlugin::GetWriterVersion(TDes* aDes) + { + _LIT(KDebugOutputWriterVersion, "1.0.0"); + aDes->Append(KDebugOutputWriterVersion); + } + +void CDebOutWriterPlugin::DoCancel() +{ + LOGTEXT(_L("CDebOutWriterPlugin::DoCancel - entry")); +} + +void CDebOutWriterPlugin::WriteData() + { + // Activate handler to write data from buffer to output + LOGTEXT(_L("CDiskWriterPlugin::WriteData() - entry")); + iWriterHandler->StartL(); + LOGTEXT(_L("CDiskWriterPlugin::WriteData() - exit")); + } + +void CDebOutWriterPlugin::HandleError(TInt aError) + { + TInt err(KErrNone); + err = iErrorStatus.Set(aError); + if(err != KErrNone) + { + RDebug::Print(_L("CDiskWriterPlugin::HandleError() - error: %d"), err); + } + } + +void CDebOutWriterPlugin::PrintDescriptorAsBase64( TDesC8& aDes, + TRequestStatus* aStatus, + TUint32 sampleTime, + TBool aEmptying) +{ + LOGTEXT(_L("CDebOutWriterPlugin::PrintDescriptorAsBase64() - entry")); + TUint len = aDes.Length(); + + // we must wait for the sample tick to be printed, in case + // prints are performed at user side, otherwise the kernel + // prints will corrupt the data + if(sampleTime != 0xffffffff) + { + TUint32 remains = sampleTime%1000; + + if(remains > 800) + { + TTimeIntervalMicroSeconds32 timeToWait = ((1050-remains)*1000); + User::After(timeToWait); + } + } + + TBuf16<75> buf; + + // Header +#ifdef OST_TRACE_COMPILER_IN_USE +// OstTrace0( TRACE_PERFORMANCE, CDEBOUTWRITERPLUGIN_PRINTDESCRIPTORASBASE64START, +// "=================================================================" ); +#else + RDebug::Print(_L("=================================================================")); +#endif + buf.Zero(); + + // base64 encoding table + const char uu_base64[64] = + { + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', + 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', + 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', + 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', + 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', + 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', + 'w', 'x', 'y', 'z', '0', '1', '2', '3', + '4', '5', '6', '7', '8', '9', '+', '/' + }; + + TChar byte1, byte2, byte3, byte4; + TUint8 count = 0x30; + // base64 encoding + for(TUint i = 0, j = 0; i < len; i += 3, j = (j + 1) % 18) + { + // byte 1 + byte1 = uu_base64[(aDes[i] >> 2) & 0x3F]; + + // byte 2 + if(i+1 < len) + byte2 = uu_base64[(aDes[i] << 4) & 0x3f | (aDes[i+1] >> 4)]; + else + byte2 = uu_base64[(aDes[i] << 4) & 0x3f]; + + // byte 3 + if(i+1 < len && i+2 < len) + byte3 = uu_base64[(aDes[i+1] << 2) & 0x3f | (aDes[i+2] >> 6)]; + else if(i+1 < len) + byte3 = uu_base64[(aDes[i+1] << 2) & 0x3f]; + else + byte3 = '='; + + // byte 4 + if(i+2 < len) + byte4 = uu_base64[aDes[i+2] & 0x3f]; + else + byte4 = '='; + + // append to buffer + buf.Append(byte1); + buf.Append(byte2); + buf.Append(byte3); + buf.Append(byte4); + + // output 72 chars / line + if(j == 17) + { + // add check number at the end of line + buf.Append(count); +#ifdef OST_TRACE_COMPILER_IN_USE +// OstTraceExt1( TRACE_PERFORMANCE, CDEBOUTWRITERPLUGIN_PRINTDESCRIPTORASBASE64LINE, "%S", &buf ); +#else + RDebug::Print(_L("%S"),&buf); +#endif + count++; + if(count > 0x39) + count = 0x30; + buf.Zero(); + } + } + +#ifdef OST_TRACE_COMPILER_IN_USE +// OstTraceExt1( TRACE_PERFORMANCE, CDEBOUTWRITERPLUGIN_PRINTDESCRIPTORASBASE64FIN, "%S", &buf ); +#else + RDebug::Print(_L("%S"),&buf); +#endif + buf.Zero(); + + // footer +#ifdef OST_TRACE_COMPILER_IN_USE +// OstTrace0( TRACE_PERFORMANCE, CDEBOUTWRITERPLUGIN_PRINTDESCRIPTORASBASE64END, +// "=================================================================" ); +#else + RDebug::Print(_L("=================================================================")); +#endif + + if(!aEmptying) + { + if(aStatus != 0) + User::RequestComplete(aStatus,0); + } + + LOGTEXT(_L("CDebOutWriterPlugin::PrintDescriptorAsBase64() - exit")); +} + + + +/* + * + * Implementation of class CDebOutWriterHandler + * + */ +CDebOutWriterHandler::CDebOutWriterHandler(CDebOutWriterPlugin* aWriter) : + CActive(EPriorityStandard) + { + LOGTEXT(_L("CDebOutWriterHandler::CDebOutWriterHandler - entry")); + iWriter = aWriter; + + // set initial mode to non-stopping + iStopping = EFalse; + + // add the handler to the active scheduler + CActiveScheduler::Add(this); + LOGTEXT(_L("CDebOutWriterHandler::CDebOutWriterHandler - exit")); + } + +CDebOutWriterHandler* CDebOutWriterHandler::NewL(CDebOutWriterPlugin* aWriter) +{ + LOGTEXT(_L("CDebOutWriterHandler::NewL() - entry")); + CDebOutWriterHandler* self = new (ELeave) CDebOutWriterHandler(aWriter); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(); + LOGTEXT(_L("CDebOutWriterHandler::NewL() - exit")); + return self; +} + +CDebOutWriterHandler::~CDebOutWriterHandler() + { + LOGTEXT(_L("CDebOutWriterHandler::~CDebOutWriterHandler - entry")); + + LOGTEXT(_L("CDebOutWriterHandler::~CDebOutWriterHandler - exit")); + } + +void CDebOutWriterHandler::ConstructL() + { + + } + +void CDebOutWriterHandler::StartL() + { + LOGTEXT(_L("CDebOutWriterHandler::StartL - entry")); + if(!IsActive()) + { + LOGTEXT(_L("CDiskWriterHandler::StartL - is not active")); + + TBapBuf* nextBuf = iWriter->iStream->GetNextFilledBuffer(); + LOGSTRING2(_L("CDiskWriterHandler::StartL - got next filled 0x%x"),nextBuf); + + if(nextBuf != 0) + { + LOGTEXT(_L("CDiskWriterHandler::StartL - writing to file")); + WriteBufferToOutput(nextBuf); + } + } + LOGTEXT(_L("CDebOutWriterHandler::StartL - entry")); + } + +void CDebOutWriterHandler::Stop() + { + LOGTEXT(_L("CDebOutWriterHandler::Stop - entry")); + + // do write once more to write the logged data to output + // set to stopping mode, needed for emptying the remaining full buffers + iStopping = ETrue; + + // stop the timer + Reset(); + + // set mode back to non-stopping + iStopping = EFalse; + LOGTEXT(_L("CDebOutWriterHandler::Stop - exit")); + } + +void CDebOutWriterHandler::Reset() + { + + // start writing new buffer if there is one available + TBapBuf* nextBuf = iWriter->iStream->GetNextFilledBuffer(); + + // empty the rest of the buffers synchronously + while(nextBuf != 0) + { + if(nextBuf->iDataSize != 0) + { + LOGTEXT(_L("CDiskWriterHandler::Reset - writing to file")); + iWriter->PrintDescriptorAsBase64(*(nextBuf->iBufDes),&iStatus,0xffffffff, iStopping); + } + + // empty buffers when profiling stopped + iWriter->iStream->AddToFreeBuffers(nextBuf); + + LOGTEXT(_L("CDiskWriterHandler::Reset - get next full buffer")); + // start writing new buffer if there is one available + nextBuf = iWriter->iStream->GetNextFilledBuffer(); + LOGSTRING2(_L("CDiskWriterHandler::Reset - got next filled 0x%x"),nextBuf); + } + } + +void CDebOutWriterHandler::HandleFullBuffers() + { + LOGTEXT(_L("CDiskWriterHandler::HandleFullBuffers - entry")); + // previous write operation has finished + // release the previous buffer + iWriter->iStream->AddToFreeBuffers(iBufferBeingWritten); + + LOGTEXT(_L("CDiskWriterHandler::HandleFullBuffers - get next full buffer")); + // start writing new buffer if there is one available + TBapBuf* nextBuf = iWriter->iStream->GetNextFilledBuffer(); + + if(nextBuf != 0) + { + LOGTEXT(_L("CDiskWriterHandler::HandleFullBuffers - writing to file")); + if(nextBuf->iDataSize != 0) + { + WriteBufferToOutput(nextBuf); + } + } + LOGTEXT(_L("CDiskWriterHandler::HandleFullBuffers - exit")); + } + +void CDebOutWriterHandler::RunL() + { + // call function to complete full buffer handling + HandleFullBuffers(); + } + +void CDebOutWriterHandler::DoCancel() + { + + } + +void CDebOutWriterHandler::WriteBufferToOutput(TBapBuf* aBuf) + { + LOGTEXT(_L("CDebOutWriterHandler::WriteBufferToOutput - entry")); + iBufferBeingWritten = aBuf; + + // set the data length just to be sure + iBufferBeingWritten->iBufDes->SetLength(aBuf->iDataSize); + + LOGTEXT(_L("CDiskWriterPlugin::WriteBufferToOutput - writing to file")); +// PrintBufferToOutput(iBufferBeingWritten, iStatus); + iWriter->PrintDescriptorAsBase64(*(iBufferBeingWritten->iBufDes),&iStatus,0xffffffff, iStopping); + // set AO back to active, until filled buffers are emptied + SetActive(); + + LOGTEXT(_L("CDebOutWriterHandler::WriteBufferToOutput - exit")); + } + +// private +void CDebOutWriterHandler::PrintBufferToOutput(TBapBuf* aBuffer, TRequestStatus& aStatus) + { + LOGTEXT(_L("CDebOutWriterHandler::WriteBufferToOutput() - debug out writer tick activated")); + + TPtrC8& aDes = (TPtrC8&)*(aBuffer->iBufDes); +#ifdef BAPPEA_SAMPLE_MARKS + TUint32 time = iSampler->GetSampleTime(); +#else + TUint32 time = 0xffffffff; +#endif + iWriter->PrintDescriptorAsBase64(aDes,&aStatus,time, iStopping); + } + diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler/plugins/DebugOutputWriterPlugin/src/DebOutWriterPluginImplementationTable.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler/plugins/DebugOutputWriterPlugin/src/DebOutWriterPluginImplementationTable.cpp Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,39 @@ +/* +* 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: +* +*/ + + +// INCLUDE FILES +#include +#include + +#include "DebOutWriterPlugin.h" + + +// Provides a key value pair table, this is used to identify +// the correct construction function for the requested interface. +const TImplementationProxy ImplementationTable[] = +{ + IMPLEMENTATION_PROXY_ENTRY(0x2001E5BA, CDebOutWriterPlugin::NewL) +}; + +// Function used to return an instance of the proxy table. +EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) +{ + aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); + return ImplementationTable; +} + diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler/plugins/DiskWriterPlugin/data/2001E5BB.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler/plugins/DiskWriterPlugin/data/2001E5BB.rss Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,51 @@ +/* +* 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: +* +*/ + + +#include + +// Declares info for two implementations +RESOURCE REGISTRY_INFO theInfo + { + // UID for the DLL. See mmp files + //__SERIES60_3X__ can't be used in resource files + dll_uid = 0x2001E5BB; + + // Declare array of interface info. This dll contains implementations for + // only one interface (CSamplerInterfaceDefinition). + interfaces = + { + INTERFACE_INFO + { + // UID of interface that is implemented + interface_uid = 0x2001E5BD; + + implementations = + { + IMPLEMENTATION_INFO + { + implementation_uid = 0x2001E5BB; + + version_no = 1; + display_name = "Disk output writer implementation"; + default_data = "dsw"; + opaque_data = "0"; + } + }; + } + }; + } diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler/plugins/DiskWriterPlugin/group/DiskWriterPlugin.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler/plugins/DiskWriterPlugin/group/DiskWriterPlugin.mmp Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,49 @@ +/* +* 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: +* +*/ + + +#include + + +TARGET PIProfilerDiskWriter.dll +TARGETTYPE PLUGIN +UID 0x10009D8D 0x2001E5BB +#ifdef WINSCW +VENDORID 0 +#else +VENDORID VID_DEFAULT +#endif +CAPABILITY ALL -TCB // AllFiles ReadDeviceData ReadUserData UserEnvironment WriteDeviceData WriteUserData + +OS_LAYER_SYSTEMINCLUDE +USERINCLUDE ../inc +SOURCEPATH ../src + +START RESOURCE ../data/2001E5BB.rss +TARGET piprofilerdiskwriter.rsc +END + +SOURCE DiskWriterPlugin.cpp +SOURCE DiskWriterPluginImplementationTable.cpp + +LIBRARY sysutil.lib +LIBRARY euser.lib +LIBRARY ECom.lib +LIBRARY EFSRV.LIB +LIBRARY commonengine.lib +LIBRARY flogger.lib + diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler/plugins/DiskWriterPlugin/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler/plugins/DiskWriterPlugin/group/bld.inf Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,20 @@ +/* +* 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: +* +*/ + + +PRJ_MMPFILES +DiskWriterPlugin.mmp diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler/plugins/DiskWriterPlugin/inc/DiskWriterPlugin.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler/plugins/DiskWriterPlugin/inc/DiskWriterPlugin.h Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,137 @@ +/* +* 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 __DISKWRITERPLUGIN_H__ +#define __DISKWRITERPLUGIN_H__ + +// Include Files +#include +#include + +#include +#include +#include // CBase +#include // TBuf +#include + +_LIT(KFileOutShortName, "dsw"); + +// forward declarations +class CDiskWriterHandler; +class CProfilerSampleStream; + +// Class Definitions + +class CDiskWriterPlugin : public CWriterPluginInterface + { +public: + // new function + static CDiskWriterPlugin* NewL(const TUid aImplementationUid, TAny* aInitParams); + ~CDiskWriterPlugin(); + + void DoCancel(); + + +public: // new functions + + TInt Start(); + + void Stop(); + + void GetCaption( TDes& aCaption ) const; + + void GetValue( const TWriterPluginValueKeys aKey, TDes& aValue ); + + void SetValue( const TWriterPluginValueKeys aKey, TDes& aValue ); + + TUid Id() const; + + void GetWriterVersion(TDes* aDes); + + TUint32 GetWriterType(); + + void HandleError(TInt aError); + + void WriteData(); + + void SetStream(CProfilerSampleStream& aStream) { iStream = &aStream; } + +private: // new functions + CDiskWriterPlugin(const TUid aImplementationUid); + void ConstructL(); + + void GetValueL( const TWriterPluginValueKeys aKey, TDes& aValue ); + void SetValueL( const TWriterPluginValueKeys aKey, TDes& aValue ); + TBool GetEnabled(); + + TInt DisplayNotifier(const TDesC& aLine1, const TDesC& aLine2, const TDesC& aButton1, const TDesC& aButton2); +public: + CProfilerSampleStream* iStream; +private: // data + + TBuf<256> iFileName; + TInt iWriterType; + TInt iWriterId; + CDiskWriterHandler* iWriterHandler; + RProperty iErrorStatus; + }; + +/* + * + * Definition of class CDiskWriterHandler + * + */ +class CDiskWriterHandler : public CActive //CBase + { +public: + + + static CDiskWriterHandler* NewL(CDiskWriterPlugin* aWriter); + ~CDiskWriterHandler(); + + void StartL(); + + void Stop(); + void RunL(); + TInt RunError(TInt aError); + + void DoCancel(); + void WriteBufferToOutput(TBapBuf* aBuf); + void Reset(); + + TInt TestFile(const TDesC& totalPrefix); +private: + CDiskWriterHandler(CDiskWriterPlugin* aWriter); + + void ConstructL(); + void WriteMemBufferToFile(TDesC8& aDes, TRequestStatus& aStatus); + static TInt Write(TAny* aObject); + void HandleFullBuffers(); + void DoWrite(); + +private: + RFile iFile; + RFs iFs; + TBuf<256> iFileName; + CDiskWriterPlugin* iWriter; + TBapBuf* iBufferBeingWritten; + TBool iStopping; + }; + +#endif // __DEBOUTWRITERPLUGIN_H__ + diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler/plugins/DiskWriterPlugin/src/DiskWriterPlugin.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler/plugins/DiskWriterPlugin/src/DiskWriterPlugin.cpp Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,479 @@ +/* +* 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: +* +*/ + + +// Include Files + +#include "DiskWriterPlugin.h" // CDiskWriterPlugin +#include +#include +#include + +// constants +//const TInt KDelayBeforeTimerStarts( 5000000 ); + +// engine properties +const TUid KEngineStatusPropertyCat={0x2001E5AD}; +enum TEnginePropertyKeys + { + EProfilerEngineStatus = 8, + EProfilerErrorStatus + }; + +/* + * + * Class CDiskWriterPlugin implementation + * + */ + +// Member Functions +CDiskWriterPlugin* CDiskWriterPlugin::NewL(const TUid /*aImplementationUid*/, TAny* /*aInitParams*/) + { + LOGTEXT(_L("CDiskWriterPlugin::NewL() - entry")); + CDiskWriterPlugin* self = new (ELeave) CDiskWriterPlugin(KDiskWriterPluginUid); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(); + LOGTEXT(_L("CDiskWriterPlugin::NewL() - exit")); + return self; + } + +CDiskWriterPlugin::CDiskWriterPlugin(const TUid aImplementationUid) : + iWriterType(aImplementationUid.iUid) + { + LOGTEXT(_L("CDiskWriterPlugin::CDiskWriterPlugin - entry")); + isEnabled = EFalse; + iWriterId = Id().iUid; + LOGTEXT(_L("CDiskWriterPlugin::CDiskWriterPlugin - exit")); + } + +CDiskWriterPlugin::~CDiskWriterPlugin() + { + LOGTEXT(_L("CDiskWriterPlugin::~CDiskWriterPlugin - entry")); + + iErrorStatus.Close(); + + if(iWriterHandler) + { + iWriterHandler->Cancel(); + delete iWriterHandler; + } + LOGTEXT(_L("CDiskWriterPlugin::~CDiskWriterPlugin - exit")); + } + +void CDiskWriterPlugin::ConstructL() + { + // second phase constructor, anything that may leave must be constructed here + LOGTEXT(_L("CDiskWriterPlugin::ConstructL() - entry")); + iWriterHandler = CDiskWriterHandler::NewL(this); + User::LeaveIfError(iErrorStatus.Attach(KEngineStatusPropertyCat, EProfilerErrorStatus)); + LOGTEXT(_L("CDiskWriterPlugin::ConstructL() - exit")); + } + +void CDiskWriterPlugin::GetCaption( TDes& aCaption ) const + { + aCaption.Copy(KFileOutShortName); + aCaption.TrimRight(); + LOGSTRING2("CDiskWriterPlugin::GetCaptionL() - Plugin name: %S", &aCaption); + } + +TUid CDiskWriterPlugin::Id() const + { + LOGSTRING2("CDiskWriterPlugin::Id():0x%X", KDiskWriterPluginUid.iUid ); + return KDiskWriterPluginUid; + } + +void CDiskWriterPlugin::GetWriterVersion(TDes* aDes) + { + _LIT(KDiskWriterVersion, "1.0.0"); + aDes->Append(KDiskWriterVersion); + } + +TInt CDiskWriterPlugin::Start() + { +// if(isEnabled) +// { +// TRAPD(err, iWriterHandler->StartL()); +// if( err != KErrNone) +// { +// LOGTEXT(_L("Could not start writer plugin")); +// return err; +// } +// } + return KErrNone; + } + +void CDiskWriterPlugin::Stop() + { + // stop writer handler normally + iWriterHandler->Stop(); + } + +TBool CDiskWriterPlugin::GetEnabled() + { + return isEnabled; + } + +TUint32 CDiskWriterPlugin::GetWriterType() + { + return iWriterType; + } + + +void CDiskWriterPlugin::SetValue( const TWriterPluginValueKeys aKey, + TDes& aValue ) + { + TRAP_IGNORE( SetValueL( aKey, aValue ) ); + } + + +void CDiskWriterPlugin::GetValue( const TWriterPluginValueKeys aKey, + TDes& aValue ) + { + TRAP_IGNORE( GetValueL( aKey, aValue ) ); + } + +void CDiskWriterPlugin::SetValueL( const TWriterPluginValueKeys aKey, TDes& aValue ) + { + TInt error(KErrNone); + + switch( aKey ) + { + case EWriterPluginEnabled: + isEnabled = ETrue; + LOGTEXT(_L("CDebOutWriterPlugin::SetValueL - plugin enabled")); + break; + case EWriterPluginDisabled: + isEnabled = EFalse; + LOGTEXT(_L("CDebOutWriterPlugin::SetValueL - plugin disabled")); + break; + case EWriterPluginSettings: // file name in case of disk writer plugin + iFileName.Zero(); + iFileName.Append(aValue); + error = iWriterHandler->TestFile(iFileName); + User::LeaveIfError(error); + break; + default: + break; + } + } + +void CDiskWriterPlugin::GetValueL( const TWriterPluginValueKeys aKey, TDes& aValue ) + { + switch( aKey ) + { + case EWriterPluginVersion: + GetWriterVersion(&aValue); + break; + case EWriterPluginType: + break; + case EWriterPluginSettings: // file name in disk writer case + aValue.Copy(iFileName); + default: + break; + } + } + +void CDiskWriterPlugin::DoCancel() + { + LOGTEXT(_L("CDebOutWriterPlugin::DoCancel - entry")); + } + +void CDiskWriterPlugin::WriteData() + { + // Activate handler to write data from buffer to output + LOGTEXT(_L("CDiskWriterPlugin::WriteData() - entry")); + iWriterHandler->StartL(); + LOGTEXT(_L("CDiskWriterPlugin::WriteData() - exit")); + } + +void CDiskWriterPlugin::HandleError(TInt aError) + { + TInt err(KErrNone); + RDebug::Print(_L("CDiskWriterPlugin::HandleError() - error received: %d"), aError); + err = iErrorStatus.Set(aError); + if(err != KErrNone) + { + RDebug::Print(_L("CDiskWriterPlugin::HandleError() - error in updating property: %d"), err); + } + } + +/* + * + * Implementation of class CDiskWriterHandler + * + */ + +CDiskWriterHandler* CDiskWriterHandler::NewL(CDiskWriterPlugin* aWriter) + { + LOGTEXT(_L("CDiskWriterHandler::NewL() - entry")); + CDiskWriterHandler* self = new (ELeave) CDiskWriterHandler(aWriter); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(); + LOGTEXT(_L("CDiskWriterHandler::NewL() - exit")); + return self; + } + +CDiskWriterHandler::CDiskWriterHandler(CDiskWriterPlugin* aWriter) : + CActive(EPriorityStandard) + { + LOGTEXT(_L("CDiskWriterHandler::CDiskWriterHandler - entry")); + + iWriter = aWriter; + + // set initial mode to non-stopping + iStopping = EFalse; + + // add the handler to the active scheduler + CActiveScheduler::Add(this); + + LOGTEXT(_L("CDiskWriterHandler::CDiskWriterHandler - exit")); + } + + +CDiskWriterHandler::~CDiskWriterHandler() + { + LOGTEXT(_L("CDiskWriterHandler::~CDiskWriterHandler - entry")); + + LOGTEXT(_L("CDiskWriterHandler::~CDiskWriterHandler - exit")); + } + +void CDiskWriterHandler::ConstructL() + { + } + +TInt CDiskWriterHandler::TestFile(const TDesC& totalPrefix) + { + TParse parse; + + TInt err(KErrNone); + if((err = parse.Set(totalPrefix, NULL, NULL)) != KErrNone) + return err; + + err = iFs.Connect(); + if(err != KErrNone) + { + LOGTEXT(_L("CDiskWriterHandler::TestFile() - Failed to open a session to file server")); + return KErrNotFound; + } + + iFs.MkDirAll(parse.FullName()); + + err = iFile.Replace(iFs,parse.FullName(),EFileWrite); + if(err != KErrNone) + { + iFs.Close(); + return KErrNotFound; + } + + iFileName.Copy(parse.FullName()); + + return KErrNone; + } + +void CDiskWriterHandler::Reset() + { + // cancel active object + Cancel(); + + // start writing new buffer if there is one available + TBapBuf* nextBuf = iWriter->iStream->GetNextFilledBuffer(); + + // empty the rest of the buffers synchronously + while(nextBuf != 0) + { + LOGTEXT(_L("CDiskWriterHandler::Reset - writing to file")); + if(nextBuf->iDataSize != 0) + { + LOGTEXT(_L("CDiskWriterHandler::Reset - writing to file")); + WriteMemBufferToFile(*(nextBuf->iBufDes),iStatus); + } + + // empty buffers when profiling stopped + iWriter->iStream->AddToFreeBuffers(nextBuf); + + LOGTEXT(_L("CDiskWriterHandler::Reset - get next full buffer")); + // start writing new buffer if there is one available + nextBuf = iWriter->iStream->GetNextFilledBuffer(); + LOGSTRING2(_L("CDiskWriterHandler::Reset - got next filled 0x%x"),nextBuf); + } + } + +void CDiskWriterHandler::HandleFullBuffers() + { + LOGTEXT(_L("CDiskWriterHandler::HandleFullBuffers - entry")); + // previous write operation has finished + // release the previous buffer + iWriter->iStream->AddToFreeBuffers(iBufferBeingWritten); + + LOGTEXT(_L("CDiskWriterHandler::HandleFullBuffers - get next full buffer")); + // start writing new buffer if there is one available + TBapBuf* nextBuf = iWriter->iStream->GetNextFilledBuffer(); + + if(nextBuf != 0) + { + LOGTEXT(_L("CDiskWriterHandler::HandleFullBuffers - writing to file")); + if(nextBuf->iDataSize != 0) + { + WriteBufferToOutput(nextBuf); + } + } + LOGTEXT(_L("CDiskWriterHandler::HandleFullBuffers - exit")); + } + +void CDiskWriterHandler::RunL() + { + LOGTEXT(_L("CDiskWriterHandler::RunL - entry")); + // call function to complete full buffer handling + HandleFullBuffers(); + LOGTEXT(_L("CDiskWriterHandler::RunL - exit")); + } + +void CDiskWriterHandler::DoCancel() + { + + } + +//----------------------------------------------------------------------------- +// CPIProfilerTraceCoreLauncher::RunError(TInt aError) +// Handle leaves from RunL(). +//----------------------------------------------------------------------------- +TInt CDiskWriterHandler::RunError(TInt aError) + { + // no reason to continue if disk full or removed + iFile.Close(); + // close handle to file server too + iFs.Close(); + iFileName.Zero(); + + iWriter->HandleError(KErrDiskFull); + return aError; + } + +void CDiskWriterHandler::WriteMemBufferToFile(TDesC8& aDes, TRequestStatus& aStatus) + { + LOGTEXT(_L("CDiskWriterPlugin::WriteMemBufferToFile - entry")); + + TUint sampleSize(aDes.Length()); + TInt err(KErrNone); + TInt drive(0); + TDriveInfo info; + + err = iFile.Drive(drive,info); + // check first if still space on disk + if( SysUtil::DiskSpaceBelowCriticalLevelL(&iFs, sampleSize, drive) ) + { + // set error to disk full + err = KErrDiskFull; + LOGTEXT(_L("CDiskWriterPlugin::WriteMemBufferToFile - disk full, cannot write")); + } + else + { + // check if profiling in stopping mode + if(iStopping) + { + // RDebug::Print(_L("CDiskWriterPlugin::WriteMemBufferToFile - data written, length %d, stopping"), aDes.Length()); + // write to file without status + err = iFile.Write(aDes); + } + else + { + // RDebug::Print(_L("CDiskWriterPlugin::WriteMemBufferToFile - data written, length %d"), aDes.Length()); + // write to file with status + iFile.Write(aDes,aStatus); + } + } + + // check if error in write + if(err != KErrNone) + { + // stop writer handler (and its timer) immediately, DO NOT try write data! + Cancel(); + + // no reason to continue if disk full or removed + // end of stream detected, file can be closed + iFile.Close(); + // close handle to file server too + iFs.Close(); + iFileName.Zero(); + + // set error status for engine to read + iWriter->HandleError(err); + } + LOGTEXT(_L("CDiskWriterPlugin::WriteMemBufferToFile - exit")); + } + +void CDiskWriterHandler::WriteBufferToOutput(TBapBuf* aBuf) + { + LOGTEXT(_L("CDiskWriterPlugin::WriteBufferToOutput - entry")); + iBufferBeingWritten = aBuf; + + // set the data length just to be sure + iBufferBeingWritten->iBufDes->SetLength(aBuf->iDataSize); + + LOGTEXT(_L("CDiskWriterPlugin::WriteBufferToOutput - writing to file")); + WriteMemBufferToFile(*(iBufferBeingWritten->iBufDes), iStatus); + + // set AO back to active, until filled buffers are emptied + SetActive(); + + LOGTEXT(_L("CDiskWriterPlugin::WriteBufferToOutput - exit")); + } + +void CDiskWriterHandler::StartL() + { + LOGTEXT(_L("CDiskWriterHandler::StartL - entry")); + if(!IsActive()) + { + LOGTEXT(_L("CDiskWriterHandler::StartL - is not active")); + + TBapBuf* nextBuf = iWriter->iStream->GetNextFilledBuffer(); + LOGSTRING2(_L("CDiskWriterHandler::StartL - got next filled 0x%x"),nextBuf); + + if(nextBuf != 0) + { + LOGTEXT(_L("CDiskWriterHandler::StartL - writing to file")); + WriteBufferToOutput(nextBuf); + } + } + LOGTEXT(_L("CDiskWriterHandler::StartL - exit")); + } + +void CDiskWriterHandler::Stop() + { + LOGTEXT(_L("CDiskWriterHandler::Stop - entry")); + + // set to stopping mode, needed for emptying the remaining full buffers + iStopping = ETrue; + + // stop the timer + Reset(); + + // end of stream detected, file can be closed + iFile.Close(); + // close handle to file server too + iFs.Close(); + iFileName.Zero(); + + // set mode back to non-stopping + iStopping = EFalse; + + LOGTEXT(_L("CDiskWriterHandler::Stop - exit")); + } + +// end of file diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler/plugins/DiskWriterPlugin/src/DiskWriterPluginImplementationTable.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler/plugins/DiskWriterPlugin/src/DiskWriterPluginImplementationTable.cpp Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,39 @@ +/* +* 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: +* +*/ + + +// INCLUDE FILES +#include +#include + +#include "DiskWriterPlugin.h" + + +// Provides a key value pair table, this is used to identify +// the correct construction function for the requested interface. +const TImplementationProxy ImplementationTable[] = +{ + IMPLEMENTATION_PROXY_ENTRY(0x2001E5BB, CDiskWriterPlugin::NewL) +}; + +// Function used to return an instance of the proxy table. +EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) +{ + aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); + return ImplementationTable; +} + diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler/plugins/GeneralsPlugin/data/2001E5B2.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler/plugins/GeneralsPlugin/data/2001E5B2.rss Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,51 @@ +/* +* 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: +* +*/ + + +#include + +// Declares info for two implementations +RESOURCE REGISTRY_INFO theInfo + { + // UID for the DLL. See mmp files + //__SERIES60_3X__ can't be used in resource files + dll_uid = 0x2001E5B2; + + // Declare array of interface info. This dll contains implementations for + // only one interface (CSamplerInterfaceDefinition). + interfaces = + { + INTERFACE_INFO + { + // UID of interface that is implemented + interface_uid = 0x2001E5BC; + + implementations = + { + IMPLEMENTATION_INFO + { + implementation_uid = 0x2001E5B2; + + version_no = 1; + display_name = "General Samplers; GPP, ITT, GFC, MEM, PRI"; + default_data = "gen"; + opaque_data = "0"; // the order number + } + }; + } + }; + } diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler/plugins/GeneralsPlugin/group/GeneralsPlugin.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler/plugins/GeneralsPlugin/group/GeneralsPlugin.mmp Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,51 @@ +/* +* 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: +* +*/ + + +#include + + +TARGET PIProfilerGenerals.dll +TARGETTYPE PLUGIN +UID 0x10009D8D 0x2001E5B2 +VENDORID VID_DEFAULT +CAPABILITY ALL -TCB + +EPOCSTACKSIZE 0x10000 + +OS_LAYER_SYSTEMINCLUDE +USERINCLUDE ../inc +SOURCEPATH ../src + +START RESOURCE ../data/2001E5B2.rss +TARGET PIProfilerGenerals.rsc +END + +SOURCE GeneralsPluginImplementationTable.cpp +SOURCE GeneralsPlugin.cpp + +LIBRARY euser.lib +LIBRARY bafl.lib +LIBRARY ECom.lib +LIBRARY apparc.lib +LIBRARY cone.lib +LIBRARY ws32.lib +LIBRARY charconv.lib +LIBRARY commonengine.lib +LIBRARY flogger.lib + +epocallowdlldata diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler/plugins/GeneralsPlugin/group/GeneralsSampler.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler/plugins/GeneralsPlugin/group/GeneralsSampler.mmp Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,45 @@ +/* +* 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: +* +*/ + + +#include +#include "kernel/kern_ext.mmh" + +TARGET PIProfilerGeneralsSampler.ldd +CAPABILITY ALL +TARGETTYPE LDD +UID 0x100000AF 0x2001E5B3 +VENDORID VID_DEFAULT + +OS_LAYER_KERNEL_SYSTEMINCLUDE +USERINCLUDE ../inc +SOURCEPATH ../src + +SOURCE GeneralsDriver.cpp +SOURCE GeneralsSampler.cia +SOURCE GppSamplerImpl.cpp +SOURCE IttSamplerImpl.cpp +SOURCE MemSamplerImpl.cpp +SOURCE PriSamplerImpl.cpp + +LIBRARY ekern.lib + +epocallowdlldata + +start wins +win32_headers +end diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler/plugins/GeneralsPlugin/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler/plugins/GeneralsPlugin/group/bld.inf Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,23 @@ +/* +* 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: +* +*/ + + +PRJ_MMPFILES +#ifdef MARM + GeneralsPlugin.mmp + GeneralsSampler.mmp +#endif diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler/plugins/GeneralsPlugin/inc/GeneralsConfig.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler/plugins/GeneralsPlugin/inc/GeneralsConfig.h Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,99 @@ +/* +* 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 GENERALS_CONFIG_H +#define GENERALS_CONFIG_H + + + // change this to reflect the ISA task amount + #define PROFILER_ISA_OS_TASK_AMOUNT 50 + + // don't change these definitions + #define PROFILER_DEFINE_ISA_TASK_NAME_ARRAY TBuf8<64> isaTaskNames[PROFILER_ISA_OS_TASK_AMOUNT]; + #define PROFILER_DEFINE_ISA_TASK_NAME(name,number) isaTaskNames[number].Append(_L8(name)); + + // change these to reflect the real ISA task names and numbers + // the last number must be PROFILER_ISA_OS_TASK_AMOUNT-1 + + #define PROFILER_ISA_TASK_NAMES PROFILER_DEFINE_ISA_TASK_NAME("SRVSCKT_TASK",0)\ + PROFILER_DEFINE_ISA_TASK_NAME("CSD_SRV_TASK",1) \ + PROFILER_DEFINE_ISA_TASK_NAME("CSD_NTB_TASK",2) \ + PROFILER_DEFINE_ISA_TASK_NAME("CSD_WTB_TASK",3) \ + PROFILER_DEFINE_ISA_TASK_NAME("PH_TASK",4) \ + PROFILER_DEFINE_ISA_TASK_NAME("L2_TASK",5) \ + PROFILER_DEFINE_ISA_TASK_NAME("RR_TASK",6) \ + PROFILER_DEFINE_ISA_TASK_NAME("GPRS_RLC_TASK",7) \ + PROFILER_DEFINE_ISA_TASK_NAME("GPRS_MAC_TASK",8) \ + PROFILER_DEFINE_ISA_TASK_NAME("RANC_TASK",9) \ + PROFILER_DEFINE_ISA_TASK_NAME("MM_TASK",10) \ + PROFILER_DEFINE_ISA_TASK_NAME("CC_TASK",11) \ + PROFILER_DEFINE_ISA_TASK_NAME("SMS_TASK",12) \ + PROFILER_DEFINE_ISA_TASK_NAME("RM_CONTROL_TASK",13) \ + PROFILER_DEFINE_ISA_TASK_NAME("GSS_SERVER_TASK",14) \ + PROFILER_DEFINE_ISA_TASK_NAME("CS_MAIN_TASK",15) \ + PROFILER_DEFINE_ISA_TASK_NAME("GPRS_TASK",16) \ + PROFILER_DEFINE_ISA_TASK_NAME("WMAC_TASK",17) \ + PROFILER_DEFINE_ISA_TASK_NAME("WMHS_TASK",18) \ + PROFILER_DEFINE_ISA_TASK_NAME("WRRC_TASK",19) \ + PROFILER_DEFINE_ISA_TASK_NAME("WRLC_UL_TASK",20) \ + PROFILER_DEFINE_ISA_TASK_NAME("WRLC_DL_TASK",21) \ + PROFILER_DEFINE_ISA_TASK_NAME("WPH_TASK",22) \ + PROFILER_DEFINE_ISA_TASK_NAME("WRAN_TASK",23) \ + PROFILER_DEFINE_ISA_TASK_NAME("SSOM_TASK",24) \ + PROFILER_DEFINE_ISA_TASK_NAME("ACCESSORY_TASK",25) \ + PROFILER_DEFINE_ISA_TASK_NAME("ADL_TASK",26) \ + PROFILER_DEFINE_ISA_TASK_NAME("AUDIO_TASK",27) \ + PROFILER_DEFINE_ISA_TASK_NAME("PN_TASK",28) \ + PROFILER_DEFINE_ISA_TASK_NAME("CORE_HI_TASK",29) \ + PROFILER_DEFINE_ISA_TASK_NAME("CORE_LO_TASK",30) \ + PROFILER_DEFINE_ISA_TASK_NAME("ENERGY_TASK",31) \ + PROFILER_DEFINE_ISA_TASK_NAME("FBUS_TASK",32) \ + PROFILER_DEFINE_ISA_TASK_NAME("PMM_FILE2_TASK",33) \ + PROFILER_DEFINE_ISA_TASK_NAME("MDI_RCV_TASK",34) \ + PROFILER_DEFINE_ISA_TASK_NAME("MDI_SEND_TASK",35) \ + PROFILER_DEFINE_ISA_TASK_NAME("MONITOR_TASK",36) \ + PROFILER_DEFINE_ISA_TASK_NAME("MTC_CTRL_TASK",37) \ + PROFILER_DEFINE_ISA_TASK_NAME("MTC_WD_TASK",38) \ + PROFILER_DEFINE_ISA_TASK_NAME("OBEX_TASK",39) \ + PROFILER_DEFINE_ISA_TASK_NAME("APDU_SERVER_TASK",40) \ + PROFILER_DEFINE_ISA_TASK_NAME("SIMSON_SERVER_TASK",41) \ + PROFILER_DEFINE_ISA_TASK_NAME("SIMLOCK_TASK",42) \ + PROFILER_DEFINE_ISA_TASK_NAME("SOS_USB_MM_TASK",43) \ + PROFILER_DEFINE_ISA_TASK_NAME("SOS_PROXY_AUX_TASK",44) \ + PROFILER_DEFINE_ISA_TASK_NAME("TERMINAL_ADAPTER_TASK",45) \ + PROFILER_DEFINE_ISA_TASK_NAME("XTI_RECEIVE_TASK",46) \ + PROFILER_DEFINE_ISA_TASK_NAME("XTI_SEND_TASK",47) \ + PROFILER_DEFINE_ISA_TASK_NAME("STARTUP_AND_BACKGROUND_TASK",48) \ + PROFILER_DEFINE_ISA_TASK_NAME("OS_IDLE_TASK",49) + + // old definitions + #define PROFILER_GENERALS_SAMPLER_ID 100 + #define PROFILER_GPP_SAMPLER_ID 1 + #define PROFILER_GFC_SAMPLER_ID 2 + #define PROFILER_ITT_SAMPLER_ID 3 + #define PROFILER_MEM_SAMPLER_ID 4 + #define PROFILER_PRI_SAMPLER_ID 5 + + #define PROFILER_GPP_SAMPLER_NAME _L("GPP") + #define PROFILER_GFC_SAMPLER_NAME _L("GFC") + #define PROFILER_ITT_SAMPLER_NAME _L("ITT") + #define PROFILER_MEM_SAMPLER_NAME _L("MEM") + #define PROFILER_PRI_SAMPLER_NAME _L("PRI") + + +#endif diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler/plugins/GeneralsPlugin/inc/GeneralsDriver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler/plugins/GeneralsPlugin/inc/GeneralsDriver.h Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,59 @@ +/* +* 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 __GENERALSSAMPLER_H__ +#define __GENERALSSAMPLER_H__ + +/* + * The user-interface to the sampling device driver sued by the profiling engine + */ +#include + +#ifndef __KERNEL_MODE__ +#include +#endif + + +/** + * The user device driver class for controlling the plugin sampler. + */ + +class RGeneralsSampler : public RPluginSampler +{ + public: + #ifndef __KERNEL_MODE__ + + /** Open a channel to the sampling device **/ + inline TInt Open(); + + #endif // !__KERNEL_MODE__ +}; + +_LIT(KPluginSamplerName,"PIProfilerGeneralsSampler"); + +#ifndef __KERNEL_MODE__ + +inline TInt RGeneralsSampler::Open() +{ + return DoCreate(KPluginSamplerName,TVersion(1,0,1),KNullUnit,NULL,NULL); +} + + +#endif +#endif + diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler/plugins/GeneralsPlugin/inc/GeneralsPlugin.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler/plugins/GeneralsPlugin/inc/GeneralsPlugin.h Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,151 @@ +/* +* 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_GENERALSECOM_SAMPLER_H +#define PROFILER_GENERALSECOM_SAMPLER_H + +#include +#include + +#include "GeneralsDriver.h" +#include "GeneralsConfig.h" +#include +#include + +// constants +const TUint KDefaultOutputCombination = 3; + +const TUint KSubSamplerCount = 5; + +// parent itself +_LIT(KGENShortName, "gen"); +_LIT(KGENMediumName, "Generic samplers plug-in"); +_LIT(KGENLongName, "Generic samplers plug-in"); + +// gpp caption definitions +_LIT8(KGPPShortName, "gpp"); +#ifdef CARBIDE_NAMES +_LIT8(KGPPLongName, "Address/Thread sampling"); +#else +_LIT8(KGPPLongName, "CPU load sampler"); +#endif +_LIT8(KGPPDescription, "CPU load sampler\nSampling thread and process load\nHW dep: N/A\nSW dep: S60 3.0\n"); + +// gfc caption definitions +_LIT8(KGFCShortName, "gfc"); +#ifdef CARBIDE_NAMES +_LIT8(KGFCLongName, "Function call sampling"); +#else +_LIT8(KGFCLongName, "Function call sampler"); +#endif +_LIT8(KGFCDescription, "Function call sampler\nCapturing function call info\nHW dep: N/A\nSW dep: S60 3.0\n"); + +// itt caption definitions +_LIT8(KITTShortName, "itt"); +#ifdef CARBIDE_NAMES +_LIT8(KITTLongName, "Dynamic binary support"); +#else +_LIT8(KITTLongName, "Instruction trace sampler"); +#endif +_LIT8(KITTDescription, "Instruction trace sampler\nTracing instructions executed on ROFS\nHW dep: N/A\nSW dep: S60 3.0\n"); + +// mem caption definitions +_LIT8(KMEMShortName, "mem"); +#ifdef CARBIDE_NAMES +_LIT8(KMEMLongName, "Memory usage sampler"); +#else +_LIT8(KMEMLongName, "Memory trace sampler"); +#endif +_LIT8(KMEMDescription, "Memory trace sampler\nTracing memory, i.e. stack and chunk usage\nHW dep: N/A\nSW dep: S60 3.0\n"); + +// pri caption definitions +_LIT8(KPRIShortName, "pri"); +#ifdef CARBIDE_NAMES +_LIT8(KPRILongName, "Thread priority sampling"); +#else +_LIT8(KPRILongName, "Priority trace sampler"); +#endif +_LIT8(KPRIDescription, "Priority trace sampler\nTracing thread priorities\nHW dep: N/A\nSW dep: S60 3.0\n"); + + +// forward definitions +class CConfigInfoArray; +class CProfilerBufferHandler; +class CProfilerSampleStream; +class TSamplerAttributes; + +class CGeneralsPlugin : public CSamplerPluginInterface +{ +public: + static CGeneralsPlugin* NewL(const TUid aImplementationUid, TAny* /*aInitParams*/); + ~CGeneralsPlugin(); + + TUint32 GetSampleTime(); + + /* + * Sub sampler specific functions + * + */ + TInt GetSamplerUidByName(TDesC8& name); + + // from CSamplerPluginInterface + TInt ResetAndActivateL(CProfilerSampleStream& aStream); + TInt StopSampling(); + TBool Enabled() { return iEnabled; } + + TUid Id( TInt aSubId ) const; + TInt SubId( TUid aSubId ) const; // internal + + void GetAttributesL(CArrayFixFlat* aAttributes); + TInt SetAttributesL(TSamplerAttributes aAttributes); + void InitiateSamplerAttributesL(); + + TInt ConvertRawSettingsToAttributes(CDesC8ArrayFlat* aSingleSettingArray); + TInt DoSetSamplerSettings(CDesC8ArrayFlat* aAllSettings, TDesC8& aSamplerName, TInt aIndex); + void SaveSettingToAttributes(const TDesC8& aSetting, TInt aIndex); + + void GetCaption( TDes& aCaption, TInt aType, TInt aSubId ) const; + + TInt GetSamplerType(); + + void InstallStreamForActiveTraces(RGeneralsSampler& sampler, CProfilerSampleStream& aStream); + +private: + CGeneralsPlugin(); + void ConstructL(); + + TInt InitiateSamplerL(); + TInt CleanSampler(); + void SetSettingsToSamplers(); + +private: + TUint8 iVersion[20]; + TPtr8 iVersionDescriptor; + + RGeneralsSampler iGeneralsSampler; + + CProfilerBufferHandler* iBufferHandler; + + CArrayFixFlat* iSamplerAttributes; + + TBuf8<9> iSearchTexts; +public: + TUint32* iSampleTime; +}; + +#endif diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler/plugins/GeneralsPlugin/inc/GfcSamplerImpl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler/plugins/GeneralsPlugin/inc/GfcSamplerImpl.h Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,249 @@ +/* +* 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_GFC_SAMPLER_H +#define PROFILER_GFC_SAMPLER_H + + +#include "GeneralsConfig.h" + +#include + +#include +#include +#include "GppSamplerImpl.h" + +extern void UsrModLr(TUint32*); + + +/* + * + * GFC sampler definition + * + */ + +template +class DProfilerGfcSampler : public DProfilerGenericSampler +{ +public: + DProfilerGfcSampler(struct TProfilerGppSamplerData* ); + ~DProfilerGfcSampler(); + + void Sample(); + TInt Reset(DProfilerSampleStream* aStream, TUint32 aSyncOffset); +private: + struct TProfilerGppSamplerData* gppSamplerData; + TUint32 gfcSample[3]; + + TUint8 encodedSample[15]; + TUint32 repeat; +}; + +/* + * + * GFC sampler implementation + * + */ + +template +DProfilerGfcSampler::DProfilerGfcSampler(struct TProfilerGppSamplerData* gppSamplerDataIn) : + DProfilerGenericSampler(PROFILER_GFC_SAMPLER_ID) +{ + this->gppSamplerData = gppSamplerDataIn; + LOGSTRING2("CProfilerGfcSampler<%d>::CProfilerGfcSampler",BufferSize); +} + +template +TInt DProfilerGfcSampler::Reset(DProfilerSampleStream* aStream, TUint32 aSyncOffset) +{ + LOGSTRING2("CProfilerGfcSampler - entry",BufferSize); + + this->repeat = 0; + for(TInt i=0;i<3;i++) + { + this->gfcSample[i] = 0; + } + + LOGSTRING2("CProfilerGfcSampler<%d>::Reset - calling superclass reset",BufferSize); + DProfilerGenericSampler::Reset(aStream); + LOGSTRING2("CProfilerGfcSampler<%d>::Reset - called superclass reset",BufferSize); + + // add the first sample, indicating the gfc trace version + TUint8 firstSample[33]; + TPtr8 firstSampleDesc(&(firstSample[1]),32); + firstSampleDesc.Zero(); + + firstSampleDesc.Append(_L8("Bappea_V")); + firstSampleDesc.Append(PROFILER_GFC_SAMPLER_VERSION); + firstSampleDesc.Append(_L8("_GFC")); + firstSample[0] = firstSampleDesc.Size(); + + this->iSampleBuffer->AddSample(firstSample,(firstSample[0]+1)); + + LOGSTRING2("CProfilerGfcSampler - exit",BufferSize); + + return KErrNone; +} + +template +void DProfilerGfcSampler::Sample() +{ + LOGSTRING2("CProfilerGfcSampler<%d>::Sample",BufferSize); + + TUint32 usr_mod_link_reg; + + UsrModLr(&usr_mod_link_reg); + + TUint32 pc = gppSamplerData->lastPcValue; + TUint32 lr = usr_mod_link_reg; + TUint32 sa = gppSamplerData->sampleNumber; + + if(pc == gfcSample[0] && lr == gfcSample[1] && sa == gfcSample[2]+1) + { + // encode repeat + repeat++; + gfcSample[2] = sa; + LOGSTRING2("CProfilerGfcSampler<%d>::Sample - repeat",BufferSize); + return; + } + else if(repeat > 0) + { + TUint8 repeatSample[3]; + repeatSample[0] = 0xff; + repeatSample[1] = (TUint8)(repeat>>8); + repeatSample[2] = (TUint8)repeat; + this->iSampleBuffer->AddSample(repeatSample,3); + + LOGSTRING3("CProfilerGfcSampler<%d>::Sample - Encoded repeat %d",BufferSize,repeat); + + repeat = 0; + } + + TInt ptr = 3; + + // encode program counter value + if(pc>=gfcSample[0]) + { + pc = (pc-gfcSample[0]); + encodedSample[0] = 0x80; + } + else + { + pc = (gfcSample[0]-pc); + encodedSample[0] = 0x00; + } + + if(pc <= (TUint32)0xff) + { + encodedSample[0] |= 1; + encodedSample[ptr] = (TUint8)pc;ptr++; + } + else if(pc <= (TUint32)0xffff) + { + encodedSample[0] |= 2; + encodedSample[ptr] = (TUint8)pc;ptr++; + encodedSample[ptr] = (TUint8)(pc>>8);ptr++; + } + else if(pc <= (TUint32)0xffffff) + { + encodedSample[0] |= 3; + encodedSample[ptr] = (TUint8)pc;ptr++; + encodedSample[ptr] = (TUint8)(pc>>8);ptr++; + encodedSample[ptr] = (TUint8)(pc>>16);ptr++; + } + else + { + encodedSample[0] |= 4; + encodedSample[ptr] = (TUint8)pc;ptr++; + encodedSample[ptr] = (TUint8)(pc>>8);ptr++; + encodedSample[ptr] = (TUint8)(pc>>16);ptr++; + encodedSample[ptr] = (TUint8)(pc>>24);ptr++; + } + + // encode link register value + if(lr>=gfcSample[1]) + { + lr = (lr-gfcSample[1]); + encodedSample[1] = 0x80; + } + else + { + lr = (gfcSample[1]-lr); + encodedSample[1] = 0x00; + } + + if(lr <= (TUint32)0xff) + { + encodedSample[1] |= 1; + encodedSample[ptr] = (TUint8)lr;ptr++; + } + else if(lr <= (TUint32)0xffff) + { + encodedSample[1] |= 2; + encodedSample[ptr] = (TUint8)lr;ptr++; + encodedSample[ptr] = (TUint8)(lr>>8);ptr++; + } + else if(lr <= (TUint32)0xffffff) + { + encodedSample[1] |= 3; + encodedSample[ptr] = (TUint8)lr;ptr++; + encodedSample[ptr] = (TUint8)(lr>>8);ptr++; + encodedSample[ptr] = (TUint8)(lr>>16);ptr++; + } + else + { + encodedSample[1] |= 4; + encodedSample[ptr] = (TUint8)lr;ptr++; + encodedSample[ptr] = (TUint8)(lr>>8);ptr++; + encodedSample[ptr] = (TUint8)(lr>>16);ptr++; + encodedSample[ptr] = (TUint8)(lr>>24);ptr++; + } + + // endcode sample number difference + if( (sa - gfcSample[2]) < (TUint8)0xff) + { + encodedSample[2] = (sa-gfcSample[2]); + } + else + { + encodedSample[2] = 0xff; + encodedSample[ptr] = (TUint8)sa;ptr++; + encodedSample[ptr] = (TUint8)(sa>>8);ptr++; + encodedSample[ptr] = (TUint8)(sa>>16);ptr++; + encodedSample[ptr] = (TUint8)(sa>>24);ptr++; + } + + // store the values for the next sample + gfcSample[0] = gppSamplerData->lastPcValue; + gfcSample[1] = usr_mod_link_reg; + gfcSample[2] = gppSamplerData->sampleNumber; + + this->iSampleBuffer->AddSample(encodedSample,ptr); + + LOGSTRING3("CProfilerGfcSampler<%d>::Sample Size %d",BufferSize,ptr); + + return; + +} + +template +DProfilerGfcSampler::~DProfilerGfcSampler() +{ + LOGSTRING2("CProfilerGfcSampler<%d>::~CProfilerGfcSampler",BufferSize); +} +#endif diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler/plugins/GeneralsPlugin/inc/GppSamplerImpl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler/plugins/GeneralsPlugin/inc/GppSamplerImpl.h Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,217 @@ +/* +* 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_GPP_SAMPLER_H +#define PROFILER_GPP_SAMPLER_H + +#include "GeneralsConfig.h" + +#include + +#include +#include + +// for RPropertyRef +#include +#include + +/* + * + * GPP sampler definition + * + */ +class GppSamplerImpl +{ +public: + + GppSamplerImpl(); + ~GppSamplerImpl(); + + TUint8* EncodeTag(TUint8* aPtr); + TUint8* EncodeInt(TUint8* aPtr,TInt aValue); + TUint8* EncodeUint(TUint8* aPtr,TUint aValue); + TUint8* EncodeText(TUint8* aPtr, const TDesC& aDes); + + TUint8* EncodeName(TUint8* aPtr, DObject& aObject,TUint32 id); + TUint8* EncodeThread(TUint8* aPtr, DThread& aThread); + + TBool IsaTaskKnown(TUint8 task); + TUint8* EncodeIsaTask(TUint8* aPtr, TUint task); + TUint8* EncodeIsaName(TUint8* aPtr, TUint task,TBool process); + + TUint8* EncodeRepeat(TUint8* aPtr); + + TInt CreateFirstSample(); + TInt SampleImpl(); + + TInt iGppSamplingPeriod; + TUint8 tempBuf[512]; + TUint iLastPc; + + TBool iIsaSample; + TInt knownIsaTasks[256]; + TUint8 knownIsaTaskCount; + TInt* isaOsTaskRunningAddr; + void Reset(); + TUint32 iSampleCount; + + PROFILER_DEFINE_ISA_TASK_NAME_ARRAY + +private: + enum TState {EStop,ERunning,EStopping}; + + const TUint* iInterruptStack; + + TUint iLastThread; + TUint iRepeat; + TUint32 iStartTime; + + RPropertyRef iIsaStartAddr; + RPropertyRef iIsaEndAddr; + RPropertyRef iIsaPluginStatus; + RPropertyRef iIsaOsTaskRunning; + TInt iIsaStatus; + TInt iIsaStart; + TInt iIsaEnd; +}; + +struct TProfilerGppSamplerData +{ +//public: + TUint32 lastPcValue; + TUint32 sampleNumber; + TInt samplingPeriod; +}; + +template +class DProfilerGppSampler : public DProfilerGenericSampler +{ +public: + DProfilerGppSampler(); + ~DProfilerGppSampler(); + + struct TProfilerGppSamplerData* GetExportData(); + void Sample(); + TInt Reset(DProfilerSampleStream* aStream, TUint32 aSyncOffset); + TInt GetPeriod(); + +private: + GppSamplerImpl gppSamplerImpl; + struct TProfilerGppSamplerData exportData; + +}; + +/* + * + * GPP sampler implementation + * + */ + +template +DProfilerGppSampler::DProfilerGppSampler() : + DProfilerGenericSampler(PROFILER_GPP_SAMPLER_ID) + { + LOGSTRING2("CProfilerGppSampler<%d>::CProfilerGppSampler",BufferSize); + } + +template +DProfilerGppSampler::~DProfilerGppSampler() + { + LOGSTRING2("CProfilerGppSampler<%d>::~CProfilerGppSampler",BufferSize); + } + +template +TInt DProfilerGppSampler::Reset(DProfilerSampleStream* aStream, TUint32 aSyncOffset) + { + LOGSTRING2("CProfilerGppSampler<%d>::Reset - calling superclass reset",BufferSize); + DProfilerGenericSampler::Reset(aStream, 0); + LOGSTRING2("CProfilerGppSampler<%d>::Reset - called superclass reset",BufferSize); + + this->gppSamplerImpl.Reset(); + + this->gppSamplerImpl.iGppSamplingPeriod = this->iSamplingPeriod; + this->gppSamplerImpl.iSampleCount = 0; + this->exportData.sampleNumber = 0; + this->exportData.lastPcValue = 0; + this->exportData.samplingPeriod = this->gppSamplerImpl.iGppSamplingPeriod; + + TInt length = gppSamplerImpl.CreateFirstSample(); + LOGSTRING3("CProfilerGPPSampler<%d>::Reset - got first sample, size %d",BufferSize,length); + + this->iSampleBuffer->AddSample(gppSamplerImpl.tempBuf,length); + + // check if sampling period > 1 ms + // NOTE: feature supported in Performance Investigator 2.01 and above + if(this->gppSamplerImpl.iGppSamplingPeriod > 1) + { + // For Address/Thread (GPP) version 2.01 or above, the first word is the sampling period in milliseconds + TUint8* w = gppSamplerImpl.tempBuf; + + (*w++) = (this->gppSamplerImpl.iGppSamplingPeriod >> 24) & 0xFF; + (*w++) = (this->gppSamplerImpl.iGppSamplingPeriod >> 16) & 0xFF; + (*w++) = (this->gppSamplerImpl.iGppSamplingPeriod >> 8) & 0xFF; + (*w++) = (this->gppSamplerImpl.iGppSamplingPeriod) & 0xFF; + + this->iSampleBuffer->AddSample(gppSamplerImpl.tempBuf,4); + } + + LOGSTRING2("CProfilerGPPSampler<%d>::Reset finished",BufferSize); + return KErrNone; + } + +template +void DProfilerGppSampler::Sample() + { + LOGSTRING2("CProfilerGppSampler<%d>::Sample",BufferSize); + + if(this->gppSamplerImpl.iSampleCount % 1000 == 0) + { + Kern::Printf(("PIPROF SAMPLE TICK, #%d"),exportData.sampleNumber); + } + + TInt length = gppSamplerImpl.SampleImpl(); + + this->gppSamplerImpl.iSampleCount++; + this->exportData.sampleNumber += this->gppSamplerImpl.iGppSamplingPeriod; + this->exportData.lastPcValue = gppSamplerImpl.iLastPc; + + if(length > 0) + { + this->iSampleBuffer->AddSample(gppSamplerImpl.tempBuf,length); + } + + LOGSTRING3("CProfilerGppSampler<%d>::Sample - length %d",BufferSize,length); + + return; + } + + +template +struct TProfilerGppSamplerData* DProfilerGppSampler::GetExportData() + { + LOGSTRING2("CProfilerGppSampler<%d>::GetExportData",BufferSize); + return &(this->exportData); + } + +template +TInt DProfilerGppSampler::GetPeriod() + { + return this->gppSamplerImpl.iGppSamplingPeriod; + } + +#endif diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler/plugins/GeneralsPlugin/inc/IttSamplerImpl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler/plugins/GeneralsPlugin/inc/IttSamplerImpl.h Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,188 @@ +/* +* 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 diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler/plugins/GeneralsPlugin/inc/MemSamplerImpl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler/plugins/GeneralsPlugin/inc/MemSamplerImpl.h Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,240 @@ +/* +* 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_MEM_SAMPLER_H +#define PROFILER_MEM_SAMPLER_H + +#include "GeneralsConfig.h" + +#include + +#include +#include +#include "GppSamplerImpl.h" + +// defines the maximum thread amount that is assumed to +// be possible with MEM trace +#define PROFILER_MAX_THREAD_AMOUNT 512 + +/* + * + * MEM sampler definition + * + */ + +class MemSamplerImpl +{ +public: + enum EProcessingState + { + EStartingToProcess, + EProcessingNames, + EProcessingData, + ENothingToProcess + }; + + MemSamplerImpl(); + ~MemSamplerImpl(); + + TInt CreateFirstSample(); + TInt SampleImpl(); + TBool SampleNeeded(); + void Reset(); + TInt ProcessChunks(); + TInt ProcessThreads(); + TInt GatherChunks(); + TInt GatherThreads(); + + TInt EncodeChunkData(DChunk& chunk); + TInt EncodeChunkName(DChunk& chunk); + TInt EncodeChunkData(DThread& thread); + TInt EncodeChunkName(DThread& thread); + + TInt EncodeTotalMemoryName(); + TInt EncodeTotalMemory(); + + TInt EncodeNameCode(); + TInt EncodeDataCode(); + + DChunk* heapChunksToSample[PROFILER_MAX_THREAD_AMOUNT]; + DChunk* heapChunkNamesToReport[PROFILER_MAX_THREAD_AMOUNT]; + TInt iCount; + TInt iChunkCount; + TInt iNewChunkCount; + TBuf8<0x50> name; + DThread* threadsToSample[PROFILER_MAX_THREAD_AMOUNT]; + DThread* threadNamesToReport[PROFILER_MAX_THREAD_AMOUNT]; + TInt iThreadCount; + TInt iNewThreadCount; + + TInt iChunksProcessing; + TInt iThreadsProcessing; + TInt iMemSamplingPeriod; + TInt iMemSamplingPeriodDiv2; + TBool iSampleThreads; + TBool iTimeToSample; + + TBool iTotalMemoryOk; + TBool iTotalMemoryNameOk; + + TUint8 sample[257]; + TPtr8 sampleDescriptor; +}; + +template +class DProfilerMemSampler : public DProfilerGenericSampler +{ +public: + DProfilerMemSampler(struct TProfilerGppSamplerData*, TInt id); + ~DProfilerMemSampler(); + + void Sample(); + TInt Reset(DProfilerSampleStream* aStream, TUint32 aSyncOffset); + TInt PostSample(); + TBool PostSampleNeeded(); + +private: + MemSamplerImpl memSamplerImpl; + struct TProfilerGppSamplerData* gppSamplerData; + TBool sampleNeeded; +}; + +/* + * + * MEM sampler implementation + * + */ + +template +DProfilerMemSampler::DProfilerMemSampler(struct TProfilerGppSamplerData* gppSamplerDataIn, TInt id) : + DProfilerGenericSampler(PROFILER_MEM_SAMPLER_ID) + { + LOGSTRING2("CProfilerMemSampler<%d>::CProfilerMemSampler",BufferSize); + this->gppSamplerData = gppSamplerDataIn; + this->iSamplingPeriod = 3000; // set default setting + } + +template +TInt DProfilerMemSampler::Reset(DProfilerSampleStream* aStream, TUint32 aSyncOffset) + { + LOGSTRING2("CProfilerMemSampler<%d>::Reset - calling superclass reset",BufferSize); + DProfilerGenericSampler::Reset(aStream); + LOGSTRING2("CProfilerMemSampler<%d>::Reset - called superclass reset",BufferSize); + memSamplerImpl.Reset(); + + this->memSamplerImpl.iMemSamplingPeriod = this->iSamplingPeriod; + this->memSamplerImpl.iMemSamplingPeriodDiv2 = (TInt)(this->memSamplerImpl.iMemSamplingPeriod / 2); + + LOGSTRING3("CProfilerMemSampler<%d>::Reset - set mem sampling period to", + BufferSize,this->memSamplerImpl.iMemSamplingPeriod); + + TInt length = memSamplerImpl.CreateFirstSample(); + this->iSampleBuffer->AddSample(memSamplerImpl.sample,length); + + this->sampleNeeded = false; + + return KErrNone; + } + +template +TInt DProfilerMemSampler::PostSample() + { + this->sampleNeeded = false; + + LOGSTRING3("CProfilerMemSampler<%d>::PostSample - state %d",BufferSize,this->sampleBuffer->GetBufferStatus()); + + TInt interruptLevel = NKern::DisableInterrupts(0); + + // first collect chunk data + TInt length = this->memSamplerImpl.SampleImpl(); + if(length != 0) + { + LOGSTRING("MEM sampler PostSample - starting to sample"); + + // then, encode the sample to the buffer + while(length > 0) + { + this->iSampleBuffer->AddSample(memSamplerImpl.sample,length); + length = this->memSamplerImpl.SampleImpl(); + // indicate that the whole MEM sample ends by having a 0x00 in the end + if(length == 0) + { + TUint8 number = 0; + LOGSTRING("MEM sampler PostSample - all samples generated!"); + + this->iSampleBuffer->AddSample(&number,1); + LOGSTRING("MEM sampler PostSample - end mark added"); + } + } + } + + LOGSTRING("MEM sampler PostSample - finished sampling"); + + NKern::RestoreInterrupts(interruptLevel); + + // finally perform superclass postsample + TInt i = this->DProfilerGenericSampler::PostSample(); + return i; + + } + +template +TBool DProfilerMemSampler::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 DProfilerMemSampler::Sample() + { + + LOGSTRING2("CProfilerMemSampler<%d>::Sample",BufferSize); + + if(memSamplerImpl.SampleNeeded()) + { + this->sampleNeeded = true; + + LOGSTRING2("CProfilerMemSampler<%d>::Sample - sample needed",BufferSize); + + // start the MEM sample with the sample time + TUint8 number = 4; // mem sampler id + this->iSampleBuffer->AddSample(&number,1); + this->iSampleBuffer->AddSample((TUint8*)&(gppSamplerData->sampleNumber),4); + + // leave the rest of the processing for PostSample() + } + + LOGSTRING2("CProfilerMemSampler<%d>::Sample",BufferSize); + return; + } + +template +DProfilerMemSampler::~DProfilerMemSampler() + { + LOGSTRING2("CProfilerMemSampler<%d>::~CProfilerMemSampler",BufferSize); + } +#endif diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler/plugins/GeneralsPlugin/inc/PriSamplerImpl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler/plugins/GeneralsPlugin/inc/PriSamplerImpl.h Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,224 @@ +/* +* 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_PRI_SAMPLER_H +#define PROFILER_PRI_SAMPLER_H + +#include "GeneralsConfig.h" + +#include + +#include +#include +#include "GppSamplerImpl.h" + +// defines the maximum thread amount that is assumed to +// be possible with PRI trace +const TInt KProfilerMaxThreadAmount = 512; + +/* + * + * PRI sampler definition + * + */ + +class PriSamplerImpl +{ +public: + enum EProcessingState + { + EStartingToProcess, + EProcessingNames, + EProcessingData, + ENothingToProcess + }; + + PriSamplerImpl(); + ~PriSamplerImpl(); + + TInt CreateFirstSample(); + TInt SampleImpl(); + TBool SampleNeeded(); + void Reset(); + TInt ProcessChunks(); + + TInt EncodeChunkData(DThread& thread); + TInt EncodeChunkName(DThread& thread); + + TInt EncodeNameCode(); + TInt EncodeDataCode(); + + TInt iCountti; + DThread* threadsToSample[KProfilerMaxThreadAmount]; + DThread* threadNamesToReport[KProfilerMaxThreadAmount]; + + TInt iThreadCount; + TInt iNewThreadCount; + + TInt iProcessing; + TInt iPriSamplingPeriod; + + TUint8 sample[257]; + TPtr8 sampleDescriptor; + +}; + +template +class DProfilerPriSampler : public DProfilerGenericSampler +{ +public: + DProfilerPriSampler(struct TProfilerGppSamplerData*, TInt id); + ~DProfilerPriSampler(); + + void Sample(); + TInt Reset(DProfilerSampleStream* aStream, TUint32 aSyncOffset); + TInt PostSample(); + TBool PostSampleNeeded(); + +private: + PriSamplerImpl priSamplerImpl; + struct TProfilerGppSamplerData* gppSamplerData; + TBool sampleNeeded; + TBool sampleInProgress; +}; + +/* + * + * PRI sampler implementation + * + */ + +template +DProfilerPriSampler::DProfilerPriSampler(struct TProfilerGppSamplerData* gppSamplerDataIn, TInt id) : + DProfilerGenericSampler(PROFILER_PRI_SAMPLER_ID) + { + LOGSTRING2("CProfilerPriSampler<%d>::CProfilerPriSampler",BufferSize); + this->gppSamplerData = gppSamplerDataIn; + this->sampleInProgress = false; + this->iSamplingPeriod = 3000; // set default setting + } + +template +TInt DProfilerPriSampler::Reset(DProfilerSampleStream* aStream, TUint32 aSyncOffset) + { + LOGSTRING2("CProfilerPriSampler<%d>::Reset - calling superclass reset",BufferSize); + DProfilerGenericSampler::Reset(aStream); + LOGSTRING2("CProfilerPriSampler<%d>::Reset - called superclass reset",BufferSize); + priSamplerImpl.Reset(); + + this->priSamplerImpl.iPriSamplingPeriod = this->iSamplingPeriod; + + + LOGSTRING3("CProfilerPriSampler<%d>::Reset - set pri sampling period to", + BufferSize,this->priSamplerImpl.iPriSamplingPeriod); + + TInt length = priSamplerImpl.CreateFirstSample(); + this->iSampleBuffer->AddSample(priSamplerImpl.sample,length); + + this->sampleInProgress = false; + this->sampleNeeded = false; + + return KErrNone; + } + +template +TInt DProfilerPriSampler::PostSample() + { + if(sampleNeeded) + { + this->sampleNeeded = false; + + LOGSTRING3("CProfilerPriSampler<%d>::PostSample - state %d",BufferSize,this->sampleBuffer->GetBufferStatus()); + + TInt interruptLevel = NKern::DisableInterrupts(0); + + TInt length = this->priSamplerImpl.SampleImpl(); + if(length != 0) + { + LOGSTRING("PRI sampler PostSample - starting to sample"); + + // then, encode the sample to the buffer + while(length > 0) + { + this->iSampleBuffer->AddSample(priSamplerImpl.sample,length); + length = this->priSamplerImpl.SampleImpl(); + // indicate that the whole PRI sample ends by having a 0x00 in the end + if(length == 0) + { + TUint8 number = 0; + LOGSTRING("PRI sampler PostSample - all samples generated!"); + + this->iSampleBuffer->AddSample(&number,1); + LOGSTRING("PRI sampler PostSample - end mark added"); + } + } + LOGSTRING("PRI sampler PostSample - finished sampling"); + } + this->sampleInProgress = false; + + NKern::RestoreInterrupts(interruptLevel); + } + + // finally perform superclass postsample + TInt i = this->DProfilerGenericSampler::PostSample(); + return i; + } + +template +TBool DProfilerPriSampler::PostSampleNeeded() + { + LOGSTRING3("CProfilerPriSampler<%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 DProfilerPriSampler::Sample() + { + LOGSTRING2("CProfilerPriSampler<%d>::Sample",BufferSize); + + if(priSamplerImpl.SampleNeeded() && this->sampleInProgress == false) + { + this->sampleInProgress = true; + this->sampleNeeded = true; + // start the PRI sample with the sample time + TUint8 number = 4; + this->iSampleBuffer->AddSample(&number,1); + this->iSampleBuffer->AddSample((TUint8*)&(gppSamplerData->sampleNumber),4); + + // leave the rest of the processing for PostSample() + } + + LOGSTRING2("CProfilerPriSampler<%d>::Sample",BufferSize); + return; + } + +template +DProfilerPriSampler::~DProfilerPriSampler() + { + LOGSTRING2("CProfilerPriSampler<%d>::~CProfilerPriSampler",BufferSize); + } +#endif diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler/plugins/GeneralsPlugin/src/GeneralsDriver.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler/plugins/GeneralsPlugin/src/GeneralsDriver.cpp Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,769 @@ +/* +* 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: +* +*/ + + +// +// LDD for thread time profiling +// + +#include + +#include "GeneralsDriver.h" +#include +#include +#include + +#include "GppSamplerImpl.h" +#include "GfcSamplerImpl.h" +#include "IttSamplerImpl.h" +#include "MemSamplerImpl.h" +#include "PriSamplerImpl.h" + + +// just for testing +extern TUint* IntStackPtr(); +extern void UsrModLr(TUint32*); + +// the synch property, for other sampler implementations +//const TUid KGppPropertyCat={0x20201F70}; +//enum TGppPropertyKeys +// { +// EGppPropertySyncSampleNumber +// }; + +static _LIT_SECURITY_POLICY_PASS(KAllowAllPolicy); +static _LIT_SECURITY_POLICY_FAIL( KDenyAllPolicy ); + + +/* + * + * + * Class DGfcProfilerFactory definition + * + * + */ + +class DGeneralsProfilerFactory : public DLogicalDevice +{ + public: + DGeneralsProfilerFactory(); + + + public: + virtual TInt Install(); + virtual void GetCaps(TDes8& aDes) const; + virtual TInt Create(DLogicalChannelBase*& aChannel); +}; + +/* + * + * + * Class DGfcDriver definition + * + * + */ +class DPluginDriver; + +class DGeneralsDriver : public DPluginDriver +{ + +public: + DGeneralsDriver(); + ~DGeneralsDriver(); + +private: + TInt NewStart(TInt aRate); + static void NewDoProfilerProfile(TAny*); + static void NewDoDfc(TAny*); + TInt Sample(); + + TInt GetSampleTime(TUint32* time); + //TInt Test(TUint32 testCase); + + TInt StartSampling(); + + void InitialiseSamplerList(); + + DProfilerSamplerBase* GetSamplerForId(TInt samplerId); + TInt GetSamplerVersion(TDes* aDes); + + TInt ProcessStreamReadRequest(TBapBuf* aBuf,TRequestStatus* aStatus); + + TInt MarkTraceActive(TInt samplerIdToActivate); + TInt MarkTraceInactive(TInt samplerIdToDisable); + TInt OutputSettingsForTrace(TInt samplerId,TInt settings); + TInt AdditionalTraceSettings(TInt samplerId,TInt settings); + TInt AdditionalTraceSettings2(TInt samplerId,TInt settings); + TInt SetSamplingPeriod(TInt /*samplerId*/,TInt settings); +private: + // create the driver in EKA-2 version + TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer); + + // receive commands and control in EKA-2 version + void HandleMsg(TMessageBase* aMsg); +private: + // timer mechanism in EKA-2 version + NTimer iTimer; + TDfc iNewDfc; + TInt iCount; + TInt iLastPcVal; + TInt iPeriod; + + // sync sample number property for synchronizing other samplers + RPropertyRef iSampleStartTimeProp; + TInt iSampleStartTime; + + DProfilerGppSampler<10000> gppSampler; + DProfilerGfcSampler<10000> gfcSampler; + DProfilerIttSampler<10000> ittSampler; + DProfilerMemSampler<20000> memSampler; + DProfilerPriSampler<10000> priSampler; + + static const TInt KSamplerAmount = 5; + DProfilerSamplerBase* iSamplers[KSamplerAmount]; +}; + +/* + * + * + * Class DGeneralsProfilerFactory implementation + * + * + */ + +DECLARE_STANDARD_LDD() + { + return new DGeneralsProfilerFactory(); + } + +TInt DGeneralsProfilerFactory::Create(DLogicalChannelBase*& aChannel) + { + aChannel = new DGeneralsDriver; + return aChannel?KErrNone:KErrNoMemory; + } + + +DGeneralsProfilerFactory::DGeneralsProfilerFactory() + { + // major, minor, and build version number + iVersion=TVersion(1,0,1); + } + + +TInt DGeneralsProfilerFactory::Install() + { + return(SetName(&KPluginSamplerName)); + } + +void DGeneralsProfilerFactory::GetCaps(TDes8& aDes) const + { + TCapsSamplerV01 b; + + b.iVersion=TVersion(1,0,1); + + aDes.FillZ(aDes.MaxLength()); + aDes.Copy((TUint8*)&b,Min(aDes.MaxLength(),sizeof(b))); + } + +/* + * + * + * Class DGeneralsDriver implementation + * + * + */ + +DGeneralsDriver::DGeneralsDriver() : + iTimer(NewDoProfilerProfile,this), + iNewDfc(NewDoDfc,this,NULL,7), + gfcSampler(gppSampler.GetExportData()), + ittSampler(gppSampler.GetExportData()), + memSampler(gppSampler.GetExportData(), PROFILER_MEM_SAMPLER_ID), + priSampler(gppSampler.GetExportData(), PROFILER_PRI_SAMPLER_ID) + { + LOGSTRING("DGeneralsDriver::DGeneralsDriver()"); + + iState = EStopped; + iEndRequestStatus = 0; + doingDfc = 0; + sampleRunning = 0; + iSyncOffset = 0; + InitialiseSamplerList(); + } + +/* + * + * This method has to be changed for each new sampler + * + */ +void DGeneralsDriver::InitialiseSamplerList() + { + // initialize all samplers to zero + for(TInt i=0;iiSamplerId == samplerIdToGet) + { + return iSamplers[i]; + } + } + return (DProfilerSamplerBase*)0; + } + + +TInt DGeneralsDriver::DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer) + { + TUint8 err(KErrNone); + if (!Kern::QueryVersionSupported(TVersion(1,0,1),aVer)) + return KErrNotSupported; + + // just for testing + LOGTEXT("Initializing the stack pointer"); + stackTop=(TUint32*)IntStackPtr(); + LOGSTRING2("Got stack pointer 0x%x",(TUint32)stackTop); + + iClient = &Kern::CurrentThread(); + err = iClient->Open(); + + iSampleStream.InsertCurrentClient(iClient); + + iTimer.Cancel(); + iNewDfc.Cancel(); + + Kern::SetThreadPriority(24); + SetDfcQ(Kern::DfcQue0()); + iNewDfc.SetDfcQ(iDfcQ); + iMsgQ.Receive(); + return err; + } + +DGeneralsDriver::~DGeneralsDriver() + { + if (iState!=EStopped) + iTimer.Cancel(); + iNewDfc.Cancel(); + iSampleStartTimeProp.Close(); + Kern::SafeClose((DObject*&)iClient,NULL); + } + + +TInt DGeneralsDriver::GetSampleTime(TUint32* time) + { + LOGSTRING("DGeneralsDriver::GetSampleTime - entry"); + + Kern::ThreadRawWrite( iClient,(TAny*)time, + (TAny*)&gppSampler.GetExportData()->sampleNumber, + 4, iClient); + + LOGSTRING("DGeneralsDriver::GetSampleTime - exit"); + + return KErrNone; + } + + +TInt DGeneralsDriver::GetSamplerVersion(TDes* aDes) + { + LOGSTRING2("DGeneralsDriver::GetSamplerVersion - 0x%x",aDes); + + TBuf8<16> aBuf; + aBuf.Append(PROFILER_SAMPLER_VERSION); + Kern::ThreadDesWrite(iClient,aDes,aBuf,0,KChunkShiftBy0,iClient); + LOGSTRING("DGeneralsDriver::GetSamplerVersion - written client descriptor"); + return KErrNone; + } + +TInt DGeneralsDriver::NewStart(TInt aDelay) + { + LOGSTRING("DGeneralsDriver::NewStart"); + iEndRequestStatus = 0; + + aDelay = Min(KMaxDelay, Max(KMinDelay, aDelay)); + + // always use this rate + iPeriod = aDelay; + + iTimer.OneShot(aDelay); + + iState = ERunning; + + return KErrNone; + } + +/* + * This function is run in each interrupt + */ +// EKA-2 implementation of the sampler method + +void DGeneralsDriver::NewDoProfilerProfile(TAny* pointer) + { + DGeneralsDriver& d = *((DGeneralsDriver*)pointer); + + if (d.iState == ERunning && d.sampleRunning == 0) + { + d.iTimer.Again(d.iPeriod); + d.sampleRunning++; + + TInt8 postSampleNeeded = 0; + + for(TInt i=0;iiEnabled) + { + d.iSamplers[i]->Sample(); + postSampleNeeded += d.iSamplers[i]->PostSampleNeeded(); + } + } + + if(postSampleNeeded > 0 && d.doingDfc == 0) + { + d.doingDfc++; + d.iNewDfc.Add(); + + d.sampleRunning--; + return; + } + d.sampleRunning--; + } + else if (d.iState == EStopping && d.sampleRunning == 0) + { + // add a dfc for this final time + d.iNewDfc.Add(); + } + else + { + // the previous sample has not finished, + Kern::Printf("DGeneralsDriver::NewDoProfilerProfile - Profiler Sampler Error - interrupted before finished sampling!!"); + } + } + + +TInt DGeneralsDriver::Sample() + { + return 0; + } +/* + * This function is run when any of the samplers + * requires post sampling + */ +void DGeneralsDriver::NewDoDfc(TAny* pointer) + { + DGeneralsDriver& d = *((DGeneralsDriver*)pointer); + + if(d.iState == ERunning) + { + // for all enabled samplers, perform + // post sample if needed + for(TInt i=0;iiEnabled) + { + if(d.iSamplers[i]->PostSampleNeeded()) + { + d.iSamplers[i]->PostSample(); + } + } + } + d.doingDfc--; + } + + else if(d.iState == EStopping) + { + // for all enabled samplers, + // perform end sampling + TBool releaseBuffer = false; + for(TInt i=0;iiEnabled) + { + LOGSTRING("DGeneralsDriver::NewDoDfc() - ending"); + // perform end sampling for all samplers + // stream mode samplers may be pending, if they + // are still waiting for another client buffer + if(d.iSamplers[i]->EndSampling() == KErrNotReady) + { + LOGSTRING("DGeneralsDriver::NewDoDfc() - stream data pending"); + releaseBuffer = true; + } + else + { + LOGSTRING("DGeneralsDriver::NewDoDfc() - no data pending"); + releaseBuffer = true; + } + } + } + + // At the end, once all the samplers are gone through, the buffer should be released + if (true == releaseBuffer) + { + LOGSTRING("DGeneralsDriver::NewDoDfc() - release the buffer"); + d.iSampleStream.ReleaseIfPending(); + } + + d.iState = EStopped; + if(d.iEndRequestStatus != 0 && d.iClient != 0) + { + // sampling has ended + Kern::RequestComplete(d.iClient,d.iEndRequestStatus,KErrNone); + } + } + } + + +/* + * All controls are handled here + */ + +void DGeneralsDriver::HandleMsg(TMessageBase* aMsg) + { + TInt r=KErrNone; + TThreadMessage& m=*(TThreadMessage*)aMsg; + + LOGSTRING5("DGeneralsDriver::HandleMsg 0x%x 0x%x 0x%x 0x%x",m.Int0(),m.Int1(),m.Int2(),m.Int3()); + + if(m.iValue == (TInt)ECloseMsg) + { + LOGSTRING("DGeneralsDriver::HandleMsg - received close message"); + iTimer.Cancel(); + iNewDfc.Cancel(); + m.Complete(KErrNone,EFalse); + iMsgQ.CompleteAll(KErrServerTerminated); + LOGSTRING("DGeneralsDriver::HandleMsg - cleaned up the driver!"); + return; + } + + if (m.Client()!=iClient) + { + LOGSTRING("DGeneralsDriver::HandleMsg - ERROR, wrong client"); + m.PanicClient(_L("GENERALSSAMPLER"),EAccessDenied); + return; + } + + TInt id=m.iValue; + switch(id) + { + //Controls are handled here + case RPluginSampler::EMarkTraceActive: + LOGSTRING("DGeneralsDriver::HandleMsg - EMarkTraceActive"); + r = MarkTraceActive((TInt)m.Int0()); + break; + + case RPluginSampler::EOutputSettingsForTrace: + LOGSTRING("DGeneralsDriver::HandleMsg - EOutputSettingsForTrace"); + r = OutputSettingsForTrace((TInt)m.Int0(),(TInt)m.Int1()); + break; + + case RPluginSampler::EAdditionalTraceSettings: + LOGSTRING("DGeneralsDriver::HandleMsg - EAdditionalTraceSettings"); + r = AdditionalTraceSettings((TInt)m.Int0(),(TInt)m.Int1()); + break; + + case RPluginSampler::EAdditionalTraceSettings2: + LOGSTRING("DGeneralsDriver::HandleMsg - EAdditionalTraceSettings2"); + r = AdditionalTraceSettings2((TInt)m.Int0(),(TInt)m.Int1()); + break; + + case RPluginSampler::ESetSamplingPeriod: + LOGSTRING2("DGeneralsDriver::HandleMsg - ESetSamplingPeriod %d", (TInt)m.Int1()); + r = SetSamplingPeriod((TInt)m.Int0(),(TInt)m.Int1()); + break; + + case RPluginSampler::EMarkTraceInactive: + LOGSTRING("DGeneralsDriver::HandleMsg - EMarkTraceInactive"); + r = MarkTraceInactive((TInt)m.Int0()); + break; + + case RPluginSampler::ESample: + LOGSTRING("DGeneralsDriver::HandleMsg - ESample"); + r = Sample(); + break; + + case RPluginSampler::EStartSampling: + LOGSTRING("DGeneralsDriver::HandleMsg - EStartSampling"); + r = StartSampling(); + break; + + case RPluginSampler::EGetSampleTime: + LOGSTRING("DGeneralsDriver::HandleMsg - EGetSampleTime"); + r = GetSampleTime(reinterpret_cast(m.Ptr0())); + break; + + case RPluginSampler::EGetSamplerVersion: + LOGSTRING("DGeneralsDriver::HandleMsg - EGetSamplerVersion"); + r = GetSamplerVersion(reinterpret_cast(m.Ptr0())); + break; + + case RPluginSampler::ECancelStreamRead: + LOGSTRING("DGeneralsDriver::HandleMsg - ECancelStreamRead"); + iStreamReadCancelStatus = reinterpret_cast(m.Ptr0()); + r = ProcessStreamReadCancel(); + break; + + + // Requests are handled here + + case ~RPluginSampler::EStopAndWaitForEnd: + LOGSTRING("DGeneralsDriver::HandleMsg - EStopAndWaitForEnd"); + iEndRequestStatus = reinterpret_cast(m.Ptr0()); + r = StopSampling(); + break; + + case ~RPluginSampler::ERequestFillThisStreamBuffer: + LOGSTRING("DGeneralsDriver::HandleMsg - ERequestFillThisStreamBuffer"); + r = ProcessStreamReadRequest( reinterpret_cast(m.Ptr1()), + reinterpret_cast(m.Ptr0())); + break; + + default: + LOGSTRING2("DGeneralsDriver::HandleMsg - ERROR, unknown command %d",id); + r = KErrNotSupported; + break; + } + + LOGSTRING("DGeneralsDriver::HandleMsg - Completed"); + m.Complete(r,ETrue); + } + + +inline TInt DGeneralsDriver::ProcessStreamReadRequest(TBapBuf* aBuf,TRequestStatus* aStatus) + { + LOGSTRING("DGeneralsDriver::ProcessStreamReadRequest - entry"); + + // a new sample buffer has been received from the client + iSampleStream.AddSampleBuffer(aBuf,aStatus); + + // check if we are waiting for the last data to be written to the client + if(iState == EStopped) + { + LOGSTRING("DGeneralsDriver::ProcessStreamReadRequest state = EStopped"); + + // sampling has stopped and stream read cancel is pending + // try to perform the end sampling procedure again + TBool releaseBuffer = false; + for(TInt i=0;iiEnabled /*&& samplers[i]->outputMode == 2*/) + { + //TInt pending = 0; + // stream mode samplers may be pending, if they + // are still waiting for another client buffer, + // in that case, the request should be completed already + if(iSamplers[i]->EndSampling() == KErrNotReady) + { + LOGSTRING("DGeneralsDriver::ProcessStreamReadRequest - still data pending"); + releaseBuffer = true; + } + else + { + LOGSTRING("DGeneralsDriver::ProcessStreamReadRequest - no data pending"); + releaseBuffer = true; + } + } + } + // At the end, once all the samplers are gone through, the buffer should be released + if (true == releaseBuffer) + { + LOGSTRING("DGeneralsDriver::ProcessStreamReadRequest - all data copied, release the buffer"); + iSampleStream.ReleaseIfPending(); + } + } + LOGSTRING("DGeneralsDriver::ProcessStreamReadRequest - exit"); + + return KErrNone; + } + + +/* + * Mark traces active or inactive, this can be done + * only if sampling is not running + */ + +inline TInt DGeneralsDriver::MarkTraceActive(TInt samplerIdToActivate) + { + LOGSTRING2("DGeneralsDriver::MarkTraceActive %d",samplerIdToActivate); + + for(TInt i=0;iiSamplerId == samplerIdToActivate) + { + iSamplers[i]->SetEnabledFlag(true); + return KErrNone; + } + } + + LOGSTRING2("DGeneralsDriver::MarkTraceActive - %d not supported",samplerIdToActivate); + return KErrNotSupported; + } + +inline TInt DGeneralsDriver::MarkTraceInactive(TInt samplerIdToDisable) + { + LOGSTRING2("DGeneralsDriver::MarkTraceInactive %d",samplerIdToDisable); + + for(TInt i=0;iiSamplerId == samplerIdToDisable) + { + iSamplers[i]->SetEnabledFlag(false); + return KErrNone; + } + } + + LOGSTRING2("DGeneralsDriver::MarkTraceInactive - %d not supported",samplerIdToDisable); + return KErrNotSupported; + } + +/* + * Set output settings for a trace + */ + +inline TInt DGeneralsDriver::OutputSettingsForTrace(TInt samplerId,TInt settings) + { + LOGSTRING3("DGeneralsDriver::OutputSettingsForTrace id:%d set:%d",samplerId,settings); + + for(TInt i=0;iiSamplerId == samplerId) + { + iSamplers[i]->SetOutputCombination(settings); + return KErrNone; + } + } + + return KErrNotSupported; + } + +/* + * Set additional settings for a trace + */ + +inline TInt DGeneralsDriver::AdditionalTraceSettings(TInt samplerId,TInt settings) + { + LOGSTRING3("DGeneralsDriver::SetAdditionalTraceSettings id:%d set:%d",samplerId,settings); + + for(TInt i=0;iiSamplerId == samplerId) + { + iSamplers[i]->SetAdditionalSettings(settings); + return KErrNone; + } + } + + return KErrNotSupported; + } + +inline TInt DGeneralsDriver::AdditionalTraceSettings2(TInt samplerId,TInt settings) + { + LOGSTRING3("DGeneralsDriver::SetAdditionalTraceSettings id:%d set:%d",samplerId,settings); + + for(TInt i=0;iiSamplerId == samplerId) + { + iSamplers[i]->SetAdditionalSettings2(settings); + return KErrNone; + } + } + + return KErrNotSupported; + } + +inline TInt DGeneralsDriver::SetSamplingPeriod(TInt samplerId,TInt settings) + { + LOGSTRING2("DGeneralsDriver::SetSamplingPeriod - set:%d",settings); + +// iPeriod = settings; + + for(TInt i(0);iiSamplerId == samplerId) + { + iSamplers[i]->SetSamplingPeriod(settings); + return KErrNone; + } + } + + return KErrNotSupported; + } + +/* + * Mark traces active or inactive, this can be done + * only if sampling is not running + */ + +TInt DGeneralsDriver::StartSampling() + { + LOGSTRING("DGeneralsDriver::StartSampling"); + + if(iState == EStopped) + { + // reset iSampleStartTimeProp property value + iSampleStartTime = NKern::TickCount(); // get the system tick value for sync purposes + TInt r = iSampleStartTimeProp.Set(iSampleStartTime); + + // reset all enabled samplers + for(TInt i=0;iiEnabled) + { + + // reset with stream option + LOGSTRING2(("DGeneralsDriver::StartSampling - stream reset for generals driver, sync offset %d"), 0); + iSamplers[i]->Reset(&iSampleStream, 0); + } + } + + NewStart(gppSampler.GetPeriod()); + return KErrNone; + } + else + { + return KErrGeneral; + } + } + + + diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler/plugins/GeneralsPlugin/src/GeneralsPlugin.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler/plugins/GeneralsPlugin/src/GeneralsPlugin.cpp Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,628 @@ +/* +* 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: +* +*/ + + +#include "GeneralsPlugin.h" +#include +#include + +const TInt KMaxSamplerAmount = 20; + +// LITERALS +_LIT8(KEnabled, "enabled"); +_LIT8(KSamplingPeriod, "sampling_period_ms"); +_LIT8(KBracketOpen, "["); +_LIT8(KBracketClose, "]"); + +/* + * + * class CGeneralsPlugin implementation + * + */ + +CGeneralsPlugin* CGeneralsPlugin::NewL(const TUid aImplementationUid, TAny* /*aInitParams*/) + { + LOGTEXT(_L("CGeneralsPlugin::NewL() - entry")); + CGeneralsPlugin* self = new (ELeave) CGeneralsPlugin(); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop(); + LOGTEXT(_L("CGeneralsPlugin::NewL() - exit")); + return self; + } + +CGeneralsPlugin::CGeneralsPlugin() : + iVersionDescriptor(&(this->iVersion[1]),0,19) + { + iSamplerType = PROFILER_KERNEL_MODE_SAMPLER; + iSamplerId = PROFILER_GENERALS_SAMPLER_ID; + iBufferHandler = NULL; + iEnabled = EFalse; + LOGTEXT(_L("CGeneralsPlugin::CGeneralsPlugin() - constructor")); + } + +void CGeneralsPlugin::ConstructL() + { + LOGTEXT(_L("CGeneralsPlugin::ConstructL() - entry")); + + // create attribute array + iSamplerAttributes = new(ELeave) CArrayFixFlat(KSubSamplerCount); + + TInt err = InitiateSamplerL(); + if( err != KErrNone ) + { + LOGTEXT(_L("CGeneralsPlugin::ConstructL - LEAVING, failed to load open sampler device")); + User::Leave(err); + } + + // initiate sampler attributes, i.e. settings for modification + InitiateSamplerAttributesL(); + + LOGTEXT(_L("CGeneralsPlugin::ConstructL() - exit")); + } + + +CGeneralsPlugin::~CGeneralsPlugin() + { + // clean all the members + CleanSampler(); // clean the created sampler + } + +TInt CGeneralsPlugin::InitiateSamplerL() + { + RThread me; + + LOGTEXT(_L("CGeneralsPlugin::InitiateSamplerL - #1")); + + me.SetPriority(EPriorityRealTime); + + LOGTEXT(_L("CGeneralsPlugin::InitiateSamplerL - #2")); + + // create + User::FreeLogicalDevice(KPluginSamplerName); + TInt err(KErrGeneral); + + LOGTEXT(_L("CGeneralsPlugin::InitiateSamplerL - #3")); + + err = User::LoadLogicalDevice(KPluginSamplerName); + if(err != KErrNone) + { + User::Leave(err); + } + + LOGTEXT(_L("CGeneralsPlugin::InitiateSamplerL - #4")); + + err = KErrGeneral; + + err = iGeneralsSampler.Open(); + if(err != KErrNone) + { + LOGSTRING2("CGeneralsPlugin::InitiateSamplerL - Could not open sampler device - waiting and trying again: %d", err); + User::Leave(err); + } + + LOGTEXT(_L("CGeneralsPlugin::InitiateSamplerL - #5")); + + return err; + } + +/* + * + * Default sampler attributes + * + */ +void CGeneralsPlugin::InitiateSamplerAttributesL() + { + + // + for(TInt i(0);iAppendL(attr); + break; + } + case PROFILER_GFC_SAMPLER_ID: + { + TSamplerAttributes attr2(KSamplerGfcPluginUid.iUid, + KGFCShortName(), + KGFCLongName(), + KGFCDescription(), + -1, + EFalse, + EFalse, + 0); + this->iSamplerAttributes->AppendL(attr2); + break; + } + case PROFILER_ITT_SAMPLER_ID: + { + TSamplerAttributes attr3(KSamplerIttPluginUid.iUid, + KITTShortName(), + KITTLongName(), + KITTDescription(), + -1, + EFalse, + EFalse, + 0); + this->iSamplerAttributes->AppendL(attr3); + break; + } + case PROFILER_MEM_SAMPLER_ID: + { + TSamplerAttributes attr4(KSamplerMemPluginUid.iUid, + KMEMShortName(), + KMEMLongName(), + KMEMDescription(), + 3000, + EFalse, + EFalse, + 0); + this->iSamplerAttributes->AppendL(attr4); + break; + } + case PROFILER_PRI_SAMPLER_ID: + { + TSamplerAttributes attr5(KSamplerPriPluginUid.iUid, + KPRIShortName(), + KPRILongName(), + KPRIDescription(), + 3000, + EFalse, + EFalse, + 0); + this->iSamplerAttributes->AppendL(attr5); + break; + } + } + } + } + +TInt CGeneralsPlugin::CleanSampler() + { + LOGTEXT(_L("CGeneralsPlugin::CleanSampler() - deleting buffer handler")); + // release the buffer handler + if(iBufferHandler) + { + iBufferHandler->Cancel(); + delete iBufferHandler; + iBufferHandler = NULL; + } + + LOGTEXT(_L("CGeneralsPlugin::CleanSampler() - closing sampler")); + iGeneralsSampler.Close(); + + LOGTEXT(_L("CGeneralsPlugin::CleanSampler() - Freeing sampler device")); + User::FreeLogicalDevice(KPluginSamplerName); + + // release attribute array + if(iSamplerAttributes) + { + iSamplerAttributes->Reset(); + } + delete iSamplerAttributes; + iSamplerAttributes = NULL; + + LOGTEXT(_L("CGeneralsPlugin::CleanSampler() - exit")); + + return KErrNone; + } + +// returns setting array +void CGeneralsPlugin::GetAttributesL(CArrayFixFlat* aAttributes) + { + TInt count(iSamplerAttributes->Count()); + // append all sampler attributes to aAttributes array + for(TInt i(0);iAppendL(iSamplerAttributes->At(i)); + } + } + +TInt CGeneralsPlugin::SetAttributesL(TSamplerAttributes aAttributes) + { + TSamplerAttributes attr; + + TInt count(iSamplerAttributes->Count()); + // loop the sub sampler attributes (by UID) + for(TInt i(0);iAt(i); + // if UIDs match replace the old + if(attr.iUid == aAttributes.iUid) + { + // replace the old attribute container + iSamplerAttributes->Delete(i); + iSamplerAttributes->InsertL(i, aAttributes); + return KErrNone; + } + } + return KErrNotFound; + } + +/* + * Method for parsing and transforming text array settings into TSamplerAttributes (per each sub sampler), + * called by CSamplerController class + * + * @param array of raw text setting lines, e.g. [gpp]\nenabled=true\nsampling_period_ms=1\n + */ +TInt CGeneralsPlugin::ConvertRawSettingsToAttributes(CDesC8ArrayFlat* aAllSettingsArray) + { + // local literals + _LIT8(KGPPShort, "gpp"); + _LIT8(KGFCShort, "gfc"); + _LIT8(KITTShort, "itt"); + _LIT8(KMEMShort, "mem"); + _LIT8(KPRIShort, "pri"); + + TInt err(KErrNone); + + TBuf8<16> samplerSearchName; + + // loop previous settings, update value if changed + for(TInt i(0);i samplerSearch; + samplerSearch.Copy(KBracketOpen); + samplerSearch.Append(aSamplerName); + samplerSearch.Append(KBracketClose); + + // read a line from ALL settings array + for (TInt i(0); iMdcaCount(); i++) + { + // check if this line has a setting block start, i.e. contains [xxx] in it + if (aAllSettings->MdcaPoint(i).CompareF(samplerSearch) == 0) + { + // right settings block found, now loop until the next block is found + for(TInt j(i+1);jMdcaCount();j++) + { + // check if the next settings block was found + if(aAllSettings->MdcaPoint(j).Left(1).CompareF(KBracketOpen) != 0) + { + // save found setting value directly to its owners attributes + SaveSettingToAttributes(aAllSettings->MdcaPoint(j), aIndex); + } + else + { + // next block found, return KErrNone + return KErrNone; + } + } + } + } + // no settings found for specific sampler + return KErrNotFound; + } + +/** + * Method for setting a specific descriptor (from settings file) to attribute structure + * + * @param aSetting + * @param aName + */ +void CGeneralsPlugin::SaveSettingToAttributes(const TDesC8& aSetting, TInt aIndex) + { + // local literals + _LIT8(KSettingItemSeparator, "="); + + // find the equal mark from the setting line + TInt sepPos = aSetting.Find(KSettingItemSeparator); + // check that '=' is found + if (sepPos > 0) + { + // check that the element matches + if (aSetting.Left(sepPos).CompareF(KEnabled) == 0) + { + TBool en; + CSamplerPluginInterface::Str2Bool(aSetting.Right(aSetting.Length()-sepPos-1), en); + if(en != iSamplerAttributes->At(aIndex).iEnabled) + { + iSamplerAttributes->At(aIndex).iEnabled = en; + } + } + else if (aSetting.Left(sepPos).CompareF(KSamplingPeriod) == 0) + { + TInt sr; + CSamplerPluginInterface::Str2Int(aSetting.Right(aSetting.Length()-sepPos-1), sr); + if(sr != iSamplerAttributes->At(aIndex).iSampleRate) + { + iSamplerAttributes->At(aIndex).iSampleRate = sr; + } + } + } + } + + +TUid CGeneralsPlugin::Id(TInt aSubId) const + { + if(aSubId == PROFILER_GPP_SAMPLER_ID) + return KSamplerGppPluginUid; + else if (aSubId == PROFILER_GFC_SAMPLER_ID) + return KSamplerGfcPluginUid; + else if (aSubId == PROFILER_ITT_SAMPLER_ID) + return KSamplerIttPluginUid; + else if (aSubId == PROFILER_MEM_SAMPLER_ID) + return KSamplerMemPluginUid; + else if (aSubId == PROFILER_PRI_SAMPLER_ID) + return KSamplerPriPluginUid; + else + return KSamplerGeneralsPluginUid; + } + +TInt CGeneralsPlugin::SubId(TUid aId) const + { +/* definitions from ProfilerConfig.h: + * #define PROFILER_GPP_SAMPLER_ID 1 + #define PROFILER_GFC_SAMPLER_ID 2 + #define PROFILER_ITT_SAMPLER_ID 3 + #define PROFILER_MEM_SAMPLER_ID 4 + #define PROFILER_PRI_SAMPLER_ID 5 + */ + + if(aId == KSamplerGppPluginUid) + return PROFILER_GPP_SAMPLER_ID; + else if (aId == KSamplerGfcPluginUid) + return PROFILER_GFC_SAMPLER_ID; + else if (aId == KSamplerIttPluginUid) + return PROFILER_ITT_SAMPLER_ID; + else if (aId == KSamplerMemPluginUid) + return PROFILER_MEM_SAMPLER_ID; + else if (aId == KSamplerPriPluginUid) + return PROFILER_PRI_SAMPLER_ID; + else + return KErrNotFound; + } + +TInt CGeneralsPlugin::GetSamplerType() + { + return iSamplerType; + } + +//TInt CGeneralsPlugin::GetSubCount() +// { +// return (TInt)KSubSamplerCount; +// } + + +TInt CGeneralsPlugin::GetSamplerUidByName(TDesC8& aName) + { + if(aName.Compare(KGPPShortName) == 0) + { + LOGTEXT(_L("GPP trace option")); + return KSamplerGppPluginUid.iUid; + } + else if(aName.Compare(KGFCShortName) == 0) + { + LOGTEXT(_L("GFC trace option")); + return KSamplerGfcPluginUid.iUid; + } + else if(aName.Compare(KITTShortName) == 0) + { + LOGTEXT(_L("ITT trace option")); + return KSamplerIttPluginUid.iUid; + } + else if(aName.Compare(KMEMShortName) == 0) + { + LOGTEXT(_L("MEM trace option")); + return KSamplerMemPluginUid.iUid; + } + else if(aName.Compare(KPRIShortName) == 0) + { + LOGTEXT(_L("PRI trace option")); + return KSamplerPriPluginUid.iUid; + } + + return -1; + + } + +void CGeneralsPlugin::GetCaption( TDes& aCaption, TInt aType, TInt aSubId ) const + { + if(aSubId == -1) + { + aCaption.Copy(_L("")); + return; + } + else if(aSubId == KSamplerGppPluginUid.iUid) + { + aCaption.Copy(KGPPShortName); + } + else if(aSubId == KSamplerIttPluginUid.iUid) + { + aCaption.Copy(KITTShortName); + } + else if(aSubId == KSamplerGfcPluginUid.iUid) + { + aCaption.Copy(KGFCShortName); + } + else if(aSubId == KSamplerMemPluginUid.iUid) + { + aCaption.Copy(KMEMShortName); + } + else if(aSubId == KSamplerPriPluginUid.iUid) + { + aCaption.Copy(KPRIShortName); + } + else + { + aCaption.Copy(KGENShortName); + } + + aCaption.TrimRight(); + LOGSTRING2("CGeneralsPlugin::GetCaptionL() - plug-in name: %S", &aCaption); + } + + +void CGeneralsPlugin::InstallStreamForActiveTraces(RGeneralsSampler& sampler, CProfilerSampleStream& aStream) + { + // output mode for this trace is stream + if(!iBufferHandler) + { + // stream object has not been created yet + LOGTEXT(_L("CGeneralsPlugin::InstallStreamForActiveTraces - creating stream for trace")); + + // use a 32KB buffer to transfer data from sampler to client + // commonStream = new RProfilerSampleStream(sampler,totalPrefix,32768); + TRAPD(err, iBufferHandler = CProfilerBufferHandler::NewL(aStream, sampler)); + if(err != KErrNone) + { + LOGTEXT(_L("CGeneralsPlugin::InstallStreamForActiveTraces() - No memory")); + return; + } + } + + // initiate receiving of data from the sampler device driver + if(iBufferHandler) + { + iBufferHandler->StartReceivingData(); + } +} + +void CGeneralsPlugin::SetSettingsToSamplers() + { + TSamplerAttributes attr; + + // loop through the setting attributes + for(TInt i(0);iCount();i++) + { + // get the attribute container + attr = iSamplerAttributes->At(i); + + // make changes according to right sampler, NOTE! The old IDs of sub samplers (i+1)! + if(attr.iEnabled) + { + iGeneralsSampler.MarkTraceActive(i+1); + + // set enabled + iEnabled = ETrue; + } + else + { + iGeneralsSampler.MarkTraceInactive(i+1); + } + // set sampling period if available + if(attr.iSampleRate != KErrNotFound) + { + iGeneralsSampler.SetSamplingPeriod(i+1, attr.iSampleRate); + } + } + } + +TInt CGeneralsPlugin::ResetAndActivateL(CProfilerSampleStream& aStream) + { + // the sampler starting functionality + LOGTEXT(_L("CGeneralsPlugin::ResetAndActivate() - entry")); + + // now before starting the latest settings must be set to samplers itself + SetSettingsToSamplers(); + + if(Enabled()) + { + LOGTEXT(_L("CGeneralsPlugin::ResetAndActivate() - starting sampling...")); + // start sampling process of enabled sub samplers + iGeneralsSampler.StartSampling(); + LOGTEXT(_L("CGeneralsPlugin::ResetAndActivate() - installing stream for an active trace...")); + + // install the trace for enabled samplers + InstallStreamForActiveTraces(iGeneralsSampler, aStream); + LOGSTRING2("CGeneralsPlugin::ResetAndActivate() - stream installed: 0x%x", aStream); + } + + LOGTEXT(_L("CGeneralsPlugin::ResetAndActivate() - exit")); + return KErrNone; + } + +TInt CGeneralsPlugin::StopSampling() + { + // RDebug::Print(_L("CGeneralsPlugin::StopSampling() - Stopping sampler LDD")); + iGeneralsSampler.StopSampling(); + // RDebug::Print(_L("CGeneralsPlugin::StopSampling() - Sampler LDD stopped")); + + // check if bufferhandler has died + if(iBufferHandler) + { + // RDebug::Print(_L("CGeneralsPlugin::StopSampling() - Canceling the buffer handler")); + iBufferHandler->Cancel(); + delete iBufferHandler; + iBufferHandler = NULL; + } + // set enabled + iEnabled = EFalse; + // RDebug::Print(_L("CGeneralsPlugin::StopSampling() - exit")); + return KErrNone; + } + + + diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler/plugins/GeneralsPlugin/src/GeneralsPluginImplementationTable.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler/plugins/GeneralsPlugin/src/GeneralsPluginImplementationTable.cpp Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,39 @@ +/* +* 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: +* +*/ + + +// INCLUDE FILES +#include +#include + +#include "GeneralsPlugin.h" + + +// Provides a key value pair table, this is used to identify +// the correct construction function for the requested interface. +const TImplementationProxy ImplementationTable[] = +{ + IMPLEMENTATION_PROXY_ENTRY(0x2001E5B2, CGeneralsPlugin::NewL) +}; + +// Function used to return an instance of the proxy table. +EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) +{ + aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); + return ImplementationTable; +} + diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler/plugins/GeneralsPlugin/src/GeneralsSampler.cia --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler/plugins/GeneralsPlugin/src/GeneralsSampler.cia Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,67 @@ +/* +* 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: +* +*/ + + +#include + +#include "GeneralsDriver.h" +#include //temporary + +#ifdef __WINS__ +__NAKED__ TUint* IntStackPtr() +{ + return 0; +} + +__NAKED__ TUint32 SPSR() +{ + return 0; +} +__NAKED__ void UsrModLr(TUint32* a) +{ + *a = 0; +} +#else + +__NAKED__ TUint* IntStackPtr() +{ + asm("mrs r1, cpsr "); + asm("bic r3, r1, #0x1f "); +//#ifdef __MISA__ +// asm("orr r3, r3, #0xd1 "); // mode_fiq, all interrupts off +//#else + asm("orr r3, r3, #0xd2 "); // mode_irq, all interrupts off +//#endif + asm("msr cpsr, r3 "); + asm("mov r0, sp "); // r0=sp_irq or sp_fiq + asm("msr cpsr, r1 "); // restore interrupts + __JUMP(,lr); +} + +__NAKED__ TUint32 SPSR() +{ + asm("mrs r0, spsr "); + __JUMP(,lr); +} +__NAKED__ void UsrModLr(TUint32*) +{ + // r0 = address to store + asm ("stmia r0,{lr}^"); + __JUMP(,lr); +} + +#endif diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler/plugins/GeneralsPlugin/src/GppSamplerImpl.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler/plugins/GeneralsPlugin/src/GppSamplerImpl.cpp Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,488 @@ +/* +* 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: +* +*/ + + +#include +#include +#include + +#include "GppSamplerImpl.h" + +extern TUint* IntStackPtr(); +#define TAG(obj) (*(TUint32*)&(obj.iAsyncDeleteNext)) + +// properties for ISA task parsing +const TUid KIsaPropertyCat={0x2001E5AD}; +enum TIsaPropertyKeys + { + EIsaPropertyIsaTaskParserStatus = 1, + EIsaPropertyIsaTaskAddressStart, + EIsaPropertyIsaTaskAddressEnd, + EIsaPropertyIsaTaskAddress, + EIsaPropertyIsaOsTaskRunningAddress, + EIsaPropertyIsaTaskParsedName + }; + + +GppSamplerImpl::GppSamplerImpl() + { + LOGTEXT("GppSamplerImpl::GppSamplerImpl"); + iInterruptStack = (TUint*)IntStackPtr(); + + LOGTEXT("GppSamplerImpl::GppSamplerImpl - attaching to properties"); + + TInt err = iIsaStartAddr.Attach(KIsaPropertyCat, EIsaPropertyIsaTaskAddressStart); + if(err != KErrNone) + LOGTEXT("GppSamplerImpl::GppSamplerImpl() - Property EIsaPropertyIsaTaskAddressStart not available"); + err = iIsaEndAddr.Attach(KIsaPropertyCat, EIsaPropertyIsaTaskAddressEnd); + if(err != KErrNone) + LOGTEXT("GppSamplerImpl::GppSamplerImpl() - Property EIsaPropertyIsaTaskAddressEnd not available"); + err = iIsaPluginStatus.Attach(KIsaPropertyCat, EIsaPropertyIsaTaskParserStatus); + if(err != KErrNone) + LOGTEXT("GppSamplerImpl::GppSamplerImpl() - Property EIsaPropertyIsaTaskParserStatus not available"); + err = iIsaOsTaskRunning.Attach(KIsaPropertyCat, EIsaPropertyIsaOsTaskRunningAddress); + if(err != KErrNone) + LOGTEXT("GppSamplerImpl::GppSamplerImpl() - Property EIsaPropertyIsaOsTaskRunningAddress not available"); + + PROFILER_ISA_TASK_NAMES + + Reset(); + } + +GppSamplerImpl::~GppSamplerImpl() + { + iIsaStartAddr.Close(); + iIsaEndAddr.Close(); + iIsaPluginStatus.Close(); + iIsaOsTaskRunning.Close(); + } + +void GppSamplerImpl::Reset() + { + LOGTEXT("GppSamplerImpl::Reset"); + iLastPc = 0; + iLastThread = 0; + iRepeat = 0; + iIsaStatus = 0; + iIsaStart = 0; + iIsaEnd = 0; +// isaOsTaskRunningAddr = 0; + iStartTime=( NKern::TickCount() & 0xfffffffc ); + + TPropertyStatus status; + TInt osAddr = 0; + + LOGTEXT("GppSamplerImpl::Reset - getting status"); + + // get status of ISA plug-in + if(iIsaPluginStatus.GetStatus(status)) + { + iIsaPluginStatus.Get(iIsaStatus); + LOGSTRING2("GppSamplerImpl::Reset - ISA plug-in status %d", iIsaStatus); + } + + if(iIsaStatus > 0) + { + LOGTEXT("GppSamplerImpl::Reset - get isa start address"); + iIsaStartAddr.Get(iIsaStart); + LOGTEXT("GppSamplerImpl::Reset - get isa end address"); + iIsaEndAddr.Get(iIsaEnd); + LOGTEXT("GppSamplerImpl::Reset - get isa os_task_running address"); + iIsaOsTaskRunning.Get(osAddr); + isaOsTaskRunningAddr = reinterpret_cast(osAddr); + LOGSTRING2("GppSamplerImpl::Reset - got isa os_task_running address 0x%X", osAddr); + } + + LOGTEXT("GppSamplerImpl::Reset - initializing isa task list"); + + iIsaSample = false; + + for(TInt i=0;i<256;i++) + knownIsaTasks[i] = -1; + + knownIsaTaskCount = 0; + + } + +TUint8* GppSamplerImpl::EncodeTag(TUint8* aPtr) +// +// Encode a tag and version to the trace data. This allows the offline analyser to +// identify the sample data. +// +{ + _LIT(KGppSamplerVersion,"Bappea_GPP_V"); + _LIT(KProfilerVersion,"#Prof#"); + _LIT(KSamplerVersion,"#Samp#"); + + TBuf<64> buf; + buf.Zero(); + buf.Append(KGppSamplerVersion); + buf.Append(PROFILER_GPP_SAMPLER_VERSION); + buf.Append(KProfilerVersion); + buf.Append(PROFILER_VERSION_SHORT); + buf.Append(KSamplerVersion); + buf.Append(PROFILER_SAMPLER_VERSION); + aPtr = EncodeText(aPtr, buf); + return aPtr; +} + +TUint8* GppSamplerImpl::EncodeInt(TUint8* aPtr,TInt aValue) +{ + LOGSTRING2("Encoding int 0x%x",aPtr); + + LOGSTRING2("TIint = 0x%x",aValue); + + TUint byte; + for (;;) + { + byte = aValue & 0x7f; + if ((aValue >> 6) == (aValue >> 7)) + break; + aValue >>= 7; + *aPtr++ = byte; + } + *aPtr++ = byte | 0x80; + + LOGSTRING2("Encoded int 0x%x",aPtr); + + return aPtr; +} + +TUint8* GppSamplerImpl::EncodeUint(TUint8* aPtr,TUint aValue) +{ + LOGSTRING2("Encoding Uint 0x%x",aPtr); + + LOGSTRING2("TUint = 0x%x",aValue); + + + TUint byte; + for (;;) + { + byte = aValue & 0x7f; + aValue >>= 7; + if (aValue == 0) + break; + *aPtr++ = byte; + } + *aPtr++ = byte | 0x80; + + LOGSTRING2("Encoded Uint 0x%x",aPtr); + + return aPtr; +} + +TUint8* GppSamplerImpl::EncodeText(TUint8* aPtr, const TDesC& aDes) +// +// Encode a descriptor into the data stream +// This is currently limited to a descriptor that is up to 255 characters in length, +// and Unicode characters are truncated to 8 bits +// +{ + LOGSTRING2("Encoding text 0x%x",aPtr); + TInt len=aDes.Length(); + *aPtr++ = TUint8(len); + const TText* p = aDes.Ptr(); + while (--len >= 0) + { + *aPtr++ = TUint8(*p++); + } + + LOGSTRING2("Encoded text 0x%x",aPtr); + return aPtr; +} + + +TUint8* GppSamplerImpl::EncodeName(TUint8* aPtr, DObject& aObject,TUint32 id) +// +// Encode the name of a kernel object +// +{ + LOGSTRING2("Encoding name 0x%x",aPtr); + TBuf8<0x5f> name; + aObject.TraceAppendName(name,false); + + if(id != 0xffffffff) + { + name.Append('['); + name.AppendNum(id,EHex); + name.Append(']'); + } + else + { + name.Append('['); + name.AppendNum((TUint32)((void*)&(((DThread*)&aObject)->iNThread)),EHex); + name.Append(']'); + } + + aPtr = EncodeText(aPtr,name); + LOGSTRING2("Encoded name 0x%x",aPtr); + return aPtr; +} + +TUint8* GppSamplerImpl::EncodeThread(TUint8* aPtr, DThread& aThread) +// +// Encode a thread name in the data stream. +// The thread is identified by its name, and the identity of its owning process. +// If the process has not been identified in the data stream already, it's name is +// also encoded. +// +{ + LOGSTRING2("Encoding thread 0x%x",aPtr); + + DProcess& p = *aThread.iOwningProcess; + + aPtr = EncodeUint(aPtr, p.iId); + if (TAG(p) != iStartTime) + { + TAG(p) = iStartTime; + // Provide the name matching this process ID + aPtr = EncodeName(aPtr, p, p.iId); + } + aPtr = EncodeName(aPtr, aThread,0xffffffff); + + LOGSTRING2("Encoded thread 0x%x",aPtr); + + return aPtr; +} + +TUint8* GppSamplerImpl::EncodeRepeat(TUint8* aPtr) +// +// Encode a repeated sequence of samples +// +{ + LOGSTRING2("Encoding repeat, 0x%x",iRepeat); + + aPtr = EncodeInt(aPtr, 0); + aPtr = EncodeUint(aPtr, iRepeat); + iRepeat = 0; + + LOGSTRING2("Encoded repeat, 0x%x",iRepeat); + + return aPtr; +} + +TInt GppSamplerImpl::CreateFirstSample() +{ + LOGTEXT("GppSamplerImpl::CreateFirstSample"); + Reset(); + + TUint8* w = this->tempBuf; + w = EncodeTag(w); + + TInt length = w-tempBuf; + + LOGSTRING2("TAG encoded, length %d",length); + return length; +} + +TBool GppSamplerImpl::IsaTaskKnown(TUint8 task) +{ + for(TInt i=0;i<256;i++) + { + if(knownIsaTasks[i] == -1) + { + knownIsaTasks[i] = task; + knownIsaTaskCount++; + return false; + } + else if(knownIsaTasks[i] == task) + { + return true; + } + } + + return false; +} + +TUint8* GppSamplerImpl::EncodeIsaTask(TUint8* aPtr, TUint task) + +{ + LOGSTRING2("Encoding ISA task 0x%x",aPtr); + + aPtr = EncodeUint(aPtr,task); + // use the task name as the process name + aPtr = EncodeIsaName(aPtr,task,true); + // then encode the task name + aPtr = EncodeIsaName(aPtr,task,false); + + LOGSTRING2("Encoded ISA task 0x%x",aPtr); + + return aPtr; +} + +TUint8* GppSamplerImpl::EncodeIsaName(TUint8* aPtr, TUint task,TBool process) +// +// Encode a descriptor into the data stream +// This is currently limited to a descriptor that is up to 255 characters in length, +// and Unicode characters are truncated to 8 bits +// +{ + TBuf8<256> aDes; + +// #ifdef NCP_COMMON_PROFILER_ISA_TASKS + if(iIsaStatus > 0) + { + // resolve the isa task name from the task name array + if((task-100000) < PROFILER_ISA_OS_TASK_AMOUNT && process == false) + { + aDes.Append(isaTaskNames[(task-100000)]); + } + else + { + aDes.Append(_L8("NativeOS_Task")); + } + } + else + { + aDes.Append(_L8("NativeOS_Task")); + } + + aDes.Append('['); + aDes.AppendNum((task-100000),EHex); + aDes.Append(']'); + + LOGSTRING2("Encoding ISA name 0x%x",aPtr); + TInt len=aDes.Length(); + *aPtr++ = TUint8(len); + const TText* p = aDes.Ptr(); + while (--len >= 0) + { + *aPtr++ = TUint8(*p++); + } + + LOGSTRING2("Encoded ISA name 0x%x",aPtr); + return aPtr; +} + + +TInt GppSamplerImpl::SampleImpl() +// +// ISR for the profile timer +// This extracts the thread and PC that was current when the interrupt went off and +// encodes it into the sample data buffer. If enough data has been generated, the +// DFC is triggered to complete a read request +// +{ + TUint8* w = this->tempBuf; + + TUint32 pc = iInterruptStack[-1]; + LOGSTRING3("pc value 0x%x sp 0x%x",pc,iInterruptStack); + + // ignore the low bit being set for THUMB mode - we use for something else + pc &= ~1; + TInt diff = pc - iLastPc; + iLastPc = pc; + + if(iIsaStatus > 0) + { + if((TUint32)pc > (TUint32)iIsaStart && (TUint32)pc < (TUint32)iIsaEnd) + { + LOGSTRING2("Identified ISA execution at 0x%x",pc); + iIsaSample = true; + } + else + { + LOGSTRING2("Normal sample at 0x%x",pc); + iIsaSample = false; + } + } + + DThread& t = Kern::CurrentThread(); + + TUint tid; + TUint8 isaTask = 0; + if(iIsaSample) + { + LOGSTRING2("Reading ISA task number from 0x%x",isaOsTaskRunningAddr); + + // if we don't get reasonable ISA address to read, skip ISA task handling + if(isaOsTaskRunningAddr == 0) + { + tid = 100000; // to tell the difference from SOS threads + iIsaSample = false; + } + else // normal ISA task parsing process + { + isaTask = *isaOsTaskRunningAddr; + LOGSTRING2("ISA task = %d",isaTask); + tid = isaTask; + // this will make sure we don't mix ISA tasks and normal tasks + tid += 100000; + } + + } + else + { + tid = t.iId; + } + + if (tid != iLastThread) + { + // Change of thread is marked in the low bit of the PC difference + diff |= 1; + } + TUint rp = iRepeat; + if (diff == 0) + { + // Identical sample, bump up the repeat count + iRepeat = rp + 1; + } + else + { + if (rp) + { + // Encode the repeat data + w = EncodeRepeat(w); + } + // Encode the PC difference + w = EncodeInt(w, diff); + if (diff & 1) + { + // Encode the new thread ID + if(iIsaSample) + { + iLastThread = tid; + w = EncodeUint(w,tid); + + if(!this->IsaTaskKnown(isaTask)) + { + w = EncodeIsaTask(w,iLastThread); + } + //LOGSTRING2("Sample total length: %d",w-tempBuf); + TInt length = w-tempBuf; + // encoded isa task, return here + return length; + } + + iLastThread = tid; + w = EncodeUint(w, tid); + + if ((TAG(t) & 0xfffffffc) != iStartTime) + { + + TAG(t) = ((TAG(t) & 0x3) | iStartTime); + // The thread is 'unknown' to this sample, so encode the thread name + w = EncodeThread(w, t); + } + } + } + LOGSTRING2("Sample total length: %d",w-tempBuf); + TInt length = w-tempBuf; + + return length; +} + diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler/plugins/GeneralsPlugin/src/IttSamplerImpl.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler/plugins/GeneralsPlugin/src/IttSamplerImpl.cpp Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,560 @@ +/* +* 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: +* +*/ + + +#include + +#include +#include + +#include "IttSamplerImpl.h" + +/* + * + * ITT sampler definition + * + */ + +IttSamplerImpl::IttSamplerImpl() +{ + this->ptrToData = new TPtr8(((TUint8*)&(this->internalData[1])),255); + this->currentLibCount = 0; + this->currentProcCount = 0; + this->iSampleProcesses = false; + + this->Reset(); +} + +IttSamplerImpl::~IttSamplerImpl() +{ + delete(this->ptrToData); +} + +TInt IttSamplerImpl::CreateFirstSample() +{ + this->iVersionData.Zero(); + this->iVersionData.Append(_L8("Bappea_ITT_V")); + this->iVersionData.Append(PROFILER_ITT_SAMPLER_VERSION); + this->itt_sample = (TUint8*)iVersionData.Ptr(); + return iVersionData.Length(); +} + +TBool IttSamplerImpl::SampleNeeded(TUint32 sampleNum) +{ + return true; +} + +TInt IttSamplerImpl::SampleImpl(TUint32 pc,TUint32 sampleNum) +{ + // in order to avoid overloading the interrupt + // only one dynamic file in each 50ms is added to the stream + // with the application of the tool in mind, this is + // a reasonable measure + +// #ifdef ITT_TEST + //if(iSampleProcesses) + { + // encode a process binary + ptrToData->Zero(); + + //static RPointerArray array = DCodeSeg::CodeSegsByName; + //TInt arrayCount = array.Count(); + + /* mietintää... + + DCodeSeg* pSeg = Kern::CodeSegFromAddress( (TLinAddr)aPtr, TheCurrentThread->iOwningProcess ); + if (!pSeg) + { + return KErrNotFound; + } + Kern::KUDesPut(aModuleName, *pSeg->iFileName); + + // lisää pohdintaa + + TInt n=0; + TInt i; + TInt c=iDynamicCode.Count(); // DProcess.iDynamicCode, type = RArray, SCodeSegEntry->iSeg/iLib + for (i=-1; i=0) + { + DLibrary* pL=iDynamicCode[i].iLib; + if (pL && pL->iState!=DLibrary::EAttached) + continue; + } + if (aFlags & ETraverseFlagAdd) + n+=pS->ListDeps(aQ,aMark); + else + n+=pS->UnListDeps(aMark); + } + } + + + */ + +/* + // testi... + // encode a process binary + //Kern::Printf("Get Processes from container..."); + DObjectCon* proc = Kern::Containers()[EProcess]; + TInt procCount = proc->Count(); + + //Kern::Printf("Got count of processes: %d", procCount); + + // go 20 executables through at a time + for(TInt i=0;iiDynamicCode.Count(); // DProcess.iDynamicCode, type = RArray, SCodeSegEntry->iSeg/iLib + + //Kern::Printf("DProcess: count of segments %d", c); + for (TInt i=-1; iiCodeSeg:pro->iDynamicCode[i].iSeg; + if(seg != 0) + { + if( (seg->iMark & 0x80) == 0) + { + this->internalData[0] = seg->iFileName->Length(); + ptrToData->Append(*(seg->iFileName)); + ptrToData->Append((TUint8*)&(seg->iRunAddress),4); + ptrToData->Append((TUint8*)&(seg->iSize),4); + //Kern::Printf("EXE1: NM %S : RA:0x%x SZ:0x%x",seg->iFileName,seg->iRunAddress,seg->iSize); + seg->iMark = (seg->iMark | 0x80); + + this->internalData[0] = ptrToData->Size(); + return ptrToData->Size()+1; + } + } + } + } +*/ +/* + + DObjectCon* libs = Kern::Containers()[ELibrary]; + TInt libCount = libs->Count(); + + //Kern::Printf("Got count of processes: %d", procCount); + + // go 20 executables through at a time + for(TInt i=0;iiCodeSeg; + if(seg != 0) + { + if( (seg->iMark & 0x80) == 0) + { + this->internalData[0] = seg->iFileName->Length(); + ptrToData->Append(*(seg->iFileName)); + ptrToData->Append((TUint8*)&(seg->iRunAddress),4); + ptrToData->Append((TUint8*)&(seg->iSize),4); + Kern::Printf("DLL: NM %S : RA:0x%x SZ:0x%x",seg->iFileName,seg->iRunAddress,seg->iSize); + seg->iMark = (seg->iMark | 0x80); + + this->internalData[0] = ptrToData->Size(); + return ptrToData->Size()+1; + } + } + } +*/ + // original + if((sampleNum % 20) != 0) return 0; + if((sampleNum % 40) == 0) + { +/* + if((sampleNum % 60) == 0) + { + // encode a process binary + ptrToData->Zero(); + DObjectCon* proc = Kern::Containers()[EProcess]; + TInt procCount = proc->Count(); + + // go 20 executables through at a time + for(TInt i=0;i<20;i++) + { + if(currentProcCount >= procCount) + { + currentProcCount = 0; + } + + DProcess* pro = (DProcess*)(*proc)[currentProcCount]; + currentProcCount++; + + DCodeSeg* seg = pro->iCodeSeg; + if(seg != 0) + { + if( (seg->iMark & 0x80) == 0) + { + this->internalData[0] = seg->iFileName->Length(); + ptrToData->Append(*(seg->iFileName)); + ptrToData->Append((TUint8*)&(seg->iRunAddress),4); + ptrToData->Append((TUint8*)&(seg->iSize),4); + //Kern::Printf("EXE: NM %S : RA:0x%x SZ:0x%x",seg->iFileName,seg->iRunAddress,seg->iSize); + seg->iMark = (seg->iMark | 0x80); + + this->internalData[0] = ptrToData->Size(); + return ptrToData->Size()+1; + } + } + } + } else + { */ + // encode a library binary + ptrToData->Zero(); + DObjectCon* libs = Kern::Containers()[ELibrary]; + TInt libCount = libs->Count(); + + // go 20 binaries through at a time + for(TInt i=0;i<20;i++) + { + if(currentLibCount >= libCount) + { + currentLibCount = 0; + } + + DLibrary* lib = (DLibrary*)(*libs)[currentLibCount]; + currentLibCount++; + + DCodeSeg* seg = lib->iCodeSeg; + if(seg != 0) + { + if( (seg->iMark & 0x80) == 0) + { + this->internalData[0] = seg->iFileName->Length(); + ptrToData->Append(*(seg->iFileName)); + ptrToData->Append((TUint8*)&(seg->iRunAddress),4); + ptrToData->Append((TUint8*)&(seg->iSize),4); + //Kern::Printf("DLL: NM %S : RA:0x%x SZ:0x%x",seg->iFileName,seg->iRunAddress,seg->iSize); + seg->iMark = (seg->iMark | 0x80); + + this->internalData[0] = ptrToData->Size(); + return ptrToData->Size()+1; + } + } + } + } else + { + SDblQue* codeSegList = Kern::CodeSegList(); + //Kern::Printf("PI"); + //TUint c = 0; + // the global list + for (SDblQueLink* codeseg= codeSegList->First(); codeseg!=(SDblQueLink*) codeSegList; codeseg=codeseg->iNext) + { + DCodeSeg* seg = _LOFF(codeseg, DCodeSeg, iLink); + if(seg != 0) + { + if( (seg->iMark & 0x80) == 0) + { + this->internalData[0] = seg->iFileName->Length(); + ptrToData->Append(*(seg->iFileName)); + ptrToData->Append((TUint8*)&(seg->iRunAddress),4); + ptrToData->Append((TUint8*)&(seg->iSize),4); + //Kern::Printf("EXE2: NM %S : RA:0x%x SZ:0x%x, time: %d",seg->iFileName,seg->iRunAddress,seg->iSize, sampleNum); + seg->iMark = (seg->iMark | 0x80); + + this->internalData[0] = ptrToData->Size(); + return ptrToData->Size()+1; + } + } + } + } + +/* + // the garbage list + for (SDblQueLink* codeseg= codeSegList->First(); codeseg!=(SDblQueLink*) codeSegList; codeseg=codeseg->iNext) + { + DCodeSeg* seg = _LOFF(codeseg,DCodeSeg, iGbgLink); + if(seg != 0) + { + if( (seg->iMark & 0x80) == 0) + { + this->internalData[0] = seg->iFileName->Length(); + ptrToData->Append(*(seg->iFileName)); + ptrToData->Append((TUint8*)&(seg->iRunAddress),4); + ptrToData->Append((TUint8*)&(seg->iSize),4); + //Kern::Printf("EXE2: NM %S : RA:0x%x SZ:0x%x, time: %d",seg->iFileName,seg->iRunAddress,seg->iSize, sampleNum); + seg->iMark = (seg->iMark | 0x80); + + this->internalData[0] = ptrToData->Size(); + return ptrToData->Size()+1; + } + } + } +*/ + + // Another try +// Kern::AccessCode(); + + //Collect all non-XIP segments that are not already marked. +/* + SDblQue* p = Kern::CodeSegList(); + SDblQueLink* anchor=&p->iA; + SDblQueLink* a=anchor->iNext; + for (; a!=anchor; a=a->iNext) + { + DEpocCodeSeg* pSeg = (DEpocCodeSeg*) _LOFF(a, DCodeSeg, iLink); + if (pSeg != 0) + { + if (pSeg->iXIP || pSeg->iMark&DCodeSeg::EMarkProfilerTAG) + { + //continue; + //if (current > (max-KMaxCreateCodeSegRecordSize)) + // break;//No more space. Finish now and wait for another GetSegments request. + + pSeg->iMark |= DCodeSeg::EMarkProfilerTAG; //Mark this segment + this->internalData[0] = pSeg->iFileName->Length(); + ptrToData->Append(*(pSeg->iFileName)); + ptrToData->Append((TUint8*)&(pSeg->iRunAddress),4); + ptrToData->Append((TUint8*)&(pSeg->iSize),4); + //Kern::Printf("EXE2: NM %S : RA:0x%x SZ:0x%x, time: %d",seg->iFileName,seg->iRunAddress,seg->iSize, sampleNum); + + this->internalData[0] = ptrToData->Size(); + return ptrToData->Size()+1; + } + } + } +*/ + +// Kern::EndAccessCode(); + + //Kern::Printf("PO"); + +/* + for(TInt i=0;iiMark & 0x80) == 0) + { + this->internalData[0] = seg->iFileName->Length(); + ptrToData->Append(*(seg->iFileName)); + ptrToData->Append((TUint8*)&(seg->iRunAddress),4); + ptrToData->Append((TUint8*)&(seg->iSize),4); + //Kern::Printf("EXE: NM %S : RA:0x%x SZ:0x%x",seg->iFileName,seg->iRunAddress,seg->iSize); + seg->iMark = (seg->iMark | 0x80); + + this->internalData[0] = ptrToData->Size(); + return ptrToData->Size()+1; + } + } + } +*/ + } +/* + #else + if((sampleNum % 50) != 0) return 0; + if((sampleNum % 100) == 0) + { + // encode a process binary + ptrToData->Zero(); + DObjectCon* proc = Kern::Containers()[EProcess]; + TInt procCount = proc->Count(); + + // go 20 executables through at a time + for(TInt i=0;i<20;i++) + { + if(currentProcCount >= procCount) + { + currentProcCount = 0; + } + + DProcess* pro = (DProcess*)(*proc)[currentProcCount]; + currentProcCount++; + + DCodeSeg* seg = pro->iCodeSeg; + if(seg != 0) + { + if( (seg->iMark & 0x80) == 0) + { + this->internalData[0] = seg->iFileName->Length(); + ptrToData->Append(*(seg->iFileName)); + ptrToData->Append((TUint8*)&(seg->iRunAddress),4); + ptrToData->Append((TUint8*)&(seg->iSize),4); + //Kern::Printf("EXE: NM %S : RA:0x%x SZ:0x%x",seg->iFileName,seg->iRunAddress,seg->iSize); + seg->iMark = (seg->iMark | 0x80); + + this->internalData[0] = ptrToData->Size(); + return ptrToData->Size()+1; + } + } + } + } + else + { + // encode a library binary + ptrToData->Zero(); + DObjectCon* libs = Kern::Containers()[ELibrary]; + TInt libCount = libs->Count(); + + // go 20 binaries through at a time + for(TInt i=0;i<20;i++) + { + if(currentLibCount >= libCount) + { + currentLibCount = 0; + } + + DLibrary* lib = (DLibrary*)(*libs)[currentLibCount]; + currentLibCount++; + + DCodeSeg* seg = lib->iCodeSeg; + if(seg != 0) + { + if( (seg->iMark & 0x80) == 0) + { + this->internalData[0] = seg->iFileName->Length(); + ptrToData->Append(*(seg->iFileName)); + ptrToData->Append((TUint8*)&(seg->iRunAddress),4); + ptrToData->Append((TUint8*)&(seg->iSize),4); + //Kern::Printf("DLL: NM %S : RA:0x%x SZ:0x%x",seg->iFileName,seg->iRunAddress,seg->iSize); + seg->iMark = (seg->iMark | 0x80); + + this->internalData[0] = ptrToData->Size(); + return ptrToData->Size()+1; + } + } + } + } + #endif +*/ + return 0; + +} + +void IttSamplerImpl::Reset() +{ + this->currentLibCount = 0; + this->currentProcCount = 0; + this->itt_sample = (TUint8*)&(this->internalData[0]); + ptrToData->Zero(); + +// #ifdef ITT_TEST + + SDblQue* codeSegList = Kern::CodeSegList(); + // the global list + for (SDblQueLink* codeseg= codeSegList->First(); codeseg!=(SDblQueLink*) codeSegList; codeseg=codeseg->iNext) + { + DCodeSeg* seg = _LOFF(codeseg,DCodeSeg, iLink); + //if(seg != 0) + { + if( (seg->iMark & 0x80) > 0) + { + seg->iMark = (seg->iMark & ~0x80); + } + } + } + + // the garbage list +/* + for (SDblQueLink* codeseg= codeSegList->First(); codeseg!=(SDblQueLink*) codeSegList; codeseg=codeseg->iNext) + { + DCodeSeg* seg = _LOFF(codeseg,DCodeSeg, iGbgLink); + if(seg != 0) + { + if( (seg->iMark & 0x80) > 0) + { + seg->iMark = (seg->iMark & ~0x80); + } + } + } +*/ +// another try +/* +// Kern::AccessCode(); + SDblQue* p = Kern::CodeSegList(); + SDblQueLink* anchor=&p->iA; + SDblQueLink* a=anchor->iNext; + for (; a!=anchor; a=a->iNext) + { + DEpocCodeSeg* pSeg = (DEpocCodeSeg*) _LOFF(a, DCodeSeg, iLink); + if (!pSeg->iXIP) + pSeg->iMark &= ~DCodeSeg::EMarkProfilerTAG; + } + +// Kern::EndAccessCode(); +*/ +/* + DObjectCon* proc = Kern::Containers()[EProcess]; + TInt procCount = proc->Count(); + + // go 20 executables through at a time + for(TInt i=0;iiDynamicCode.Count(); // DProcess.iDynamicCode, type = RArray, SCodeSegEntry->iSeg/iLib + + //Kern::Printf("Reset: DProcess: count of segments %d", c); + for (TInt i=-1; iiCodeSeg:pro->iDynamicCode[i].iSeg; + if(seg != 0) + { + if( (seg->iMark & 0x80) > 0) + { + seg->iMark = (seg->iMark & ~0x80); + } + } + } + } + + //Kern::Printf("Reset: Exiting..."); + + #else +*/ + DObjectCon* libs = Kern::Containers()[ELibrary]; + TInt libCount = libs->Count(); + for(TInt i=0;iiCodeSeg; + if( (seg->iMark & 0x80) > 0) + { + seg->iMark = (seg->iMark & ~0x80); + } + } + + DObjectCon* procs = Kern::Containers()[EProcess]; + TInt procCount = procs->Count(); + for(TInt i=0;iiCodeSeg; + if(seg != 0) + { + if( (seg->iMark & 0x80) > 0) + { + seg->iMark = (seg->iMark & ~0x80); + } + } + } + //#endif +} diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler/plugins/GeneralsPlugin/src/MemSamplerImpl.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler/plugins/GeneralsPlugin/src/MemSamplerImpl.cpp Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,643 @@ +/* +* 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: +* +*/ + + +#include +#include + +#include +#include + +#include "MemSamplerImpl.h" + +// for testing precise stack utilization tracing... +// crashes at the moment + +#include + +#if !defined(__NKERN_H__) +#include +#endif + +#define TAG(obj) (*(TUint32*)&(obj->iAsyncDeleteNext)) +#define PROFILER_CHUNK_MARK ((TUint32)0x00001000) +#define PROFILER_MEM_THREAD_MARK ((TUint32)0x00000001) + +_LIT8(KMemVersion, "1.56"); + +MemSamplerImpl::MemSamplerImpl() : + sampleDescriptor(&(this->sample[1]),0,256) + { + LOGTEXT("MemSamplerImpl::MemSamplerImpl() - konstruktori"); + + iCount = 0; + iSampleThreads = true; + iTimeToSample = false; + + iTotalMemoryOk = false; + iTotalMemoryNameOk = false; + + iNewChunkCount = 0; + iChunkCount = 0; + iChunksProcessing = ENothingToProcess; + iThreadsProcessing = ENothingToProcess; + + for(TInt i(0);iheapChunksToSample[i] = 0; + this->heapChunkNamesToReport[i] = 0; + } + + + iNewThreadCount = 0; + iThreadCount = 0; + + for(TInt i=0;ithreadsToSample[i] = 0; + this->threadNamesToReport[i] = 0; + } + } + +MemSamplerImpl::~MemSamplerImpl() + { + + } + +TInt MemSamplerImpl::CreateFirstSample() + { + LOGTEXT("MemSamplerImpl::CreateFirstSample - entry"); + + this->sampleDescriptor.Zero(); + this->sampleDescriptor.Append(_L8("Bappea_V")); + this->sampleDescriptor.Append(KMemVersion); + this->sampleDescriptor.Append(_L8("_MEM")); + + sample[0] = this->sampleDescriptor.Size(); + + LOGTEXT("MemSamplerImpl::CreateFirstSample - exit"); + + return (TInt)(sample[0]+1); + } + +TBool MemSamplerImpl::SampleNeeded() + { + + iCount++; + if ((iCount % iMemSamplingPeriod) == 0 || (iCount % iMemSamplingPeriodDiv2) == 0) + { + LOGTEXT("MemSamplerImpl::SampleNeeded - true1"); + iTimeToSample = true; + return true; + } + else + { + return false; + } + + } + + +TInt MemSamplerImpl::SampleImpl() + { + + /* + * + * EKA-2 implementation of MEM trace + * + */ + + // check if either chunk or thread lists have unprocessed items + if(this->iChunksProcessing == ENothingToProcess && !iSampleThreads) + { + if(!iTimeToSample) + { + return 0; + } + else + { + iTimeToSample = false; + // gather first all chunks + return GatherChunks(); + } + } + else if(!iSampleThreads) + { + // still something to go through in lists + TInt length = this->ProcessChunks(); + + if(length == 0) + { + this->iChunksProcessing = ENothingToProcess; + // switch to collect thread data + iSampleThreads = true; + } + return length; + } + + if(this->iThreadsProcessing == ENothingToProcess && iSampleThreads) + { + if(!iTimeToSample) + { + return 0; + } + else + { + iTimeToSample = false; + // gather first all thread stacks + return GatherThreads(); + } + } + + else if(iSampleThreads) + { + // process now thread stack list + TInt length = this->ProcessThreads(); + + if(length == 0) + { + this->iThreadsProcessing = ENothingToProcess; + // switch to collect chunk data + iSampleThreads = false; + } + return length; + } + + // should not reach this point... + return 0; + } + +inline TInt MemSamplerImpl::GatherChunks() + { + // encode a process binary + name.Zero(); + DObjectCon& chunks = *Kern::Containers()[EChunk]; + + this->iChunkCount = 0; + this->iNewChunkCount = 0; + this->iTotalMemoryOk = false; + TInt totalChunkCount = chunks.Count(); + + for(TInt i=0;iTraceAppendName(name,false); + const TUint8* ptr = name.Ptr(); + + TAG(c) = (PROFILER_CHUNK_MARK); + this->heapChunkNamesToReport[iNewChunkCount] = c; + iNewChunkCount++; + } + else + { + LOGSTRING3("Chunk %d marked already - 0x%x",i,TAG(c)); + } + + // the chunk has been tagged, add heap chunks to the list + this->heapChunksToSample[this->iChunkCount] = c; + this->iChunkCount++; + LOGSTRING2("Added chunk %d to Chunks",i); + } + + if(this->iChunkCount > 0 || this->iNewChunkCount > 0) + { + this->iChunksProcessing = EStartingToProcess; + + // process the first sample + TInt length = this->ProcessChunks(); + + if(length == 0) + { + this->iChunksProcessing = ENothingToProcess; + } + + return length; + } + else + { + // there were no threads, should not take place + LOGTEXT("MemSamplerImpl::SampleImpl - Error, no threads"); + return 0; + } + } + +inline TInt MemSamplerImpl::GatherThreads() + { + // The thread memory consumption + DObjectCon& threads = *Kern::Containers()[EThread]; + + this->iThreadCount = 0; + this->iNewThreadCount = 0; + this->iTotalMemoryOk = false; + + TInt totalThreadCount = threads.Count(); + + for(TInt i=0;ithreadNamesToReport[iNewThreadCount] = t; + iNewThreadCount++; + // tag the thread + TAG(t) |= PROFILER_MEM_THREAD_MARK; + LOGSTRING2("New Thread %d",i); + } + else + { + LOGSTRING3("Thread %d marked already - 0x%x",i,TAG(t)); + } + + // the chunk has been tagged, add heap chunks to the list + this->threadsToSample[this->iThreadCount] = t; + this->iThreadCount++; + LOGSTRING2("Added thread %d to threads to sample",i); + } + + if(this->iThreadCount > 0 || this->iNewThreadCount > 0) + { + this->iThreadsProcessing = EStartingToProcess; + + // process the first sample + TInt length = this->ProcessThreads(); + + if(length == 0) + { + this->iThreadsProcessing = ENothingToProcess; + } + + return length; + } + else + { + // there were no threads, should not take place + LOGTEXT("MemSamplerImpl::SampleImpl - Error, no threads"); + return 0; + } + } + +inline TInt MemSamplerImpl::ProcessChunks() + { + if(iNewChunkCount > 0) + { + + if(this->iChunksProcessing == EStartingToProcess) + { + // this is the first sample, encode a code for names + this->iChunksProcessing = EProcessingNames; + return EncodeNameCode(); + } + + if(iTotalMemoryNameOk == false) + { + return EncodeTotalMemoryName(); + } + + // there are new chunk names to report + iNewChunkCount--; + DChunk* c = this->heapChunkNamesToReport[iNewChunkCount]; + return EncodeChunkName(*c); + + } + else if(iChunkCount > 0) + { + if(this->iChunksProcessing == EProcessingNames || this->iChunksProcessing == EStartingToProcess) + { + // this is the first data sample, encode a code for data + this->iChunksProcessing = EProcessingData; + return EncodeDataCode(); + } + + if(this->iTotalMemoryOk == false) + { + return EncodeTotalMemory(); + } + + // there are no new chunks to report + // thus generate the real report + iChunkCount--; + DChunk* c = this->heapChunksToSample[iChunkCount]; + return EncodeChunkData(*c); + } + else + { + // everything is processed + return 0; + } + } + +inline TInt MemSamplerImpl::ProcessThreads() + { + + if(iNewThreadCount > 0) + { + if(this->iThreadsProcessing == EStartingToProcess) + { + // this is the first sample, encode a code for names + this->iThreadsProcessing = EProcessingNames; + return EncodeNameCode(); + } + + if(iTotalMemoryNameOk == false) + { + return EncodeTotalMemoryName(); + } + + iNewThreadCount--; + DThread* t = this->threadNamesToReport[iNewThreadCount]; + return EncodeChunkName(*t); + + + } + else if(iThreadCount > 0) + { + if(this->iThreadsProcessing == EProcessingNames || this->iThreadsProcessing == EStartingToProcess) + { + // this is the first data sample, encode a code for data + this->iThreadsProcessing = EProcessingData; + return EncodeDataCode(); + } + + if(this->iTotalMemoryOk == false) + { + return EncodeTotalMemory(); + } + + // there are no new threads to report + // thus generate the real report + iThreadCount--; + DThread* t = this->threadsToSample[iThreadCount]; + return EncodeChunkData(*t); + } + else + { + // everything is processed + return 0; + } + } + +inline TInt MemSamplerImpl::EncodeNameCode() + { + sample[0] = 1; + sample[1] = 0xaa; + return 2; + } + +inline TInt MemSamplerImpl::EncodeDataCode() + { + sample[0] = 1; + sample[1] = 0xdd; + return 2; + } + +inline TInt MemSamplerImpl::EncodeTotalMemoryName() + { + this->iTotalMemoryNameOk = true; + + TUint8* size = &sample[0]; + *size = 0; + + // encode name + this->sampleDescriptor.Zero(); + this->sampleDescriptor.Append(_L("TOTAL_MEMORY")); + *size += this->sampleDescriptor.Size(); + + // add id here + TUint32 id = 0xbabbeaaa; + this->sampleDescriptor.Append((TUint8*)&(id),sizeof(TUint32)); + *size += sizeof(TUint32); + + // the size is the descriptor length + the size field + return ((TInt)(*size))+1; + } + +inline TInt MemSamplerImpl::EncodeTotalMemory() + { + + TUint8* size = &sample[0]; + *size = 0; + + NKern::LockSystem(); + TUint32 freeRam = Kern::FreeRamInBytes(); + TUint32 totalRam = Kern::SuperPage().iTotalRamSize; + NKern::UnlockSystem(); + + this->sampleDescriptor.Zero(); + + TUint32 id = 0xbabbeaaa; + TUint32 zero = 0; + + this->sampleDescriptor.Append((TUint8*)&(id),sizeof(TUint32)); + *size += sizeof(TUint); + + this->sampleDescriptor.Append((TUint8*)&(totalRam),sizeof(TInt)); + *size += sizeof(TInt); + + // append the cell amount allocated + this->sampleDescriptor.Append((TUint8*)&(zero),sizeof(TInt)); + *size += sizeof(TInt); + + // append the chunk size + this->sampleDescriptor.Append((TUint8*)&(freeRam),sizeof(TUint)); + *size += sizeof(TUint); + + // append the thread user stack size + this->sampleDescriptor.Append((TUint8*)&(zero),sizeof(TInt)); + *size += sizeof(TInt); + + this->iTotalMemoryOk = true; + + return ((TInt)(*size))+1; + } + +inline TInt MemSamplerImpl::EncodeChunkName(DChunk& c) + { + // the size of the following name is in the first byte + TUint8* size = &sample[0]; + *size = 0; + + // encode chunk name + this->sampleDescriptor.Zero(); + this->sampleDescriptor.Append(_L("C_")); + c.TraceAppendFullName(this->sampleDescriptor,false); + *size += this->sampleDescriptor.Size(); + + // add chunk object address here + TUint32 chunkAddr = (TUint32)&c; + this->sampleDescriptor.Append((TUint8*)&(chunkAddr),sizeof(TUint32)); + *size += sizeof(TUint32); + + // the size is the descriptor length + the size field + LOGSTRING2("Non-Heap Chunk Name - %d",*size); + return ((TInt)(*size))+1; + } + +inline TInt MemSamplerImpl::EncodeChunkName(DThread& t) + { + // the size of the following name is in the first byte + TUint8* size = &sample[0]; + *size = 0; + this->sampleDescriptor.Zero(); + + this->sampleDescriptor.Append(_L("T_")); + t.TraceAppendFullName(this->sampleDescriptor,false); + *size += this->sampleDescriptor.Size(); + + // copy the 4 bytes from the thread id field + this->sampleDescriptor.Append((TUint8*)&(t.iId),sizeof(TUint)); + *size += sizeof(TUint); + + // the size is the descriptor length + the size field + LOGSTRING2("Name - %d",*size); + return ((TInt)(*size))+1; + } + +inline TInt MemSamplerImpl::EncodeChunkData(DChunk& c) + { + // the size of the following name is in the first byte + TUint8* size = &sample[0]; + *size = 0; + this->sampleDescriptor.Zero(); + TInt zero(0); + + TUint32 address = (TUint32)&c; + + this->sampleDescriptor.Append((TUint8*)&address,sizeof(TUint32)); + *size += sizeof(TUint); + + // copy the total amount of memory allocated + this->sampleDescriptor.Append((TUint8*)&(c.iSize),sizeof(TInt)); + *size += sizeof(TInt); + + // append the cell amount allocated + this->sampleDescriptor.Append((TUint8*)&(zero),sizeof(TInt)); + *size += sizeof(TInt); + + // append the chunk size + this->sampleDescriptor.Append((TUint8*)&(c.iSize),sizeof(TUint)); + *size += sizeof(TUint); + + // append the thread user stack size + this->sampleDescriptor.Append((TUint8*)&(zero),sizeof(TInt)); + *size += sizeof(TInt); + + LOGSTRING2("Data - %d",*size); + return ((TInt)(*size))+1; + + } + +inline TInt MemSamplerImpl::EncodeChunkData(DThread& t) + { + LOGTEXT("MemSamplerImpl::EncodeChunkData - entry"); + //LOGSTRING2("MemSamplerImpl::EncodeChunkData - processing thread 0x%x ",&t); + + // the size of the following name is in the first byte + TUint8* size = &sample[0]; + *size = 0; + this->sampleDescriptor.Zero(); + + LOGTEXT("MemSamplerImpl::EncodeChunkData - cleared"); + + this->sampleDescriptor.Append((TUint8*)&(t.iId),sizeof(TUint)); + *size += sizeof(TUint); + + // copy the total amount of memory allocated for user side stack + this->sampleDescriptor.Append((TUint8*)&(t.iUserStackSize),sizeof(TInt)); + *size += sizeof(TInt); + + TInt zero = 0; + // append the cell amount allocated (zero, not in use here) + this->sampleDescriptor.Append((TUint8*)&zero,sizeof(TInt)); + *size += sizeof(TInt); + + // append the chunk size (this is not a chunk) + this->sampleDescriptor.Append((TUint8*)&(zero),sizeof(TUint)); + *size += sizeof(TUint); + + /* + // for testing precise stack utlilsation tracing... + // crashes at the moment + + // append the current status of thread's stack utilisation + // this equals (stack pointer - stack base address) + TUint32* sp=(TUint32*)t.iNThread.iSavedSP; + TUint aUsrSP=sp[SP_R13U]; + //TInt value = aUsrSP-t.iUserStackRunAddress; + this->sampleDescriptor.Append((TUint8*)&(aUsrSP),sizeof(TInt)); + *size += sizeof(TInt); + */ + + // append user stack (max) size + this->sampleDescriptor.Append((TUint8*)&(t.iUserStackSize),sizeof(TInt)); + *size += sizeof(TInt); + + LOGSTRING2("Data -> %d",*size); + return ((TInt)(*size))+1; + } + +void MemSamplerImpl::Reset() + { + LOGTEXT("MemSamplerImpl::Reset"); + iCount = 0; // sample threads 1 cycle after actual MEM sample time... + this->iSampleThreads = true; + this->iTimeToSample = false; + this->iChunkCount = 0; + this->iNewChunkCount = 0; + + this->iTotalMemoryOk = false; + this->iTotalMemoryNameOk = false; + + this->iChunksProcessing = ENothingToProcess; + this->iThreadsProcessing = ENothingToProcess; + this->sampleDescriptor.Zero(); + + // clear all chunk tags + DObjectCon* chunks = Kern::Containers()[EChunk]; + TInt totalChunkCount = chunks->Count(); + for(TInt i=0;iiThreadCount = 0; + this->iNewThreadCount = 0; + this->sampleDescriptor.Zero(); + + // clear all chunk tags + DObjectCon* threads = Kern::Containers()[EThread]; + TInt totalThreadCount = threads->Count(); + for(TInt i=0;i +#include + +#include +#include + +#include "PriSamplerImpl.h" + +#if !defined(__NKERN_H__) +#include +#endif + +#define TAG(obj) (*(TUint32*)&(obj->iAsyncDeleteNext)) +#define PROFILER_THREAD_MARK ((TUint32)0x00000002) + + +PriSamplerImpl::PriSamplerImpl() : + sampleDescriptor(&(this->sample[1]),0,256) + { + LOGTEXT("PriSamplerImpl::PriSamplerImpl() - konstruktori"); + + iCountti = 50; // sample threads 16 cycles before actual MEM and PRI sample time... + iNewThreadCount = 0; + iThreadCount = 0; + iProcessing = ENothingToProcess; + + for(TInt i=0;ithreadsToSample[i] = 0; + this->threadNamesToReport[i] = 0; + } + + } + +PriSamplerImpl::~PriSamplerImpl() + { + + } + +TInt PriSamplerImpl::CreateFirstSample() + { + LOGTEXT("PriSamplerImpl::CreateFirstSample - entry"); + + this->sampleDescriptor.Zero(); + this->sampleDescriptor.Append(_L8("Bappea_V")); + this->sampleDescriptor.Append(PROFILER_PRI_SAMPLER_VERSION); + this->sampleDescriptor.Append(_L8("_PRI")); + + sample[0] = this->sampleDescriptor.Size(); + + LOGTEXT("PriSamplerImpl::CreateFirstSample - exit"); + + return (TInt)(sample[0]+1); + } + +TBool PriSamplerImpl::SampleNeeded() + { + iCountti++; + if(iCountti % (iPriSamplingPeriod) == 0) + { + LOGTEXT("PriSamplerImpl::SampleNeeded - true"); + return true; + } + else + { + return false; + } + } + + +TInt PriSamplerImpl::SampleImpl() + { + /* + * + * EKA-2 implementation of PRI trace + * + */ + if(this->iProcessing == ENothingToProcess) + { + if((iCountti % iPriSamplingPeriod) != 0 ) return 0; + + LOGTEXT("Processing threads..."); + + DObjectCon& threads = *Kern::Containers()[EThread]; + + // PRI trace variables + this->iThreadCount = 0; + this->iNewThreadCount = 0; + TInt totalThreadCount = threads.Count(); + + for(TInt i=0;ithreadNamesToReport[iNewThreadCount] = t; + iNewThreadCount++; + // tag the thread + TAG(t) |= PROFILER_THREAD_MARK; + LOGSTRING2("New Thread %d",i); + } + else + { + LOGSTRING3("Thread %d marked already - 0x%x",i,TAG(t)); + } + + // the thread has been tagged, add heap chunks to the list + this->threadsToSample[this->iThreadCount] = t; + this->iThreadCount++; + LOGSTRING2("Added thread %d to threads to sample",i); + } + + if(this->iThreadCount > 0 || this->iNewThreadCount > 0) + { + this->iProcessing = EStartingToProcess; + + // process the first sample + TInt length = this->ProcessChunks(); + + if(length == 0) + { + this->iProcessing = ENothingToProcess; + } + + return length; + } + else + { + // there were no threads, should not take place + LOGTEXT("PriSamplerImpl::SampleImpl - Error, no threads"); + return 0; + } + } + else + { + TInt length = this->ProcessChunks(); + if(length == 0) + { + this->iProcessing = ENothingToProcess; + } + return length; + } + } + +inline TInt PriSamplerImpl::ProcessChunks() + { + /* + * + * EKA-2 implementation of PRI trace + * + */ + + if(iNewThreadCount > 0) + { + if(this->iProcessing == EStartingToProcess) + { + // this is the first sample, encode a code for names + this->iProcessing = EProcessingNames; + return EncodeNameCode(); + } + + // there are new thread names to report + iNewThreadCount--; + DThread* t = this->threadNamesToReport[iNewThreadCount]; + return EncodeChunkName(*t); + } + else if(iThreadCount > 0) + { + if(this->iProcessing == EProcessingNames || this->iProcessing == EStartingToProcess) + { + // this is the first data sample, encode a code for data + this->iProcessing = EProcessingData; + return EncodeDataCode(); + } + + // there are no new chunks to report + // thus generate the real report + iThreadCount--; + DThread* t = this->threadsToSample[iThreadCount]; + LOGSTRING2("PriSamplerImpl::ProcessChunks - starting to process thread 0x%x",t); + return EncodeChunkData(*t); + } + else + { + // everything is processed + return 0; + } + } + +inline TInt PriSamplerImpl::EncodeNameCode() + { + sample[0] = 1; + sample[1] = 0xbb; // pri trace name code + return 2; + } + +inline TInt PriSamplerImpl::EncodeDataCode() + { + sample[0] = 1; + sample[1] = 0xee; // pri trace data code + return 2; + } + + +inline TInt PriSamplerImpl::EncodeChunkName(DThread& t) + { + // the size of the following name is in the first byte + TUint8* size = &sample[0]; + *size = 0; + this->sampleDescriptor.Zero(); + + t.TraceAppendFullName(this->sampleDescriptor,false); + *size += this->sampleDescriptor.Size(); + + // copy the 4 bytes from the thread id field + this->sampleDescriptor.Append((TUint8*)&(t.iId),sizeof(TUint)); + *size += sizeof(TUint); + + // the size is the descriptor length + the size field + LOGSTRING2("Name size - %d",*size); + return ((TInt)(*size))+1; + } + + +inline TInt PriSamplerImpl::EncodeChunkData(DThread& t) + { + LOGTEXT("PriSamplerImpl::EncodeChunkData - entry"); + LOGSTRING2("PriSamplerImpl::EncodeChunkData - processing thread 0x%x ",&t); + + // the size of the following name is in the first byte + TUint8* size = &sample[0]; + *size = 0; + this->sampleDescriptor.Zero(); + + LOGTEXT("PriSamplerImpl::EncodeChunkData - cleared"); + + // append the thread id + this->sampleDescriptor.Append((TUint8*)&(t.iId),sizeof(TUint)); + *size += sizeof(TUint); + +// NKern::LockSystem(); +// TInt priority(-1); +// if(&t && t.Open()== KErrNone) +// { +// priority = t.iDefaultPriority; +// } +// NKern::UnlockSystem(); + + // append the priority of the nanokernel fast semaphore +// this->sampleDescriptor.Append((TUint8*)&priority,sizeof(TUint8)); + // append the priority of the nanokernel fast semaphore + this->sampleDescriptor.Append((TUint8*)&(t.iNThread.iPriority),sizeof(TUint8)); + // add space because EKA-1 implementation needs it + this->sampleDescriptor.Append((TUint8)0x0); + *size += 2*sizeof(TUint8); + + LOGTEXT("PriSamplerImpl::EncodeChunkData - appended priority"); + + + LOGSTRING2("Data size - %d",*size); + return ((TInt)(*size))+1; + } + + +void PriSamplerImpl::Reset() + { + /* + * + * EKA-2 implementation of PRI trace + * + */ + + LOGTEXT("PriSamplerImpl::Reset"); + iCountti = 50; // sample threads 16 cycles before actual MEM and PRI sample time... + this->iThreadCount = 0; + this->iNewThreadCount = 0; + this->iProcessing = ENothingToProcess; + this->sampleDescriptor.Zero(); + + + // clear all thread tags + DObjectCon* threads = Kern::Containers()[EThread]; + TInt totalThreadCount = threads->Count(); + for(TInt i=0;i + + +PRJ_EXPORTS +../inc/ProfilerTraces.h OS_LAYER_PLATFORM_EXPORT_PATH(piprofiler/ProfilerTraces.h) +../inc/ProfilerVersion.h OS_LAYER_PLATFORM_EXPORT_PATH(piprofiler/ProfilerVersion.h) +../inc/ProfilerConfig.h OS_LAYER_PLATFORM_EXPORT_PATH(piprofiler/ProfilerConfig.h) +../inc/ProfilerAttributes.h OS_LAYER_PLATFORM_EXPORT_PATH(piprofiler/ProfilerAttributes.h) +../inc/ProfilerGenericClassesUsr.h OS_LAYER_PLATFORM_EXPORT_PATH(piprofiler/ProfilerGenericClassesUsr.h) +../inc/ProfilerGenericClassesUsr.inl OS_LAYER_PLATFORM_EXPORT_PATH(piprofiler/ProfilerGenericClassesUsr.inl) +../inc/ProfilerGenericClassesKrn.h OS_LAYER_PLATFORM_EXPORT_PATH(piprofiler/ProfilerGenericClassesKrn.h) +../inc/ProfilerGenericClassesKrn.inl OS_LAYER_PLATFORM_EXPORT_PATH(piprofiler/ProfilerGenericClassesKrn.inl) +../inc/ProfilerGenericClassesCommon.h OS_LAYER_PLATFORM_EXPORT_PATH(piprofiler/ProfilerGenericClassesCommon.h) +../inc/ProfilerEngineAPI.h OS_LAYER_PLATFORM_EXPORT_PATH(piprofiler/ProfilerEngineAPI.h) +../inc/EngineUIDs.h OS_LAYER_PLATFORM_EXPORT_PATH(piprofiler/EngineUIDs.h) +../inc/PluginDriver.h OS_LAYER_PLATFORM_EXPORT_PATH(piprofiler/PluginDriver.h) +../inc/PluginDriver.inl OS_LAYER_PLATFORM_EXPORT_PATH(piprofiler/PluginDriver.inl) +../inc/PluginSampler.h OS_LAYER_PLATFORM_EXPORT_PATH(piprofiler/PluginSampler.h) +../inc/ProfilerSession.h OS_LAYER_PLATFORM_EXPORT_PATH(piprofiler/ProfilerSession.h) +../inc/SamplerPluginInterface.h OS_LAYER_PLATFORM_EXPORT_PATH(piprofiler/SamplerPluginInterface.h) +../inc/SamplerPluginInterface.inl OS_LAYER_PLATFORM_EXPORT_PATH(piprofiler/SamplerPluginInterface.inl) +../inc/WriterPluginInterface.h OS_LAYER_PLATFORM_EXPORT_PATH(piprofiler/WriterPluginInterface.h) +../inc/WriterPluginInterface.inl OS_LAYER_PLATFORM_EXPORT_PATH(piprofiler/WriterPluginInterface.inl) +../inc/ProfilerEngineStatusChecker.h OS_LAYER_PLATFORM_EXPORT_PATH(piprofiler/ProfilerEngineStatusChecker.h) +../inc/ProfilerEngineStatusChecker.inl OS_LAYER_PLATFORM_EXPORT_PATH(piprofiler/ProfilerEngineStatusChecker.inl) diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler_api/inc/EngineUIDs.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler_api/inc/EngineUIDs.h Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,135 @@ +/* +* 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 ENGINEUIDS_H +#define ENGINEUIDS_H + +#include + +// No item is selected in the container's listbox +const TUid KSamplerNoneSelected = { 0x00000001 }; +const TUid KWriterNoneSelected = { 0x00000002 }; + +/* + * Sampler plugin implementation UIDs + * + */ +// Use this UID if plugin is GeneralsPlugin: +const TUid KSamplerGeneralsPluginUid = { 0x2001E5B2 }; + +/* + * + * The sub samplers of GeneralsPlugin + * NOTE: NOT real reserved UIDs!!! + * + */ + // Use this UID if plugin is GppPlugin: + const TUid KSamplerGppPluginUid = { 0x2001E570 }; + + // Use this UID if plugin is GfcPlugin: + const TUid KSamplerGfcPluginUid = { 0x2001E571 }; + + // Use this UID if plugin is IttPlugin: + const TUid KSamplerIttPluginUid = { 0x2001E572 }; + + // Use this UID if plugin is MemPlugin: + const TUid KSamplerMemPluginUid = { 0x2001E573 }; + + // Use this UID if plugin is PriPlugin: + const TUid KSamplerPriPluginUid = { 0x2001E574 }; + + +// Use this UID if plugin is GeneralsPlugin: +const TUid KSamplerInternalsPluginUid = { 0x2001E5B4 }; + +/* + * + * The sub samplers of InternalsPlugin + * NOTE: NOT real reserved UIDs!!! + * + */ + // Use this UID if plugin is IrqPlugin: + const TUid KSamplerIrqPluginUid = { 0x2001E575 }; + + // Use this UID if plugin is SwiPlugin: + const TUid KSamplerSwiPluginUid = { 0x2001E577 }; + + // Use this UID if plugin is PecPlugin: + const TUid KSamplerPecPluginUid = { 0x2001E579 }; + + // Use this UID if plugin is L2IPlugin: + const TUid KSamplerL2IPluginUid = { 0x2001E581 }; + +/* + * + * Other plugins/samplers + * + */ + +// Use this UID if plugin is BupPlugin: +const TUid KSamplerBupPluginUid = { 0x2001E5B6 }; + +// Use this UID if plugin is IsaPlugin: +const TUid KSamplerIsaPluginUid = { 0x2001E5B8 }; + +// Use this UID if plugin is PwrPlugin: +const TUid KSamplerPwrPluginUid = { 0x2001E5B9 }; + +// Use this UID if plugin is TipPlugin: +//const TUid KSamplerTipPluginUid = { 0x20201F78 }; + +// Use this UID if plugin is ScrPlugin: +//const TUid KSamplerScrPluginUid = { 0x20201F82 }; + + + + + +// NOTE: The following UIDs are reserved for own sampler plug-in development!!! +// Use this UID if plugin is Ext1Plugin: +const TUid KSamplerExt1PluginUid = { 0x20201F84 }; +// Use this UID if plugin is Ext2Plugin: +const TUid KSamplerExt2PluginUid = { 0x20201F85 }; +// Use this UID if plugin is Ext3Plugin: +const TUid KSamplerExt3PluginUid = { 0x20201F86 }; +// Use this UID if plugin is Ext4Plugin: +const TUid KSamplerExt4PluginUid = { 0x20201F87 }; +// Use this UID if plugin is Ext5Plugin: +const TUid KSamplerExt5PluginUid = { 0x20201F88 }; +// Use this UID if plugin is Ext6Plugin: +const TUid KSamplerExt6PluginUid = { 0x20201F89 }; + + +/* +// UID of Profiler Engine application. +// This UID is used for accessing the help IDs controlled by Sampler help files +const TUid KUidSampler = { 0x200058EC }; +*/ + +/* + * Writer plugin implementation UIDs + * + */ +// Use this UID if plugin belongs to DebOutWriterPlugin: +const TUid KDebOutWriterPluginUid = { 0x2001E5BA }; + +// Use this UID if plugin belongs to MmcOutWriterPlugin: +const TUid KDiskWriterPluginUid = { 0x2001E5BB }; + +#endif // ENGINEUIDS_H +// End of File diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler_api/inc/PluginDriver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler_api/inc/PluginDriver.h Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,85 @@ +/* +* 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: +* +*/ + + +#include + +const TInt KMinRate = 10; +const TInt KMaxRate = 1000; + +enum TState{ERunning, EStopping, EStopped}; + +const TUid KGppPropertyCat={0x20201F70}; +enum TGppPropertyKeys + { + EGppPropertySyncSampleNumber + }; + + +/* + * + * + * Class DPluginDriver definition, inherited by sampler implementations except GPP + * + * + */ + +class DPluginDriver : public DLogicalChannel +{ + +public: + DPluginDriver(); + ~DPluginDriver(); + +public: + TInt ProcessStreamReadCancel(); + + TInt StopSampling(); + +private: + TInt ProcessPrintStreamRequest(TDesC8* aDes/*,TRequestStatus* aStatus*/); + + void FastPrintf(TDesC8* aDes); + +public: + DThread* iClient; + + // property and value; + // GPP sampler start time, needed to set other samplers in sync + RPropertyRef iSampleStartTimeProp; + TInt iSampleStartTime; + TUint32 iSyncOffset; // offset from the start + + + TUint32 sampleRunning; + const TUint* iInterruptStack; + TState iState; + TInt doingDfc; + + // request status objects for requests + TRequestStatus* iEndRequestStatus; + TRequestStatus* iStreamReadCancelStatus; + + // sample stream object used in stream mode + DProfilerSampleStream iSampleStream; + + // just for testing + TUint32* stackTop; + +}; + +#include diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler_api/inc/PluginDriver.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler_api/inc/PluginDriver.inl Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,77 @@ +/* +* 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: +* +*/ + + +// +// LDD for thread time profiling +// + +#include +#include + + +#include +#include + +#include + + +/* + * + * + * Class DPluginDriver implementation + * + * + */ +inline DPluginDriver::DPluginDriver() //: iSubsRequest(&HandleSubsComplete, this) + { + //iClientProcess = &Kern::CurrentProcess(); + } +inline DPluginDriver::~DPluginDriver() + { + + } + +/* + * Methods for controlling stream read option + */ + +inline TInt DPluginDriver::ProcessStreamReadCancel() +{ + return KErrNone; +} + +/* + * Mark traces active or inactive, this can be done + * only if sampling is not running + */ + +inline TInt DPluginDriver::StopSampling() +{ + if(this->iState == ERunning) + { + this->iState = EStopping; + return KErrNone; + } + else + { + return KErrGeneral; + } +} + + + diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler_api/inc/PluginSampler.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler_api/inc/PluginSampler.h Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,247 @@ +/* +* 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 __PLUGINSAMPLER_H__ +#define __PLUGINSAMPLER_H__ + +/* + * The user-interface to the sampling device driver sued by the profiling engine + */ +// #include +// #include // versions removed from ProfilerConfig.h + +#ifndef __KERNEL_MODE__ +#include +#endif + +/* + * Forward declarations + */ +class TBapBuf; + +/** + * A minimal capabilities class for the Sampling device. + * It just returns the version number. + */ +class TCapsSamplerV01 + { +public: + TVersion iVersion; + }; + + +const TInt KMinDelay = 1; +const TInt KMaxDelay = 10000; + +/** + * The user device driver class for controlling the plugin sampler. + */ + +class RPluginSampler : public RBusLogicalChannel // public RPluginSampler +{ + friend class DPluginDriver; + public: + enum TControl + { + EOutputSettingsForTrace, + EMarkTraceActive, + EMarkTraceInactive, + ESample, + EStartSampling, + EGetSampleTime, + EGetSamplerVersion, + EStopAndWaitForEnd, + ESetSamplingPeriod, + EAdditionalTraceSettings, + EAdditionalTraceSettings2, + EAdditionalTraceSettings3, + EAdditionalTraceSettings4, + //EPrintTraces, + ECancelStreamRead, + ERequestFillThisStreamBuffer, + ERequestPrintStreamBuffer, + ETest + }; + + public: + #ifndef __KERNEL_MODE__ + + inline ~RPluginSampler(); + + /** + * + * Methods for controlling the sampler device + * + **/ + /** Open a channel to the sampling device **/ + virtual TInt Open() = 0; + + /** Set sampling period for sampler */ + inline void SetSamplingPeriod(TInt samplerId, TInt settings); + + /** Set additional trace settings **/ + inline void AdditionalSettingsForTrace(TInt samplerId,TInt settings); + inline void AdditionalSettingsForTrace2(TInt samplerId,TInt settings); + inline void AdditionalSettingsForTrace3(TInt samplerId,TInt settings); + inline void AdditionalSettingsForTrace4(TInt samplerId,TInt settings); + + /** Mark trace active **/ + inline void MarkTraceActive(TUint32 id); + + /** Mark trace inactive **/ + inline void MarkTraceInactive(TUint32 id); + + /** Sample command to kernel LDD**/ + inline void Sample(); + + /** Start tracing **/ + inline void StartSampling(); + + /** Stop tracing **/ + inline void StopSampling(); + + /** Get current sampling time **/ + inline TUint32 GetSampleTime(); + + /** Get sampler version as descriptor **/ + virtual void GetSamplerVersion(TDes*); + + /** Get next filled buffer in stream mode **/ + void GetNextbuffer( ); + + /** Request stream read **/ + void FillThisStreamBuffer(TBapBuf* aBuffer, TRequestStatus& aStatus); + + /** Request print buffer**/ + void PrintStreamBuffer(TDesC16* aBuffer); + + /** Run test case **/ + inline void Test(TUint32 testCase); + + #endif // !__KERNEL_MODE__ +}; + + +#ifndef __KERNEL_MODE__ +inline RPluginSampler::~RPluginSampler() +{ +} + +inline void RPluginSampler::AdditionalSettingsForTrace(TInt samplerId,TInt settings) + { + DoControl(EAdditionalTraceSettings, + reinterpret_cast(samplerId), + reinterpret_cast(settings)); + } + +inline void RPluginSampler::AdditionalSettingsForTrace2(TInt samplerId,TInt settings) + { + DoControl(EAdditionalTraceSettings2, + reinterpret_cast(samplerId), + reinterpret_cast(settings)); + } + +inline void RPluginSampler::AdditionalSettingsForTrace3(TInt samplerId,TInt settings) + { + DoControl(EAdditionalTraceSettings3, + reinterpret_cast(samplerId), + reinterpret_cast(settings)); + } + +inline void RPluginSampler::AdditionalSettingsForTrace4(TInt samplerId,TInt settings) + { + DoControl(EAdditionalTraceSettings4, + reinterpret_cast(samplerId), + reinterpret_cast(settings)); + } + +inline void RPluginSampler::SetSamplingPeriod(TInt samplerId, TInt settings) + { + DoControl(ESetSamplingPeriod, + reinterpret_cast(samplerId), + reinterpret_cast(settings)); + } + + +inline void RPluginSampler::MarkTraceActive(TUint32 id) +{ + DoControl(EMarkTraceActive, reinterpret_cast(id)); +} + +inline void RPluginSampler::MarkTraceInactive(TUint32 id) +{ + DoControl(EMarkTraceInactive, reinterpret_cast(id)); +} + +inline void RPluginSampler::Sample() + { + DoControl(ESample); + } + +inline void RPluginSampler::StartSampling() +{ + // at first, start the kernel side samplers + DoControl(EStartSampling); +} + +inline void RPluginSampler::StopSampling() +{ + // stop the device driver and the kernel mode samplers + TRequestStatus status; + status = KRequestPending; + DoRequest(EStopAndWaitForEnd,status); + User::WaitForRequest(status); +} + +inline TUint32 RPluginSampler::GetSampleTime() +{ + TUint32* sampleTime = new TUint32; + + DoControl(EGetSampleTime,reinterpret_cast(sampleTime)); + TUint32 value = *sampleTime; + delete sampleTime; + + return value; +} + +inline void RPluginSampler::GetSamplerVersion(TDes* aDes) +{ + TBuf8<16> buf; + DoControl(EGetSamplerVersion,(TAny*)&buf); + CnvUtfConverter::ConvertToUnicodeFromUtf8(*aDes,buf); +} + +inline void RPluginSampler::PrintStreamBuffer(TDesC16* aDes) +{ + DoControl(ERequestPrintStreamBuffer,reinterpret_cast(aDes)); +} + +inline void RPluginSampler::FillThisStreamBuffer(TBapBuf* aBuffer, TRequestStatus& aStatus) +{ + aStatus = KRequestPending; + DoRequest(ERequestFillThisStreamBuffer,aStatus,(TAny*)aBuffer); + +} + +inline void RPluginSampler::Test(TUint32 testCase) +{ + DoControl(ETest,reinterpret_cast(testCase)); +} + +#endif +#endif diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler_api/inc/ProfilerAttributes.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler_api/inc/ProfilerAttributes.h Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,133 @@ +/* +* 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_ATTRIBUTES_H +#define PROFILER_ATTRIBUTES_H + +// INCLUDES +#include +#include +#include + +// LITERALS +_LIT8(KDefaultTraceFilePrefix, "PIProfiler_#"); +_LIT8(KDefaultTraceOutput, "file_system"); +_LIT8(KDefaultTraceFileSaveDrive, "C:\\data\\"); + +// CONSTANTS +const TUint KPrefixMaxLength = 64; + +/* + * + * TGeneralAttributes class definition, internal settings format + * + */ +class TGeneralAttributes + { +public: + TBuf8 iTraceOutput; + TBuf8 iTraceFilePrefix; + TBuf8 iSaveFileDrive; + }; + + + +/* + * + * TSettingItem class definition, internal settings format + * + */ +class TSettingItem + { +public: + enum + { + ESettingItemTypeInt = 0, + ESettingItemTypeBool, + ESettingItemTypeHex, + ESettingItemTypeText + }; + +public: + TBuf<64> iSettingText; + TUint32 iType; + TBuf<128> iValue; + TBuf<256> iSettingDescription; + TBuf<64> iUIText; + }; +/* + * + * TSamplerAttributes class definition, internal settings format + * + */ +class TSamplerAttributes + { +public: + // default constructor + TSamplerAttributes(); + // constructor + TSamplerAttributes(TInt32 aUid, + const TDesC8& aShortName, + const TDesC8& aName, + const TDesC8& aDescription, + TInt aSampleRate, + TBool aEnabled, + TBool aHidden, + TInt aItemCount); +public: + TInt32 iUid; + TBuf8<8> iShortName; // name of the plugin, short name + TBuf8<64> iName; // name of the plugin, long name + TBuf8<256> iDescription; // sampler description, info about HW/SW dependencies etc. + TInt iSampleRate; // sample rate of the plugin + TBool iEnabled; // previous state of plugin + TBool iIsHidden; + TInt iItemCount; // plugin specific setting item count + + // plugin specific settings, plugin implementation dependent + TSettingItem iSettingItem1; + TSettingItem iSettingItem2; + TSettingItem iSettingItem3; + TSettingItem iSettingItem4; + TSettingItem iSettingItem5; + TSettingItem iSettingItem6; + }; + +inline TSamplerAttributes::TSamplerAttributes() + {} + +inline TSamplerAttributes::TSamplerAttributes(TInt32 aUid, + const TDesC8& aShortName, + const TDesC8& aName, + const TDesC8& aDescription, + TInt aSampleRate, + TBool aEnabled, + TBool aHidden, + TInt aItemCount) + { + iUid = aUid; + iShortName.Copy(aShortName); + iName.Copy(aName); + iDescription.Copy(aDescription); + iSampleRate = aSampleRate; + iEnabled = aEnabled; + iIsHidden = aHidden; + iItemCount = aItemCount; + } + +#endif diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler_api/inc/ProfilerConfig.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler_api/inc/ProfilerConfig.h Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,101 @@ +/* +* 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 PI_PROFILER_CONFIG_H +#define PI_PROFILER_CONFIG_H + +// NCP release process will move the PIProfiler flags as Carbon feature flags +// where the product responsibles can choose the right settings for PI Profiler +// compilation. + + /*** NOTE!!! + * Uncomment the following definition if compiling the Profiler by your own + ***/ + #define PROFILER_SISX + + /* + * + * Filename and path for the settings file + * this file is written on application exit and + * it contains the settings of the profiler application + * + */ + +// #define PROFILER_SETTINGS_DRIVE _L("C:\\") +// #define PROFILER_SETTINGS_MAXLENGTH 32 +// #define PROFILER_SETTINGS_FILENAME _L("ProfilerSettings.txt") + const TInt KProfilerSettingsMaxLength = 32; + _LIT(KProfilerSettingsFileName, "PIProfilerSettings.txt"); + + // a fix for going through the different drives for settings file + #define PROFILER_SETTINGS_DRIVE_COUNT 3 + #define PROFILER_SETTINGS_DRIVE_ARRAY TBuf<4> settingsDrives[PROFILER_SETTINGS_DRIVE_COUNT]; + #define PROFILER_DEFINE_SETTINGS_DRIVE(name,number) settingsDrives[number].Append(_L(name)); + + // change these to reflect the drive names and numbers + // the last number must be PROFILER_SETTINGS_DRIVE_COUNT-1 + #define PROFILER_SETTINGS_DRIVES PROFILER_DEFINE_SETTINGS_DRIVE("C:\\",0) \ + PROFILER_DEFINE_SETTINGS_DRIVE("E:\\",1) \ + PROFILER_DEFINE_SETTINGS_DRIVE("Z:\\",2) + + /* + * + * Locations of PI Profiler binaries + * + */ + + #define PROFILERENGINE_EXE_PATH_PRIMARY _L("C:\\sys\\bin\\PIProfilerEngine.exe") + #define PROFILERENGINE_EXE_PATH_SECONDARY _L("Z:\\sys\\bin\\PIProfilerEngine.exe") + + /* + * + * PI Profiler tool composition definitions + * + */ + + // sampler codes and names + #define PROFILER_USER_MODE_SAMPLER 123 + #define PROFILER_KERNEL_MODE_SAMPLER 321 + #define PROFILER_DUMMY_SAMPLER 213 + + // old definitions + #define PROFILER_GENERALS_SAMPLER_ID 100 + #define PROFILER_INTERNALS_SAMPLER_ID 101 + #define PROFILER_GPP_SAMPLER_ID 1 + #define PROFILER_GFC_SAMPLER_ID 2 + #define PROFILER_ITT_SAMPLER_ID 3 + #define PROFILER_MEM_SAMPLER_ID 4 + #define PROFILER_PRI_SAMPLER_ID 5 + #define PROFILER_IRQ_SAMPLER_ID 6 + #define PROFILER_BUP_SAMPLER_ID 7 + #define PROFILER_SWI_SAMPLER_ID 8 + #define PROFILER_TIP_SAMPLER_ID 9 + #define PROFILER_PEC_SAMPLER_ID 10 + #define PROFILER_PWR_SAMPLER_ID 11 + #define PROFILER_IPC_SAMPLER_ID 12 + #define PROFILER_ISA_SAMPLER_ID 13 + + // sampler IDs for external, e.g. 3rd party sampler plug-ins + #define PROFILER_EXT1_SAMPLER_ID 14 + #define PROFILER_EXT2_SAMPLER_ID 15 + #define PROFILER_EXT3_SAMPLER_ID 16 + #define PROFILER_EXT4_SAMPLER_ID 17 + #define PROFILER_EXT5_SAMPLER_ID 18 + #define PROFILER_EXT6_SAMPLER_ID 19 + +#endif diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler_api/inc/ProfilerEngineAPI.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler_api/inc/ProfilerEngineAPI.h Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,88 @@ +/* +* 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 PROFILERCONTROLLER_H +#define PROFILERCONTROLLER_H + +#include +#include + +class CProfilerSettings; + +class CProfilerEngineAPI : public CBase +{ +public: + enum TProfilerEngineTraceMode + { + EProfilerEngineDebugOutputMode, + EProfilerEngineFileSystemMode + }; + + ~CProfilerEngineAPI(); + + IMPORT_C static CProfilerEngineAPI* NewL(); + void ConstructL(); + + IMPORT_C void SaveSettings(); + IMPORT_C void LoadSettings(); + + // controlling all sampler plugins + IMPORT_C TInt StartProfiling(); + IMPORT_C TBool StopProfiling(); + IMPORT_C TInt LaunchProfiler(); + + // controlling separate plugins + IMPORT_C TInt StartSampler(TUint32 aUid); + IMPORT_C TInt StopSampler(TUint32 aUid); + IMPORT_C TInt EnableSampler(TUint32 aUid); + IMPORT_C TInt DisableSampler(TUint32 aUid); + IMPORT_C TInt EnableWriter(TUint32 aUid); + IMPORT_C TInt DisableWriter(TUint32 aUid); + + // for meeting the HTI requirements + IMPORT_C TInt SetSettings(TUint aSamplerId, TDes& aSettings); + IMPORT_C TInt SetTraceMode(TProfilerEngineTraceMode aMode, TDes& aTraceDataStruct); + IMPORT_C TInt GetSamplerInfo(TUint aSamplerId, TDes& aCompleteSamplerInfo); + + // old implementations + IMPORT_C TBool GetSamplerVersion(TDes& version); + + IMPORT_C void LeaveProfilerBG(TBool aVal); + + +public: + TBool DriveIsValidL(const TDesC& drive); + IMPORT_C CProfilerSettings* Settings() const; + +private: + + CProfilerEngineAPI(); + + TInt FindProcessL(); +private: + CProfilerSettings* iSettings; + + RProcess* iProfilerProcess; + + TBool iProfilerLaunched; + + TBool iLeaveProfilerBG; + + }; + +#endif diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler_api/inc/ProfilerEngineStatusChecker.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler_api/inc/ProfilerEngineStatusChecker.h Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,74 @@ +/* +* 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_STATUS_CHECKER_H +#define PROFILER_STATUS_CHECKER_H + +#include +#include +#include // RProperty + +// CONSTANTS +const TUid KEngineStatusPropertyCat = { 0x2001E5AD }; +enum TEnginePropertyKeys + { + EProfilerEngineStatus = 8 + }; + +// CLASS DECLARATIONS +class MProfilerStatusObserver + { + public: // Enums + enum KProfilerStatus + { + EIdle = 0, + EInitializing, + ERunning, + EStopping, + ERestarting + }; + + public: // New + virtual void HandleProfilerStatusChange( + KProfilerStatus aStatus ) = 0; + virtual void HandleProfilerErrorL( + TInt aError ) = 0; + }; + + +class CProfilerEngineStatusChecker : public CActive + { +public: + inline static CProfilerEngineStatusChecker* CProfilerEngineStatusChecker::NewL(); + inline ~CProfilerEngineStatusChecker(); + inline void SetObserver(MProfilerStatusObserver* aObserver); + inline TInt GetInitialState(); +private: + inline CProfilerEngineStatusChecker(); + inline void ConstructL(); + inline void RunL(); + inline void DoCancel(); +private: + TInt iPrevStat; + MProfilerStatusObserver* iObserver; + RProperty iEngineStatus; + }; + +#include + + +#endif // PROFILER_STATUS_CHECKER_H diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler_api/inc/ProfilerEngineStatusChecker.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler_api/inc/ProfilerEngineStatusChecker.inl Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,128 @@ +/* +* 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: +* +*/ + +// ------------------------------------------------------------------------------ +// +// class CProfilerEngineStatusChecker +// +// ------------------------------------------------------------------------------ +// +inline CProfilerEngineStatusChecker* CProfilerEngineStatusChecker::NewL() + { + CProfilerEngineStatusChecker* self = new(ELeave) CProfilerEngineStatusChecker(); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + +// -------------------------------------------------------------------------------------------- +inline CProfilerEngineStatusChecker::CProfilerEngineStatusChecker() : + CActive(EPriorityStandard) + { + } + +inline CProfilerEngineStatusChecker::~CProfilerEngineStatusChecker() + { + Cancel(); + iEngineStatus.Close(); + } + +// -------------------------------------------------------------------------------------------- +inline void CProfilerEngineStatusChecker::ConstructL() + { + User::LeaveIfError(iEngineStatus.Attach(KEngineStatusPropertyCat, EProfilerEngineStatus)); + CActiveScheduler::Add(this); + + // check engine status, if not available set to idle + if(iEngineStatus.Get(iPrevStat) != KErrNone) + { + iPrevStat = MProfilerStatusObserver::EIdle; + } + + // subscribe to P&S status property + iEngineStatus.Subscribe(iStatus); + SetActive(); + } + +inline TInt CProfilerEngineStatusChecker::GetInitialState() + { + // check engine status, if not available set to idle + TInt err(iEngineStatus.Get(KEngineStatusPropertyCat, EProfilerEngineStatus, iPrevStat)); + if(err != KErrNone) + { + iPrevStat = MProfilerStatusObserver::EIdle; + } + return iPrevStat; + } + +// -------------------------------------------------------------------------------------------- +inline void CProfilerEngineStatusChecker::RunL() + { + // resubscribe before processing new value to prevent missing updates + iEngineStatus.Subscribe(iStatus); + SetActive(); + + TInt stat(0); + if(iEngineStatus.Get(KEngineStatusPropertyCat, EProfilerEngineStatus, stat) == KErrNone) + { + // check if status one of error codes (< 0) + if(stat < KErrNone) + { + // some error occurred on engine side => set UI idle and show an error note + iObserver->HandleProfilerErrorL(stat); + } + else + { + if(iPrevStat != stat) + { + switch(stat) + { + case 0: + iObserver->HandleProfilerStatusChange(MProfilerStatusObserver::EIdle); + break; + case 1: + iObserver->HandleProfilerStatusChange(MProfilerStatusObserver::EInitializing); + break; + case 2: + iObserver->HandleProfilerStatusChange(MProfilerStatusObserver::ERunning); + break; + case 3: + iObserver->HandleProfilerStatusChange(MProfilerStatusObserver::EStopping); + break; + default: + iObserver->HandleProfilerErrorL(stat); + break; + } + iPrevStat = stat; + } + } + } + } + +// -------------------------------------------------------------------------------------------- + +inline void CProfilerEngineStatusChecker::DoCancel() + { + iEngineStatus.Cancel(); + } + +// -------------------------------------------------------------------------------------------- +inline void CProfilerEngineStatusChecker::SetObserver(MProfilerStatusObserver* aObserver) + { + iObserver = aObserver; + } diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler_api/inc/ProfilerGenericClassesCommon.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler_api/inc/ProfilerGenericClassesCommon.h Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,55 @@ +/* +* 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 PROFILERGENERICCLASSESCOMMON_H +#define PROFILERGENERICCLASSESCOMMON_H + + #include + +/* + * + * Class TProfilerSampleBufStruct definition + * + */ + + +class TProfilerSampleBufStruct +{ +public: + TUint32 iSampleRemainder; + TUint8 iDataStart; +}; + +/* + * + * Class TBapBuf definition + * + */ + +class TBapBuf +{ +public: + TPtr8* iDes; + TPtr8* iBufDes; + TInt iBufferSize; + TInt iDataSize; + TUint8* iBuffer; + TBapBuf* iNext; +}; + +#endif diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler_api/inc/ProfilerGenericClassesKrn.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler_api/inc/ProfilerGenericClassesKrn.h Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,422 @@ +/* +* 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 PROFILERGENERICCLASSESKRN_H +#define PROFILERGENERICCLASSESKRN_H + + #include + #include + + #include + + #define PROFILER_KERNEL_MODE + +#ifdef PROFILER_KERNEL_MODE +class DProfilerSampleBuffer; + +class DProfilerSampleStream + { +public: + DProfilerSampleStream(); + ~DProfilerSampleStream(); + + void InsertCurrentClient(DThread* aClient); + void AddSampleBuffer(TBapBuf* aBuffer,TRequestStatus* aStatus); + void ReleaseIfPending(); + + void AddSamples(DProfilerSampleBuffer& aBuffer, TInt aSamplerId); + TInt EndSampling(DProfilerSampleBuffer& aBuffer,TInt aSamplerId); + + void PerformCopy(TUint8 aSamplerId,TUint8* aSrc,TPtr8* dst,TInt aOffset,TInt aAmount); + +private: + TBapBuf* iCurrentBuffer; + TRequestStatus* iPendingRequest; + DThread* iClient; + TInt iAddingSamples; + }; + +class DProfilerSampleBuffer : public DBase + { + friend class DProfilerSampleStream; +public: + + enum ProfilerBufferStatus + { + BufferOk, + BufferCopyAsap, + BufferBeingCopied, + BufferFull, + BufferDataEnd + }; + + DProfilerSampleBuffer(TUint8* aBuffer, TUint8* aDblBuffer, TUint32 aSize); + ~DProfilerSampleBuffer(); + TInt AddSample(TUint8* aSample, TUint32 aLength); + TUint32 GetBufferStatus(); + void ClearBuffer(); + void EndSampling(); + void DataCopied(); + + TUint32 iBufferStatus; +private: + TUint32 iBytesWritten; + TUint32 iDblBytesWritten; + TUint32 iDblBytesRead; + + TUint32 iBufferDataSize; + TUint32 iBufferRealSize; + + TProfilerSampleBufStruct* iDblBufStruct; + TProfilerSampleBufStruct* iBufStruct; + }; + +#endif + + + +/* + * + * Abstract class CProfilerSamplerBase definition + * + */ + +#ifdef PROFILER_KERNEL_MODE +class DProfilerSamplerBase : public DBase + { +public: + DProfilerSamplerBase(); + virtual ~DProfilerSamplerBase(); + + virtual TInt Initialise() = 0; + virtual void Sample() = 0; + virtual TBool PostSampleNeeded() = 0; + virtual TInt PostSample() = 0; + virtual TInt EndSampling() = 0; + + virtual TInt Reset(DProfilerSampleStream* aStream = 0, TUint32 aSyncOffset = 0) = 0; + + virtual void SetEnabledFlag(TBool aFlag) = 0; + virtual TBool GetEnabledFlag() = 0; + virtual void SetOutputCombination(TInt aSettings) = 0; + virtual void SetSamplingPeriod(TInt aSettings) = 0; + virtual void SetAdditionalSettings(TInt aSettings) = 0; + virtual void SetAdditionalSettings2(TInt aSettings) = 0; + virtual void SetAdditionalSettings3(TInt aSettings) = 0; + virtual void SetAdditionalSettings4(TInt aSettings) = 0; + + TInt iSamplerId; + TInt iOutputCombination; + TBool iEnabled; + }; + +/* + * + * Template abstract class CProfilerGenericSampler definition + * + */ + +// size parameter given defines the explicit buffer size in bytes for this sampler +template +class DProfilerGenericSampler : public DProfilerSamplerBase + { +public: + DProfilerGenericSampler(TInt aSamplerId); + virtual ~DProfilerGenericSampler(); + + TInt Initialise(); + virtual void Sample() = 0; + TBool PostSampleNeeded(); + TInt PostSample(); + TInt EndSampling(); + virtual TInt Reset(DProfilerSampleStream* aStream = 0, TUint32 aSyncOffset = 0); + + + void SetEnabledFlag(TBool aFlag); + TBool GetEnabledFlag(); + void SetOutputCombination(TInt aComb); + void SetSamplingPeriod(TInt aSettings); + void SetAdditionalSettings(TInt aSettings); + void SetAdditionalSettings2(TInt aSettings); + void SetAdditionalSettings3(TInt aSettings); + void SetAdditionalSettings4(TInt aSettings); + + DProfilerSampleBuffer* iSampleBuffer; + DProfilerSampleStream* iStream; + + // for right alignment + TUint8 iBuffer[BufferSize+4]; + TUint8 iDblBuffer[BufferSize+4]; + + TInt iSamplingPeriod; + TInt iAdditionalSettings; + TInt iAdditionalSettings2; + TInt iAdditionalSettings3; + TInt iAdditionalSettings4; + }; + +/* + * + * Template abstract class CProfilerGenericSampler implementation + * + */ + +template +DProfilerGenericSampler::DProfilerGenericSampler(TInt aSamplerId) + { + iSamplerId = aSamplerId; + iEnabled = false; + iSampleBuffer = 0; + iAdditionalSettings = 0; + iAdditionalSettings2 = 0; + iAdditionalSettings3 = 0; + iAdditionalSettings4 = 0; + iStream = 0; + Initialise(); + } + +template +DProfilerGenericSampler::~DProfilerGenericSampler() + { + LOGSTRING2("CProfilerGenericSampler<%d>::CProfilerGenericSampler",BufferSize); + + if(iSampleBuffer != 0) + delete iSampleBuffer; + + } + +template +TInt DProfilerGenericSampler::Initialise() + { + LOGSTRING2("CProfilerGenericSampler<%d>::Initialise - chunk option",BufferSize); + + // stream is not used in chunk mode + iStream = 0; + + // create the sample buffer object with the buffers + if(iSampleBuffer == 0) + { + iSampleBuffer = new DProfilerSampleBuffer(iBuffer,iDblBuffer,BufferSize); + } + else + { + LOGSTRING2("CProfilerGenericSampler<%d>::Initialise - ERROR 1",BufferSize); + } + + return KErrNone; + } + + + +template +TInt DProfilerGenericSampler::Reset(DProfilerSampleStream* aStream, TUint32 aSyncOffset) + { + LOGSTRING4("CProfilerGenericSampler<%d>::Reset %d, sync offset %d",BufferSize,aStream,aSyncOffset); + // reset the sample buffer and resolve the chunk again + + // CURRENT VERSION SUPPORTS ONLY STREAM MODE! + LOGSTRING2("CProfilerGenericSampler<%d>::Reset - stream option",BufferSize); + + // initialise the sampler with the stream option + iStream = aStream; + + // clear the sample buffer + if(iSampleBuffer != 0) + { + iSampleBuffer->ClearBuffer(); + } + else + { + LOGSTRING2("CProfilerGenericSampler<%d>::Initialise - ERROR no buffer",BufferSize); + } + + return KErrNone; + + } + +template +TBool DProfilerGenericSampler::PostSampleNeeded() + { + LOGSTRING4("CProfilerGenericSampler<%d>::PostSampleNeeded - ID %d, state %d",iSamplerId,BufferSize,iSampleBuffer->GetBufferStatus()); + + TUint32 status = iSampleBuffer->iBufferStatus; + + if(status == DProfilerSampleBuffer::BufferCopyAsap || status == DProfilerSampleBuffer::BufferFull) + { + return true; + } + + return false; + } + + +template +TInt DProfilerGenericSampler::PostSample() + { + LOGSTRING4("CProfilerGenericSampler<%d>::PostSample - ID %d, state %d",iSamplerId,BufferSize,iSampleBuffer->GetBufferStatus()); + + TUint32 status = iSampleBuffer->iBufferStatus; + + if(status == DProfilerSampleBuffer::BufferCopyAsap || status == DProfilerSampleBuffer::BufferFull) + { + // write data to the stream + iStream->AddSamples(*iSampleBuffer,iSamplerId); + } + + return KErrNone; + } + +template +TInt DProfilerGenericSampler::EndSampling() + { + LOGSTRING3("CProfilerGenericSampler<%d>::EndSampling, ID %d",BufferSize,iSamplerId); + + // only if write to stream option is selected + if(iStream->EndSampling(*iSampleBuffer,iSamplerId) == 0) + { + return KErrNone; + } + else + { + // there is still data to copy + return KErrNotReady; + } + } + +template +void DProfilerGenericSampler::SetEnabledFlag(TBool aFlag) + { + LOGSTRING2("CProfilerGenericSampler<%d>::SetEnabledFlag",BufferSize); + iEnabled = aFlag; + } + +template +TBool DProfilerGenericSampler::GetEnabledFlag() + { + LOGSTRING2("CProfilerGenericSampler<%d>::GetEnabledFlag",BufferSize); + return iEnabled; + } + +template +void DProfilerGenericSampler::SetOutputCombination(TInt aComb) + { + LOGSTRING2("CProfilerGenericSampler<%d>::SetOutputCombination",BufferSize); + iOutputCombination = aComb; + } + +template +void DProfilerGenericSampler::SetAdditionalSettings(TInt aSettings) + { + LOGSTRING3("CProfilerGenericSampler<%d>::SetAdditionalSettings to 0x%x",BufferSize,aSettings); + iAdditionalSettings = aSettings; + } + +template +void DProfilerGenericSampler::SetAdditionalSettings2(TInt aSettings) + { + LOGSTRING3("CProfilerGenericSampler<%d>::SetAdditionalSettings2 to 0x%x",BufferSize,aSettings); + iAdditionalSettings2 = aSettings; + } + +template +void DProfilerGenericSampler::SetAdditionalSettings3(TInt aSettings) + { + LOGSTRING3("CProfilerGenericSampler<%d>::SetAdditionalSettings3 to 0x%x",BufferSize,aSettings); + iAdditionalSettings3 = aSettings; + } + +template +void DProfilerGenericSampler::SetAdditionalSettings4(TInt aSettings) + { + LOGSTRING3("CProfilerGenericSampler<%d>::SetAdditionalSettings4 to 0x%x",BufferSize,aSettings); + iAdditionalSettings4 = aSettings; + } + +template +void DProfilerGenericSampler::SetSamplingPeriod(TInt aSettings) + { + LOGSTRING3("CProfilerGenericSampler<%d>::SetSamplingPeriod to 0x%x",BufferSize,aSettings); + iSamplingPeriod = aSettings; + } + +/* + * + * Just a test class that is derived from CProfilerGenericSampler + * + */ + +template +class DProfilerExampleSampler : public DProfilerGenericSampler + { +public: + TUint32 iSampleNumber; + + DProfilerExampleSampler(TInt aSamplerId); + ~DProfilerExampleSampler(); + + void Sample(); + void Sample(TInt aCount, TInt aLastPc); + }; + + +/* + * + * Just a test class that is derived from CProfilerGenericSampler + * + */ + +template +DProfilerExampleSampler::DProfilerExampleSampler(TInt aSamplerId) : + DProfilerGenericSampler(aSamplerId) + { + iSampleNumber = 0; + LOGSTRING2("CProfilerExampleSampler<%d>::CProfilerExampleSampler",BufferSize); + } + +template +void DProfilerExampleSampler::Sample() + { + LOGSTRING2("CProfilerExampleSampler<%d>::Sample",BufferSize); + TBuf8<20>* testiBuf = new TBuf8<20>; + + testiBuf->AppendNum((TInt)iSampleNumber); + iSampleNumber++; + + this->iSampleBuffer->AddSample((TUint8*)testiBuf->Ptr(),testiBuf->Length()); + delete testiBuf; + return; + } + +template +void DProfilerExampleSampler::Sample(TInt aCount, TInt aLastPc) + { + return; + } + +template +DProfilerExampleSampler::~DProfilerExampleSampler() + { + LOGSTRING2("CProfilerExampleSampler<%d>::~CProfilerExampleSampler",BufferSize); + } + +#include + +#endif + + +#endif diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler_api/inc/ProfilerGenericClassesKrn.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler_api/inc/ProfilerGenericClassesKrn.inl Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,531 @@ +/* +* 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: +* +*/ + + +#include + +#include + + +/* + * + * Class CProfilerSamplerBase implementation + * + */ + +inline DProfilerSamplerBase::DProfilerSamplerBase() + { + + } + +inline DProfilerSamplerBase::~DProfilerSamplerBase() + { + + } + +/* + * + * Class CProfilerSampleBuffer implementation + * + */ + +inline DProfilerSampleBuffer::DProfilerSampleBuffer(TUint8* aBuffer, + TUint8* aDblBuffer, + TUint32 aBufferSize ) + { + LOGSTRING3("CProfilerSampleBuffer::CProfilerSampleBuffer AtFirst: b:0x%x db:0x%x",aBuffer,aDblBuffer); + + // make sure the alignment is right + if((((TUint32)aBuffer) %4) != 0) + aBuffer += (4-(((TUint32)aBuffer)%4)); + if((((TUint32)aDblBuffer) %4) != 0) + aDblBuffer += (4-(((TUint32)aDblBuffer)%4)); + + LOGSTRING3("CProfilerSampleBuffer::CProfilerSampleBuffer b:0x%x db:0x%x",aBuffer,aDblBuffer); + + iBufStruct = (TProfilerSampleBufStruct*)aBuffer; + iDblBufStruct = (TProfilerSampleBufStruct*)aDblBuffer; + + LOGSTRING3("CProfilerSampleBuffer::CProfilerSampleBuffer bufStruct rem:0x%x dbuStruct rem:0x%x", + &iBufStruct->iSampleRemainder,&iDblBufStruct->iSampleRemainder); + + iBufferDataSize = aBufferSize-4; + iBufferRealSize = aBufferSize; + + ClearBuffer(); + } + +inline DProfilerSampleBuffer::~DProfilerSampleBuffer() + { + + } + +inline TInt DProfilerSampleBuffer::AddSample(TUint8* aSample, TUint32 aLength) + { + TUint32 bytesTotal; + + // check whether the buffer status is + switch (iBufferStatus) + { + case DProfilerSampleBuffer::BufferOk: + // add the data normally to the buffer + bytesTotal = iBytesWritten+aLength; + + if(bytesTotal < iBufferDataSize) + { + memcpy((&(iBufStruct->iDataStart))+iBytesWritten,aSample,aLength); + iBytesWritten+=aLength; + return 0; + } + else + { + + // the sample does not fit to the buffer + // first copy as much data as we can fit to the first buffer + TUint32 fitsToBuffer = iBufferDataSize-iBytesWritten; + TUint32 remaining = aLength-fitsToBuffer; + + memcpy((&(iBufStruct->iDataStart))+iBytesWritten,aSample,fitsToBuffer); + iBytesWritten = iBufferDataSize; + + // ->switch to the double buffer + iBufferStatus = DProfilerSampleBuffer::BufferCopyAsap; + + TProfilerSampleBufStruct* tmpPtr = iBufStruct; + iBufStruct = iDblBufStruct; + iDblBufStruct = tmpPtr; + + iDblBytesWritten = iBytesWritten; + + // and this is the remainder of a sample + // that will be copied to the new buffer + // just in a while + iBufStruct->iSampleRemainder = remaining; + + // now that the buffers have been switched + // add the rest of the sample to the buffer + aSample+=fitsToBuffer; + + // there should be room - in case the single sample + // is smaller than the whole buffer! so we don't + // bother to check + + memcpy((&(iBufStruct->iDataStart)),aSample,remaining); + iBytesWritten = remaining; + return 0; + } + + case DProfilerSampleBuffer::BufferCopyAsap: + + // no difference to the BufferOk case + // unless the double buffer gets filled + // before the data has been copied + // add the data normally to the buffer + bytesTotal = iBytesWritten+aLength; + + if(bytesTotal < iBufferDataSize) + { + memcpy((&(iBufStruct->iDataStart))+iBytesWritten,aSample,aLength); + iBytesWritten+=aLength; + return 0; + } + else + { + // the double buffer is now also full - there is no + // place to put the data -> we have to waste it! + // this is an indication of a too small buffer size + iBufferStatus = DProfilerSampleBuffer::BufferFull; + LOGSTRING("CProfilerSampleBuffer::AddSample - double buffer full!!"); + return -1; + } + + case DProfilerSampleBuffer::BufferBeingCopied: + + // no difference to the BufferCopyAsap case + bytesTotal = iBytesWritten+aLength; + + if(bytesTotal < iBufferDataSize) + { + memcpy((&(iBufStruct->iDataStart))+iBytesWritten,aSample,aLength); + iBytesWritten+=aLength; + return 0; + } + else + { + // the double buffer is now also full - there is no + // place to put the data -> we have to waste it! + // this is an indication of a too small buffer size + LOGSTRING("CProfilerSampleBuffer::AddSample - double buffer full!!"); + + // don't change the state to CProfilerSampleBuffer::BufferFull, since it is + // already being copied + return -1; + } + + case DProfilerSampleBuffer::BufferFull: + // the buffer is still full, there is noting we can do + // about it -> return + LOGSTRING("CProfilerSampleBuffer::AddSample - double buffer full!!"); + return -1; + + default: + LOGSTRING("CProfilerSampleBuffer::AddSample - wrong switch!!"); + return -1; + } + } + +inline void DProfilerSampleBuffer::EndSampling() + { + LOGSTRING("CProfilerSampleBuffer::EndSampling"); + // this will switch to the dbl buffer even though + // the buffer is not full, so that data can be copied + + // during this operation, no other buffer + // operations are allowed + + // ensure that the normal buffer is in use and that the + // buffer is in normal state ( this procedure is performed only once ) + if(iBufferStatus == DProfilerSampleBuffer::BufferOk) + { + // ->switch to the double buffer + LOGSTRING("CProfilerSampleBuffer::EndSampling - switching to double buffer"); + iBufferStatus = DProfilerSampleBuffer::BufferCopyAsap; + + TProfilerSampleBufStruct* tmpPtr = iBufStruct; + iBufStruct = iDblBufStruct; + iDblBufStruct = tmpPtr; + + iDblBytesWritten = iBytesWritten; + + // there is no new sample so the remainder is + // zero, (this shouldn't be used anyway) + iBufStruct->iSampleRemainder = 0; + } + } + +inline TUint32 DProfilerSampleBuffer::GetBufferStatus() + { + return iBufferStatus; + } + +inline void DProfilerSampleBuffer::ClearBuffer() + { + LOGSTRING2("CProfilerSampleBuffer::ClearBuffer - %d",bufferDataSize); + + // the buffers are of same size + TUint8* ptr1 = (TUint8*)&(iBufStruct->iDataStart); + TUint8* ptr2 = (TUint8*)&(iDblBufStruct->iDataStart); + + for(TUint32 i=0;iiSampleRemainder = 0; + iDblBufStruct->iSampleRemainder = 0; + + // written the dblBufStruct + iBytesWritten = 0; + iDblBytesWritten = 0; + iDblBytesRead = 0; + + iBufferStatus = DProfilerSampleBuffer::BufferOk; + } + +inline void DProfilerSampleBuffer::DataCopied() + { + iDblBytesRead = 0; + iDblBytesWritten = 0; + iBufferStatus = DProfilerSampleBuffer::BufferOk; + } + +/* + * + * Class DProfilerSampleStream implementation + * + */ + +inline DProfilerSampleStream::DProfilerSampleStream() + { + LOGSTRING("DProfilerSampleStream::DProfilerSampleStream"); + + iCurrentBuffer = 0; + iPendingRequest = 0; + iAddingSamples = 0; + iClient = 0; + } + +inline DProfilerSampleStream::~DProfilerSampleStream() + { + LOGSTRING("DProfilerSampleStream::~DProfilerSampleStream"); + } + +inline void DProfilerSampleStream::InsertCurrentClient(DThread* aClient) + { + iClient = aClient; + LOGSTRING2("DProfilerSampleStream::InsertCurrentClient - iClient is 0x%x",iClient); + } + + +inline void DProfilerSampleStream::AddSampleBuffer(TBapBuf* aBuffer,TRequestStatus* aStatus) + { + if(iCurrentBuffer != 0 || iPendingRequest != 0) + { + LOGSTRING("DProfilerSampleStream::AddSampleBuffer - ERROR 1"); + return; + } + + LOGSTRING3("DProfilerSampleStream::AddSampleBuffer - OK 0x%x,0x%x",aBuffer,aStatus); + iCurrentBuffer = aBuffer; + iPendingRequest = aStatus; + + LOGSTRING2("DProfilerSampleStream::AddSampleBuffer - Current Client is 0x%x",iClient); + } + + +inline void DProfilerSampleStream::ReleaseIfPending() + { + LOGSTRING("DProfilerSampleStream::ReleaseIfPending - entry"); + + if(iCurrentBuffer != 0 && iPendingRequest != 0 && iClient != 0) + { + LOGSTRING("DProfilerSampleStream::ReleaseIfPending - release buffer"); + + LOGSTRING2("DProfilerSampleStream::AddSamples - completing request 0x%x",iPendingRequest); + Kern::RequestComplete(iClient,iPendingRequest,KErrNone); + + iPendingRequest = 0; + iCurrentBuffer = 0; + } + + LOGSTRING("DProfilerSampleStream::ReleaseIfPending - exit"); + } + +inline void DProfilerSampleStream::AddSamples(DProfilerSampleBuffer& aBuffer, TInt aSamplerId) + { + LOGSTRING3("DProfilerSampleStream::AddSamples - entry ID: %d, currentbuffer: 0x%x", aSamplerId,iCurrentBuffer); + if(iCurrentBuffer != 0) + { + // the following will perform simple mutual exclusion + iAddingSamples++; + if(iAddingSamples > 1) + { + // there is someone else adding samples to the buffer + LOGSTRING("DProfilerSampleStream::AddSamples - mutex in use"); + iAddingSamples--; + return; + } + + LOGSTRING("DProfilerSampleStream::AddSamples - reading TBapBuf"); + + // use a copy of the client TBapBuf structure during processing + TBapBuf realBuf; + TPtr8 ptr((TUint8*)&realBuf,(TInt)sizeof(TBapBuf)); + + Kern::ThreadRawRead(iClient,(TAny*)(iCurrentBuffer),(TAny*)&realBuf,sizeof(TBapBuf)); + + ptr.SetLength(sizeof(TBapBuf)); + + LOGSTRING4("DProfilerSampleStream::AddSamples - read %d bytes from 0x%x of thread 0x%x",ptr.Size(),iCurrentBuffer,iClient); + + LOGSTRING5("DProfilerSampleStream::AddSamples - current buffer 0x%x -> b:0x%x s:%d d:%d", + &realBuf, + realBuf.iBuffer, + realBuf.iBufferSize, + realBuf.iDataSize); + + // get the address of the source buffer data + TUint8* src = (TUint8*)&(aBuffer.iDblBufStruct->iDataStart); + src += aBuffer.iDblBytesRead; + + // the amount of data to copy is the 4 header bytes + + // the remaining data in the buffer + TInt amount = aBuffer.iDblBytesWritten-aBuffer.iDblBytesRead; + + TUint8* dst = realBuf.iBuffer; + + LOGSTRING4("DProfilerSampleStream::AddSamples - s:0x%x d:0x%x a:%d",src,dst,amount); + + if(realBuf.iDataSize == 0) + { + LOGSTRING("DProfilerSampleStream::AddSamples - case 1"); + + // the buffer is empty + if(realBuf.iBufferSize >= (amount+4)) + { + LOGSTRING("DProfilerSampleStream::AddSamples - case 1.1"); + + // the source buffer is smaller or of equal size than the amount of output data + PerformCopy((TUint8)aSamplerId,src,realBuf.iBufDes,0,amount); + realBuf.iDataSize += amount+4; + // the rest of the source buffer was copied at once, so signal the buffer + aBuffer.DataCopied(); + } + else + { + LOGSTRING("DProfilerSampleStream::AddSamples - case 1.2"); + + // only a part of the source buffer will fit to the client side buffer + amount = realBuf.iBufferSize-4; + PerformCopy((TUint8)aSamplerId,src,realBuf.iBufDes,0,amount); + realBuf.iDataSize += amount+4; + // add the amount of bytes read to the source buffer + aBuffer.iDblBytesRead+=amount; + } + } + else + { + LOGSTRING("DProfilerSampleStream::AddSamples - case 2"); + + // there is data in the client buffer + dst += realBuf.iDataSize; + TInt remainingSpace = realBuf.iBufferSize-realBuf.iDataSize; + + if( remainingSpace >= (amount+4) ) + { + LOGSTRING("DProfilerSampleStream::AddSamples - case 2.1"); + + // the source buffer is smaller or of equal size than the amount of output data + PerformCopy((TUint8)aSamplerId,src,realBuf.iBufDes,realBuf.iDataSize,amount); + realBuf.iDataSize += (amount+4); + // the rest of the source buffer was copied at once, so signal the buffer + aBuffer.DataCopied(); + } + else + { + LOGSTRING("DProfilerSampleStream::AddSamples - case 2.2"); + + // only a part of the source buffer will fit to the client side buffer + if(remainingSpace >= 12) + { + LOGSTRING("DProfilerSampleStream::AddSamples - case 2.3"); + + amount = remainingSpace-4; + // there are at least 8 bytes left for data, write it + PerformCopy((TUint8)aSamplerId,src,realBuf.iBufDes,realBuf.iDataSize,amount); + realBuf.iDataSize += (amount+4); + // add the amount of bytes read to the source buffer + aBuffer.iDblBytesRead+=amount; + } + } + } + + // copy the data in the modified TBapBuf structure back to the client + LOGSTRING("DProfilerSampleStream::AddSamples - writing TBapBuf"); + //iClient->Write(currentBuffer,ptr); + + Kern::ThreadDesWrite(iClient,(TAny*)(realBuf.iDes),ptr,0,KChunkShiftBy0,iClient); + + // if the client side buffer is full or nearly full, signal the client + LOGSTRING("DProfilerSampleStream::AddSamples - data copied"); + + if(realBuf.iBufferSize-realBuf.iDataSize < 12) + { + LOGSTRING("DProfilerSampleStream::AddSamples - release buffer"); + + LOGSTRING2("DProfilerSampleStream::AddSamples - completing request 0x%x",iPendingRequest); + + Kern::RequestComplete(iClient,iPendingRequest,KErrNone); + + iPendingRequest = 0; + iCurrentBuffer = 0; + //iClient = 0; + } + + // free the lock + iAddingSamples--; + } + LOGSTRING("DProfilerSampleStream::AddSamples - exit"); + } + + + +inline TInt DProfilerSampleStream::EndSampling(DProfilerSampleBuffer& aBuffer,TInt aSamplerId) + { + LOGSTRING2("DProfilerSampleStream::EndSampling, sampler ID: %d",aSamplerId); + + // switch the buffer to double buffer + // even though it would not be full yet + // the switch is done only once / end sampling procedure + // (Only with BufferOk status) + aBuffer.EndSampling(); + + LOGSTRING2("DProfilerSampleStream::EndSampling, iClient: 0x%x",iClient); + + if(aBuffer.iBufferStatus != DProfilerSampleBuffer::BufferDataEnd) + { + // add these final samples to the client buffer + AddSamples(aBuffer,aSamplerId); + + // if all data was copied to the buffer, the buffer status is now BufferOk + + if(aBuffer.iBufferStatus != DProfilerSampleBuffer::BufferOk) + { + LOGSTRING("DProfilerSampleStream::EndSampling - more data to copy"); + // there is still more data to copy, the pending request should have been + // completed in AddSamples(), because the client buffer got filled + return 1; + } + else + { + // buffer status was changed to BufferOk in AddSamples() - + // this means all data from it could be copied + // now we have to change the status of the buffer to BufferDataEnd, so + // we know that the particular buffer has no more data to copy + LOGSTRING("DProfilerSampleStream::EndSampling - switch to BufferDataEnd"); + aBuffer.iBufferStatus = DProfilerSampleBuffer::BufferDataEnd; + } + } + + // the buffer was completely emptied to the client buffer, or there was no + // data to copy to the client side + LOGSTRING("DProfilerSampleStream::EndSampling - no more data to copy"); + + return 0; + } + +inline void DProfilerSampleStream::PerformCopy(TUint8 aSamplerId,TUint8* aSrc,TPtr8* aDst,TInt aOffset,TInt aAmount) + { + LOGSTRING2("DProfilerSampleStream::PerformCopy for sampler ID: %d",aSamplerId); + LOGSTRING5("DProfilerSampleStream::PerformCopy - 0x%x -> 0x%x - %d - offset: %d",aSrc, aDst, aAmount, aOffset); + TUint32 header; + header = aAmount & 0x00ffffff; + header += (aSamplerId << 24); + TPtr8 ptr((TUint8*)&header,4); + ptr.SetLength(4); + + LOGSTRING2("DProfilerSampleStream::PerformCopy - start header copy HDR = 0x%x",header); + + // write the header + Kern::ThreadDesWrite(iClient,(TAny*)aDst,ptr,aOffset,KChunkShiftBy0); + + LOGSTRING2("DProfilerSampleStream::PerformCopy - copied header %d bytes",ptr.Size()); + aOffset+=4; + + LOGSTRING("DProfilerSampleStream::PerformCopy - start copy"); + // write the data + ptr.Set(aSrc,aAmount,aAmount); + ptr.SetLength(aAmount); + + Kern::ThreadDesWrite(iClient,(TAny*)aDst,ptr,aOffset,KChunkShiftBy0); + + + LOGSTRING2("DProfilerSampleStream::PerformCopy - copied data %d bytes",ptr.Size()); + + } diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler_api/inc/ProfilerGenericClassesUsr.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler_api/inc/ProfilerGenericClassesUsr.h Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,121 @@ +/* +* 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 PROFILERGENERICCLASSESUSR_H +#define PROFILERGENERICCLASSESUSR_H + +#include +#include +#include +#include +#include + +#include +#include +#include + + +/* + * + * Class MProfilerBufferHandlerObserver definition + * + */ +class MProfilerBufferHandlerObserver + { +public: + virtual TBapBuf* GetNextFreeBuffer() = 0; + virtual void AddToFilledBuffers(TBapBuf* aFilledBuffer) = 0; + }; + +/* + * + * Class CProfilerBufferHandler definition + * + */ +// forward declarations +class CProfilerSampleStream; + +class CProfilerBufferHandler : public CActive + { +public: + static CProfilerBufferHandler* CProfilerBufferHandler::NewL(CProfilerSampleStream& aStream, RPluginSampler& aSampler); + CProfilerBufferHandler(CProfilerSampleStream& aStream, RPluginSampler& aSampler); + ~CProfilerBufferHandler(); + + void ConstructL(); + + // for plugins to start receiving trace data + void StartReceivingData(); +private: + void RunL(); + TInt RunError(TInt aError); + void DoCancel(); + void HandleEndOfStream(); +public: + TInt iFinished; +private: + RPluginSampler& iSampler; + TBapBuf* iBufferInProcess; + TBool iEndOfStreamDetected; + + CProfilerSampleStream& iObserver; + }; + +/* + * + * Class CProfilerSampleStream definition + * + */ +class CWriterPluginInterface; + +class CProfilerSampleStream : public CBase, MProfilerBufferHandlerObserver +{ +public: + static CProfilerSampleStream* CProfilerSampleStream::NewL(TInt aBufSize); + ~CProfilerSampleStream(); + + void ConstructL(); + + void Finalise(); + void EmptyBuffers(); + inline void AddToFreeBuffers(TBapBuf* freeBuffer); + void SetWriter(CWriterPluginInterface& aWriter); + + // from MProfilerBufferHandlerObserver + TBapBuf* GetNextFreeBuffer(); + void AddToFilledBuffers(TBapBuf* aFilledBuffer); + inline TBapBuf* GetNextFilledBuffer(); + void ResetBuffers(); + void InitialiseBuffers(); + inline void NotifyWriter(); +private: + CProfilerSampleStream(TInt aBufSize); + + +public: + TInt iFinished; + CWriterPluginInterface* iWriter; +private: + TInt iBufferSize; + TBapBuf* iFreeBuffers; + TBapBuf* iFilledBuffers; +}; + +#include + +#endif diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler_api/inc/ProfilerGenericClassesUsr.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler_api/inc/ProfilerGenericClassesUsr.inl Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,499 @@ +/* +* 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: +* +*/ + + +#include +#include + +#include +#include + +// constants +const TInt KInitialFreeBufferAmount = 4; + +/* + * + * Class CProfilerBufferHandler implementation + * + */ +inline CProfilerBufferHandler* CProfilerBufferHandler::NewL(CProfilerSampleStream& aStream, RPluginSampler& aSampler) + { + LOGTEXT(_L("CProfilerBufferHandler::NewL - entry")); + CProfilerBufferHandler* self = new(ELeave) CProfilerBufferHandler(aStream, aSampler); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +inline CProfilerBufferHandler::CProfilerBufferHandler(CProfilerSampleStream& aStream, RPluginSampler& aSampler) + : CActive(EPriorityStandard), + iSampler(aSampler), + iObserver(aStream) + { + } + +inline CProfilerBufferHandler::~CProfilerBufferHandler() + { + LOGTEXT(_L("CProfilerBufferHandler::~CProfilerBufferHandler() - entry")); + } + +inline void CProfilerBufferHandler::ConstructL() + { + LOGTEXT(_L("CProfilerBufferHandler::ConstructL - entry")); + iBufferInProcess = 0; + iEndOfStreamDetected = false; + + iFinished = 0; + // add the buffer handler to the active scheduler + CActiveScheduler::Add(this); + } + +inline void CProfilerBufferHandler::StartReceivingData() + { + LOGTEXT(_L("CProfilerBufferHandler::StartReceivingData - entry")); + + iEndOfStreamDetected = false; + // this method initiates receiving data from the sampler + iBufferInProcess = iObserver.GetNextFreeBuffer(); + + LOGSTRING5("CProfilerBufferHandler::StartReceivingData - 0x%x -> b:0x%x s:%d d:%d", + iBufferInProcess, + iBufferInProcess->iBuffer, + iBufferInProcess->iBufferSize, + iBufferInProcess->iDataSize); + + iSampler.FillThisStreamBuffer(iBufferInProcess,iStatus); + + LOGTEXT(_L("CProfilerBufferHandler::StartReceivingData - SetActive")); + SetActive(); + + LOGTEXT(_L("CProfilerBufferHandler::StartReceivingData - exit")); + } + +inline TInt CProfilerBufferHandler::RunError(TInt aError) + { + // handle the error case by stopping the trace + HandleEndOfStream(); + return aError; + } + +inline void CProfilerBufferHandler::HandleEndOfStream() + { + LOGTEXT(_L("CProfilerBufferHandler::RunError - entry")); + // Cancel has been called, the stream should be about to end now, + // we will wait for the rest of the buffers to be filled synchronously + // the end of the stream will be indicated through an empty buffer + // at first, complete the ongoing request + if(iStatus == KRequestPending && iBufferInProcess != 0) + { + LOGTEXT(_L("CProfilerBufferHandler::DoCancel - case 1")); + + // wait for the buffer to be filled synchronously + User::WaitForRequest(iStatus); + + // add the received buffer to the list of filled buffers + iObserver.AddToFilledBuffers(iBufferInProcess); + // continue writing to output + iObserver.NotifyWriter(); + + if(iBufferInProcess->iDataSize == 0) + { + // a buffer with size 0 was received + LOGTEXT(_L("CProfilerBufferHandler::DoCancel - case 1.1")); + iEndOfStreamDetected = true; + } + + // there will be no more asynchronous requests + iBufferInProcess = 0; + } + else if (iBufferInProcess != 0) + { + LOGTEXT(_L("CProfilerBufferHandler::DoCancel - case 2")); + + // add the buffer into filled, i.e. ready-to-write buffers + iObserver.AddToFilledBuffers(iBufferInProcess); + iObserver.NotifyWriter(); + + if(iBufferInProcess->iDataSize == 0) + { + // a buffer with size 0 was received + LOGTEXT(_L("CProfilerBufferHandler::DoCancel - case 2.1")); + iEndOfStreamDetected = true; + } + // there will be no more asynchronous requests + iBufferInProcess = 0; + } + + // then, continue until end of stream has been reached + while(iEndOfStreamDetected == false) + { + // the end of stream has not yet been detected, so get more + // buffers from the sampler, until we get an empty one + + if(iStatus == KRequestPending) + { + LOGTEXT(_L("CProfilerBufferHandler::DoCancel - ERROR 1")); + } + + LOGTEXT(_L("CProfilerBufferHandler::DoCancel - case 3")); + + TBapBuf* nextFree = iObserver.GetNextFreeBuffer(); + iSampler.FillThisStreamBuffer(nextFree,iStatus); + // wait for the buffer to be filled synchronously + User::WaitForRequest(iStatus); + + // call the writer plugin to write data to output + iObserver.AddToFilledBuffers(nextFree); + iObserver.NotifyWriter(); + + // check if end-of-data message (i.e. data size is 0 sized) received + if(nextFree->iDataSize == 0) + { + LOGTEXT(_L("CProfilerBufferHandler::DoCancel - case 3.1")); + // a buffer with size 0 was received + iEndOfStreamDetected = true; + nextFree = 0; + } + } + } + +inline void CProfilerBufferHandler::RunL() + { + LOGTEXT(_L("CProfilerBufferHandler::RunL - entry")); + + // is called by the active scheduler + // when a buffer has been received + + // buffer with dataSize 0 is returned when the sampling ends + if(iBufferInProcess->iDataSize != 0) + { + LOGTEXT(_L("CProfilerBufferHandler::RunL - buffer received")); + + TBapBuf* nextFree = iObserver.GetNextFreeBuffer(); + + LOGSTRING5("CProfilerBufferHandler::RunL - 0x%x -> b:0x%x s:%d d:%d", + nextFree, + nextFree->iBuffer, + nextFree->iBufferSize, + nextFree->iDataSize); + + iSampler.FillThisStreamBuffer(nextFree,iStatus); + + LOGTEXT(_L("CProfilerBufferHandler::RunL - issued new sample command")); + + // add the received buffer to the list of filled buffers + iObserver.AddToFilledBuffers(iBufferInProcess); + iObserver.NotifyWriter(); + + // the empty buffer is now the one being processed + iBufferInProcess = nextFree; + + LOGTEXT(_L("CProfilerBufferHandler::RunL - SetActive")); + SetActive(); + } + else + { + LOGTEXT(_L("CProfilerBufferHandler::RunL - end of stream detected")); + iEndOfStreamDetected = true; + + // add the empty buffer to the writer so that it will also get the information + // about the finished stream + iObserver.AddToFilledBuffers(iBufferInProcess); + iObserver.NotifyWriter(); + + iBufferInProcess = 0; + Cancel(); + + } + LOGTEXT(_L("CProfilerBufferHandler::RunL - exit")); + } + +inline void CProfilerBufferHandler::DoCancel() + { + LOGTEXT(_L("CProfilerBufferHandler::DoCancel - entry")); + HandleEndOfStream(); + LOGTEXT(_L("CProfilerBufferHandler::DoCancel - exit")); + } + + +/* + * + * Class CProfilerSampleStream implementation + * + * - used by Plugin + **/ + +inline CProfilerSampleStream* CProfilerSampleStream::NewL(TInt aBufSize) + { + LOGTEXT(_L("CProfilerSampleStream::NewL - entry")); + CProfilerSampleStream* self = new(ELeave) CProfilerSampleStream(aBufSize); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +inline CProfilerSampleStream::CProfilerSampleStream(TInt aBufSize) : + iBufferSize(aBufSize) + { + LOGTEXT(_L("CProfilerSampleStream::CProfilerSampleStream - entry")); + + iFilledBuffers = 0; + iFreeBuffers = 0; + iFinished = 0; + + LOGTEXT(_L("CProfilerSampleStream::CProfilerSampleStream - exit")); + } + +inline CProfilerSampleStream::~CProfilerSampleStream() + { + LOGTEXT(_L("CProfilerSampleStream::~CProfilerSampleStream - entry")); + + // empty all buffers + EmptyBuffers(); + + LOGTEXT(_L("CProfilerSampleStream::~CProfilerSampleStream - exit")); + } + +inline void CProfilerSampleStream::ConstructL() + { + + } + +inline void CProfilerSampleStream::SetWriter(CWriterPluginInterface& aWriter) + { + // set writer plugin + iWriter = &aWriter; + } + +inline void CProfilerSampleStream::Finalise() + { + LOGTEXT(_L("CProfilerSampleStream::Finalise - entry")); + } + +inline void CProfilerSampleStream::ResetBuffers() + { + + // empty buffers + EmptyBuffers(); + + // re-initialise buffers + InitialiseBuffers(); + } + +inline void CProfilerSampleStream::InitialiseBuffers() + { + // re-initialize member variables + iFilledBuffers = 0; + iFreeBuffers = 0; + iFinished = 0; + + // create three(orig. two) new TBapBuf objects and add them to the + // list of free buffers + for(TInt i(0);iiBuffer = (TUint8*)User::Alloc(iBufferSize); + + // initialize the new buffer + newBuf->iBufferSize = iBufferSize; + newBuf->iDataSize = 0; + newBuf->iNext = 0; + newBuf->iDes = new TPtr8((TUint8*)newBuf,sizeof(TBapBuf)); + newBuf->iDes->SetLength(sizeof(TBapBuf)); + newBuf->iBufDes = new TPtr8((TUint8*)newBuf->iBuffer,iBufferSize); + newBuf->iBufDes->SetLength(iBufferSize); + AddToFreeBuffers(newBuf); + } + } + +inline void CProfilerSampleStream::EmptyBuffers() + { + LOGTEXT(_L("CProfilerSampleStream::EmptyBuffers - entry")); + + // delete all free buffers + while(iFreeBuffers != 0) + { + LOGSTRING2("CProfilerSampleStream::EmptyBuffers - deleting 0x%x",iFreeBuffers); + + // store the next buffer in the list + TBapBuf* nextFree = iFreeBuffers->iNext; + // delete the first one in the list + delete iFreeBuffers->iBufDes; + delete iFreeBuffers->iDes; + delete iFreeBuffers->iBuffer; + delete iFreeBuffers; + // set the list start to the next buffer + iFreeBuffers = nextFree; + } + iFreeBuffers = 0; + LOGTEXT(_L("CProfilerSampleStream::EmptyBuffers - exit")); + } + +inline TBapBuf* CProfilerSampleStream::GetNextFreeBuffer() + { + LOGTEXT(_L("CProfilerSampleStream::GetNextFreeBuffer - entry")); + + // get a new buffer from the free buffers list + TBapBuf* nextFree = iFreeBuffers; + + // check if we got a buffer or not + if(nextFree == 0) + { + // if there are no free buffers, + // create a new one + LOGTEXT(_L("CProfilerSampleStream::GetNextFreeBuffer - creating new buffer")); + TBapBuf* newBuf = (TBapBuf*)User::Alloc(sizeof(TBapBuf)); + if(newBuf != 0) + { + newBuf->iBuffer = (TUint8*)User::Alloc(iBufferSize); + if(newBuf->iBuffer != 0) + { + newBuf->iBufferSize = iBufferSize; + newBuf->iDataSize = 0; + newBuf->iNext = 0; + newBuf->iDes = new TPtr8((TUint8*)newBuf,sizeof(TBapBuf)); + newBuf->iDes->SetLength(sizeof(TBapBuf)); + newBuf->iBufDes = new TPtr8((TUint8*)newBuf->iBuffer,iBufferSize); + newBuf->iBufDes->SetLength(iBufferSize); + nextFree = newBuf; + } + else + { + LOGTEXT(_L("CProfilerSampleStream::GetNextFreeBuffer - Out of memory (1)!!")); + return 0; + } + } + else + { + LOGTEXT(_L("CProfilerSampleStream::GetNextFreeBuffer - Out of memory (2)!!")); + delete newBuf; + return 0; + } + } + else + { + // set the list to point to next free buffer + iFreeBuffers = nextFree->iNext; + } + + LOGTEXT(_L("CProfilerSampleStream::GetNextFreeBuffer - exit")); + return nextFree; + } + +inline void CProfilerSampleStream::AddToFilledBuffers(TBapBuf* aFilledBuffer) + { + LOGSTRING2(_L("CProfilerSampleStream::AddToFilledBuffers - entry, size %d"), aFilledBuffer->iDataSize); + + // add this buffer to the list of filled buffers + if(iFilledBuffers == 0) + { + // the list is empty, so add the the beginning of the list + // there is no next buffer in the list at the moment + aFilledBuffer->iNext = 0; + iFilledBuffers = aFilledBuffer; + } + else + { + // there are buffers in the list, add this buffer to the beginning of the list + aFilledBuffer->iNext = iFilledBuffers; + iFilledBuffers = aFilledBuffer; + } + LOGTEXT(_L("CProfilerSampleStream::AddToFilledBuffers - exit")); + } + +TBapBuf* CProfilerSampleStream::GetNextFilledBuffer() + { + LOGTEXT(_L("CProfilerSampleStream::GetNextFilledBuffer - entry")); + + if(iFilledBuffers == 0) + { + // there are no filled buffers in the list + LOGTEXT(_L("CProfilerSampleStream::GetNextFilledBuffer - no filled bufs")); + return 0; + } + else + { + // get a buffer from the end of the list + TBapBuf* buf = iFilledBuffers; + TBapBuf* prev = 0; + + if(buf->iNext == 0) + { + // this was the last (and only) buffer + iFilledBuffers = 0; + LOGTEXT(_L("CProfilerSampleStream::GetNextFilledBuffer - last filled")); + return buf; + } + else + { + LOGTEXT(_L("CProfilerSampleStream::GetNextFilledBuffer - searching last filled")); + while(buf->iNext != 0) + { + // there are two or more buffers in the list + // proceed until the end of the list is found + prev = buf; + buf = buf->iNext; + } + // now buf->next is 0, return buf and set the next + // element of prev to NULL + prev->iNext = 0; + LOGTEXT(_L("CProfilerSampleStream::GetNextFilledBuffer - found last")); + return buf; + } + } + } + +inline void CProfilerSampleStream::AddToFreeBuffers(TBapBuf* aFreeBuffer) + { + LOGTEXT(_L("CProfilerSampleStream::AddToFreeBuffers - entry")); + + // set data size of the buffer to 0 + aFreeBuffer->iDataSize = 0; + + // add this buffer to the list of free buffers + if(iFreeBuffers == 0) + { + // this is the first buffer, so set the next to point to NULL + aFreeBuffer->iNext = 0; + } + else + { + // otherwise set to point to the beginning of the list + aFreeBuffer->iNext = iFreeBuffers; + } + + // set this buffer to be the first one in the list + iFreeBuffers = aFreeBuffer; + + LOGTEXT(_L("CProfilerSampleStream::AddToFreeBuffers - exit")); + } + +void CProfilerSampleStream::NotifyWriter() + { + // notify writer plugin to write data from filled buffer list + LOGTEXT(_L("CProfilerSampleStream::NotifyWriter() - entry")); + iWriter->WriteData(); + LOGTEXT(_L("CProfilerSampleStream::NotifyWriter() - exit")); + } + +// end of file + + + diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler_api/inc/ProfilerSession.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler_api/inc/ProfilerSession.h Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,392 @@ +/* +* 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_SESSION_H__ +#define __PROFILER_SESSION_H__ + +#include +#include +#include +#include +#include +#include + +_LIT(KProfilerName,"PIProfilerEngine"); + +/** + * The RProfiler class provides a functional interface to the sampling profiler. + * + * The engine must already be running for this interface to work, this can be + * achieved by executing PIProfilerEngine.exe. The control methods are all static, and + * require no other context. + */ +NONSHARABLE_CLASS( RProfiler ) : public RSessionBase + { +public: + enum TCommand { + // profiler controls + EStartSampling = 1, + EStopSampling, +// ELoadSettings, + EExitProfiler, + EFinalise, + + // general attributes + EGetGeneralAttributes, + EGetSamplerAttributes, + EGetSamplerAttributeCount, + ESetGeneralAttributes, + ESetSamplerAttributes, + + // generic settings + ESetTraceFilePrefix, + ESetTraceFileDrive, + EGetSamplerVersion, + EGetFileName, + EGetActiveWriter, + ERefreshProfilerStatus + }; + + enum TSamplerState { + EIdle = 0, + EInitializing, + ERunning, + EStopping, + EStopped + }; +public: + + + /* + * + * Methods for commanding Profiler Engine + * + */ + + // get general settings + static inline TInt GetGeneralAttributes(TGeneralAttributes& aAttributes); + + // get samplers; names, settings, states, descriptions etc. in one array containing all sampler attributes + static inline TInt GetSamplerAttributes(CArrayFixFlat& aAttributeArray); + + // save settings back to engine and plugins + static inline TInt SetGeneralAttributes(TGeneralAttributes aAttributes); + + // save settings back to engine and plugins + static inline TInt SetSamplerAttributes(TSamplerAttributes aAttributes); + + // refresh profiler engine status + static inline TInt RefreshProfilerStatus(); + + /** Start sampling */ + static inline TInt StartSampling(); + /** Stop sampling */ + static inline TInt StopSampling(); + /** Load settings */ +// static inline TInt LoadSettings(TDesC& aSettingsFile); + /** Exit profiler */ + static inline TInt ExitProfiler(); + + /** Get file name */ + static inline TInt GetFileName(TDes&); + /** Get active writer */ + static inline TInt GetActiveWriter(TDes&); + /** Perform a test case */ + static inline TInt Test(TUint32 testCase); + /** Issue a control request to the engine without data*/ + static inline TInt ControlState(TCommand aRequest); + /** Issue a control request to the engine with descriptor data to write there*/ + static inline TInt ControlWrite(TCommand aRequest,TDesC& data); + /** Issue a control request to the engine with numeric and descriptor data to write there*/ + static inline TInt ControlWrite(TCommand aRequest,TInt numData, TDesC& data); + /** Issue a control request to read descriptor data from the engine*/ + static inline TInt ControlRead(TCommand aRequest,TDes& data); + /** Actually sends the message to profiler engine*/ + static inline TInt PerformControl( TCommand aRequest, + TDesC* fromDescriptor = NULL, + TUint32 numData1 = 0, + TDes* toDescriptor = NULL, + TUint32 numData2 = 0xffffffff); + +private: + inline RProfiler(); + }; + +inline RProfiler::RProfiler() + {} + +// +// Connect to the profiler engine, and issue the control request if successful +// +inline TInt RProfiler::ControlState(TCommand aRequest) + { return PerformControl(aRequest); } + +// +// Connect to the profiler engine, and issue the control request if successful +// +inline TInt RProfiler::ControlWrite(TCommand aRequest,TDesC& data) + { return PerformControl(aRequest,&data,0); } + +// +// Connect to the profiler engine, and issue the control request if successful +// +inline TInt RProfiler::ControlWrite(TCommand aRequest,TInt numData, TDesC& data) + { return PerformControl(aRequest,&data,numData); } + +// +// Connect to the profiler engine, and issue the control request if successful +// +inline TInt RProfiler::ControlRead(TCommand aRequest,TDes& data) + { return PerformControl(aRequest,0,0,&data); } + +inline TInt RProfiler::PerformControl(TCommand aRequest,TDesC* fromDescriptor,TUint32 numData1,TDes* toDescriptor,TUint32 numData2) + { + LOGTEXT(_L("Creating a session to profiler")); + RProfiler p; + TUint count(0); + TInt r(KErrNone); + + // in boot measurement mode, count until 30s + #ifdef PROFILER_BOOT_MEASUREMENT + while(count < 60) + #else + while(count < 6) + #endif + { + r = p.CreateSession(KProfilerName, TVersion(), 0); + if (r == KErrNone) + { + LOGSTRING2("Succeeded, sending a message %d", aRequest); + LOGSTRING5(" - parameters 0x%x 0x%x 0x%x 0x%x",fromDescriptor,numData1,toDescriptor,numData2); + TInt err = KErrNone; + + TIpcArgs a; + a.Set(0,fromDescriptor); + a.Set(1,numData1); + a.Set(2,toDescriptor); + a.Set(3,numData2); + err = p.SendReceive(aRequest,a); + + p.RSessionBase::Close(); + + if(err != KErrNone) + { + LOGSTRING2("RProfiler responded with an error - code %d !!",err); + return err; + } + else + { + LOGTEXT(_L("OK, message sent, closing")); + return KErrNone; + } + } + + LOGSTRING2("Error in opening session to profiler - code %d !!",r); + //#ifdef PROFILER_BOOT_MEASUREMENT + // there was an error contacting the Profiler + // indicates that the server is most probably not up + // however, since it should be(unless some resource is not yet ready) + // we can just wait + User::After(500000); // wait 1/2 s + count++; + //#else + // exit immediately on error + //return r; + //#endif + } + return r; + } + +// the new UI access methods +inline TInt RProfiler::GetGeneralAttributes(TGeneralAttributes& aAttributes) + { +#ifdef _TEST_ + _LIT(KDefaultTraceOutput,"debug_output"); + _LIT(KDefaultTraceFilePrefix,"PIProfiler_#"); + _LIT(KDefaultTraceFileSaveDrive,"E:\\"); + aAttributes.iTraceOutput.Copy(KDefaultTraceOutput); + aAttributes.iTraceFilePrefix.Copy(KDefaultTraceFilePrefix); + aAttributes.iSaveFileDrive.Copy(KDefaultTraceFileSaveDrive); +#else + LOGTEXT(_L("Creating a session to profiler")); + RProfiler p; + TInt r(KErrNone); + r = p.CreateSession(KProfilerName, TVersion(), 0); + if (r == KErrNone) + { + LOGSTRING2("Succeeded, sending a message %d", EGetGeneralAttributes); + + TPckg attrPckg(aAttributes); + TIpcArgs a(&attrPckg); + r = p.SendReceive(RProfiler::EGetGeneralAttributes,a); + + p.RSessionBase::Close(); + + if(r != KErrNone) + { + LOGSTRING2("Profiler responded with an error - code %d !!",r); + return r; + } + else + { + LOGTEXT(_L("OK, message sent, closing")); + return KErrNone; + } + } +#endif + return r; // return error code + } +inline TInt RProfiler::GetSamplerAttributes(CArrayFixFlat& aAttributes) + { +#ifdef _TEST_ + _LIT(KDefaultTraceOutput,"debug_output"); + _LIT(KDefaultTraceFilePrefix,"PIProfiler_#"); + _LIT(KDefaultTraceFileSaveDrive,"E:\\"); + aAttributes.iTraceOutput.Copy(KDefaultTraceOutput); + aAttributes.iTraceFilePrefix.Copy(KDefaultTraceFilePrefix); + aAttributes.iSaveFileDrive.Copy(KDefaultTraceFileSaveDrive); +#else + // do receive stream of TSamplerAttributes + LOGTEXT(_L("Creating a session to profiler")); + RProfiler p; + TInt r(KErrNone); + r = p.CreateSession(KProfilerName, TVersion(), 0); + if (r == KErrNone) + { + TInt attrCount(0); + TPckg pckg(attrCount); + TIpcArgs args(&pckg); + + r = p.SendReceive(RProfiler::EGetSamplerAttributeCount, args); + + HBufC8* buffer = HBufC8::NewL(attrCount*sizeof(TSamplerAttributes)); + TPtr8 ptr(buffer->Des()); + TIpcArgs args2(&ptr); + r = p.SendReceive(RProfiler::EGetSamplerAttributes, args2); + + TInt len(ptr.Length()); + TInt pos(0); + while (pos != len) + { + TPckgBuf attrPckg; + attrPckg.Copy(ptr.Mid(pos, attrPckg.Length())); + pos += attrPckg.Length(); + + aAttributes.AppendL(attrPckg()); + } + + p.RSessionBase::Close(); + + if(r != KErrNone) + { + LOGSTRING2("Profiler responded with an error - code %d !!",r); + return r; + } + else + { + LOGTEXT(_L("OK, message sent, closing")); + return KErrNone; + } + } +#endif + return KErrNone; + } + +inline TInt RProfiler::SetGeneralAttributes(TGeneralAttributes aAttributes) + { + // do receive stream of TSamplerAttributes + LOGTEXT(_L("Creating a session to profiler")); + RProfiler p; + TInt r(KErrNone); + r = p.CreateSession(KProfilerName, TVersion(), 0); + if (r == KErrNone) + { + + TPckg attrPckg(aAttributes); + TIpcArgs a(&attrPckg); + r = p.SendReceive(RProfiler::ESetGeneralAttributes,a); + + p.RSessionBase::Close(); + + if(r != KErrNone) + { + LOGSTRING2("Profiler responded with an error - code %d !!",r); + return r; + } + else + { + LOGTEXT(_L("OK, message sent, closing")); + return KErrNone; + } + } + return r; + } + +// save settings back to engine and plugins +inline TInt RProfiler::SetSamplerAttributes(TSamplerAttributes aAttributes) + { + // do receive stream of TSamplerAttributes + LOGTEXT(_L("Creating a session to profiler")); + RProfiler p; + TInt r(KErrNone); + r = p.CreateSession(KProfilerName, TVersion(), 0); + if (r == KErrNone) + { + + TPckg attrPckg(aAttributes); + + TIpcArgs a; + a.Set(0,&attrPckg); + + r = p.SendReceive(RProfiler::ESetSamplerAttributes,a); + + p.RSessionBase::Close(); + + if(r != KErrNone) + { + LOGSTRING2("Profiler responded with an error - code %d !!",r); + return r; + } + else + { + LOGTEXT(_L("OK, message sent, closing")); + return KErrNone; + } + } + return r; + } + +inline TInt RProfiler::RefreshProfilerStatus() + {return ControlState(RProfiler::ERefreshProfilerStatus); } + +inline TInt RProfiler::StartSampling() + {return ControlState(RProfiler::EStartSampling);} + +inline TInt RProfiler::StopSampling() + {return ControlState(RProfiler::EStopSampling);} + +inline TInt RProfiler::ExitProfiler() + {return ControlState(RProfiler::EExitProfiler);} + +inline TInt RProfiler::GetFileName(TDes& fileName) + {return ControlRead(EGetFileName,fileName);} + +inline TInt RProfiler::GetActiveWriter(TDes& writerDes) + {return ControlRead(EGetActiveWriter,writerDes);} + +#endif // __PROFILER_SESSION_H__ diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler_api/inc/ProfilerTraces.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler_api/inc/ProfilerTraces.h Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,146 @@ +/* +* 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_TRACES_H__ +#define __PROFILER_TRACES_H__ + +#include + + +// --------------------------------------------------------------------------- +// You change these logging method values below! Recompile the application to take changes effect. + + // logging methods + // 0 = No logging + // 1 = Flogger + // 2 = RDebug + // 3 = Flogger and RDebug + +#undef _DEBUG + + #ifndef _DEBUG + + // Logging method for UREL builds: + #define PROFILER_LOGGING_METHOD 0 + + #else + + // Logging method for UDEB builds: + #define PROFILER_LOGGING_METHOD 2 + + #endif + + #ifndef _KERNEL_DEBUG + + // Logging method for UREL builds: + #define KERNEL_LOGGING_METHOD 0 + + #else + + // Logging method for UDEB builds: + #define KERNEL_LOGGING_METHOD 1 + + #endif + + + +#ifndef __KERNEL_MODE__ + +// --------------------------------------------------------------------------- +// Do not make any changes to lines below... + + #if PROFILER_LOGGING_METHOD == 1 || PROFILER_LOGGING_METHOD == 3 + + #include + _LIT(KLogFolder,"PIProfiler"); + _LIT(KLogFile,"PIProfiler_Trace.txt"); + + #endif + + #if PROFILER_LOGGING_METHOD == 2 || PROFILER_LOGGING_METHOD == 3 + + #include + + #endif + + + #if PROFILER_LOGGING_METHOD == 0 + + #define LOGTEXT(AAA) + #define LOGSTRING(AAA) + #define LOGSTRING2(AAA,BBB) + #define LOGSTRING3(AAA,BBB,CCC) + #define LOGSTRING4(AAA,BBB,CCC,DDD) + #define LOGSTRING5(AAA,BBB,CCC,DDD,EEE) + + + #elif PROFILER_LOGGING_METHOD == 1 + + #define LOGTEXT(AAA) RFileLogger::Write(KLogFolder(),KLogFile(),EFileLoggingModeAppend, AAA) + #define LOGSTRING(AAA) do { _LIT(tempLogDes,AAA); RFileLogger::Write(KLogFolder(),KLogFile(),EFileLoggingModeAppend,tempLogDes()); } while (0) + #define LOGSTRING2(AAA,BBB) do { _LIT(tempLogDes,AAA); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue(tempLogDes()),BBB); } while (0) + #define LOGSTRING3(AAA,BBB,CCC) do { _LIT(tempLogDes,AAA); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue(tempLogDes()),BBB,CCC); } while (0) + #define LOGSTRING4(AAA,BBB,CCC,DDD) do { _LIT(tempLogDes,AAA); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue(tempLogDes()),BBB,CCC,DDD); } while (0) + #define LOGSTRING5(AAA,BBB,CCC,DDD,EEE) do { _LIT(tempLogDes,AAA); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue(tempLogDes()),BBB,CCC,DDD,EEE); } while (0) + + #elif PROFILER_LOGGING_METHOD == 2 + + #define LOGTEXT(AAA) RDebug::Print(AAA); + #define LOGSTRING(AAA) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes); } while (0) + #define LOGSTRING2(AAA,BBB) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB); } while (0) + #define LOGSTRING3(AAA,BBB,CCC) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB, CCC); } while (0) + #define LOGSTRING4(AAA,BBB,CCC,DDD) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB, CCC, DDD); } while (0) + #define LOGSTRING5(AAA,BBB,CCC,DDD,EEE) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB, CCC, DDD, EEE); } while (0) + + #elif PROFILER_LOGGING_METHOD == 3 + + #define LOGTEXT(AAA) RDebug::Print(AAA); RFileLogger::Write(KLogFolder(),KLogFile(),EFileLoggingModeAppend, AAA) + #define LOGSTRING(AAA) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes); RFileLogger::Write(KLogFolder(),KLogFile(),EFileLoggingModeAppend,tempLogDes()); } while (0) + #define LOGSTRING2(AAA,BBB) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue(tempLogDes()),BBB); } while (0) + #define LOGSTRING3(AAA,BBB,CCC) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB, CCC); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue(tempLogDes()),BBB,CCC); } while (0) + #define LOGSTRING4(AAA,BBB,CCC,DDD) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB, CCC, DDD); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue(tempLogDes()),BBB,CCC,DDD); } while (0) + #define LOGSTRING5(AAA,BBB,CCC,DDD,EEE) do { _LIT(tempLogDes,AAA); RDebug::Print(tempLogDes, BBB, CCC, DDD, EEE); RFileLogger::WriteFormat(KLogFolder(),KLogFile(),EFileLoggingModeAppend,TRefByValue(tempLogDes()),BBB,CCC,DDD,EEE); } while (0) + + #endif + +#else __KERNEL_MODE__ + + #if KERNEL_LOGGING_METHOD == 0 + + #define LOGTEXT(AAA) + #define LOGSTRING(AAA) + #define LOGSTRING2(AAA,BBB) + #define LOGSTRING3(AAA,BBB,CCC) + #define LOGSTRING4(AAA,BBB,CCC,DDD) + #define LOGSTRING5(AAA,BBB,CCC,DDD,EEE) + + #else + + #define LOGTEXT(AAA) Kern::Printf(AAA) + #define LOGSTRING(AAA) Kern::Printf(AAA); + #define LOGSTRING2(AAA,BBB) Kern::Printf(AAA, BBB); + #define LOGSTRING3(AAA,BBB,CCC) Kern::Printf(AAA, BBB, CCC); + #define LOGSTRING4(AAA,BBB,CCC,DDD) Kern::Printf(AAA, BBB, CCC, DDD); + #define LOGSTRING5(AAA,BBB,CCC,DDD,EEE) Kern::Printf(AAA, BBB, CCC, DDD, EEE); + + #endif +#endif +// --------------------------------------------------------------------------- + +#endif // __PROFILER_TRACES_H__ + diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler_api/inc/ProfilerVersion.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler_api/inc/ProfilerVersion.h Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,46 @@ +/* +* 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_TOOL_VERSION_H +#define PROFILER_TOOL_VERSION_H + + /* + * + * PI Profiler tool composition definitions + * + */ + + #define PROFILER_VERSION "PI Profiler v2.00.0" + #define PROFILER_VERSION_SHORT _L("2.00.0") + #define PROFILER_SAMPLER_VERSION _L("2.00.0") + #define PROFILER_RELEASE_DATE _L("23rd February 2009. ") + + #define PROFILER_GPP_SAMPLER_VERSION _L("1.10") + #define PROFILER_GFC_SAMPLER_VERSION _L8("1.10") + #define PROFILER_ITT_SAMPLER_VERSION _L8("1.22") + #define PROFILER_MEM_SAMPLER_VERSION _L8("1.56") + #define PROFILER_PRI_SAMPLER_VERSION _L8("1.56") + #define PROFILER_BUP_SAMPLER_VERSION _L8("1.20") + #define PROFILER_IRQ_SAMPLER_VERSION _L8("1.20") + #define PROFILER_TIP_SAMPLER_VERSION _L8("1.10") + #define PROFILER_PEC_SAMPLER_VERSION _L8("1.24") + #define PROFILER_PWR_SAMPLER_VERSION _L8("1.57") + #define PROFILER_SCR_SAMPLER_VERSION _L8("1.57") + #define PROFILER_IPC_SAMPLER_VERSION _L8("1.59") + +#endif diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler_api/inc/SamplerPluginInterface.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler_api/inc/SamplerPluginInterface.h Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,265 @@ +/* +* 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 __SAMPLER_PLUGIN_INTERFACE__ +#define __SAMPLER_PLUGIN_INTERFACE__ + +#include +#include +#include +#include // internal settings format presentations + + +// Constant for indexing (iOrder): +const TInt KSamplerPluginNotIndexed = -1; + +/** + * Constant: KSamplerPluginInterfaceUid + * + * Description: UID of this ECOM interface. It should be unique in the system. + * It is used to identify this specific custom interface. + * Implementations of this interface will use this ID, when they + * publish the implementation. Clients use this UID to search for + * implementations for this interface (the + * EcomInterfaceDefinition.inl does this). + */ +const TUid KSamplerPluginInterfaceUid = {0x2001E5BC}; + +/** + * + * Description: UID of this ECOM interface. It should be unique in the system. + * + */ +enum TGenericSettingTypes +{ + EEnablePlugin, + EOutputSettings, + ESaveDrive, + EFilePrefix, + ETracingMode +}; + + +enum TSamplerCaptionTypes + { + ECaptionLengthShort, + ECaptionLengthMedium, + ECaptionLengthLong, + ESettingsCaption + }; + + +/** +* Used by GetValue(). These are the keys for retrieving a specific +* value. This enum can be extended to provide other values as well as +* long as the original keys are not changed. +*/ +enum TSamplerPluginValueKeys + { + + ESamplerPluginKeySettingsItemValueString = 1, + ESamplerPluginSettings, + ESamplerPluginEnabled, + ESamplerPluginDisabled, + ESamplerPluginType, + ESamplerPluginVersion + }; + + +/** + * Class: CSamplerInterfaceDefinition + * + * Description: Custom ECOM interface definition. This interface is used by + * clients to find specific instance and do corresponding + * calculation operation for given too numbers. Plugin + * implementations implement the Calculate function. + */ +class TBapBuf; +class CProfilerSampleStream; + +class CSamplerPluginInterface : public CBase +{ + + // CSamplerPluginLoader accesses iOrder which should not be accessed outside. + friend class CSamplerPluginLoader; + +public: + // Wrapper functions to handle ECOM "connectivity". + // These are implemented in EComInterfaceDefinition.inl. + // These functions are used only by the client. + + /** + * Function: NewL + * + * Description: Wraps ECom object instantitation. Will search for + * interface implementation, which matches to given + * aOperationName. + * + * Param: aOperationName name of requested implementation. + * Implementations advertise their "name" as specified + * in their resource file field + * IMPLEMENTATION_INFO::default_data. + * For details, see EcomInterfaceDefinition.inl comments. + * In this example, the allowed values are "sum" and + * "multiply". + * + * Note: This is not a "normal" NewL method, since normally NewL + * methods are only defined for concrete classes. + * Note that also implementations of this interface provide + * NewL methods. They are the familiar NewL's, which create + * instance of classes. + */ + static CSamplerPluginInterface* NewL(const TUid aImplementationUid, TAny* aInitParams); + + /** + * Function: ~CSamplerPluginInterface + * + * Description: Wraps ECom object destruction. Notifies the ECOM + * framework that specific instance is being destroyed. + * See EcomInterfaceDefinition.inl for details. + */ + virtual ~CSamplerPluginInterface(); +protected: // New + + /** + * C++ constructor. + */ + CSamplerPluginInterface(); + +public: + // Public pure virtual functions, which are implemented by + // interface implementations (See ..\plugin) + + /** + * Method for initializing and starting of profiling in single plugin implementation + * @param aStream is a data stream to store the gathered data, provided by engine + * @return TInt if no error KErrNone, else any of system-wide errors + */ + virtual TInt ResetAndActivateL(CProfilerSampleStream& aStream) = 0; + + /** + * Method for stopping of profiling in single plugin implementation + * @return TInt if no error KErrNone, else any of system-wide errors + */ + virtual TInt StopSampling() = 0; + /** + * Method for checking if plugin is enabled + * @return TBool if enabled return ETrue else EFalse + */ + virtual TBool Enabled() = 0; + + /** + * Method for getting an array of sampler attributes, size of an array: 1...n + * @return array of settings of one or several sampler plugins + */ + virtual void GetAttributesL(CArrayFixFlat* aAttributeArray) = 0; + + /** + * Method for setting configurations of single sampler attributes + * @param aAttributes contains settings of a single sampler plugin + */ + virtual TInt SetAttributesL(TSamplerAttributes aAttributes) = 0; + + /** + * Method for parsing text formatted settings block and converting + * it to TSamplerAttributes data structure + * @param aSingleSettingArray containing setting lines of a single sampler + * @return status of conversion, if success KErrNone, else KErrGeneral + */ + virtual TInt ConvertRawSettingsToAttributes(CDesC8ArrayFlat* aSingleSettingArray) = 0; + + /** + * Method for getting caption of this plugin. This should be the + * localized name of the settings view to be shown in parent view. + * @param aCaption pointer to Caption variable + * @param aType caption type; ECaptionLengthShort, ECaptionLengthMedium or ECaptionLengthLong + * @param aSubId sub sampler id, if -1 returning main plugin's caption + */ + virtual void GetCaption( TDes& aCaption, TInt aType, TInt aSubId) const = 0; + + /** + * Method for getting UID of this plugin. + * @param aSubId the implementation id of sub sampler + * @returns uid of sampler or sub sampler, if aSubId -1 uid of sampler, else uid of sub sampler + */ + virtual TUid Id(TInt aSubId) const = 0; + + /** + * Method for getting locally defined sub ID value inside a specific plug-in. + * @param aUid of a specific sampler + * @returns local ID of sampler or sub sampler + */ + virtual TInt SubId(TUid aUid) const = 0; + + // subsampler settings, i.e. samplers implemented within a plugin + virtual TInt GetSamplerUidByName(TDesC8& name) = 0; + + // sampler type + virtual TInt GetSamplerType() = 0; + + + // some internal inline methods, used by engine + inline TInt Flush(); + inline TInt AddSample(TUint8* sample, TUint32 length, TInt limitSize); + inline void SetOrder( TInt aOrder ); + inline static void ListAllImplementationsL(RImplInfoPtrArray& aImplInfoArray); + + /** + * Static methods for getting setting value out of descriptor + * + * @param aBuf buffer where to convert the value + * @param aValue parameter where to store the requested type of value + */ + inline static void Str2Bool(const TDesC8& aBuf, TBool& aValue); + inline static void Str2Int(const TDesC8& aBuf, TInt& aValue); + inline static void Str2Int(const TDesC8& aBuf, TUint32& aValue); + + /** iDtor_ID_Key Instance identifier key. When instance of an + * implementation is created by ECOM framework, the + * framework will assign UID for it. The UID is used in + * destructor to notify framework that this instance is + * being destroyed and resources can be released. + */ + TUid iDtor_ID_Key; + + /** + * Index of the plugin in listbox. Used for CSamplerPluginLoader. Default + * value is KSamplerPluginNotIndexed which means not ordered. This value is + * read, if defined, from the opaque_data field of the plugin's resource + * definition. Index starts from 0. + */ + TInt iOrder; + +public: + TInt iSamplerType; + + // this variable must be defined by the extending classes!! + TInt iSamplerId; + + CProfilerSampleStream* iStream; + TBool iEnabled; + +private: + TBapBuf* iBuffer; +}; + +#include +#include + + +#endif // __SAMPLER_PLUGIN_INTERFACE__ diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler_api/inc/SamplerPluginInterface.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler_api/inc/SamplerPluginInterface.inl Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,215 @@ +/* +* 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: +* +*/ + + +// LITERALS +_LIT8(KTrue, "true"); +_LIT8(KFalse, "false"); + +inline CSamplerPluginInterface::CSamplerPluginInterface() + : iOrder( KSamplerPluginNotIndexed ) + { + iBuffer = 0; + iStream = 0; + } + +// ----------------------------------------------------------------------------- +// CSamplerPluginInterface::~CSamplerPluginInterface() +// Destructor. +// ----------------------------------------------------------------------------- +// +inline CSamplerPluginInterface::~CSamplerPluginInterface() + { + iBuffer = 0; + REComSession::DestroyedImplementation(iDtor_ID_Key); + } + + +inline CSamplerPluginInterface* CSamplerPluginInterface::NewL(const TUid aImplementationUid, TAny* aInitParams) + { + // Define options, how the default resolver will find appropriate + // implementation. + return REINTERPRET_CAST(CSamplerPluginInterface*, + REComSession::CreateImplementationL(aImplementationUid, + _FOFF( CSamplerPluginInterface, iDtor_ID_Key ), + aInitParams)); + } + +inline void CSamplerPluginInterface::ListAllImplementationsL(RImplInfoPtrArray& aImplInfoArray) + { + REComSession::ListImplementationsL(KSamplerPluginInterfaceUid, aImplInfoArray); + } + +inline void CSamplerPluginInterface::SetOrder( TInt aOrder ) + { + iOrder = aOrder; + } + +inline TInt CSamplerPluginInterface::Flush() + { + // complete the header + TUint32 header; + header = (iBuffer->iDataSize & 0x00ffffff) - 4; + header += (iSamplerId << 24); + + // flush the header info + iBuffer->iBuffer[0] = header; + iBuffer->iBuffer[1] = header >> 8; + iBuffer->iBuffer[2] = header >> 16; + iBuffer->iBuffer[3] = header >> 24; + + // write data to filled buffers + iStream->AddToFilledBuffers(iBuffer); + // notify selected writer plugin to write data to output + iStream->NotifyWriter(); + + iBuffer = 0; + + return KErrNone; +} + + +inline TInt CSamplerPluginInterface::AddSample(TUint8* aSample, TUint32 aLength, TInt aLimitSize) + { + LOGTEXT(_L("CSamplerPluginInterface::AddSample - entry")); + if(iBuffer == 0) + { + // get next free buffer where to write data + iBuffer = iStream->GetNextFreeBuffer(); + iBuffer->iBufDes->Zero(); + + // get space for the header + TUint32 header = 0; + iBuffer->iBufDes->Append((TUint8*)&header, 4); + iBuffer->iDataSize += 4; + } + + // add data to the buffer... + // if all data fit to the current buffer + if(iBuffer->iBufferSize - iBuffer->iDataSize >= (TInt)aLength) + { + iBuffer->iBufDes->Append(aSample, (TInt)aLength); + iBuffer->iDataSize += (TInt)aLength; + } + else + { + // fill in the buffer + TUint32 rest = iBuffer->iBufferSize - iBuffer->iDataSize; + iBuffer->iBufDes->Append(aSample, rest); + iBuffer->iDataSize += (TInt)rest; + + // The buffer is full now, complete the header + TUint32 header; + header = (iBuffer->iDataSize & 0x00ffffff) - 4; + header += (iSamplerId << 24); + iBuffer->iBuffer[0] = header; + iBuffer->iBuffer[1] = header >> 8; + iBuffer->iBuffer[2] = header >> 16; + iBuffer->iBuffer[3] = header >> 24; + + // write data to filled buffers + iStream->AddToFilledBuffers(iBuffer); + // notify selected writer plugin to write data to output + iStream->NotifyWriter(); + + // Fetch an empty buffer and reserve space for the header + iBuffer = iStream->GetNextFreeBuffer(); + iBuffer->iBufDes->Zero(); + header = 0; + iBuffer->iBufDes->Append((TUint8*)&header, 4); + iBuffer->iDataSize += 4; + + // copy the rest of data to the new buffer + iBuffer->iBufDes->Append(aSample+rest, aLength-rest); + iBuffer->iDataSize += (TInt)aLength-rest; + } + + // Once iBuffer->dataSize reaches the limitSize, data from iBuffer is flushed to file/debug port. + // If limitSize is set to zero, buffer is not changed until iBuffer gets full. + if(aLimitSize != 0) + { + if(iBuffer->iDataSize >= aLimitSize) + { + // The buffer is full now, complete the header + TUint32 header; + header = (iBuffer->iDataSize & 0x00ffffff) - 4; + header += (iSamplerId << 24); + iBuffer->iBuffer[0] = header; + iBuffer->iBuffer[1] = header >> 8; + iBuffer->iBuffer[2] = header >> 16; + iBuffer->iBuffer[3] = header >> 24; + + + // write data to filled buffers + iStream->AddToFilledBuffers(iBuffer); + // notify selected writer plugin to write data to output + iStream->NotifyWriter(); + + // Fetch an empty buffer and reserve space for the header + iBuffer = iStream->GetNextFreeBuffer(); + iBuffer->iBufDes->Zero(); + header = 0; + iBuffer->iBufDes->Append((TUint8*)&header, 4); + iBuffer->iDataSize += 4; + } + } + return KErrNone; + } + +// ---------------------------------------------------------------------------- +// Converts given descriptor into TBool value. +// ---------------------------------------------------------------------------- +// +inline void CSamplerPluginInterface::Str2Bool(const TDesC8& aBuf, TBool& aValue) + { + if (aBuf.CompareF(KFalse) == 0) + aValue = EFalse; + else + aValue = ETrue; + } + +// ---------------------------------------------------------------------------- +// Converts given descriptor into TInt value. +// ---------------------------------------------------------------------------- +// +inline void CSamplerPluginInterface::Str2Int(const TDesC8& aBuf, TInt& aValue) + { + TLex8 conv; + conv.Assign(aBuf); + + if (conv.Val(aValue) != KErrNone) + aValue = 0; + } + +// ---------------------------------------------------------------------------- +// Converts given descriptor into TInt value. +// ---------------------------------------------------------------------------- +// +inline void CSamplerPluginInterface::Str2Int(const TDesC8& aBuf, TUint32& aValue) + { + TInt temp(0); + + TLex8 conv; + conv.Assign(aBuf); + + if (conv.Val(temp) != KErrNone) + aValue = 0; + else + aValue = (TUint32)temp; + } + +// End of file diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler_api/inc/WriterPluginInterface.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler_api/inc/WriterPluginInterface.h Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,176 @@ +/* +* 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 __WRITERPLUGIN_INTERFACE__ +#define __WRITERPLUGIN_INTERFACE__ + +#include +#include +#include + + +// Constant for indexing (iOrder): +const TInt KWriterPluginNotIndexed = -1; + +/** + * Constant: KWriterPluginInterfaceUid + * + * Description: UID of this ECOM interface. It should be unique in the system. + * It is used to identify this specific custom interface. + * Implementations of this interface will use this ID, when they + * publish the implementation. Clients use this UID to search for + * implementations for this interface (the + * EcomInterfaceDefinition.inl does this). + */ +const TUid KWriterPluginInterfaceUid = {0x2001E5BD}; + +/** +* Used by GetValue(). These are the keys for retrieving a specific +* value. This enum can be extended to provide other values as well as +* long as the original keys are not changed. +*/ +enum TWriterPluginValueKeys + { + EWriterPluginKeySettingsItemValueString = 1, + EWriterPluginSettings, + EWriterPluginEnabled, + EWriterPluginDisabled, + EWriterPluginType, + EWriterPluginVersion + }; +/** + * + * Description: UID of this ECOM interface. It should be unique in the system. + * + */ + +/** + * Class: CWriterInterfaceDefinition + * + * Description: Custom ECOM interface definition. This interface is used by + * clients to find specific instance and do corresponding + * calculation operation for given too numbers. Plugin + * implementations implement the Calculate function. + */ + +class CProfilerSampleStream; + +class CWriterPluginInterface : public CBase + { + + // CSamplerPluginLoader accesses iOrder which should not be accessed outside. + friend class CWriterPluginLoader; + +public: // Wrapper functions to handle ECOM "connectivity". + // These are implemented in EComInterfaceDefinition.inl. + // These functions are used only by the client. + /** + * Function: NewL + * + * Description: Wraps ECom object instantitation. Will search for + * interface implementation, which matches to given + * aOperationName. + * + * Param: aOperationName name of requested implementation. + * Implementations advertise their "name" as specified + * in their resource file field + * IMPLEMENTATION_INFO::default_data. + * For details, see EcomInterfaceDefinition.inl comments. + * In this example, the allowed values are "sum" and + * "multiply". + * + * Note: This is not a "normal" NewL method, since normally NewL + * methods are only defined for concrete classes. + * Note that also implementations of this interface provide + * NewL methods. They are the familiar NewL's, which create + * instance of classes. + */ + static CWriterPluginInterface* NewL(const TUid aImplementationUid, TAny* aInitParams); + + /** + * Function: ~CWriterPluginInterface + * + * Description: Wraps ECom object destruction. Notifies the ECOM + * framework that specific instance is being destroyed. + * See EcomInterfaceDefinition.inl for details. + */ + virtual ~CWriterPluginInterface(); +protected: // New + + /** + * C++ constructor. + */ + CWriterPluginInterface(); + +public: + /** + * Method for getting caption of this plugin. This should be the + * localized name of the settings view to be shown in parent view. + * + * @param aCaption pointer to Caption variable + */ + virtual TInt Start() = 0; + + virtual void Stop() = 0; + + virtual void GetCaption( TDes& aCaption ) const = 0; + + virtual TUid Id() const = 0; + + virtual void GetValue( const TWriterPluginValueKeys aKey, TDes& aValue ) = 0; + + virtual void SetValue( const TWriterPluginValueKeys aKey, TDes& aValue ) = 0; + + virtual void GetWriterVersion(TDes* aDes) = 0; + + virtual TUint32 GetWriterType() = 0; + + virtual TBool GetEnabled() = 0; + + virtual void WriteData() = 0; + virtual void SetStream( CProfilerSampleStream& aStream ) = 0; + + // internal inline functions + inline static void ListAllImplementationsL( RImplInfoPtrArray& aImplInfoArray ); + inline void SetOrder( TInt aOrder ); + +private: + + /** iDtor_ID_Key Instance identifier key. When instance of an + * implementation is created by ECOM framework, the + * framework will assign UID for it. The UID is used in + * destructor to notify framework that this instance is + * being destroyed and resources can be released. + */ + TUid iDtor_ID_Key; + + /** + * Index of the plugin in listbox. Used for CSamplerPluginLoader. Default + * value is KSamplerPluginNotIndexed which means not ordered. This value is + * read, if defined, from the opaque_data field of the plugin's resource + * definition. Index starts from 0. + */ + TInt iOrder; +public: + TInt iAdditionalSettings; + TBool isEnabled; + }; + +#include + +#endif // __WRITERPLUGIN_INTERFACE__ diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler_api/inc/WriterPluginInterface.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler_api/inc/WriterPluginInterface.inl Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,69 @@ +/* +* 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: +* +*/ + + +inline CWriterPluginInterface::CWriterPluginInterface() + : iOrder( KWriterPluginNotIndexed ) + { + + } + +// ----------------------------------------------------------------------------- +// CWriterPluginInterface::~CWriterPluginInterface() +// Destructor. +// ----------------------------------------------------------------------------- +// +inline CWriterPluginInterface::~CWriterPluginInterface() + { + // We don't unload the plugin object here. The loader + // has to do this for us. Without this kind of destruction idiom, + // the view framework can potentially unload an ECOM plugin dll whilst + // there are still child views (Created by the plugin) that are registered + // with the view framework. If this occurs, the plugin code segment isn't + // loaded anymore and so there is no way to run the subsequent destructor + // code => exception. + + // If in the NewL some memory is reserved for member data, it must be + // released here. This interface does not have any instance variables so + // no need to delete anything. + + // Inform the ECOM framework that this specific instance of the + // interface has been destroyed. + REComSession::DestroyedImplementation(iDtor_ID_Key); + } + +inline CWriterPluginInterface* CWriterPluginInterface::NewL(const TUid aImplementationUid, TAny* aInitParams) + { + // Define options, how the default resolver will find appropriate + // implementation. + return REINTERPRET_CAST(CWriterPluginInterface*, + REComSession::CreateImplementationL(aImplementationUid, + _FOFF( CWriterPluginInterface, iDtor_ID_Key ), + aInitParams)); + } + +inline void CWriterPluginInterface::ListAllImplementationsL(RImplInfoPtrArray& aImplInfoArray) + { + REComSession::ListImplementationsL(KWriterPluginInterfaceUid, aImplInfoArray); + } + +inline void CWriterPluginInterface::SetOrder( TInt aOrder ) + { + iOrder = aOrder; + } + +// end of file diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofiler_api/piprofiler_api.metaxml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofiler_api/piprofiler_api.metaxml Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,18 @@ + + + PIProfiler API + Defines the PIProfiler API, which is used for different PI Profiler sub projects. + c++ + piprofiler + + + + + + + + + no + no + + diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofilerui/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofilerui/group/bld.inf Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2007 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: +* +*/ + + + +#include + +#include "../gui/group/bld.inf" + + +PRJ_EXPORTS +../rom/piprofilerui.iby CORE_IBY_EXPORT_PATH(tools,piprofilerui.iby) + + +PRJ_MMPFILES +#ifndef SBSV2 + #ifdef MARM + gnumakefile piprofilerui_stub_sis.mk + #endif +#endif + + +#ifdef SBSV2 + #ifdef MARM + START EXTENSION app-services/buildstubsis + OPTION SRCDIR ../sis + OPTION SISNAME PIProfilerUI_stub + END + #endif +#endif diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofilerui/group/piprofilerui_stub_sis.mk --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofilerui/group/piprofilerui_stub_sis.mk Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,55 @@ +# +# 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: +# + +TARGETDIR=$(EPOCROOT)EPOC32\Data\Z\System\Install + +SISNAME=PIProfilerUI_stub +PKGNAME=PIProfilerUI_stub + +$(TARGETDIR) : + @perl -S emkdir.pl "$(TARGETDIR)" + +do_nothing : + rem do_nothing + +SISFILE=$(TARGETDIR)\$(SISNAME).sis + +$(SISFILE) : ..\sis\$(PKGNAME).pkg + makesis -s $? $@ + + + +MAKMAKE : do_nothing + +RESOURCE : do_nothing + +SAVESPACE : do_nothing + +BLD : do_nothing + +FREEZE : do_nothing + +LIB : do_nothing + +CLEANLIB : do_nothing + +FINAL : $(TARGETDIR) $(SISFILE) + +CLEAN : + @if exist $(SISFILE) erase $(SISFILE) + +RELEASABLES : + @echo $(SISFILE) diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofilerui/gui/data/piprofilerui.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofilerui/gui/data/piprofilerui.rss Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,926 @@ +/* +* 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: +* +*/ + + + + +NAME PIPR + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "profiler_gui.hrh" +#include "profiler_gui_std.h" +#include +#include + + +// --------------------------------------------------------- +// +// Define the resource file signature +// This resource should be empty. +// +// --------------------------------------------------------- +// +RESOURCE RSS_SIGNATURE { } + +// --------------------------------------------------------- +// +// Default Document Name +// +// --------------------------------------------------------- +// +RESOURCE TBUF r_default_document_name { buf=""; } + +// --------------------------------------------------------- +// +// Define default menu and CBA key. +// +// --------------------------------------------------------- +// +RESOURCE EIK_APP_INFO { } + +//---------------------------------------------------- +// +// r_profiler_gui_hotkeys +// +//---------------------------------------------------- +// +RESOURCE HOTKEYS r_profiler_gui_hotkeys + { + control= + { + HOTKEY { command=EAknCmdExit; key='e'; } + }; + } + + +//---------------------------------------------------- +// r_profiler_gui_view_main +//---------------------------------------------------- +// +RESOURCE AVKON_VIEW r_profiler_gui_view_main + { + hotkeys=r_profiler_gui_hotkeys; + menubar=r_profiler_gui_menubar_view_main; + cba=R_AVKON_SOFTKEYS_OPTIONS_EXIT; + } + +//---------------------------------------------------- +// r_profiler_gui_menubar_view_main +//---------------------------------------------------- +// +RESOURCE MENU_BAR r_profiler_gui_menubar_view_main + { + titles= + { + MENU_TITLE { menu_pane=r_profiler_gui_app_menu; txt="App"; }, + MENU_TITLE { menu_pane=r_profiler_gui_view_main_menu; txt="Main"; } + }; + } + +//---------------------------------------------------- +// r_profiler_gui_view_main_menu +//---------------------------------------------------- +// + +RESOURCE MENU_PANE r_profiler_gui_view_main_menu + { + items= + { + }; + } + + + +//---------------------------------------------------- +// r_profiler_gui_app_menu +//---------------------------------------------------- +// +RESOURCE MENU_PANE r_profiler_gui_app_menu + { + items= + { + MENU_ITEM { command=EProfilerGuiCmdStartAll; txt="Start profiling"; }, + MENU_ITEM { command=EProfilerGuiCmdStopAll; txt="Stop profiling"; }, + MENU_ITEM { command=EProfilerGuiCmdSamplerControl; txt="Sampler control"; cascade=r_profiler_sampler_control_menu; }, + MENU_ITEM { command=EProfilerGuiCmdSettings; txt="Settings"; }, + MENU_ITEM { command=EProfilerGuiCmdAbout; txt="About"; }, + MENU_ITEM { command=EAknCmdExit; txt="Exit"; } + }; + } + +//---------------------------------------------------- +// r_profiler_sampler_control_menu +//---------------------------------------------------- +// +RESOURCE MENU_PANE r_profiler_sampler_control_menu + { + items= + { + MENU_ITEM { command=EProfilerGuiCmdSamplerEnable; txt="Enable"; }, + MENU_ITEM { command=EProfilerGuiCmdSamplerDisable; txt="Disable"; }, + MENU_ITEM { command=EProfilerGuiCmdSamplerSettings; txt="Sampler settings"; }, + MENU_ITEM { command=EProfilerGuiCmdSamplerInfo; txt="Sampler info"; } + }; + } + + +//---------------------------------------------------- +// r_profiler_gui_settings_dialog +// Dialog for setting list +//---------------------------------------------------- +// +RESOURCE DIALOG r_profiler_gui_settings_dialog + { + flags = + EEikDialogFlagNoDrag | EEikDialogFlagFillAppClientRect | + EEikDialogFlagButtonsRight | EEikDialogFlagCbaButtons | + EEikDialogFlagWait | EEikDialogFlagNoTitleBar; + buttons = R_AVKON_SOFTKEYS_OPTIONS_BACK; + items = + { + DLG_LINE + { + type = EAknCtSettingListBox; + id = EProfilerGuiSettingItemList; + itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; + control = LISTBOX + { + flags = EAknListBoxSelectionList; + }; + } + }; + } + +// generic resources +RESOURCE POPUP_SETTING_LIST r_popup_setting_list_editor + { + } +RESOURCE AVKON_SETTING_PAGE r_binary_setting_page + { + number = EAknSettingPageNoOrdinalDisplayed; + type = EAknCtPopupSettingList; + editor_resource_id = r_popup_setting_list_editor; + } +RESOURCE AVKON_POPUP_SETTING_TEXTS r_yesno_binaryselection_texts + { + setting_texts_resource = r_yesno_binaryselection_text_array; + } +RESOURCE ARRAY r_yesno_binaryselection_text_array + { + items = + { + AVKON_ENUMERATED_TEXT { value=0; text = "No"; }, + AVKON_ENUMERATED_TEXT { value=1; text = "Yes"; } + }; + } + + +// +// resources for plugin name mode selection +// +RESOURCE TBUF r_plugin_name_mode_setting_title + { + buf = "Sampler name length"; + } +RESOURCE AVKON_SETTING_PAGE r_plugin_name_mode_setting_page + { + number = EAknSettingPageNoOrdinalDisplayed; + type = EAknCtPopupSettingList; + editor_resource_id = r_popup_setting_list_editor; + } +RESOURCE AVKON_POPUP_SETTING_TEXTS r_plugin_name_mode_setting_texts + { + setting_texts_resource = r_plugin_name_mode_text_array; + } +RESOURCE ARRAY r_plugin_name_mode_text_array + { + items = + { + AVKON_ENUMERATED_TEXT { value=ESamplerNameShort; text = "Short"; }, + AVKON_ENUMERATED_TEXT { value=ESamplerNameMedium; text = "Medium"; }, + AVKON_ENUMERATED_TEXT { value=ESamplerNameLong; text = "Long"; } + }; + } + + +// +// resources for trace output selection +// +RESOURCE TBUF r_trace_output_setting_title + { + buf = "Output to"; + } +RESOURCE AVKON_SETTING_PAGE r_trace_output_setting_page + { + number = EAknSettingPageNoOrdinalDisplayed; + type = EAknCtPopupSettingList; + editor_resource_id = r_popup_setting_list_editor; + } +RESOURCE AVKON_POPUP_SETTING_TEXTS r_trace_output_setting_texts + { + setting_texts_resource = r_trace_output_text_array; + } +RESOURCE ARRAY r_trace_output_text_array + { + items = + { + AVKON_ENUMERATED_TEXT { value=EOutputToDebugPort; text = "Debug output"; }, + AVKON_ENUMERATED_TEXT { value=EOutputToFileSystem; text = "File system"; } + }; + } + + +// +// resources for save_file_prefix selection +// +RESOURCE TBUF r_save_file_prefix_setting_title + { + buf = "File prefix"; + } +RESOURCE AVKON_SETTING_PAGE r_save_file_prefix_setting_page + { + type = EEikCtEdwin; + editor_resource_id = r_save_file_prefix_text_editor; + } + +RESOURCE EDWIN r_save_file_prefix_text_editor + { + lines = 0; // expanding to multiple rows + maxlength = 63; + flags = EEikEdwinNoLineOrParaBreaks; + } + +// +// resources for save file drive selection +// +RESOURCE TBUF r_save_file_drive_setting_title + { + buf = "Save file in"; + } +RESOURCE AVKON_SETTING_PAGE r_save_file_drive_setting_page + { + type = EEikCtEdwin; + editor_resource_id = r_save_file_drive_text_editor; + } + +RESOURCE EDWIN r_save_file_drive_text_editor + { + lines = 0; // expanding to multiple rows + maxlength = 63; + flags = EEikEdwinNoLineOrParaBreaks; + } + +// +// resources for trace mode selection +// +RESOURCE TBUF r_trace_mode_setting_title + { + buf = "Trace mode"; + } +RESOURCE AVKON_SETTING_PAGE r_trace_mode_setting_page + { + number = EAknSettingPageNoOrdinalDisplayed; + type = EAknCtPopupSettingList; + editor_resource_id = r_popup_setting_list_editor; + } +RESOURCE AVKON_POPUP_SETTING_TEXTS r_trace_mode_setting_texts + { + setting_texts_resource = r_trace_mode_text_array; + } +RESOURCE ARRAY r_trace_mode_text_array + { + items = + { + AVKON_ENUMERATED_TEXT { value=ETraceModeStream; text = "Stream"; }, + AVKON_ENUMERATED_TEXT { value=ETraceModeBuffer; text = "Memory buffer"; } + }; + } + + +//---------------------------------------------------- +// r_profiler_gui_settings_menubar +//---------------------------------------------------- +// + +RESOURCE MENU_BAR r_profiler_gui_settings_menubar + { + titles = + { + MENU_TITLE + { + menu_pane = r_profiler_gui_settings_menupane; + txt = " "; // dummy + } + }; + } + +RESOURCE MENU_PANE r_profiler_gui_settings_menupane + { + items = + { + MENU_ITEM + { + command = EProfilerGuiCmdSettingsChange; + txt = "Change"; + }, + MENU_ITEM + { + command = EProfilerGuiCmdSettingsExit; + txt = "Exit"; + } + }; + } + +//---------------------------------------------------- +// r_profiler_gui_settings_dialog +// Dialog for setting list +//---------------------------------------------------- +// +RESOURCE DIALOG r_profiler_sampler_settings_dialog + { + flags = + EEikDialogFlagNoDrag | EEikDialogFlagFillAppClientRect | + EEikDialogFlagButtonsRight | EEikDialogFlagCbaButtons | + EEikDialogFlagWait | EEikDialogFlagNoTitleBar; + buttons = R_AVKON_SOFTKEYS_OPTIONS_BACK; + items = + { + DLG_LINE + { + type = EAknCtSettingListBox; + id = EProfilerSamplerSettingItemList; + itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; + control = LISTBOX + { + flags = EAknListBoxSelectionList; + }; + } + }; + } + +//---------------------------------------------------- +// r_profiler_sampler_settings_menubar +//---------------------------------------------------- +// + +RESOURCE MENU_BAR r_profiler_sampler_settings_menubar + { + titles = + { + MENU_TITLE + { + menu_pane = r_profiler_sampler_settings_menupane; + txt = "Sampler settings"; + } + }; + } + +RESOURCE MENU_PANE r_profiler_sampler_settings_menupane + { + items = + { + MENU_ITEM + { + command = EProfilerGuiCmdSettingsChange; + txt = "Change"; + }, + MENU_ITEM + { + command = EProfilerGuiCmdSettingsExit; + txt = "Exit"; + } + }; + } + + +// --------------------------------------------------------- +// +// r_profiler_gui_about_dialog +// About dialog - show version and copyright info etc. +// +// --------------------------------------------------------- +// +RESOURCE DIALOG r_profiler_gui_about_dialog + { + flags = EGeneralQueryFlags | EEikDialogFlagNoBorder | EEikDialogFlagNoShadow; + buttons = R_AVKON_SOFTKEYS_OK_EMPTY; + items= + { + DLG_LINE + { + type = EAknCtPopupHeadingPane; + id = EAknMessageQueryHeaderId; + control = AVKON_HEADING + { + label = "About Profiler"; + headinglayout = R_AVKON_WML_SIGN_QUERY_HEADING_PANE; + }; + }, + DLG_LINE + { + type = EAknCtMessageQuery; + id = EAknMessageQueryContentId; + control = AVKON_MESSAGE_QUERY + { + message = "Version 2.0.0 - 4th March 2009. Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved."; + }; + } + }; + } + +// --------------------------------------------------------- +// r_sampler_rate_setting_page +// --------------------------------------------------------- +// +RESOURCE AVKON_SETTING_PAGE r_sampler_rate_setting_page + { + type = EAknCtIntegerEdwin; + editor_resource_id = r_sampler_rate_integer_editor; + } +RESOURCE AVKON_INTEGER_EDWIN r_sampler_rate_integer_editor + { + maxlength = 6; + min = 250; + max = 999999; + } + +// --------------------------------------------------------- +// r_cpu_sampler_rate_setting_page +// --------------------------------------------------------- +// +RESOURCE AVKON_SETTING_PAGE r_cpu_sampler_rate_setting_page + { + type = EAknCtIntegerEdwin; + editor_resource_id = r_cpu_sampler_rate_integer_editor; + } +RESOURCE AVKON_INTEGER_EDWIN r_cpu_sampler_rate_integer_editor + { + maxlength = 5; + min = 1; + max = 10000; + } + +// --------------------------------------------------------- +// +// r_generic_sampler_dlg_line_sample_rate +// Empty about dialog - show sampler plugin info in this +// +// --------------------------------------------------------- +// +RESOURCE DLG_LINE r_generic_sampler_dlg_line_sample_rate + { + type = EEikCtNumberEditor; + prompt = "Sample rate (ms)"; + id = EProfilerGuiGenericSamplerQuerySampleRate; + itemflags = EEikDlgItemTakesEnterKey | EEikDlgItemOfferAllHotKeys; + control = NUMBER_EDITOR + { + min = 1000; + max = 10000; + }; + } + +// --------------------------------------------------------- +// +// r_profiler_gui_empty_about_dialog +// Empty about dialog - show sampler plugin info in this +// +// --------------------------------------------------------- +// +RESOURCE DIALOG r_profiler_gui_empty_about_dialog + { + flags = EGeneralQueryFlags | EEikDialogFlagNoBorder | EEikDialogFlagNoShadow; + buttons = R_AVKON_SOFTKEYS_OK_EMPTY; + items= + { + DLG_LINE + { + type = EAknCtPopupHeadingPane; + id = EAknMessageQueryHeaderId; + control = AVKON_HEADING + { + label = "About"; + headinglayout = R_AVKON_WML_SIGN_QUERY_HEADING_PANE; + }; + }, + DLG_LINE + { + type = EAknCtMessageQuery; + id = EAknMessageQueryContentId; + control = AVKON_MESSAGE_QUERY + { + message = ""; + }; + } + }; + } + + +RESOURCE TBUF r_dummy_setting_title + { + buf = ""; + } + +RESOURCE TBUF r_sample_rate_setting_title + { + buf = "Sample rate (ms)"; + } + +RESOURCE TBUF r_item1_setting_title + { + buf = "Item1"; + } + +RESOURCE TBUF r_item2_setting_title + { + buf = "Item2"; + } + +RESOURCE TBUF r_item3_setting_title + { + buf = "Item3"; + } + +RESOURCE TBUF r_item4_setting_title + { + buf = "Item4"; + } + +RESOURCE TBUF r_item5_setting_title + { + buf = "Item5"; + } + +RESOURCE TBUF r_item6_setting_title + { + buf = "Item6"; + } + +RESOURCE AVKON_SETTING_PAGE r_numeric_setting_page + { + type = EAknCtIntegerEdwin; + editor_resource_id = r_numeric_integer_editor; + } +RESOURCE AVKON_INTEGER_EDWIN r_numeric_integer_editor + { + maxlength = 5; + min = 0; + max = 10000; + } + +// +// resources for text selection +// +RESOURCE AVKON_SETTING_PAGE r_generic_text_setting_page + { + type = EEikCtEdwin; + editor_resource_id = r_generic_text_editor; + } + +RESOURCE EDWIN r_generic_text_editor + { + lines = 0; // expanding to multiple rows + maxlength = 63; + flags = EEikEdwinNoLineOrParaBreaks; + } + + +// --------------------------------------------------------- +// r_general_confirmation_query +// --------------------------------------------------------- +// + +RESOURCE DIALOG r_general_confirmation_query + { + flags = EGeneralQueryFlags; + buttons = R_AVKON_SOFTKEYS_YES_NO; + items = + { + DLG_LINE + { + type = EAknCtQuery; + id = EGeneralQuery; + control = AVKON_CONFIRMATION_QUERY + { + layout = EConfirmationQueryLayout; + }; + } + }; + } + +// --------------------------------------------------------- +// r_general_text_query +// --------------------------------------------------------- +// +RESOURCE DIALOG r_general_text_query + { + flags = EGeneralQueryFlags; + buttons = R_AVKON_SOFTKEYS_OK_CANCEL; + items= + { + DLG_LINE + { + type = EAknCtQuery; + id = EGeneralQuery; + control = AVKON_DATA_QUERY + { + layout = EDataLayout; + control = EDWIN + { + width = 256; + lines = 3; + maxlength = 256; + }; + }; + } + }; + } + +// --------------------------------------------------------- +// r_general_text_query +// --------------------------------------------------------- +// +RESOURCE DIALOG r_general_numeric_query + { + flags = EGeneralQueryFlags; + buttons = R_AVKON_SOFTKEYS_OK_CANCEL; + items = + { + DLG_LINE + { + type = EAknCtQuery; + id = EGeneralQuery; + control= AVKON_DATA_QUERY + { + layout = ENumberLayout; + control = AVKON_INTEGER_EDWIN + { + min = -999999; + max = 999999; + }; + }; + } + }; + } + + +// --------------------------------------------------------- +// r_item_action_query +// --------------------------------------------------------- +// +RESOURCE DIALOG r_item_action_query_enabled + { + flags = EGeneralQueryFlags; + buttons = R_AVKON_SOFTKEYS_OK_CANCEL; + items = + { + AVKON_LIST_QUERY_DLG_LINE + { + control= AVKON_LIST_QUERY_CONTROL + { + listtype = EAknCtSinglePopupMenuListBox; + listbox = AVKON_LIST_QUERY_LIST + { + array_id = r_item_action_query_array_enabled; + }; + heading = "Sampler controls"; + }; + } + }; + } + +RESOURCE DIALOG r_item_action_query_disabled + { + flags = EGeneralQueryFlags; + buttons = R_AVKON_SOFTKEYS_OK_CANCEL; + items = + { + AVKON_LIST_QUERY_DLG_LINE + { + control= AVKON_LIST_QUERY_CONTROL + { + listtype = EAknCtSinglePopupMenuListBox; + listbox = AVKON_LIST_QUERY_LIST + { + array_id = r_item_action_query_array_disabled; + }; + heading = "Sampler controls"; + }; + } + }; + } + +RESOURCE DIALOG r_item_action_query_hidden_settings_enabled + { + flags = EGeneralQueryFlags; + buttons = R_AVKON_SOFTKEYS_OK_CANCEL; + items = + { + AVKON_LIST_QUERY_DLG_LINE + { + control= AVKON_LIST_QUERY_CONTROL + { + listtype = EAknCtSinglePopupMenuListBox; + listbox = AVKON_LIST_QUERY_LIST + { + array_id = r_item_action_query_array_hidden_settings_enabled; + }; + heading = "Sampler controls"; + }; + } + }; + } + +RESOURCE DIALOG r_item_action_query_hidden_settings_disabled + { + flags = EGeneralQueryFlags; + buttons = R_AVKON_SOFTKEYS_OK_CANCEL; + items = + { + AVKON_LIST_QUERY_DLG_LINE + { + control= AVKON_LIST_QUERY_CONTROL + { + listtype = EAknCtSinglePopupMenuListBox; + listbox = AVKON_LIST_QUERY_LIST + { + array_id = r_item_action_query_array_hidden_settings_disabled; + }; + heading = "Sampler controls"; + }; + } + }; + } + +RESOURCE DIALOG r_item_action_query_hidden_start_stop + { + flags = EGeneralQueryFlags; + buttons = R_AVKON_SOFTKEYS_OK_CANCEL; + items = + { + AVKON_LIST_QUERY_DLG_LINE + { + control= AVKON_LIST_QUERY_CONTROL + { + listtype = EAknCtSinglePopupMenuListBox; + listbox = AVKON_LIST_QUERY_LIST + { + array_id = r_item_action_query_array_hidden_start_stop; + }; + heading = "Sampler controls"; + }; + } + }; + } + +RESOURCE ARRAY r_item_action_query_array_disabled + { + items = + { + LBUF {txt = "Enable"; }, + LBUF {txt = "Sampler settings"; }, + LBUF {txt = "Sampler info"; } + }; + } + +RESOURCE ARRAY r_item_action_query_array_enabled + { + items = + { + LBUF {txt = "Disable"; }, + LBUF {txt = "Sampler settings"; }, + LBUF {txt = "Sampler info"; } + }; + } + +RESOURCE ARRAY r_item_action_query_array_hidden_settings_disabled + { + items = + { + LBUF {txt = "Enable"; }, + LBUF {txt = "Sampler info"; } + }; + } + +RESOURCE ARRAY r_item_action_query_array_hidden_settings_enabled + { + items = + { + LBUF {txt = "Disable"; }, + LBUF {txt = "Sampler info"; } + }; + } + +RESOURCE ARRAY r_item_action_query_array_hidden_start_stop + { + items = + { + LBUF {txt = "Sampler settings"; }, + LBUF {txt = "Sampler info"; } + }; + } + +RESOURCE STATUS_PANE_APP_MODEL r_profiler_gui_status_pane + { + panes = + { + SPANE_PANE + { + id = EEikStatusPaneUidTitle; + type = EAknCtTitlePane; + resource = r_profiler_gui_title_resource; + }, + SPANE_PANE + { + id = EEikStatusPaneUidNavi; + type = EAknCtNaviPane; + resource = r_profiler_gui_navi_text_idle; + } + }; + } + +RESOURCE TITLE_PANE r_profiler_gui_title_resource + { + txt = "PI Profiler"; + } + +RESOURCE TBUF r_profiler_gui_navi_text_idle + { + buf = "Idle"; + } + +RESOURCE TBUF r_profiler_gui_navi_text_initializing + { + buf = "Initializing..."; + } + +RESOURCE TBUF r_profiler_gui_navi_text_running + { + buf = "Profiling..."; + } + +RESOURCE TBUF r_profiler_gui_navi_text_stopping + { + buf = "Stopping..."; + } + +RESOURCE DIALOG r_profiler_gui_conf_query + { + flags = EAknGeneralQueryFlags; + buttons = R_AVKON_SOFTKEYS_YES_NO; + items = + { + DLG_LINE + { + type = EAknCtQuery; + id = EProfilerGuiViewConfQuery; + control = AVKON_CONFIRMATION_QUERY + { + layout = EConfirmationQueryLayout; + label = "Leave profiling on?"; + }; + } + }; + } + +// +// RESOURCE LOCALISABLE_APP_INFO +// +// --------------------------------------------------------- +// +RESOURCE LOCALISABLE_APP_INFO r_profiler_gui_localisable_app_info + { + short_caption = "PI Profiler"; + caption_and_icon = + CAPTION_AND_ICON_INFO + { + caption = "PI Profiler"; + + number_of_icons = 1; + + // Note for ROM-based apps it is recommended to add the drive letter + icon_file = APP_BITMAP_DIR"\\piprofilerui_aif.mif"; + }; + } diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofilerui/gui/data/piprofilerui_reg.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofilerui/gui/data/piprofilerui_reg.rss Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,36 @@ +/* +* 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: +* +*/ + + + + +#include +#include +#include + + +UID2 KUidAppRegistrationResourceFile +UID3 0x2001E5AE + + +RESOURCE APP_REGISTRATION_INFO + { + app_file = "PIProfilerUI"; + localisable_resource_file = APP_RESOURCE_DIR"\\PIProfilerUI"; + localisable_resource_id = R_PROFILER_GUI_LOCALISABLE_APP_INFO; + group_name = "RnD Tools"; + } diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofilerui/gui/group/backup_registration.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofilerui/gui/group/backup_registration.xml Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,8 @@ + + + + + + + + diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofilerui/gui/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofilerui/gui/group/bld.inf Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,50 @@ +/* +* 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: +* +*/ + + + +#include + + +PRJ_EXPORTS +../group/backup_registration.xml Z:/private/2001E5AE/backup_registration.xml + + +PRJ_MMPFILES +#ifndef SBSV2 + gnumakefile piprofilerui_icons_aif.mk + gnumakefile piprofilerui_extraicons.mk +#endif + +piprofilerui.mmp + + +#ifdef SBSV2 + PRJ_EXTENSIONS + START EXTENSION s60/mifconv + OPTION TARGETFILE piprofilerui_aif.mif + OPTION SOURCEDIR ../icons + OPTION SOURCES -c8,8 qgn_menu_piprofilerui + END + + START EXTENSION s60/mifconv + OPTION TARGETFILE piprofilerui_extraicons.mif + OPTION HEADERFILE piprofilerui_extraicons.mbg + OPTION SOURCEDIR ../icons + OPTION SOURCES -c8,8 qgn_prob_piprofilerui_status_disabled -c8,8 qgn_prob_piprofilerui_status_enabled + END +#endif diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofilerui/gui/group/piprofilerui.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofilerui/gui/group/piprofilerui.mmp Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,84 @@ +/* +* 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: +* +*/ + + + +#include +#include + + +TARGET PIProfilerUI.exe +TARGETTYPE exe +EPOCSTACKSIZE 0x8000 +EPOCHEAPSIZE 0x10000 0x1000000 // Min 64Kb, Max 16Mb + +UID 0x100039CE 0x2001E5AE + +VENDORID VID_DEFAULT +CAPABILITY ALL -TCB //swevent networkservices + +LANG SC + +START RESOURCE ../data/piprofilerui.rss +HEADER +TARGETPATH APP_RESOURCE_DIR +END + +START RESOURCE ../data/piprofilerui_reg.rss +DEPENDS piprofilerui.rsg +TARGETPATH /private/10003a3f/apps +END + +APP_LAYER_SYSTEMINCLUDE +USERINCLUDE ../inc +SOURCEPATH ../src + + +SOURCE profiler_gui_app.cpp +SOURCE profiler_gui_document.cpp +SOURCE profiler_gui_appui.cpp +SOURCE profiler_gui_model.cpp +SOURCE profiler_gui_mainview.cpp +SOURCE profiler_gui_maincontainer.cpp +SOURCE profiler_gui_settingsviewdlg.cpp +SOURCE profiler_gui_samplersettingsviewdlg.cpp + + +LIBRARY euser.lib +LIBRARY eiksrv.lib +LIBRARY commonengine.lib +LIBRARY apparc.lib +LIBRARY cone.lib +LIBRARY eikcore.lib +LIBRARY eikcoctl.lib +LIBRARY eikctl.lib +LIBRARY eikdlg.lib +LIBRARY avkon.lib +LIBRARY ws32.lib +LIBRARY apgrfx.lib +LIBRARY efsrv.lib +LIBRARY bafl.lib +LIBRARY gdi.lib +LIBRARY aknnotify.lib +LIBRARY aknicon.lib +LIBRARY aknskins.lib +LIBRARY aknskinsrv.lib +LIBRARY egul.lib +LIBRARY estor.lib +LIBRARY flogger.lib +LIBRARY charconv.lib +LIBRARY platformenv.lib diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofilerui/gui/group/piprofilerui_extraicons.mk --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofilerui/gui/group/piprofilerui_extraicons.mk Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,60 @@ +# +# 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: +# + +ifeq (WINS,$(findstring WINS, $(PLATFORM))) +ZDIR=$(EPOCROOT)epoc32\release\$(PLATFORM)\$(CFG)\z +else +ZDIR=$(EPOCROOT)epoc32\data\z +endif + +TARGETDIR=$(ZDIR)\resource\apps +ICONTARGETFILENAME=$(TARGETDIR)\piprofilerui_extraicons.mif + +HEADERDIR=$(EPOCROOT)epoc32\include +HEADERFILENAME=$(HEADERDIR)\piprofilerui_extraicons.mbg + + +do_nothing : + @rem do_nothing + +MAKMAKE : do_nothing + +BLD : do_nothing + +CLEAN : + @if exist $(ICONTARGETFILENAME) erase $(ICONTARGETFILENAME) + @if exist $(HEADERFILENAME) erase $(HEADERFILENAME) + +LIB : do_nothing + +CLEANLIB : do_nothing + +RESOURCE : $(ICONTARGETFILENAME) + +$(ICONTARGETFILENAME) (HEADERFILENAME) : ..\icons\qgn_prob_piprofilerui_status_disabled.svg ..\icons\qgn_prob_piprofilerui_status_enabled.svg + mifconv $(ICONTARGETFILENAME) /h$(HEADERFILENAME) \ + /c8,8 ..\icons\qgn_prob_piprofilerui_status_disabled.svg \ + /c8,8 ..\icons\qgn_prob_piprofilerui_status_enabled.svg + +FREEZE : do_nothing + +SAVESPACE : do_nothing + +RELEASABLES : + @echo $(HEADERFILENAME) && \ + @echo $(ICONTARGETFILENAME) + +FINAL : do_nothing diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofilerui/gui/group/piprofilerui_icons_aif.mk --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofilerui/gui/group/piprofilerui_icons_aif.mk Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,54 @@ +# +# 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: +# + +ifeq (WINS,$(findstring WINS, $(PLATFORM))) +ZDIR=$(EPOCROOT)epoc32\release\$(PLATFORM)\$(CFG)\z +else +ZDIR=$(EPOCROOT)epoc32\data\z +endif + +TARGETDIR=$(ZDIR)\resource\apps +ICONTARGETFILENAME=$(TARGETDIR)\piprofilerui_aif.mif + + +do_nothing : + @rem do_nothing + +MAKMAKE : do_nothing + +BLD : do_nothing + +CLEAN : + @if exist $(ICONTARGETFILENAME) erase $(ICONTARGETFILENAME) + +LIB : do_nothing + +CLEANLIB : do_nothing + +RESOURCE : $(ICONTARGETFILENAME) + +$(ICONTARGETFILENAME) : ..\icons\qgn_menu_piprofilerui.svg + mifconv $(ICONTARGETFILENAME) \ + /c8,8 ..\icons\qgn_menu_piprofilerui.svg + +FREEZE : do_nothing + +SAVESPACE : do_nothing + +RELEASABLES : + @echo $(ICONTARGETFILENAME) + +FINAL : do_nothing diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofilerui/gui/group/piprofilerui_stub_sis.mk --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofilerui/gui/group/piprofilerui_stub_sis.mk Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,55 @@ +# +# 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: +# + +TARGETDIR=$(EPOCROOT)EPOC32\Data\Z\System\Install + +SISNAME=PIProfilerUI_stub +PKGNAME=PIProfilerUI_stub + +$(TARGETDIR) : + @perl -S emkdir.pl "$(TARGETDIR)" + +do_nothing : + rem do_nothing + +SISFILE=$(TARGETDIR)\$(SISNAME).sis + +$(SISFILE) : ..\..\sis\$(PKGNAME).pkg + makesis -s $? $@ + + + +MAKMAKE : do_nothing + +RESOURCE : do_nothing + +SAVESPACE : do_nothing + +BLD : do_nothing + +FREEZE : do_nothing + +LIB : do_nothing + +CLEANLIB : do_nothing + +FINAL : $(TARGETDIR) $(SISFILE) + +CLEAN : + @if exist $(SISFILE) erase $(SISFILE) + +RELEASABLES : + @echo $(SISFILE) diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofilerui/gui/icons/qgn_menu_piprofilerui.svg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofilerui/gui/icons/qgn_menu_piprofilerui.svg Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofilerui/gui/icons/qgn_prob_piprofilerui_status_disabled.svg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofilerui/gui/icons/qgn_prob_piprofilerui_status_disabled.svg Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,59 @@ + + + + + + image/svg+xml + + + + + + + + diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofilerui/gui/icons/qgn_prob_piprofilerui_status_enabled.svg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofilerui/gui/icons/qgn_prob_piprofilerui_status_enabled.svg Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,17 @@ + + + + + + diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofilerui/gui/inc/profiler_gui.hrh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofilerui/gui/inc/profiler_gui.hrh Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,115 @@ +/* +* 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 PROFILERGUI_HRH +#define PROFILERGUI_HRH + +enum TProfilerCmdSamplerIds + { + EProfilerGuiCmdSamplerEnable = 1, // id cannot be 0 + EProfilerGuiCmdSamplerDisable, + EProfilerGuiCmdSamplerSettings, + EProfilerGuiCmdSamplerInfo + }; + +enum TSamplerSettingItemIds + { + EProfilerGuiGenericSamplerQuerySampleRate = 0, + EProfilerGuiGenericSamplerQueryItem1, + EProfilerGuiGenericSamplerQueryItem2, + EProfilerGuiGenericSamplerQueryItem3, + EProfilerGuiGenericSamplerQueryItem4, + EProfilerGuiGenericSamplerQueryItem5, + EProfilerGuiGenericSamplerQueryItem6 + }; + +enum TGeneralSettingItemIds + { + ESettingListItemPluginTraceOutput = 0, + ESettingListItemPluginSaveFileDrive, + ESettingListItemPluginTraceFilePrefix + }; + +enum TProfilerGuiCommandIds + { + EProfilerGuiCmdStart = 1000, + EProfilerGuiCmdStop, + EProfilerGuiCmdStartAll, + EProfilerGuiCmdStopAll, + + EProfilerGuiCmdSamplerControl, + EProfilerGuiCmdSamplerSettingsChange, + EProfilerGuiCmdSamplerSettingsExit, + + EProfilerGuiCmdSettings, + EProfilerGuiCmdSettingsChange, + EProfilerGuiCmdSettingsExit, + EProfilerGuiCmdSettingsBack, + + EProfilerGuiCmdAbout, + + EProfilerGuiViewConfQuery, + EProfilerGuiSettingItemList, + EProfilerSamplerSettingItemList + }; + +enum TProfilerGuiSettingSamplerNameLength + { + ESamplerNameShort, + ESamplerNameMedium, + ESamplerNameLong + }; + +enum TProfilerGuiSettingTraceMode + { + ETraceModeStream, + ETraceModeBuffer + }; + +enum TProfilerGuiSettingOutputMode + { + EOutputToDebugPort = 0, + EOutputToFileSystem + }; + +enum TProfilerGuiSettingSaveFileDrive + { + ETraceSaveFileDriveC, + ETraceSaveFileDriveD, + ETraceSaveFileDriveE, + ETraceSaveFileDriveF, + ETraceSaveFileDriveG, + ETraceSaveFileDriveH, + ETraceSaveFileDriveI, + ETraceSaveFileDriveJ, + ETraceSaveFileDriveK, + ETraceSaveFileDriveL + }; + +enum TItemActionMenuTypes + { + EItemActionMenuTypeEnable = 0, + EItemActionMenuTypeDisable, + EItemActionMenuTypeEditSettings, + EItemActionMenuTypeInfo, + EItemActionMenuTypeStart, // for future use + EItemActionMenuTypeStop // for future use + }; + +#endif // PROFILERGUI_HRH diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofilerui/gui/inc/profiler_gui_app.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofilerui/gui/inc/profiler_gui_app.h Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,61 @@ +/* +* 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_GUI_APP_H +#define PROFILER_GUI_APP_H + + +// INCLUDES +#include + +// CONSTANTS +// UID of the application +const TUid KUidProfilerGui = { 0x2001E5AE }; + +// CLASS DECLARATION + +/** +* CProfilerGuiApp application class. +* Provides factory to create concrete document object. +* +*/ +class CProfilerGuiApp : public CAknApplication + { + + public: // Functions from base classes + + private: + + /** + * From CApaApplication, creates CProfilerGuiDocument document object. + * @return A pointer to the created document object. + */ + CApaDocument* CreateDocumentL(); + + /** + * From CApaApplication, returns application's UID (KUidProfilerGui). + * @return The value of KUidProfilerGui. + */ + TUid AppDllUid() const; + }; + +#endif + +// End of File + diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofilerui/gui/inc/profiler_gui_appui.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofilerui/gui/inc/profiler_gui_appui.h Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,67 @@ +/* +* 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_GUI_APPUI_H +#define PROFILER_GUI_APPUI_H + +// INCLUDES +#include +#include +#include +#include +#include +#include +#include +#include "profiler_gui_std.h" + +// profiler engine inclusions +#include + +// FORWARD DECLARATIONS +class CProfilerGuiModel; + +// CLASS DECLARATIONS + +class CProfilerGuiAppUi : public CAknViewAppUi + { +public: // constructors and destructor + void ConstructL(); + ~CProfilerGuiAppUi(); + + // profiler specific + void StartProfilerL(); + void StopProfilerL(); +private: // From MEikMenuObserver + void DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane); + +private: + void HandleCommandL(TInt aCommand); + virtual TKeyResponse HandleKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType); + void HandleSystemEventL(const TWsEvent& aEvent); + + void SaveSettingsL(); + void LoadSettingsL(); + TInt RunConfQueryL( const TDesC* aOverrideText ); +private: //Data + CProfilerGuiModel* iModel; + }; + +#endif + +// End of File diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofilerui/gui/inc/profiler_gui_attributes.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofilerui/gui/inc/profiler_gui_attributes.h Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,33 @@ +/* +* 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_GUI_ATTRIBUTES_H +#define PROFILER_GUI_ATTRIBUTES_H + +// INCLUDES +#include +#include + +// CONSTANTS + +// FORWARD DECLARATIONS + +// CLASS DECLARATIONS + +#endif diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofilerui/gui/inc/profiler_gui_document.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofilerui/gui/inc/profiler_gui_document.h Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,78 @@ +/* +* 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_GUI_DOCUMENT_H +#define PROFILER_GUI_DOCUMENT_H + +// INCLUDES +#include + +// CONSTANTS + +// FORWARD DECLARATIONS +class CEikAppUi; +class CProfilerGuiModel; + + +// CLASS DECLARATION + +/** +* CProfilerGuiDocument application class. +*/ +class CProfilerGuiDocument : public CAknDocument + { + public: // Constructors and destructor + static CProfilerGuiDocument* NewL(CEikApplication& aApp); + virtual ~CProfilerGuiDocument(); + + public: // New functions + + public: // from CEikDocument + + protected: // New functions + + protected: // Functions from base classes + + private: + + /** + * EPOC default constructor. + */ + CProfilerGuiDocument(CEikApplication& aApp); + void ConstructL(); + + private: + + /** + * From CEikDocument, create CProfilerGuiAppUi "App UI" object. + */ + CEikAppUi* CreateAppUiL(); + + public: + inline CProfilerGuiModel* Model() { return iModel; } + + private: + CProfilerGuiModel* iModel; + + }; + +#endif + +// End of File + diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofilerui/gui/inc/profiler_gui_maincontainer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofilerui/gui/inc/profiler_gui_maincontainer.h Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,67 @@ +/* +* 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_GUI_VALUESCONTAINER_H +#define PROFILER_GUI_VALUESCONTAINER_H + +// INCLUDES +#include +#include +#include +#include + +// FORWARD DECLARATIONS +class CProfilerGuiModel; +class CAknInfoPopupNoteController; + +// CLASS DECLARATIONS + +class CProfilerGuiMainContainer : public CCoeControl, MCoeControlObserver, MEikListBoxObserver + { +public: + void ConstructL(const TRect& aRect); + ~CProfilerGuiMainContainer(); + +private: + void SizeChanged(); + TInt CountComponentControls() const; + CCoeControl* ComponentControl(TInt aIndex) const; + void Draw(const TRect& aRect) const; + void HandleResourceChange(TInt aType); + void HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType); // From MEikListBoxObserver + void HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType); // From MCoeControlObserver + TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType); + +public: + const CArrayFix* ListBoxSelectionIndexes(); + TInt ListBoxSelectionIndexesCount(); + void SetDefaultTitlePaneTextL(); + TInt CurrentListBoxItemIndex(); + void SetListBoxTextArrayL(CDesCArray* aTextArray); + inline CAknSingleGraphicStyleListBox* ListBox() { return iListBox; } + void ShowWriterInfoPopupL(const TDesC& aNote); +private: + CProfilerGuiModel* iModel; + CAknSingleGraphicStyleListBox* iListBox; + CAknInfoPopupNoteController* iInfoPopup; + }; + +#endif + +// End of File diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofilerui/gui/inc/profiler_gui_mainview.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofilerui/gui/inc/profiler_gui_mainview.h Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,83 @@ +/* +* 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_GUI_VALUESVIEW_H +#define PROFILER_GUI_VALUESVIEW_H + +// INCLUDES +#include + +#include "profiler_gui_std.h" +#include "profiler_gui_model.h" + + +// CONSTANTS +// UID of view +const TUid KMainViewUID = {1}; + +// FORWARD DECLARATIONS +class CProfilerGuiMainContainer; +class CProfilerGuiModel; +class CProfilerEngineStatusChecker; +class CAknNavigationDecorator; + + +/** +* CProfilerGuiMainView view class. +* +*/ +class CProfilerGuiMainView : public CAknView + { + public: // Constructors and destructor + void ConstructL(); + ~CProfilerGuiMainView(); + + public: // Functions from base classes + TUid Id() const; + void HandleCommandL(TInt aCommand); + void HandleClientRectChange(); + + /** + * Method for updating the Profiler engine status pane + * Called by Model class + * + * @param aStatus new status of profiler engine + */ + void UpdateStatusPaneL( TInt aStatus ); + + private: // From MEikMenuObserver + void DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane); + + private: // From AknView + void DoActivateL(const TVwsViewId& aPrevViewId, TUid aCustomMessageId, const TDesC8& aCustomMessage); + void DoDeactivate(); + void HandleStatusPaneSizeChange(); + void SetupStatusPaneL(); + void CleanupStatusPaneL(); + HBufC* GetLabelTextLC(TInt aStatus); + private: // Data + CAknNavigationDecorator* iNaviDecorator; + CProfilerGuiMainContainer* iContainer; + CProfilerGuiModel* iModel; + + }; + +#endif + +// End of File diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofilerui/gui/inc/profiler_gui_model.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofilerui/gui/inc/profiler_gui_model.h Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,150 @@ +/* +* 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_GUI_MODEL_H +#define PROFILER_GUI_MODEL_H + +// SYSTEM INCLUDES +#include +#include +#include +#include +#include +#include // RProperty + +// LOCAL INCLUDES +#include "profiler_gui_mainview.h" +#include "profiler_gui.hrh" + +// COMMON INCLUDES +#include +#include +#include + +// setting keys (do not change uids of existing keys to maintain compatibility to older versions!) +const TUid KPSettingPluginNameMode = { 0x00 }; +const TUid KPSettingPluginSaveFileDrive = { 0x01 }; +const TUid KPSettingPluginTraceOutput = { 0x02 }; +const TUid KPSettingPluginSaveFilePrefix = { 0x03 }; +const TUid KPSettingPluginTraceMode = { 0x04 }; + + +// FORWARD DECLARATIONS +class CProfilerGuiMainView; +class CProfilerGuiMainContainer; +class CEikonEnv; +class TSamplerAttributes; +class CProfilerEngineStatusChecker; +class MProfilerStatusObserver; + + +typedef CArrayFixSeg CSamplerItemList; + + + +class CProfilerGuiModel : public CActive, MProfilerStatusObserver + { +private: + enum TContainerDrawState + { + EDrawStateInvalid = -1, + EDrawStateMain + }; + public: + static CProfilerGuiModel* NewL(); + ~CProfilerGuiModel(); + void ActivateModelL(); + void DeActivateModelL(); + void SetMainView(CProfilerGuiMainView* aMainView); + void UpdateState(TInt aState); + TBool GetSelectedItemHasSettings(); + TBool GetSelectedItemEnabled(); + TBool GetSelectedItemHidden(); + TInt EditSelectedSamplerL(TInt index); + void SelectedSamplerInfoL(TInt index); + void TerminateProfilerL(); + TBool CheckTraceLocationSanityL(TGeneralAttributes& aAttr, TBool aQuietCheck); + private: + void RunL(); + void DoCancel(); + void LoadPluginsL(); + TInt EditSamplerL(TSamplerAttributes& aItem); + void SamplerInfoL(TSamplerAttributes& aItem); +private: + CProfilerGuiModel(); + void ConstructL(); + TInt LoadGeneralSettingsL(); + + void AppendToSamplerItemListL(TSamplerAttributes& aItem); + void DisableOrEnableFromSamplerItemListL(TInt aIndex); + void DeleteAllSamplerItems(); + void RefreshViewL(TBool aClearSelection=ETrue); + void LaunchProfilerEngineL(); + void UpdateUIRunningStateL(); + TInt FindProcessL(RProcess& aProc); +public: + void StartAllSamplerItemsL(); + void StopAllSamplerItemsL(); + void DeleteAllSamplerItemsL(); + void DisableAllSamplerItemsL(); + void EnableAllSamplerItemsL(); + + TInt SamplerItemCount() const; + void ShowItemActionMenuL(); + void StopSelectedOrHighlightedItemsL(); + void DisableOrEnableSelectedOrHighlightedItemsL(); + + CDesCArray* GenerateListBoxItemTextArrayL(); + void StartNewSamplerL(TInt aCommand); + void AddNewSamplersL(CArrayFixFlat& iSamplerAttributes); + + void SaveGeneralSettingsL(); + void SetMainContainer(CProfilerGuiMainContainer* aContainer); + TInt LaunchSettingsDialogL(); + inline CEikonEnv* EikonEnv() { return iEnv; } + inline CProfilerGuiMainContainer* MainContainer() { return iMainContainer; } + inline TBool SamplerItemsExists() { return iSamplerItemList->Count() > 0; } + + TPtrC GetWriterInfoNoteL(const TDesC& aNote); + +public: + // from MProfilerStatusObserver + void NotifyContainerReadyL(); + void HandleProfilerStatusChange( KProfilerStatus aStatus ); + void HandleProfilerErrorL( TInt aError ); + +private: + static const TInt iSamplerNameMode = ESamplerNameLong; + CProfilerGuiMainContainer* iMainContainer; + CEikonEnv* iEnv; + TInt iDrawState; + CSamplerItemList* iSamplerItemList; + TInt iReferenceNumber; + CArrayFixFlat* iSamplerAttributes; + TGeneralAttributes iGeneralAttributes; + TBool iProfilerStatus; // Status of Engine before it was launched by this application + CProfilerGuiMainView* iMainView; + + // checkers + CProfilerEngineStatusChecker* iStatusChecker; +public: + TInt iState; + }; + +#endif diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofilerui/gui/inc/profiler_gui_samplersettingsviewdlg.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofilerui/gui/inc/profiler_gui_samplersettingsviewdlg.h Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,92 @@ +/* +* 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_GUI_SAMPLERSETTINGSVIEWDLG_H +#define PROFILER_GUI_SAMPLERSETTINGSVIEWDLG_H + +// INCLUDES +#include +#include +#include +#include +#include +#include + +#include "profiler_gui_model.h" + + +// FORWARD DECLARATIONS +class CAknSettingItemArray; +class CAknSettingStyleListBox; +class CAknNavigationControlContainer; +class CAknNavigationDecorator; +class CAknTabGroup; +class TProfilerSamplerSettings; + +// CONSTANTS +const TUint KMaxItemCount = 7; +const TInt KMaxSettingUITextLength = 64; + +// CLASS DEFINITIONS + +class CProfilerSamplerSettingsViewDlg : public CAknDialog, public MEikListBoxObserver, public MAknTabObserver + { +public: + static CProfilerSamplerSettingsViewDlg* NewL(TSamplerAttributes& aSettings); + virtual ~CProfilerSamplerSettingsViewDlg(); + +public: // From MEikListBoxObserver + void HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType); + +public: // From MAknTabObserver + void TabChangedL(TInt aIndex); + +public: // From CAknDialog + void ProcessCommandL(TInt aCommandId); + +protected: // From CEikDialog + TKeyResponse OfferKeyEventL(const TKeyEvent &aKeyEvent, TEventCode aType); + void PreLayoutDynInitL(); + TBool OkToExitL(TInt aButtonId); + +private: // New methods + void ShowSettingPageL(TBool aCalledFromMenu); + void SetVisibilitiesOfSettingItemsL(); + void UpdateListBoxL(); + void AddSettingItemL(TInt aId, TInt aTitleResource, TInt aSettingPageResource, TInt aAssociatedResource, TInt aOrdinal); + +private: // Constructors + CProfilerSamplerSettingsViewDlg(TSamplerAttributes& aSettings); + void ConstructL(); + CAknSettingItem* GetSettingItemL(TSettingItem& aItem, TInt aIndex, TInt& aSettingPageResource); +private: // Data + CAknSettingItemArray* iSettingItemArray; + CAknSettingStyleListBox* iListBox; + CAknNavigationControlContainer* iNaviContainer; + TSamplerAttributes& iSettings; + TInt iItemCount; + + // item bufs for textual settings data + TInt iItemBuf[KMaxItemCount]; + }; + +#endif + +// End of File + diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofilerui/gui/inc/profiler_gui_settingsviewdlg.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofilerui/gui/inc/profiler_gui_settingsviewdlg.h Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,91 @@ +/* +* 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_GUI_SETTINGSVIEWDLG_H +#define PROFILER_GUI_SETTINGSVIEWDLG_H + +// INCLUDES +#include +#include +#include +#include +#include +#include + +#include "profiler_gui_model.h" + + +// FORWARD DECLARATIONS +class CAknSettingItemArray; +class CAknSettingStyleListBox; +class CAknNavigationControlContainer; +class CAknNavigationDecorator; +class CAknTabGroup; +class TProfilerGuiSettings; + + +// CLASS DEFINITIONS + +class CProfilerGuiSettingsViewDlg : public CAknDialog, public MEikListBoxObserver, public MAknTabObserver + { +public: + static CProfilerGuiSettingsViewDlg* NewL(TGeneralAttributes& aSettings); + virtual ~CProfilerGuiSettingsViewDlg(); + +public: // From MEikListBoxObserver + void HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType); + +public: // From MAknTabObserver + void TabChangedL(TInt aIndex); + +public: // From CAknDialog + void ProcessCommandL(TInt aCommandId); + +protected: // From CEikDialog + TKeyResponse OfferKeyEventL(const TKeyEvent &aKeyEvent, TEventCode aType); + void PreLayoutDynInitL(); + TBool OkToExitL(TInt aButtonId); + +private: // New methods + void ShowSettingPageL(TBool aCalledFromMenu); + void SetVisibilitiesOfSettingItemsL(); + void UpdateListBoxL(); + void AddSettingItemL(TInt aId, TInt aTitleResource, TInt aSettingPageResource, TInt aAssociatedResource, TInt aOrdinal); + +private: // Constructors + CProfilerGuiSettingsViewDlg(TGeneralAttributes& aSettings); + void ConstructL(); + +private: // Data + CAknSettingItemArray* iSettingItemArray; + CAknSettingStyleListBox* iListBox; + CAknNavigationControlContainer* iNaviContainer; + TGeneralAttributes& iSettings; + + // temporary member variables + TInt iTraceOutput; + TBuf<64> iSaveDrive; + TBuf<64> iFilePrefix; + }; + + +#endif + +// End of File + diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofilerui/gui/inc/profiler_gui_std.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofilerui/gui/inc/profiler_gui_std.h Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,28 @@ +/* +* 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_GUI_STD_H +#define PROFILER_GUI_STD_H + + + +#endif + +// End of File + diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofilerui/gui/src/profiler_gui_app.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofilerui/gui/src/profiler_gui_app.cpp Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,64 @@ +/* +* 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: +* +*/ + + + +// INCLUDE FILES +#include "profiler_gui_app.h" +#include "profiler_gui_document.h" +#include + +#include + + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CProfilerGuiApp::AppDllUid() +// Returns application UID +// --------------------------------------------------------- +// +TUid CProfilerGuiApp::AppDllUid() const + { + return KUidProfilerGui; + } + +// --------------------------------------------------------- +// CProfilerGuiApp::CreateDocumentL() +// Creates CProfilerGuiDocument object +// --------------------------------------------------------- +// +CApaDocument* CProfilerGuiApp::CreateDocumentL() + { + return CProfilerGuiDocument::NewL( *this ); + } + +// ================= OTHER EXPORTED FUNCTIONS ============== + +LOCAL_C CApaApplication* NewApplication() + { + return new CProfilerGuiApp; + } + + +GLDEF_C TInt E32Main() + { + return EikStart::RunApplication(NewApplication); + } + +// End of File + diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofilerui/gui/src/profiler_gui_appui.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofilerui/gui/src/profiler_gui_appui.cpp Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,248 @@ +/* +* 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: +* +*/ + + + +// INCLUDE FILES +#include "profiler_gui_appui.h" +#include "profiler_gui_mainview.h" +#include "profiler_gui.hrh" +#include "profiler_gui_model.h" +#include "profiler_gui_document.h" +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + + +// ================= MEMBER FUNCTIONS ======================= + +void CProfilerGuiAppUi::ConstructL() + { + // set as system application to prevent getting shut down events + iEikonEnv->SetSystem(ETrue); + + BaseConstructL(EAknEnableSkin); + + // get model + iModel = static_cast(reinterpret_cast(iEikonEnv->AppUi())->Document())->Model(); + + LOGTEXT(_L("ProfilerGuiAppUi::ConstructL - setting main view settings")); + + CProfilerGuiMainView* mainView = new(ELeave) CProfilerGuiMainView; + CleanupStack::PushL(mainView); + mainView->ConstructL(); + AddViewL(mainView); // transfer ownership to CAknViewAppUi + CleanupStack::Pop(); // mainView + + LOGTEXT(_L("ProfilerGuiAppUi::ConstructL - setting default view")); + + SetDefaultViewL(*mainView); + + LOGTEXT(_L("ProfilerGuiAppUi::ConstructL - activating model")); + + // notify the model that everything has been constructed + iModel->ActivateModelL(); + } + +// -------------------------------------------------------------------------------------------- + +CProfilerGuiAppUi::~CProfilerGuiAppUi() + { + // notify the model that the application is closing + if (iModel) + TRAP_IGNORE(iModel->DeActivateModelL()); + + } + +// -------------------------------------------------------------------------------------------- + +void CProfilerGuiAppUi::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane) + { + if (aResourceId == R_PROFILER_GUI_APP_MENU) + { + if(iModel->iState == MProfilerStatusObserver::ERunning) + { + aMenuPane->SetItemDimmed(EProfilerGuiCmdStartAll, ETrue); + aMenuPane->SetItemDimmed(EProfilerGuiCmdStopAll, EFalse); + aMenuPane->SetItemDimmed(EProfilerGuiCmdSamplerControl, ETrue); + aMenuPane->SetItemDimmed(EProfilerGuiCmdSettings, ETrue); + } + else if(iModel->iState == MProfilerStatusObserver::EIdle) + { + aMenuPane->SetItemDimmed(EProfilerGuiCmdStartAll, EFalse); + aMenuPane->SetItemDimmed(EProfilerGuiCmdStopAll, ETrue); + aMenuPane->SetItemDimmed(EProfilerGuiCmdSamplerControl, EFalse); + aMenuPane->SetItemDimmed(EProfilerGuiCmdSettings, EFalse); + } + else + { + // if initializing or stopping no start/stop actions allowed + aMenuPane->SetItemDimmed(EProfilerGuiCmdStartAll, ETrue); + aMenuPane->SetItemDimmed(EProfilerGuiCmdStopAll, ETrue); + aMenuPane->SetItemDimmed(EProfilerGuiCmdSamplerControl, ETrue); + aMenuPane->SetItemDimmed(EProfilerGuiCmdSettings, ETrue); + } + } + + if(aResourceId == R_PROFILER_SAMPLER_CONTROL_MENU) + { + // check if item hidden, i.e. sampler cannot be started/stopped + if(!iModel->GetSelectedItemHidden()) + { + // item enabled => dimm the "enable" item, and other way round + if(iModel->GetSelectedItemEnabled()) + { + aMenuPane->SetItemDimmed(EProfilerGuiCmdSamplerEnable, ETrue); + aMenuPane->SetItemDimmed(EProfilerGuiCmdSamplerDisable, EFalse); + } + // item enabled => dimm the "enable" item, and other way round + else + { + aMenuPane->SetItemDimmed(EProfilerGuiCmdSamplerEnable, EFalse); + aMenuPane->SetItemDimmed(EProfilerGuiCmdSamplerDisable, ETrue); + } + + } + // item hidden => dimm both enable and disable items + else + { + aMenuPane->SetItemDimmed(EProfilerGuiCmdSamplerEnable, ETrue); + aMenuPane->SetItemDimmed(EProfilerGuiCmdSamplerDisable, ETrue); + } + + // if sampler item has specific settings to control + if(iModel->GetSelectedItemHasSettings()) + { + aMenuPane->SetItemDimmed(EProfilerGuiCmdSamplerSettings, EFalse); + } + else + { + aMenuPane->SetItemDimmed(EProfilerGuiCmdSamplerSettings, ETrue); + } + } + } + +// -------------------------------------------------------------------------------------------- + +TKeyResponse CProfilerGuiAppUi::HandleKeyEventL(const TKeyEvent& /*aKeyEvent*/, TEventCode /*aType*/) + { + return EKeyWasNotConsumed; + } + +void CProfilerGuiAppUi::HandleSystemEventL(const TWsEvent& aEvent) + { + switch (*(TApaSystemEvent*)(aEvent.EventData())) + { + case EApaSystemEventShutdown: + // check if still profiling + if( iModel->iState != MProfilerStatusObserver::EIdle ) + { + // stop profiling process + iModel->StopAllSamplerItemsL(); + } + + // terminate profiler engine + iModel->TerminateProfilerL(); + break; + default: + break; + } + // call base class implementation + CAknAppUi::HandleSystemEventL(aEvent); + } + +// -------------------------------------------------------------------------------------------- + +void CProfilerGuiAppUi::HandleCommandL(TInt aCommand) + { + switch ( aCommand ) + { + case EProfilerGuiCmdSettings: + { + // check if exit command received + if (iModel->LaunchSettingsDialogL() == EAknCmdExit) + { + // terminate profiler engine... + iModel->TerminateProfilerL(); + + // ... and exit + Exit(); + } + break; + } + case EProfilerGuiCmdAbout: + { + CAknMessageQueryDialog* dialog = new(ELeave) CAknMessageQueryDialog; + dialog->ExecuteLD(R_PROFILER_GUI_ABOUT_DIALOG); + } + break; + + // a normal way to close an application + case EAknCmdExit: + case EEikCmdExit: + case EAknSoftkeyExit: + { + // check if still profiling + if( iModel->iState != MProfilerStatusObserver::EIdle && + iModel->iState != MProfilerStatusObserver::EStopping ) + { + // ask user if he wants to leave profiling running in background process + if( this->RunConfQueryL( NULL ) == 0 ) + { + // stop profiling process + iModel->StopAllSamplerItemsL(); + + // terminate profiler engine + iModel->TerminateProfilerL(); + } + } + else + { + // terminate profiler engine + iModel->TerminateProfilerL(); + } + + Exit(); + } + break; + + default: + break; + } + } + +TInt CProfilerGuiAppUi::RunConfQueryL( const TDesC* aOverrideText ) + { + CAknQueryDialog* queryDialog = CAknQueryDialog::NewL(); + + if(aOverrideText) + { + queryDialog->SetPromptL(*aOverrideText); + } + return queryDialog->ExecuteLD(R_PROFILER_GUI_CONF_QUERY); + } + + +// End of File diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofilerui/gui/src/profiler_gui_document.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofilerui/gui/src/profiler_gui_document.cpp Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,72 @@ +/* +* 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: +* +*/ + + + +// INCLUDE FILES +#include "profiler_gui_document.h" +#include "profiler_gui_appui.h" +#include "profiler_gui_model.h" + +// ================= MEMBER FUNCTIONS ======================= + +// constructor +CProfilerGuiDocument::CProfilerGuiDocument(CEikApplication& aApp) +: CAknDocument(aApp) + { + } + +// ---------------------------------------------------- + +// destructor +CProfilerGuiDocument::~CProfilerGuiDocument() + { + delete iModel; + } + +// ---------------------------------------------------- + +// EPOC default constructor can leave. +void CProfilerGuiDocument::ConstructL() + { + iModel = CProfilerGuiModel::NewL(); + } + +// ---------------------------------------------------- + +// Two-phased constructor. +CProfilerGuiDocument* CProfilerGuiDocument::NewL(CEikApplication& aApp) + { + CProfilerGuiDocument* self = new(ELeave) CProfilerGuiDocument(aApp); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + + return self; + } + +// ---------------------------------------------------- +// CProfilerGuiDocument::CreateAppUiL() +// constructs CProfilerGuiAppUi +// ---------------------------------------------------- +// +CEikAppUi* CProfilerGuiDocument::CreateAppUiL() + { + return new (ELeave) CProfilerGuiAppUi; + } + +// End of File diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofilerui/gui/src/profiler_gui_maincontainer.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofilerui/gui/src/profiler_gui_maincontainer.cpp Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,332 @@ +/* +* 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: +* +*/ + + + +// INCLUDE FILES +#include "profiler_gui_maincontainer.h" +#include "profiler_gui.hrh" +#include "profiler_gui_document.h" +#include "profiler_gui_appui.h" +#include "profiler_gui_model.h" +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +_LIT(KExtraIconsPath, "\\resource\\apps\\piprofilerui_extraicons.mif"); + +// ===================================== MEMBER FUNCTIONS ===================================== + +void CProfilerGuiMainContainer::ConstructL(const TRect& aRect) + { + iModel = static_cast(reinterpret_cast(iEikonEnv->AppUi())->Document())->Model(); + iModel->SetMainContainer(this); + + CreateWindowL(); + SetRect(aRect); + SetBlank(); + + // init listbox + iListBox = new(ELeave) CAknSingleGraphicStyleListBox; + iListBox->SetContainerWindowL(*this); + iListBox->ConstructL(this, EAknListBoxMarkableList); + iListBox->View()->SetListEmptyTextL(_L("No plugins found yet")); + + // if description length longer than screen width, scroll the text + iListBox->ItemDrawer()->ColumnData()->EnableMarqueeL(ETrue); + + // create icon array and add marking indicator to it + CAknIconArray* iconArray = new(ELeave) CAknIconArray(1); + CleanupStack::PushL(iconArray); + CFbsBitmap* markBitmap = NULL; + CFbsBitmap* markBitmapMask = NULL; + + TRgb defaultColor; + defaultColor = iEikonEnv->Color(EColorControlText); + + AknsUtils::CreateColorIconL(AknsUtils::SkinInstance(), + KAknsIIDQgnIndiMarkedAdd, + KAknsIIDQsnIconColors, + EAknsCIQsnIconColorsCG13, + markBitmap, + markBitmapMask, + AknIconUtils::AvkonIconFileName(), + EMbmAvkonQgn_indi_marked_add, + EMbmAvkonQgn_indi_marked_add_mask, + defaultColor + ); + + CGulIcon* markIcon = CGulIcon::NewL(markBitmap, markBitmapMask); + iconArray->AppendL(markIcon); + + // append icons from profiler_gui_extraicons.mif + TFileName extraIconsPath; + extraIconsPath.Copy(KExtraIconsPath); + TParsePtrC parse((CEikonEnv::Static()->EikAppUi()->Application())->AppFullName()); // get path where this app is installed + extraIconsPath.Insert(0, parse.Drive()); // drive letter + + CFbsBitmap* redBitmap = NULL; + CFbsBitmap* redBitmapMask = NULL; + CFbsBitmap* greenBitmap = NULL; + CFbsBitmap* greenBitmapMask = NULL; + + AknIconUtils::CreateIconL(redBitmap, redBitmapMask, extraIconsPath, EMbmPiprofilerui_extraiconsQgn_prob_piprofilerui_status_disabled, EMbmPiprofilerui_extraiconsQgn_prob_piprofilerui_status_disabled_mask); + AknIconUtils::CreateIconL(greenBitmap, greenBitmapMask, extraIconsPath, EMbmPiprofilerui_extraiconsQgn_prob_piprofilerui_status_enabled, EMbmPiprofilerui_extraiconsQgn_prob_piprofilerui_status_enabled_mask); + + CGulIcon* redIcon = CGulIcon::NewL(redBitmap, redBitmapMask); + iconArray->AppendL(redIcon); + + CGulIcon* greenIcon = CGulIcon::NewL(greenBitmap, greenBitmapMask); + iconArray->AppendL(greenIcon); + + // set icon array + CleanupStack::Pop(); // iconArray + iListBox->ItemDrawer()->ColumnData()->SetIconArray(iconArray); + + iListBox->CreateScrollBarFrameL(ETrue); + iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto); + iListBox->SetListBoxObserver(this); + + // set size of the listbox + TSize outputRectSize; + AknLayoutUtils::LayoutMetricsSize(AknLayoutUtils::EMainPane, outputRectSize); + TRect outputRect(outputRectSize); + iListBox->SetRect(outputRect); + + iListBox->ActivateL(); + + ActivateL(); + + iInfoPopup = CAknInfoPopupNoteController::NewL(); + iInfoPopup->SetTimePopupInView(5000); + iInfoPopup->SetTimeDelayBeforeShow(500); + iInfoPopup->SetTextL(_L("TIP: Check also sampler specific settings!")); + iInfoPopup->ShowInfoPopupNote(); + } + +// -------------------------------------------------------------------------------------------- + +CProfilerGuiMainContainer::~CProfilerGuiMainContainer() + { + delete iInfoPopup; + + if (iListBox) + delete iListBox; + } + +// -------------------------------------------------------------------------------------------- + +void CProfilerGuiMainContainer::SizeChanged() +{ + TSize outputRectSize; + AknLayoutUtils::LayoutMetricsSize(AknLayoutUtils::EMainPane, outputRectSize); + TRect outputRect(outputRectSize); + + if (iListBox) + iListBox->SetRect(outputRect); +} + +// -------------------------------------------------------------------------------------------- + +TInt CProfilerGuiMainContainer::CountComponentControls() const + { + if (iListBox) + return 1; + else + return 0; + } + +// -------------------------------------------------------------------------------------------- + +CCoeControl* CProfilerGuiMainContainer::ComponentControl(TInt /*aIndex*/) const + { + if (iListBox) + return iListBox; + else + return NULL; + } + +// -------------------------------------------------------------------------------------------- + +TInt CProfilerGuiMainContainer::CurrentListBoxItemIndex() + { + if (iListBox) + { + return iListBox->CurrentItemIndex(); + } + else + return KErrNotFound; + } + +// -------------------------------------------------------------------------------------------- + +void CProfilerGuiMainContainer::SetListBoxTextArrayL(CDesCArray* aTextArray) + { + if (iListBox) + { + iListBox->Model()->SetItemTextArray(aTextArray); + iListBox->Model()->SetOwnershipType(ELbmOwnsItemArray); + iListBox->HandleItemAdditionL(); + iListBox->UpdateScrollBarsL(); + } + } + +// -------------------------------------------------------------------------------------------- + +const CArrayFix* CProfilerGuiMainContainer::ListBoxSelectionIndexes() + { + if (iListBox) + { + const CListBoxView::CSelectionIndexArray* indices = iListBox->SelectionIndexes(); + return static_cast*>(indices); + } + else + return NULL; + } + +// -------------------------------------------------------------------------------------------- + +TInt CProfilerGuiMainContainer::ListBoxSelectionIndexesCount() + { + if (iListBox) + { + return iListBox->SelectionIndexes()->Count(); + } + else + return KErrNotFound; + } + +// -------------------------------------------------------------------------------------------- + +void CProfilerGuiMainContainer::Draw(const TRect& aRect) const + { + CWindowGc& gc = SystemGc(); + gc.Clear(aRect); + } + +// -------------------------------------------------------------------------------------------- + +void CProfilerGuiMainContainer::HandleControlEventL(CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/) + { + } + +// -------------------------------------------------------------------------------------------- + +void CProfilerGuiMainContainer::SetDefaultTitlePaneTextL() + { + _LIT(KTitleText, "PIProfiler"); + + CEikStatusPane* sp = iEikonEnv->AppUiFactory()->StatusPane(); + CAknTitlePane* tp = static_cast( sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) ); + tp->SetTextL( KTitleText ); + } + +// -------------------------------------------------------------------------------------------- + +TKeyResponse CProfilerGuiMainContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType) + { + if(aType != EEventKey) + return EKeyWasNotConsumed; + + if (iListBox && iListBox->Model()->NumberOfItems() > 0) + { + // handle OK/Enter keys + if (aKeyEvent.iCode == EKeyOK || aKeyEvent.iCode == EKeyEnter) + { + // check if profiler state is idle + if(iModel->iState == MProfilerStatusObserver::EIdle) + { + // show action menu only if state is idle + iModel->ShowItemActionMenuL(); + } + } + else + { + return iListBox->OfferKeyEventL(aKeyEvent, aType); + } + } + + return EKeyWasNotConsumed; + } + +// -------------------------------------------------------------------------------------------- + +void CProfilerGuiMainContainer::HandleListBoxEventL(CEikListBox* /*aListBox*/, TListBoxEvent aEventType) + { + switch (aEventType) + { + case EEventEnterKeyPressed: + case EEventItemDoubleClicked: + { + iModel->ShowItemActionMenuL(); + } + break; + default: + break; + } + } + +// -------------------------------------------------------------------------------------------- + +void CProfilerGuiMainContainer::HandleResourceChange(TInt aType) + { + if ( aType == KEikDynamicLayoutVariantSwitch ) + { + TRect mainPaneRect; + AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect); + SetRect(mainPaneRect); + + TSize outputRectSize; + AknLayoutUtils::LayoutMetricsSize(AknLayoutUtils::EMainPane, outputRectSize); + TRect outputRect(outputRectSize); + iListBox->SetRect(outputRect); + } + else + { + CCoeControl::HandleResourceChange(aType); + } + } + +// -------------------------------------------------------------------------------------------- + +void CProfilerGuiMainContainer::ShowWriterInfoPopupL(const TDesC& aNote) + { + if(!iInfoPopup) + { + iInfoPopup = CAknInfoPopupNoteController::NewL(); + } + // Hide the note. The last note may be visible when creating the second + iInfoPopup->HideInfoPopupNote(); + iInfoPopup->SetTimePopupInView(5000); + iInfoPopup->SetTimeDelayBeforeShow(500); + iInfoPopup->SetTextL(iModel->GetWriterInfoNoteL(aNote)); + iInfoPopup->ShowInfoPopupNote(); + } + + +// End of File diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofilerui/gui/src/profiler_gui_mainview.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofilerui/gui/src/profiler_gui_mainview.cpp Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,330 @@ +/* +* 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: +* +*/ + + + +// INCLUDE FILES +#include "profiler_gui.hrh" +#include "profiler_gui_mainview.h" +#include "profiler_gui_maincontainer.h" +#include "profiler_gui_document.h" +#include "profiler_gui_model.h" +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// CProfilerGuiMainView::ConstructL(const TRect& aRect) +// EPOC two-phased constructor +// --------------------------------------------------------- +// +void CProfilerGuiMainView::ConstructL() + { + BaseConstructL( R_PROFILER_GUI_VIEW_MAIN ); + + iModel = static_cast(reinterpret_cast(iEikonEnv->AppUi())->Document())->Model(); + iNaviDecorator = NULL; + iModel->SetMainView(this); + } + +// --------------------------------------------------------- +// CProfilerGuiMainView::~CProfilerGuiMainView() +// --------------------------------------------------------- +// +CProfilerGuiMainView::~CProfilerGuiMainView() + { + + if(iNaviDecorator) + { + delete iNaviDecorator; + iNaviDecorator = NULL; + } + + if (iContainer) + { + AppUi()->RemoveFromViewStack( *this, iContainer ); + delete iContainer; + iContainer = NULL; + } + + } + +// --------------------------------------------------------- +// TUid CProfilerGuiMainView::Id() +// --------------------------------------------------------- +// +TUid CProfilerGuiMainView::Id() const + { + return KMainViewUID; + } + +// --------------------------------------------------------- +// TUid CProfilerGuiMainView::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane) +// --------------------------------------------------------- +// +void CProfilerGuiMainView::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane) + { + AppUi()->DynInitMenuPaneL(aResourceId, aMenuPane); + } + + +// --------------------------------------------------------- +// CProfilerGuiMainView::HandleCommandL(TInt aCommand) +// --------------------------------------------------------- +// +void CProfilerGuiMainView::HandleCommandL(TInt aCommand) + { + switch ( aCommand ) + { + // commands from sampler control sub menu + case EProfilerGuiCmdSamplerEnable: + { + iModel->DisableOrEnableSelectedOrHighlightedItemsL(); + break; + } + case EProfilerGuiCmdSamplerDisable: + { + iModel->DisableOrEnableSelectedOrHighlightedItemsL(); + break; + } + case EProfilerGuiCmdSamplerSettings: + { + // check if sampler settings dialog returned exit command + iModel->EditSelectedSamplerL(iContainer->CurrentListBoxItemIndex()); + break; + } + case EProfilerGuiCmdSamplerInfo: + { + iModel->SelectedSamplerInfoL(iContainer->CurrentListBoxItemIndex()); + break; + } + + case EProfilerGuiCmdStartAll: + { + // still using the old way of starting all the samplers simultaneously + if( iModel->iState != MProfilerStatusObserver::ERunning ) + { + // set state as "initializing" for a moment before profiling has started, + // NOTE: engine changes to "Running" state + iModel->iState = MProfilerStatusObserver::EInitializing; + // start the actual sampling process on Profiler Engine + iModel->StartAllSamplerItemsL(); + } + + // prevent the control of sampler specific settings during the trace + iContainer->SetDimmed(ETrue); + break; + } + case EProfilerGuiCmdStopAll: + { + // check if still profiling + if( iModel->iState != MProfilerStatusObserver::EIdle ) + { + // set to stopping mode + iModel->iState = MProfilerStatusObserver::EStopping; + // stop actual sampling process on Profiler Engine + iModel->StopAllSamplerItemsL(); + } + + // return the control to sampler specific settings when tracing stopped + iContainer->SetDimmed(EFalse); + + break; + } + + default: + { + AppUi()->HandleCommandL(aCommand); + break; + } + } + } + +// --------------------------------------------------------- +// CProfilerGuiMainView::HandleClientRectChange() +// --------------------------------------------------------- +// +void CProfilerGuiMainView::HandleClientRectChange() + { + if ( iContainer ) + { + iContainer->SetRect( ClientRect() ); + } + } + +// --------------------------------------------------------- +// CProfilerGuiMainView::DoActivateL(...) +// --------------------------------------------------------- +// +void CProfilerGuiMainView::DoActivateL( + const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/, + const TDesC8& /*aCustomMessage*/) + { + // show wait dialog + CAknGlobalNote* waitDialog = CAknGlobalNote::NewLC(); + waitDialog->SetSoftkeys(R_AVKON_SOFTKEYS_EMPTY); + TInt dialogId = waitDialog->ShowNoteL(EAknGlobalWaitNote, _L("Initializing samplers")); + + // setup the profiler engine status pane + SetupStatusPaneL(); + + // check if container creation succesfull + if (!iContainer) + { + iContainer = new (ELeave) CProfilerGuiMainContainer; + iModel->SetMainContainer(iContainer); + iContainer->SetMopParent(this); + iContainer->ConstructL( ClientRect() ); + iModel->NotifyContainerReadyL(); + AppUi()->AddToStackL( *this, iContainer ); + } + + // remove the wait dialog + waitDialog->CancelNoteL(dialogId); + CleanupStack::PopAndDestroy(); //waitDialog; + } + +// --------------------------------------------------------- +// CProfilerGuiMainView::DoDeactivate() +// --------------------------------------------------------- +// +void CProfilerGuiMainView::DoDeactivate() + { + TRAP_IGNORE(CleanupStatusPaneL()); + + if (iContainer) + { + AppUi()->RemoveFromViewStack( *this, iContainer ); + delete iContainer; + iContainer = NULL; + } + } + +void CProfilerGuiMainView::HandleStatusPaneSizeChange() + { + CAknView::HandleStatusPaneSizeChange(); + + TInt result; + TRAP(result, SetupStatusPaneL()); + } + + +void CProfilerGuiMainView::SetupStatusPaneL() + { + TUid naviPaneUid = TUid::Uid(EEikStatusPaneUidNavi); + CEikStatusPaneBase::TPaneCapabilities subPaneNavi = StatusPane()->PaneCapabilities(naviPaneUid); + if(subPaneNavi.IsPresent() && subPaneNavi.IsAppOwned()) + { + CAknNavigationControlContainer* naviPane = static_cast (StatusPane()->ControlL(naviPaneUid)); + if(iNaviDecorator) + { + delete iNaviDecorator; + iNaviDecorator = NULL; + } + + // get the initial status label + HBufC* labelText = GetLabelTextLC(iModel->iState); + iNaviDecorator = naviPane->CreateNavigationLabelL(*labelText); + CleanupStack::PopAndDestroy(labelText); + + naviPane->PushL(*iNaviDecorator); + } + } + +void CProfilerGuiMainView::CleanupStatusPaneL() + { + // destructor for navi pane, called by destructor + TUid naviPaneUid = TUid::Uid(EEikStatusPaneUidNavi); + CEikStatusPaneBase::TPaneCapabilities subPaneNavi = StatusPane()->PaneCapabilities(naviPaneUid); + if(subPaneNavi.IsPresent() && subPaneNavi.IsAppOwned()) + { + CAknNavigationControlContainer* naviPane = static_cast (StatusPane()->ControlL(naviPaneUid)); + if(iNaviDecorator) + { + naviPane->Pop(iNaviDecorator); + delete iNaviDecorator; + iNaviDecorator = NULL; + } + } + } + +HBufC* CProfilerGuiMainView::GetLabelTextLC(TInt aStatus) + { + // get the predefined status text + HBufC* labelText = NULL; + switch(aStatus) + { + case MProfilerStatusObserver::EIdle: + labelText = StringLoader::LoadLC(R_PROFILER_GUI_NAVI_TEXT_IDLE); + break; + case MProfilerStatusObserver::EInitializing: + labelText = StringLoader::LoadLC(R_PROFILER_GUI_NAVI_TEXT_INITIALIZING); + break; + case MProfilerStatusObserver::ERunning: + labelText = StringLoader::LoadLC(R_PROFILER_GUI_NAVI_TEXT_RUNNING); + break; + case MProfilerStatusObserver::EStopping: + labelText = StringLoader::LoadLC(R_PROFILER_GUI_NAVI_TEXT_STOPPING); + break; + case MProfilerStatusObserver::ERestarting: + labelText = StringLoader::LoadLC(R_PROFILER_GUI_NAVI_TEXT_RUNNING); + break; + default: + labelText = StringLoader::LoadLC(R_PROFILER_GUI_NAVI_TEXT_IDLE); + break; + } + return labelText; + } + +void CProfilerGuiMainView::UpdateStatusPaneL( TInt aStatus ) + { + TUid naviPaneUid = TUid::Uid(EEikStatusPaneUidNavi); + CEikStatusPaneBase::TPaneCapabilities subPaneNavi = StatusPane()->PaneCapabilities(naviPaneUid); + // check if navi pane is correctly initialized + if(subPaneNavi.IsPresent() && subPaneNavi.IsAppOwned()) + { + CAknNavigationControlContainer* naviPane = static_cast (StatusPane()->ControlL(naviPaneUid)); + if(iNaviDecorator) + { + delete iNaviDecorator; + iNaviDecorator = NULL; + } + HBufC* labelText; + + // get the right status label text + labelText = GetLabelTextLC(aStatus); + iNaviDecorator = naviPane->CreateNavigationLabelL(*labelText); + CleanupStack::PopAndDestroy(labelText); + + naviPane->PushL(*iNaviDecorator); + } + } + + +// End of File diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofilerui/gui/src/profiler_gui_model.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofilerui/gui/src/profiler_gui_model.cpp Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,1119 @@ +/* +* 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: +* +*/ + + + +// INCLUDE FILES +#include "profiler_gui_samplersettingsviewdlg.h" +#include "profiler_gui_model.h" +#include "profiler_gui_app.h" +#include "profiler_gui_settingsviewdlg.h" +#include "profiler_gui_maincontainer.h" +#include "profiler_gui.hrh" +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +// UIDs +#include + +#include +#include + +// LITERALS +_LIT(KAppName, "PIProfiler"); +_LIT(KWarningNote, "NOTE: output changed!\n"); +_LIT(KProfilerEngineExe, "PIProfilerEngine.exe"); + +// literals for default general setting values +_LIT8(KTraceOutput, "file_system"); +_LIT8(KTraceDebugOutput, "debug_output"); +_LIT8(KProfilerDefaultDrive, "E:\\data"); +_LIT8(KProfilerDefaultPrefix, "Profiler_#"); + + +// ===================================== MEMBER FUNCTIONS ===================================== + +CProfilerGuiModel* CProfilerGuiModel::NewL() + { + CProfilerGuiModel* self = new(ELeave) CProfilerGuiModel; + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + return self; + } + +// -------------------------------------------------------------------------------------------- + +CProfilerGuiModel::CProfilerGuiModel() : CActive(EPriorityStandard) + { + } + +// -------------------------------------------------------------------------------------------- + +void CProfilerGuiModel::ConstructL() + { + // initialize basic settings + iDrawState = EDrawStateInvalid; + iReferenceNumber = 0; + iState = MProfilerStatusObserver::EIdle; + + iEnv = CEikonEnv::Static(); + + // profiler engine specific initialization + LaunchProfilerEngineL(); + + // max sampler item list length is 64, i.e. max 64 sampler plugins loaded + iSamplerItemList = new(ELeave) CSamplerItemList(64); + + // initialize attribute arrays + iSamplerAttributes = new(ELeave) CArrayFixFlat(20); // max sampler count is 20 + + // engine status checker + iStatusChecker = CProfilerEngineStatusChecker::NewL(); + iStatusChecker->SetObserver(this); + + CActiveScheduler::Add(this); + } + +void CProfilerGuiModel::UpdateUIRunningStateL() + { + // prevent the control of sampler specific settings during the trace + iMainContainer->SetDimmed(ETrue); + + // update status pane + iMainView->UpdateStatusPaneL(iState); + + // show an info popup showing the logging method + iMainContainer->ShowWriterInfoPopupL(KNullDesC); + + // refresh view + RefreshViewL(); + } + +// -------------------------------------------------------------------------------------------- +void CProfilerGuiModel::NotifyContainerReadyL() + { + // load initial plugins + LoadPluginsL(); + + // get the initial state + if( iStatusChecker->GetInitialState() == MProfilerStatusObserver::ERunning ) + { + // set model state to restarting and grabbing an existing profiler process + iState = MProfilerStatusObserver::ERestarting; + + // update status pane to correspond the running mode + UpdateUIRunningStateL(); + + // set model state to running + iState = MProfilerStatusObserver::ERunning; + + } + } + +// -------------------------------------------------------------------------------------------- + +void CProfilerGuiModel::ActivateModelL() + { + // load general settings + if( LoadGeneralSettingsL() != KErrNone ) + { + LOGTEXT(_L("ProfilerGuiAppUi::ActivateModelL - could not connect profiler engine")); + } + } + +// -------------------------------------------------------------------------------------------- + +void CProfilerGuiModel::DeActivateModelL() + { + Cancel(); + + // for a faster exit, send the application to background + TApaTask selfTask(iEnv->WsSession()); + selfTask.SetWgId(iEnv->RootWin().Identifier()); + selfTask.SendToBackground(); + } + +// -------------------------------------------------------------------------------------------- + +CProfilerGuiModel::~CProfilerGuiModel() + { + if (iSamplerItemList) + { + DeleteAllSamplerItems(); + delete iSamplerItemList; + iSamplerItemList = NULL; + } + + if(iStatusChecker) + { + iStatusChecker->Cancel(); + delete iStatusChecker; + iStatusChecker = NULL; + } + + + if(iSamplerAttributes) + { + iSamplerAttributes->Reset(); + delete iSamplerAttributes; + iSamplerAttributes = NULL; + } + + } + +// -------------------------------------------------------------------------------------------- + +void CProfilerGuiModel::DoCancel() + { + + } + +// -------------------------------------------------------------------------------------------- + +void CProfilerGuiModel::RunL() + { + + } + +// -------------------------------------------------------------------------------------------- + +void CProfilerGuiModel::SetMainContainer(CProfilerGuiMainContainer* aContainer) + { + iMainContainer = aContainer; + iDrawState = EDrawStateMain; + } + +void CProfilerGuiModel::UpdateState(TInt aState) + { + iState = aState; + } + +TInt CProfilerGuiModel::FindProcessL(RProcess& aProc) + { + TProcessId engId; + TFindProcess procName; + procName.Find(_L("PIProfilerEngine.exe*")); + TFullName aResult; + TFullName aResult2; + TInt err(KErrNone); + + // find the first appearance + err = procName.Next(aResult); + if(err != KErrNone) + { + // did not find any engine process + return err; + } + else + { + err = aProc.Open(procName); + if(err == KErrNone) + { + if(aProc.ExitCategory().Length() > 0) + { + aProc.Close(); + // process already exited => create a new one + return KErrNotFound; + } + aProc.Close(); + } + } + +// // check now if a second appearance exists in process list, +// // i.e. engine started from eshell => two engine processes appear in normal case +// procName.Next(aResult2); +// +// // check if aResult2 contained the second appearance of profiler engine +// if(aResult2.CompareF(aResult) > 0) +// { +// // other process found, i.e. right process to communicate with, in case started from eshell +// err = aProc.Open(procName); +// if(err == KErrNone) +// { +// if(aProc.ExitCategory().Length() > 0) +// { +// // process already exited => create a new one +// return KErrNotFound; +// } +// aProc.Close(); +// } +// } + + return err; + } + +void CProfilerGuiModel::LaunchProfilerEngineL() + { + LOGTEXT(_L("CProfilerGuiModel::LaunchProfilerEngineL - start")); + + TRequestStatus stat = KRequestPending; + RProcess proc; + + TInt err(KErrNone); + + // check if process exists + err = FindProcessL(proc); + + // check if already exists and don't start a new eshell profiling + if( err == KErrNotFound ) + { + // try create new process + err = proc.Create(KProfilerEngineExe, _L("")); + + // check if RProcess::Create() succeeded + if( err == KErrNone ) + { + // kick off the engine process + proc.Resume(); + + // wait for the constructor to complete + proc.Rendezvous(stat); // Trigger rendezvous on the supplied TRequestStatus object + User::WaitForRequest(stat); + + // just lose the handle + proc.Close(); + } + } + } + +//----------------------------------------------------------------------------- +// CProfilerGuiModel::TerminateProfilerL() +// Stops Profiler Engine if it has been launched by this launcher. +//----------------------------------------------------------------------------- + +void CProfilerGuiModel::TerminateProfilerL() + { + LOGTEXT(_L("CProfilerGuiModel::TerminateProfiler - entry")); + + // exit profiler engine + RProfiler::ExitProfiler(); + + LOGTEXT(_L("CProfilerGuiModel::TerminateProfiler - exit")); + + } + +void CProfilerGuiModel::AddNewSamplersL(CArrayFixFlat& aAttributes) + { + TSamplerAttributes item; + + TInt count(aAttributes.Count()); + + // loop the attribute array and insert them into view list + for (TInt i(0);iListBox()->SetCurrentItemIndexAndDraw(iMainContainer->ListBox()->Model()->NumberOfItems()-1); + + } + // refresh again + if(iReferenceNumber > 0) + { + RefreshViewL(ETrue); + } + } + +TBool CProfilerGuiModel::CheckTraceLocationSanityL(TGeneralAttributes& aAttr, TBool aQuietCheck) + { + RFs fs; + User::LeaveIfError(fs.Connect()); + + TBuf<32> drive; + + CnvUtfConverter::ConvertToUnicodeFromUtf8(drive, aAttr.iSaveFileDrive); + + TBool ret(EFalse); + + if(aAttr.iSaveFileDrive.Find(_L8("C:\\")) != KErrNotFound && BaflUtils::CheckFolder(fs, drive) == KErrNone) + ret = ETrue; + else if(aAttr.iSaveFileDrive.Find(_L8("D:\\")) != KErrNotFound && BaflUtils::CheckFolder(fs, drive) == KErrNone) + ret = ETrue; + else if(aAttr.iSaveFileDrive.Find(_L8("E:\\")) != KErrNotFound && BaflUtils::CheckFolder(fs, drive) == KErrNone) + ret = ETrue; + else if(aAttr.iSaveFileDrive.Find(_L8("F:\\")) != KErrNotFound && BaflUtils::CheckFolder(fs, drive) == KErrNone) + ret = ETrue; + else if(aAttr.iSaveFileDrive.Find(_L8("G:\\")) != KErrNotFound && BaflUtils::CheckFolder(fs, drive) == KErrNone) + ret = ETrue; + else if(aAttr.iSaveFileDrive.Find(_L8("H:\\")) != KErrNotFound && BaflUtils::CheckFolder(fs, drive) == KErrNone) + ret = ETrue; + else if(aAttr.iSaveFileDrive.Find(_L8("I:\\")) != KErrNotFound && BaflUtils::CheckFolder(fs, drive) == KErrNone) + ret = ETrue; + else + { + // show error + if(aQuietCheck == EFalse) + { + CAknErrorNote* note = new(ELeave) CAknErrorNote(); + note->ExecuteLD(_L("Unable to find drive, check settings!")); + ret = EFalse; + } + } + + return ret; + } + +// -------------------------------------------------------------------------------------------- + +TInt CProfilerGuiModel::LaunchSettingsDialogL() + { + // launch the settings dialog + TGeneralAttributes newSettings = iGeneralAttributes; + TBool quietCheck(EFalse); + + CProfilerGuiSettingsViewDlg* dlg = CProfilerGuiSettingsViewDlg::NewL(newSettings); + TInt returnValue = dlg->ExecuteLD(R_PROFILER_GUI_SETTINGS_DIALOG); + + // check if exit command => no error note to user + if(returnValue == EAknCmdExit) + quietCheck = ETrue; + + // always save settings since the settings dialog does not provide a possibility to cancel + iGeneralAttributes.iTraceOutput.Copy(newSettings.iTraceOutput); + iGeneralAttributes.iTraceFilePrefix.Copy(newSettings.iTraceFilePrefix); + + // check if debug output selected no check of + if(newSettings.iTraceOutput.CompareF(KTraceDebugOutput) != 0) + { + // Check save file drive sanity + if(CheckTraceLocationSanityL(newSettings, quietCheck)) + { + // save the new location + iGeneralAttributes.iSaveFileDrive.Copy(newSettings.iSaveFileDrive); + } + } + // saves the general settings to profiler engine + SaveGeneralSettingsL(); + + // make sure that the title of the application is correct + CEikStatusPane* sp = iEnv->AppUiFactory()->StatusPane(); + CAknTitlePane* tp = static_cast( sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) ); + tp->SetTextL(KAppName); + + return returnValue; + } + + +TPtrC CProfilerGuiModel::GetWriterInfoNoteL(const TDesC& aNote) + { + TBuf<256> buf; + TBuf<128> descBuf; + + buf.Zero(); + + // get active profiler since it + RProfiler::GetActiveWriter(buf); + + if(iGeneralAttributes.iTraceOutput.CompareF(KTraceOutput) == 0) + { + if(iState == MProfilerStatusObserver::EInitializing || + iState == MProfilerStatusObserver::ERestarting ) + { + descBuf.Zero(); + // set the additional note if available + buf.Copy(aNote); + RProfiler::GetFileName(descBuf); + buf.Append(_L("Writing to ")); + buf.Append(descBuf); + } + else if(iState == MProfilerStatusObserver::EIdle || + iState == MProfilerStatusObserver::EStopping || + iState == MProfilerStatusObserver::ERunning ) + { + descBuf.Zero(); + // set the additional note if available + buf.Copy(aNote); + RProfiler::GetFileName(descBuf); + buf.Append(_L("Wrote trace data to ")); + buf.Append(descBuf); + } + else + { + buf.Copy(KNullDesC); + } + } + else if(iGeneralAttributes.iTraceOutput.CompareF(KTraceDebugOutput) == 0) + { + if(iState == MProfilerStatusObserver::EInitializing || + iState == MProfilerStatusObserver::ERestarting ) + { + buf.Copy(_L("Writing to debug output...")); + } + else if( iState == MProfilerStatusObserver::EIdle || + iState == MProfilerStatusObserver::EStopping || + iState == MProfilerStatusObserver::ERunning ) + { + buf.Copy(_L("Wrote trace data to debug output")); + } + else + { + buf.Copy(KNullDesC); + } + } + else + { + // should not reach this point + buf.Copy(KNullDesC); + } + + return TPtrC(buf); + } + +// -------------------------------------------------------------------------------------------- + +TInt CProfilerGuiModel::EditSamplerL(TSamplerAttributes& aItem) + { + // edit sampler specific settings i.e. attributes + TSamplerAttributes& newSettings = aItem; + TInt indexToReplace(iMainContainer->CurrentListBoxItemIndex()); + + // create a new settings editor dialog + CProfilerSamplerSettingsViewDlg* dlg = CProfilerSamplerSettingsViewDlg::NewL(newSettings); + TInt returnValue = dlg->ExecuteLD(R_PROFILER_SAMPLER_SETTINGS_DIALOG); + + // save settings + aItem = newSettings; + + // replace the old attribute container with saved values + iSamplerItemList->Delete(indexToReplace); + iSamplerItemList->InsertL(indexToReplace, newSettings); + + // save the settings to sampler item + RProfiler::SetSamplerAttributes(newSettings); + + // make sure that the title of the application is correct + CEikStatusPane* sp = iEnv->AppUiFactory()->StatusPane(); + CAknTitlePane* tp = static_cast( sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) ); + tp->SetTextL(KAppName); + + return returnValue; + } + + +void CProfilerGuiModel::SamplerInfoL(TSamplerAttributes& aItem) + { + TBuf<64> header; + TBuf<256> info; + + _LIT(KSamplerStr, "Sampler Info"); + +// CnvUtfConverter::ConvertToUnicodeFromUtf8(header, aItem.iName); + + header.Append(KSamplerStr); + + CnvUtfConverter::ConvertToUnicodeFromUtf8(info, aItem.iDescription); + + CAknMessageQueryDialog* dialog = new(ELeave) CAknMessageQueryDialog; + //dialog->ExecuteLD(info); + dialog->PrepareLC( R_PROFILER_GUI_EMPTY_ABOUT_DIALOG ); + dialog->SetHeaderText(header); + dialog->SetMessageTextL(info); + dialog->RunLD(); + + RefreshViewL(EFalse); + } + +// -------------------------------------------------------------------------------------------- + +void CProfilerGuiModel::StartAllSamplerItemsL() + { + TBuf<256> activeWriterDes; + TBuf8<256> writer8; + + // try to start profiling process through client-server interface + if(RProfiler::StartSampling() == KErrNotFound) + { + // profiler stopped (e.g. from eshell) and must be restarted + LaunchProfilerEngineL(); + + // set general attributes + SaveGeneralSettingsL(); + + // set sampler attributes + for(TInt i(0);iCount();i++) + { + // set the attributes for each sampler loaded in the UI + RProfiler::SetSamplerAttributes(iSamplerAttributes->At(i)); + } + + // try to launch sampling again + RProfiler::StartSampling(); + } + + // get selected writer + RProfiler::GetActiveWriter(activeWriterDes); + CnvUtfConverter::ConvertFromUnicodeToUtf8(writer8, activeWriterDes); + + // check that output mode has not changed for a problem with trace file name + // problem cases: + // - trace file name and/or path false + // - disk full, cannot write to given location + // - false drive, e.g. x: + if(writer8.CompareF(iGeneralAttributes.iTraceOutput) != 0) + { + // save change also to general attributes + iGeneralAttributes.iTraceOutput.Copy(writer8); + // show an info popup showing the logging method + iMainContainer->ShowWriterInfoPopupL(KWarningNote); + } + else + { + // show an info popup showing the logging method + iMainContainer->ShowWriterInfoPopupL(KNullDesC); + } + + // update the view + RefreshViewL(); + } +// -------------------------------------------------------------------------------------------- + +void CProfilerGuiModel::DeleteAllSamplerItemsL() + { + DeleteAllSamplerItems(); + + RefreshViewL(); + } + + +void CProfilerGuiModel::StopAllSamplerItemsL() + { + // show an info popup showing the logging method + iMainContainer->ShowWriterInfoPopupL(KNullDesC); + + // Stop profiling process through CS session + RProfiler::StopSampling(); + + RefreshViewL(); + } + +// -------------------------------------------------------------------------------------------- + +void CProfilerGuiModel::RefreshViewL(TBool aClearSelection) + { + // refresh the main list view + if (iMainContainer && iDrawState == EDrawStateMain && iMainContainer->ListBox()) + { + // clear selections if any + iMainContainer->ListBox()->ClearSelection(); + + // set item index to 0 + if (aClearSelection) + iMainContainer->ListBox()->SetCurrentItemIndex(0); + + // set text items + iMainContainer->SetListBoxTextArrayL(GenerateListBoxItemTextArrayL()); + } + } + +// -------------------------------------------------------------------------------------------- + +void CProfilerGuiModel::AppendToSamplerItemListL(TSamplerAttributes& aItem) + { + // append single sampler item into sampler item list + if (iSamplerItemList) + iSamplerItemList->AppendL( aItem ); + else + User::Leave(KErrNotReady); + } + +// -------------------------------------------------------------------------------------------- + +void CProfilerGuiModel::DisableOrEnableFromSamplerItemListL(TInt aIndex) + { + if (iSamplerItemList) + { + if (iSamplerItemList->Count() > aIndex && aIndex >= 0) + { + TSamplerAttributes& attr = iSamplerItemList->At(aIndex); + if (attr.iEnabled) + { + attr.iEnabled = EFalse; + } + else if (!attr.iEnabled) + { + attr.iEnabled = ETrue; + } + // save settings to engine + RProfiler::SetSamplerAttributes(attr); + } + else + User::Leave(KErrNotFound); + } + else + { + User::Leave(KErrNotReady); + } + + } + +// -------------------------------------------------------------------------------------------- + +TInt CProfilerGuiModel::SamplerItemCount() const + { + TInt count(0); + + if (iSamplerItemList) + count = iSamplerItemList->Count(); + + return count; + } + +// -------------------------------------------------------------------------------------------- + +void CProfilerGuiModel::DeleteAllSamplerItems() + { + // reset sampler array + iSamplerItemList->Reset(); + } + +// -------------------------------------------------------------------------------------------- + +CDesCArray* CProfilerGuiModel::GenerateListBoxItemTextArrayL() + { + CDesCArray* textArray = new(ELeave) CDesCArrayFlat(64); + CleanupStack::PushL(textArray); + + _LIT(KEntryTemplateRedIcon, "1\t%S\t\t"); + _LIT(KEntryTemplateGreenIcon, "2\t%S\t\t"); + + TSamplerAttributes attr; + TInt itemCount(SamplerItemCount()); + for (TInt i(0); i textEntry; + TBuf<512> description; + + attr = iSamplerItemList->At(i); + + description.Copy(attr.iName); + + if (attr.iEnabled) + textEntry.Format(KEntryTemplateGreenIcon, &description); + else + textEntry.Format(KEntryTemplateRedIcon, &description); + + textArray->AppendL(textEntry); + } + + CleanupStack::Pop(); //textArray + return textArray; + } + +// -------------------------------------------------------------------------------------------- + +TBool CProfilerGuiModel::GetSelectedItemEnabled() + { + TInt currentItemIndex = iMainContainer->CurrentListBoxItemIndex(); + + if (SamplerItemCount() > currentItemIndex && currentItemIndex >= 0) + { + return iSamplerItemList->At(currentItemIndex).iEnabled; + } + return EFalse; + } + +// -------------------------------------------------------------------------------------------- + +TBool CProfilerGuiModel::GetSelectedItemHasSettings() + { + TInt currentItemIndex = iMainContainer->CurrentListBoxItemIndex(); + + if (SamplerItemCount() > currentItemIndex && currentItemIndex >= 0) + { + if(iSamplerItemList->At(currentItemIndex).iItemCount != 0 || + iSamplerItemList->At(currentItemIndex).iSampleRate != KErrNotFound) + { + return ETrue; + } + else + { + return EFalse; + } + } + return EFalse; + } + +// -------------------------------------------------------------------------------------------- + +TBool CProfilerGuiModel::GetSelectedItemHidden() + { + TInt currentItemIndex = iMainContainer->CurrentListBoxItemIndex(); + + if (SamplerItemCount() > currentItemIndex && currentItemIndex >= 0) + { + if(iSamplerItemList->At(currentItemIndex).iIsHidden) + { + return ETrue; + } + else + { + return EFalse; + } + } + return EFalse; + } + +// -------------------------------------------------------------------------------------------- + +TInt CProfilerGuiModel::EditSelectedSamplerL(TInt index) + { + TSamplerAttributes sampler; + if(SamplerItemCount() > index && index >= 0) + { + sampler = iSamplerItemList->At(index); + return EditSamplerL(sampler); + } + return KErrNone; + } + +// -------------------------------------------------------------------------------------------- + +void CProfilerGuiModel::SelectedSamplerInfoL(TInt index) + { + if(SamplerItemCount() > index && index >= 0) + { + SamplerInfoL(iSamplerItemList->At(index)); + } + } + +// -------------------------------------------------------------------------------------------- + +void CProfilerGuiModel::ShowItemActionMenuL() + { + TInt currentItemIndex = iMainContainer->CurrentListBoxItemIndex(); + + if (SamplerItemCount() > currentItemIndex && currentItemIndex >= 0) + { + // show a query dialog + TInt queryIndex(0); + CAknListQueryDialog* listQueryDlg = new(ELeave) CAknListQueryDialog(&queryIndex); + TInt resource = 0; + TSamplerAttributes sampler = iSamplerItemList->At(currentItemIndex); + + // check if sampler enabled + if(sampler.iEnabled) + { + resource = R_ITEM_ACTION_QUERY_ENABLED; + } + else + { + resource = R_ITEM_ACTION_QUERY_DISABLED; + } + + // check if sampler plugin hidden => don't allow starting and stopping of sampling + if(sampler.iIsHidden) + { + resource = R_ITEM_ACTION_QUERY_HIDDEN_START_STOP; + } + else if(( sampler.iItemCount == 0 && + sampler.iSampleRate == KErrNotFound ) && + sampler.iEnabled ) + { + resource = R_ITEM_ACTION_QUERY_HIDDEN_SETTINGS_ENABLED; + } + else if(( sampler.iItemCount == 0 && + sampler.iSampleRate == KErrNotFound ) && + !sampler.iEnabled ) + { + resource = R_ITEM_ACTION_QUERY_HIDDEN_SETTINGS_DISABLED; + } + + // execute query dialog with the given resource + if (listQueryDlg->ExecuteLD(resource)) + { + if(!sampler.iIsHidden) + { + if(sampler.iItemCount != 0 || + sampler.iSampleRate != KErrNotFound ) + { + // enable/disable sampler + if (queryIndex == EItemActionMenuTypeEnable) + { + DisableOrEnableSelectedOrHighlightedItemsL(); + } + // edit sampler settings + else if (queryIndex == EItemActionMenuTypeEditSettings - 1) + { + EditSamplerL(sampler); + } + // info + else if (queryIndex == EItemActionMenuTypeInfo - 1) + { + SamplerInfoL(sampler); + } + } + else + { + // special case, use raw query indexes + if (queryIndex == 0) + { + DisableOrEnableSelectedOrHighlightedItemsL(); + } + else if (queryIndex == 1) + { + SamplerInfoL(sampler); + } + } + } + else + { + if(sampler.iItemCount != 0 || + sampler.iSampleRate != KErrNotFound) + { + // special case, use raw query indexes + // edit sampler settings + if (queryIndex == 0) + { + EditSamplerL(sampler); + } + // sampler info + else if (queryIndex == 1) + { + SamplerInfoL(sampler); + } + } + else + { + // only sampler info available if hidden and no setting items to be set + if (queryIndex == 0) + { + SamplerInfoL(sampler); + } + + } + } + } + } + } + +void CProfilerGuiModel::DisableOrEnableSelectedOrHighlightedItemsL() + { + const CArrayFix* selectionIndexes = iMainContainer->ListBoxSelectionIndexes(); + + // by default use selected items + if (selectionIndexes && selectionIndexes->Count() > 0) + { + TInt ref(0); + TKeyArrayFix key(0, ECmpTUint16); + TInt index(0); + + for (TInt i=0; iFind(ref, key, index) == 0) + { + DisableOrEnableFromSamplerItemListL(i); + } + } + + RefreshViewL(EFalse); + } + + // or if none selected, use the current item index + else + { + TInt currentItemIndex = iMainContainer->CurrentListBoxItemIndex(); + + if (SamplerItemCount() > currentItemIndex && currentItemIndex >= 0) + { + DisableOrEnableFromSamplerItemListL(currentItemIndex); + + RefreshViewL(EFalse); + } + } + } + +void CProfilerGuiModel::LoadPluginsL() + { + // get samplers from Profiler Engine (client-server session) + // and add the to the samplers list for the first time + LOGTEXT(_L("CProfilerGuiModel::LoadPlugins - get sampler plugins")); + TInt err = RProfiler::GetSamplerAttributes(*iSamplerAttributes); + + // check if engine provided a list of samplers + if( err != KErrNone ) + { + // could not get samplers from engine + LOGTEXT(_L("CProfilerGuiModel::LoadPlugins - failed to connect engine")); + } + else + { + LOGTEXT(_L("CProfilerGuiModel::LoadPlugins - adding new samplers into view")); + AddNewSamplersL(*iSamplerAttributes); + } + + LOGTEXT(_L("CProfilerGuiModel::LoadPlugins - exit")); + } + +// -------------------------------------------------------------------------------------------- + +TInt CProfilerGuiModel::LoadGeneralSettingsL() + { + // local variable for getting saved settings from profiler engine + TGeneralAttributes generalAttr; + TInt err(KErrNone); + + // before loading saved settings (from settings file) set the default values + iGeneralAttributes.iTraceOutput.Copy(KTraceOutput); + iGeneralAttributes.iTraceFilePrefix.Copy(KProfilerDefaultPrefix); + iGeneralAttributes.iSaveFileDrive.Copy(KProfilerDefaultDrive); + + // request to + err = RProfiler::GetGeneralAttributes(generalAttr); + + // check that request succesfull + if( err != KErrNone ) + { + // could not connect profiler engine, use + return err; + } + + // check if saved settings different than the default + if(generalAttr.iTraceOutput.MatchF(iGeneralAttributes.iTraceOutput) == KErrNotFound) + { + iGeneralAttributes.iTraceOutput.Copy(generalAttr.iTraceOutput); + } + + if(generalAttr.iTraceFilePrefix.MatchF(iGeneralAttributes.iTraceFilePrefix) == KErrNotFound) + { + iGeneralAttributes.iTraceFilePrefix.Copy(generalAttr.iTraceFilePrefix); + } + + if(generalAttr.iSaveFileDrive.MatchF(iGeneralAttributes.iSaveFileDrive) == KErrNotFound) + { + iGeneralAttributes.iSaveFileDrive.Copy(generalAttr.iSaveFileDrive); + } + return err; + } + +// -------------------------------------------------------------------------------------------- + +void CProfilerGuiModel::SaveGeneralSettingsL() + { + TInt err(KErrNone); + + // save general attributes to Profiler Engine + err = RProfiler::SetGeneralAttributes(iGeneralAttributes); + + // check if save failed + if(err == KErrNotFound) + { + // profiler stopped (e.g. from eshell) and must be restarted + LaunchProfilerEngineL(); + + err = RProfiler::SetGeneralAttributes(iGeneralAttributes); + if(err != KErrNone) + { + // leave no use to continue + User::Leave(err); + } + } + } + +void CProfilerGuiModel::SetMainView(CProfilerGuiMainView* aMainView) + { + iMainView = aMainView; + } + +// -------------------------------------------------------------------------------------------- + +void CProfilerGuiModel::HandleProfilerStatusChange( KProfilerStatus aStatus ) + { + iState = aStatus; + TRAP_IGNORE(iMainView->UpdateStatusPaneL(aStatus)); + } + +void CProfilerGuiModel::HandleProfilerErrorL( TInt aError ) + { + TBuf<64> errorMsg; + _LIT(KErrorMessage, "Error: "); + _LIT(KNoMemory, "Cannot write to file, check settings"); + + errorMsg.Copy(KErrorMessage); + // message from pwr sampler + if( aError < -1000 ) + { + errorMsg.Append(_L("Stop other power measurement tools!")); + } + else if( aError == KErrAlreadyExists || aError == 11 ) + { + errorMsg.Append(_L("Close old Profiler before launching!")); + } + else if( aError == KErrNotReady ) + { + errorMsg.Append(_L("Memory card removed, failed to write!")); + } + else if( aError == KErrPathNotFound ) + { + errorMsg.Append(_L("Given trace data location does not exist")); + } + else + { + if( aError == KErrNoMemory || + aError == KErrOverflow || + aError == KErrDirFull || + aError == KErrDiskFull || + aError == KErrNotReady ) + { + errorMsg.Append(KNoMemory); + } + else + { + errorMsg.Append(_L("code: ")); + errorMsg.AppendNum(aError); + } + } + // simply show an error note + CAknErrorNote* note = new(ELeave) CAknErrorNote(); + note->ExecuteLD(errorMsg); + + // set state idle in all error cases + iState = MProfilerStatusObserver::EIdle; + + // update status pane + iMainView->UpdateStatusPaneL(iState); + + // set plugin list back to enabled + iMainContainer->SetDimmed(EFalse); + + // refresh and set menus etc. in correct state + RefreshViewL(); + } + +// End of File diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofilerui/gui/src/profiler_gui_samplersettingsviewdlg.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofilerui/gui/src/profiler_gui_samplersettingsviewdlg.cpp Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,468 @@ +/* +* 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: +* +*/ + + + +// INCLUDE FILES +#include "profiler_gui_samplersettingsviewdlg.h" +#include "profiler_gui_model.h" +#include "profiler_gui.hrh" +#include "profiler_gui_std.h" +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +// LITERALS +_LIT8(KCPUSamplerName, "gpp"); +_LIT(KEmptySettingItem, ""); + +// ===================================== MEMBER FUNCTIONS ===================================== + +CProfilerSamplerSettingsViewDlg* CProfilerSamplerSettingsViewDlg::NewL(TSamplerAttributes& aSettings) + { + CProfilerSamplerSettingsViewDlg* self = new(ELeave) CProfilerSamplerSettingsViewDlg(aSettings); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +// -------------------------------------------------------------------------------------------- + +CProfilerSamplerSettingsViewDlg::~CProfilerSamplerSettingsViewDlg() + { + // restore default navi pane + if(iNaviContainer) + iNaviContainer->Pop(); + + if (iSettingItemArray) + { + iSettingItemArray->ResetAndDestroy(); + delete iSettingItemArray; + } + + } + +// -------------------------------------------------------------------------------------------- + +CProfilerSamplerSettingsViewDlg::CProfilerSamplerSettingsViewDlg(TSamplerAttributes& aSettings) + : iSettings(aSettings) + { + } + +// -------------------------------------------------------------------------------------------- + +void CProfilerSamplerSettingsViewDlg::ConstructL() + { + // construct a menu bar + CAknDialog::ConstructL(R_PROFILER_SAMPLER_SETTINGS_MENUBAR); + + CEikStatusPane* sp = iEikonEnv->AppUiFactory()->StatusPane(); + + // set empty navi pane label + iNaviContainer = static_cast(sp->ControlL(TUid::Uid(EEikStatusPaneUidNavi))); + iNaviContainer->PushDefaultL(); + + // set title text + CAknTitlePane* tp = static_cast( sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) ); + tp->SetTextL( _L("Sampler Settings") ); + + iItemCount = iSettings.iItemCount; + + } + +// -------------------------------------------------------------------------------------------- + +void CProfilerSamplerSettingsViewDlg::HandleListBoxEventL(CEikListBox* /*aListBox*/, TListBoxEvent aEventType) + { + switch (aEventType) + { + case EEventEnterKeyPressed: + case EEventItemDoubleClicked: + ShowSettingPageL(EFalse); + break; + default: + break; + } + } + +// -------------------------------------------------------------------------------------------- + +void CProfilerSamplerSettingsViewDlg::TabChangedL(TInt /*aIndex*/) + { + iListBox->SetCurrentItemIndex(0); + + SetVisibilitiesOfSettingItemsL(); + } + +// -------------------------------------------------------------------------------------------- + +void CProfilerSamplerSettingsViewDlg::ProcessCommandL(TInt aCommandId) + { + CAknDialog::ProcessCommandL(aCommandId); + + switch (aCommandId) + { + case EProfilerGuiCmdSettingsChange: + ShowSettingPageL(ETrue); + break; + case EProfilerGuiCmdSettingsExit: + TryExitL(EAknCmdExit); + break; + default: + break; + } + } + +// -------------------------------------------------------------------------------------------- + +TKeyResponse CProfilerSamplerSettingsViewDlg::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType) + { + + return CAknDialog::OfferKeyEventL(aKeyEvent, aType); + } + +// -------------------------------------------------------------------------------------------- + +void CProfilerSamplerSettingsViewDlg::PreLayoutDynInitL() + { + iListBox = static_cast( Control(EProfilerSamplerSettingItemList) ); + iListBox->SetMopParent(this); + iListBox->CreateScrollBarFrameL(ETrue); + iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto); + iListBox->SetListBoxObserver(this); + + iSettingItemArray = new(ELeave) CAknSettingItemArray(16, EFalse, 0); + + CTextListBoxModel* model = iListBox->Model(); + model->SetItemTextArray(iSettingItemArray); + model->SetOwnershipType(ELbmDoesNotOwnItemArray); + + UpdateListBoxL(); + } + +// -------------------------------------------------------------------------------------------- + +TBool CProfilerSamplerSettingsViewDlg::OkToExitL(TInt aButtonId) + { + // save all settings when exiting, only numeric values are needed to saved since copied from TBuf + for(TInt i(1);iAt(i)->IsHidden() == EFalse) + { + switch(i) + { + case 1: + { + // check if settings value type integer + if(iSettings.iSettingItem1.iType == TSettingItem::ESettingItemTypeInt) + { + iSettings.iSettingItem1.iValue.Num(iItemBuf[i]); + } + break; + } + case 2: + { + // check if settings value type integer + if(iSettings.iSettingItem2.iType == TSettingItem::ESettingItemTypeInt) + { + iSettings.iSettingItem2.iValue.Num(iItemBuf[i]); + } + break; + } + case 3: + { + // check if settings value type integer + if(iSettings.iSettingItem3.iType == TSettingItem::ESettingItemTypeInt) + { + iSettings.iSettingItem3.iValue.Num(iItemBuf[i]); + } + break; + } + case 4: + { + // check if settings value type integer + if(iSettings.iSettingItem4.iType == TSettingItem::ESettingItemTypeInt) + { + iSettings.iSettingItem4.iValue.Num(iItemBuf[i]); + } + + break; + } + case 5: + { + // check if settings value type integer + if(iSettings.iSettingItem5.iType == TSettingItem::ESettingItemTypeInt) + { + iSettings.iSettingItem5.iValue.Num(iItemBuf[i]); + } + + break; + } + case 6: + { + // check if settings value type integer + if(iSettings.iSettingItem6.iType == TSettingItem::ESettingItemTypeInt) + { + iSettings.iSettingItem6.iValue.Num(iItemBuf[i]); + } + + break; + } + } + } + } + return CAknDialog::OkToExitL(aButtonId); + } + +// -------------------------------------------------------------------------------------------- + +void CProfilerSamplerSettingsViewDlg::ShowSettingPageL(TInt aCalledFromMenu) + { + TInt listIndex = iListBox->CurrentItemIndex(); + TInt realIndex = iSettingItemArray->ItemIndexFromVisibleIndex(listIndex); + CAknSettingItem* item = iSettingItemArray->At(realIndex); + item->EditItemL(aCalledFromMenu); + item->StoreL(); + SetVisibilitiesOfSettingItemsL(); + DrawNow(); + } + +// -------------------------------------------------------------------------------------------- + +void CProfilerSamplerSettingsViewDlg::SetVisibilitiesOfSettingItemsL() + { + if (iSettingItemArray->Count() > 0) + { + if(iSettings.iSampleRate > 0) + { + ((*iSettingItemArray)[EProfilerGuiGenericSamplerQuerySampleRate])->SetHidden(EFalse); + } + else + { + ((*iSettingItemArray)[EProfilerGuiGenericSamplerQuerySampleRate])->SetHidden(ETrue); + } + if(iItemCount>0) + ((*iSettingItemArray)[EProfilerGuiGenericSamplerQueryItem1])->SetHidden(EFalse); + if(iItemCount>1) + ((*iSettingItemArray)[EProfilerGuiGenericSamplerQueryItem2])->SetHidden(EFalse); + if(iItemCount>2) + ((*iSettingItemArray)[EProfilerGuiGenericSamplerQueryItem3])->SetHidden(EFalse); + if(iItemCount>3) + ((*iSettingItemArray)[EProfilerGuiGenericSamplerQueryItem4])->SetHidden(EFalse); + if(iItemCount>4) + ((*iSettingItemArray)[EProfilerGuiGenericSamplerQueryItem5])->SetHidden(EFalse); + if(iItemCount>5) + ((*iSettingItemArray)[EProfilerGuiGenericSamplerQueryItem6])->SetHidden(EFalse); + + iSettingItemArray->RecalculateVisibleIndicesL(); + iListBox->HandleItemAdditionL(); + iListBox->UpdateScrollBarsL(); + } + } + +// -------------------------------------------------------------------------------------------- + +void CProfilerSamplerSettingsViewDlg::UpdateListBoxL() + { + iSettingItemArray->ResetAndDestroy(); + + // create items + TInt ordinal(0); + + AddSettingItemL(EProfilerGuiGenericSamplerQuerySampleRate, + R_SAMPLE_RATE_SETTING_TITLE, + R_SAMPLER_RATE_SETTING_PAGE, + NULL, + ordinal++); + + if(iItemCount>0) + AddSettingItemL(EProfilerGuiGenericSamplerQueryItem1, + R_ITEM1_SETTING_TITLE, + NULL, + NULL, + ordinal++); + if(iItemCount>1) + AddSettingItemL(EProfilerGuiGenericSamplerQueryItem2, + R_ITEM2_SETTING_TITLE, + NULL, + NULL, + ordinal++); + if(iItemCount>2) + AddSettingItemL(EProfilerGuiGenericSamplerQueryItem3, + R_ITEM3_SETTING_TITLE, + NULL, + NULL, + ordinal++); + if(iItemCount>3) + AddSettingItemL(EProfilerGuiGenericSamplerQueryItem4, + R_ITEM4_SETTING_TITLE, + NULL, + NULL, + ordinal++); + if(iItemCount>4) + AddSettingItemL(EProfilerGuiGenericSamplerQueryItem5, + R_ITEM5_SETTING_TITLE, + NULL, + NULL, + ordinal++); + if(iItemCount>5) + AddSettingItemL(EProfilerGuiGenericSamplerQueryItem6, + R_ITEM6_SETTING_TITLE, + NULL, + NULL, + ordinal++); + + SetVisibilitiesOfSettingItemsL(); + } + +// -------------------------------------------------------------------------------------------- + +CAknSettingItem* CProfilerSamplerSettingsViewDlg::GetSettingItemL(TSettingItem& aItem, TInt aIndex, TInt& aSettingPageResource) + { + CAknSettingItem* settingItem = NULL; + + // set default setting page dialog style resource + aSettingPageResource = R_GENERIC_TEXT_SETTING_PAGE; + + // check if setting item type integer + if(aItem.iType == TSettingItem::ESettingItemTypeInt) + { + TLex* lex = new TLex(aItem.iValue); + // check if value valid + if(lex->Val(iItemBuf[aIndex]) != KErrNone) + { + // if value not valid set to 0 + iItemBuf[aIndex] = 0; + } + settingItem = new(ELeave) CAknIntegerEdwinSettingItem(aIndex, iItemBuf[aIndex]); + aSettingPageResource = R_NUMERIC_SETTING_PAGE; + delete lex; + return settingItem; + } + else // else manipulate as a text setting + { + settingItem = new(ELeave) CAknTextSettingItem(aIndex, aItem.iValue); + settingItem->SetEmptyItemTextL(KEmptySettingItem); + return settingItem; + } + } + +// -------------------------------------------------------------------------------------------- + +void CProfilerSamplerSettingsViewDlg::AddSettingItemL(TInt aId, + TInt aTitleResource, + TInt aSettingPageResource, + TInt aAssociatedResource, + TInt aOrdinal) + { + // create a setting item + CAknSettingItem* settingItem = NULL; + + TBuf ptr; + switch(aId) + { + case EProfilerGuiGenericSamplerQuerySampleRate: + { + settingItem = new (ELeave) CAknIntegerEdwinSettingItem(aId, iSettings.iSampleRate); + break; + } + case EProfilerGuiGenericSamplerQueryItem1: + { + ptr.Copy(iSettings.iSettingItem1.iUIText); + settingItem = GetSettingItemL(iSettings.iSettingItem1, aId, aSettingPageResource); + break; + } + case EProfilerGuiGenericSamplerQueryItem2: + { + ptr.Copy(iSettings.iSettingItem2.iUIText); + settingItem = GetSettingItemL(iSettings.iSettingItem2, aId, aSettingPageResource); + break; + } + case EProfilerGuiGenericSamplerQueryItem3: + { + ptr.Copy(iSettings.iSettingItem3.iUIText); + settingItem = GetSettingItemL(iSettings.iSettingItem3, aId, aSettingPageResource); + break; + } + case EProfilerGuiGenericSamplerQueryItem4: + { + ptr.Copy(iSettings.iSettingItem4.iUIText); + settingItem = GetSettingItemL(iSettings.iSettingItem4, aId, aSettingPageResource); + break; + } + case EProfilerGuiGenericSamplerQueryItem5: + { + ptr.Copy(iSettings.iSettingItem5.iUIText); + settingItem = GetSettingItemL(iSettings.iSettingItem5, aId, aSettingPageResource); + break; + } + case EProfilerGuiGenericSamplerQueryItem6: + { + ptr.Copy(iSettings.iSettingItem6.iUIText); + settingItem = GetSettingItemL(iSettings.iSettingItem6, aId, aSettingPageResource); + break; + } + } + + CleanupStack::PushL(settingItem); + + // get title text + HBufC* itemTitle; + + if( ptr.Compare(KNullDesC) == 0 ) + { + itemTitle = StringLoader::LoadLC(aTitleResource); + + // special case: check if CPU sampler + if(iSettings.iShortName.CompareF(KCPUSamplerName) == 0) + { + // change setting page using different value range, since > 10000 ms rates are too big + aSettingPageResource = R_CPU_SAMPLER_RATE_SETTING_PAGE; + } + + // construct the setting item + settingItem->ConstructL(EFalse, aOrdinal, *itemTitle, NULL, aSettingPageResource, + EAknCtPopupSettingList, NULL, aAssociatedResource); + // append the setting item to settingitem array + iSettingItemArray->InsertL(aOrdinal, settingItem); + + CleanupStack::PopAndDestroy(); //itemTitle + } + else + { + // construct the setting item + settingItem->ConstructL(EFalse, aOrdinal, ptr, NULL, aSettingPageResource, + EAknCtPopupSettingList, NULL, aAssociatedResource); + + // append the setting item to settingitem array + iSettingItemArray->InsertL(aOrdinal, settingItem); + } + + CleanupStack::Pop(); //settingItem + } + +// -------------------------------------------------------------------------------------------- +// End of File + diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofilerui/gui/src/profiler_gui_settingsviewdlg.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofilerui/gui/src/profiler_gui_settingsviewdlg.cpp Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,373 @@ +/* +* 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: +* +*/ + + + +// INCLUDE FILES +#include "profiler_gui_settingsviewdlg.h" +#include "profiler_gui_model.h" +#include "profiler_gui.hrh" +#include "profiler_gui_std.h" +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +// LITERALS +_LIT8(KDebugOutput, "debug_output"); +_LIT8(KFileSystem, "file_system"); +_LIT(KEmptySettingItem, ""); + +// ===================================== MEMBER FUNCTIONS ===================================== + +CProfilerGuiSettingsViewDlg* CProfilerGuiSettingsViewDlg::NewL(TGeneralAttributes& aSettings) + { + CProfilerGuiSettingsViewDlg* self = new(ELeave) CProfilerGuiSettingsViewDlg(aSettings); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +// -------------------------------------------------------------------------------------------- + +CProfilerGuiSettingsViewDlg::~CProfilerGuiSettingsViewDlg() + { + // restore default navi pane + if(iNaviContainer) + iNaviContainer->Pop(); + + if (iSettingItemArray) + { + iSettingItemArray->ResetAndDestroy(); + delete iSettingItemArray; + } + + } + +// -------------------------------------------------------------------------------------------- + +CProfilerGuiSettingsViewDlg::CProfilerGuiSettingsViewDlg(TGeneralAttributes& aSettings) : iSettings(aSettings) + { + } + +// -------------------------------------------------------------------------------------------- + +void CProfilerGuiSettingsViewDlg::ConstructL() + { + // construct a menu bar + CAknDialog::ConstructL(R_PROFILER_GUI_SETTINGS_MENUBAR); + + CEikStatusPane* sp = iEikonEnv->AppUiFactory()->StatusPane(); + + // set empty navi pane label + iNaviContainer = static_cast(sp->ControlL(TUid::Uid(EEikStatusPaneUidNavi))); + iNaviContainer->PushDefaultL(); + + // set title text + CAknTitlePane* tp = static_cast( sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) ); + tp->SetTextL( _L("Settings") ); + + } + +// -------------------------------------------------------------------------------------------- + +void CProfilerGuiSettingsViewDlg::HandleListBoxEventL(CEikListBox* /*aListBox*/, TListBoxEvent aEventType) + { + switch (aEventType) + { + case EEventEnterKeyPressed: + case EEventItemDoubleClicked: + ShowSettingPageL(EFalse); + break; + default: + break; + } + } + +// -------------------------------------------------------------------------------------------- + +void CProfilerGuiSettingsViewDlg::TabChangedL(TInt /*aIndex*/) + { + iListBox->SetCurrentItemIndex(0); + + SetVisibilitiesOfSettingItemsL(); + } + +// -------------------------------------------------------------------------------------------- + +void CProfilerGuiSettingsViewDlg::ProcessCommandL(TInt aCommandId) + { + CAknDialog::ProcessCommandL(aCommandId); + + switch (aCommandId) + { + case EProfilerGuiCmdSettingsChange: + ShowSettingPageL(ETrue); + break; + case EProfilerGuiCmdSettingsExit: + TryExitL(EAknCmdExit); + break; + default: + break; + } + } + +// -------------------------------------------------------------------------------------------- + +TKeyResponse CProfilerGuiSettingsViewDlg::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType) + { + /* + if (iTabGroup == NULL) + { + return EKeyWasNotConsumed; + } + */ +/* + TInt active = iTabGroup->ActiveTabIndex(); + TInt count = iTabGroup->TabCount(); + + switch ( aKeyEvent.iCode ) + { + case EKeyLeftArrow: + if (active > 0) + { + active--; + iTabGroup->SetActiveTabByIndex(active); + TabChangedL(active); + } + break; + + case EKeyRightArrow: + if((active + 1) < count) + { + active++; + iTabGroup->SetActiveTabByIndex(active); + TabChangedL(active); + } + break; + } +*/ + return CAknDialog::OfferKeyEventL(aKeyEvent, aType); + } + +// -------------------------------------------------------------------------------------------- + +void CProfilerGuiSettingsViewDlg::PreLayoutDynInitL() + { + iListBox = static_cast( Control(EProfilerGuiSettingItemList) ); + iListBox->SetMopParent(this); + iListBox->CreateScrollBarFrameL(ETrue); + iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto); + iListBox->SetListBoxObserver(this); + + iSettingItemArray = new(ELeave) CAknSettingItemArray(16, EFalse, 0); + + CTextListBoxModel* model = iListBox->Model(); + model->SetItemTextArray(iSettingItemArray); + model->SetOwnershipType(ELbmDoesNotOwnItemArray); + + UpdateListBoxL(); + } + +// -------------------------------------------------------------------------------------------- + +TBool CProfilerGuiSettingsViewDlg::OkToExitL(TInt aButtonId) + { + // save settings to iSettings before exiting + + // check if trace output target changed + if(iTraceOutput == EOutputToDebugPort) + { + iSettings.iTraceOutput.Copy(KDebugOutput); + } + else + { + iSettings.iTraceOutput.Copy(KFileSystem); + } + + // save trace file prefix + if(iFilePrefix.CompareF(KNullDesC) != 0) + { + CnvUtfConverter::ConvertFromUnicodeToUtf8(iSettings.iTraceFilePrefix, iFilePrefix); + } + + // save the drive + if(iSaveDrive.CompareF(KNullDesC) != 0) + { + CnvUtfConverter::ConvertFromUnicodeToUtf8(iSettings.iSaveFileDrive, iSaveDrive); + } + + return CAknDialog::OkToExitL(aButtonId); + } + + + +// -------------------------------------------------------------------------------------------- + +void CProfilerGuiSettingsViewDlg::ShowSettingPageL(TInt aCalledFromMenu) + { + TInt listIndex = iListBox->CurrentItemIndex(); + TInt realIndex = iSettingItemArray->ItemIndexFromVisibleIndex(listIndex); + CAknSettingItem* item = iSettingItemArray->At(realIndex); + item->EditItemL(aCalledFromMenu); + item->StoreL(); + SetVisibilitiesOfSettingItemsL(); + DrawNow(); + } + +// -------------------------------------------------------------------------------------------- + +void CProfilerGuiSettingsViewDlg::SetVisibilitiesOfSettingItemsL() + { + + // check if setting item array contains more than 0 items + if (iSettingItemArray->Count() > 0) + { +// ((*iSettingItemArray)[ESettingListItemPluginNameMode])->SetHidden(ETrue); + ((*iSettingItemArray)[ESettingListItemPluginTraceOutput])->SetHidden(EFalse); + if(iTraceOutput == EOutputToDebugPort) + { + ((*iSettingItemArray)[ESettingListItemPluginSaveFileDrive])->SetHidden(ETrue); + ((*iSettingItemArray)[ESettingListItemPluginTraceFilePrefix])->SetHidden(ETrue); + } + else + { + ((*iSettingItemArray)[ESettingListItemPluginSaveFileDrive])->SetHidden(EFalse); + ((*iSettingItemArray)[ESettingListItemPluginTraceFilePrefix])->SetHidden(EFalse); + } +// ((*iSettingItemArray)[ESettingListItemPluginTraceMode])->SetHidden(ETrue); + + iSettingItemArray->RecalculateVisibleIndicesL(); + iListBox->HandleItemAdditionL(); + iListBox->UpdateScrollBarsL(); + } + } + +// -------------------------------------------------------------------------------------------- + +void CProfilerGuiSettingsViewDlg::UpdateListBoxL() + { + iSettingItemArray->ResetAndDestroy(); + + // create items + TInt ordinal(0); + +// AddSettingItemL(ESettingListItemPluginNameMode, +// R_PLUGIN_NAME_MODE_SETTING_TITLE, +// R_PLUGIN_NAME_MODE_SETTING_PAGE, +// R_PLUGIN_NAME_MODE_SETTING_TEXTS, +// ordinal++); + + AddSettingItemL(ESettingListItemPluginTraceOutput, + R_TRACE_OUTPUT_SETTING_TITLE, + R_TRACE_OUTPUT_SETTING_PAGE, + R_TRACE_OUTPUT_SETTING_TEXTS, + ordinal++); + + AddSettingItemL(ESettingListItemPluginSaveFileDrive, + R_SAVE_FILE_DRIVE_SETTING_TITLE, + R_SAVE_FILE_DRIVE_SETTING_PAGE, + NULL, //R_SAVE_FILE_DRIVE_SETTING_TEXTS, + ordinal++); + + AddSettingItemL(ESettingListItemPluginTraceFilePrefix, + R_SAVE_FILE_PREFIX_SETTING_TITLE, + R_SAVE_FILE_PREFIX_SETTING_PAGE, + NULL, + ordinal++); + +// AddSettingItemL(ESettingListItemPluginTraceMode, +// R_TRACE_MODE_SETTING_TITLE, +// R_TRACE_MODE_SETTING_PAGE, +// R_TRACE_MODE_SETTING_TEXTS, +// ordinal++); + + SetVisibilitiesOfSettingItemsL(); + } + +// -------------------------------------------------------------------------------------------- + +void CProfilerGuiSettingsViewDlg::AddSettingItemL(TInt aId, + TInt aTitleResource, + TInt aSettingPageResource, + TInt aAssociatedResource, + TInt aOrdinal) + { + // create a setting item + CAknSettingItem* settingItem = NULL; + + switch (aId) + { + + case ESettingListItemPluginSaveFileDrive: + { + CnvUtfConverter::ConvertToUnicodeFromUtf8(iSaveDrive, iSettings.iSaveFileDrive); + settingItem = new(ELeave) CAknTextSettingItem(aId, iSaveDrive); + settingItem->SetEmptyItemTextL(KEmptySettingItem); + break; + } + case ESettingListItemPluginTraceOutput: + if(iSettings.iTraceOutput.MatchF(KDebugOutput) != KErrNotFound) + { + iTraceOutput = EOutputToDebugPort; + } + else + { + iTraceOutput = EOutputToFileSystem; + } + settingItem = new(ELeave) CAknEnumeratedTextPopupSettingItem(aId, iTraceOutput); + + break; + + case ESettingListItemPluginTraceFilePrefix: + { + CnvUtfConverter::ConvertToUnicodeFromUtf8(iFilePrefix, iSettings.iTraceFilePrefix); + settingItem = new(ELeave) CAknTextSettingItem(aId, iFilePrefix); + settingItem->SetEmptyItemTextL(KEmptySettingItem); + break; + } + default: + User::Panic(_L("NotSetItem"), 50); + break; + + } + + CleanupStack::PushL(settingItem); + + // get title text + HBufC* itemTitle = StringLoader::LoadLC(aTitleResource); + + // construct the setting item + settingItem->ConstructL(EFalse, aOrdinal, *itemTitle, NULL, aSettingPageResource, + EAknCtPopupSettingList, NULL, aAssociatedResource); + + // append the setting item to settingitem array + iSettingItemArray->InsertL(aOrdinal, settingItem); + + CleanupStack::PopAndDestroy(); //itemTitle + CleanupStack::Pop(); //settingItem + } + +// End of File + diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofilerui/rom/piprofilerui.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofilerui/rom/piprofilerui.iby Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,36 @@ +/* +* 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 __PROFILERGUI_IBY__ +#define __PROFILERGUI_IBY__ + +S60_APP_EXE(PIProfilerUI) +S60_APP_AIF_ICONS(PIProfilerUI) +S60_APP_RESOURCE(PIProfilerUI) +SCALABLE_IMAGE(APP_BITMAP_DIR, APP_BITMAP_DIR, PIProfilerui_ExtraIcons) +#ifdef S60_UPGRADABLE_APP_REG_RSC + S60_UPGRADABLE_APP_REG_RSC(PIProfilerUI) +#else + S60_APP_AIF_RSC(PIProfilerUI) +#endif + +data=ZPRIVATE\2001E5AE\backup_registration.xml private\2001E5AE\backup_registration.xml +data=ZSYSTEM\Install\PIProfilerUI_stub.sis system\install\PIProfilerUI_stub.sis + +#endif // __PROFILERGUI_IBY__ diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofilerui/sis/PIProfilerUI_S60-30.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofilerui/sis/PIProfilerUI_S60-30.pkg Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,37 @@ +; +; 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: +; +&EN + +; Standard SIS file header +#{"PIProfilerUI"},(0x2001E5AE),2,0,0,TYPE=SA + +; Supports S60 v 3.0 +[0x101F7961], 0, 0, 0, {"S60ProductID"} + +; Non-localised vendor name +:"Nokia Corporation" + +; Localised vendor names +%{"Nokia Corporation"} + +; normal stuff: +"\epoc32\RELEASE\armv5\urel\PIProfilerUI.exe"-"!:\sys\bin\PIProfilerUI.exe" +"\epoc32\data\z\Resource\apps\piprofilerui_aif.mif"-"!:\Resource\Apps\piprofilerui_aif.mif" +"\epoc32\data\z\Resource\apps\piprofilerui_ExtraIcons.mif"-"!:\Resource\Apps\piprofilerui_ExtraIcons.mif" +"\epoc32\data\z\Resource\apps\piprofilerui.rsc"-"!:\Resource\Apps\piprofilerui.rsc" +"\epoc32\data\z\PRIVATE\10003A3F\APPS\piprofilerui_reg.rsc"-"!:\private\10003a3f\import\apps\piprofilerui_reg.rsc" +"..\gui\group\backup_registration.xml"-"!:\private\2001E5AE\backup_registration.xml" + diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofilerui/sis/PIProfilerUI_S60-30_PU.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofilerui/sis/PIProfilerUI_S60-30_PU.pkg Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,37 @@ +; +; 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: +; +&EN + +; Standard SIS file header +#{"PIProfilerUI"},(0x2001E5AE),2,0,1,TYPE=PU + +; Supports S60 v 3.0 +[0x101F7961], 0, 0, 0, {"S60ProductID"} + +; Non-localised vendor name +:"Nokia Corporation" + +; Localised vendor names +%{"Nokia Corporation"} + +; normal stuff: +"\epoc32\RELEASE\armv5\urel\PIProfilerUI.exe"-"!:\sys\bin\PIProfilerUI.exe" +"\epoc32\data\z\Resource\apps\piprofilerui_aif.mif"-"!:\Resource\Apps\piprofilerui_aif.mif" +"\epoc32\data\z\Resource\apps\piprofilerui_ExtraIcons.mif"-"!:\Resource\Apps\piprofilerui_ExtraIcons.mif" +"\epoc32\data\z\Resource\apps\piprofilerui.rsc"-"!:\Resource\Apps\piprofilerui.rsc" +"\epoc32\data\z\PRIVATE\10003A3F\APPS\piprofilerui_reg.rsc"-"!:\private\10003a3f\import\apps\piprofilerui_reg.rsc" +"..\gui\group\backup_registration.xml"-"!:\private\2001E5AE\backup_registration.xml" + diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofilerui/sis/PIProfilerUI_stub.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofilerui/sis/PIProfilerUI_stub.pkg Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,33 @@ +; +; 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: +; +&EN + +; Standard SIS file header +#{"ProfilerGUI"},(0x2001E5AE),1,0,0 + +; Non-localised vendor name +:"Nokia Corporation" + +; Localised vendor names +%{"Nokia Corporation"} + +; normal stuff: +""-"!:\sys\bin\PIProfilerUI.exe" +""-"!:\Resource\Apps\piprofilerui_aif.mif" +""-"!:\Resource\Apps\piprofilerui_ExtraIcons.mif" +""-"!:\Resource\Apps\piprofilerui.rsc" +""-"!:\private\10003a3f\import\apps\piprofilerui_reg.rsc" +""-"!:\private\2001E5AE\backup_registration.xml" diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofilerui/sis/make_sisx.bat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofilerui/sis/make_sisx.bat Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,25 @@ +rem +rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +rem All rights reserved. +rem This component and the accompanying materials are made available +rem under the terms of "Eclipse Public License v1.0" +rem which accompanies this distribution, and is available +rem at the URL "http://www.eclipse.org/legal/epl-v10.html". +rem +rem Initial Contributors: +rem Nokia Corporation - initial contribution. +rem +rem Contributors: +rem +rem Description: +rem + +@echo off + +echo Making SISX installation packages for ProfilerGui +echo NOTE! There is a different batch script for building PU SISXs! + +call makesis -v PIProfilerUI_S60-30.pkg +call signsis -v -s PIProfilerUI_S60-30.sis PIProfilerUI_S60-30.sisx ..\..\..\cert\RDTest_02.der ..\..\..\cert\RDTest_02.key + +dir .\ diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/piprofilerui/sis/make_sisx_update.bat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/piprofilerui/sis/make_sisx_update.bat Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,25 @@ +rem +rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +rem All rights reserved. +rem This component and the accompanying materials are made available +rem under the terms of "Eclipse Public License v1.0" +rem which accompanies this distribution, and is available +rem at the URL "http://www.eclipse.org/legal/epl-v10.html". +rem +rem Initial Contributors: +rem Nokia Corporation - initial contribution. +rem +rem Contributors: +rem +rem Description: +rem + +@echo off + +echo Making SISX installation packages for ProfilerGui +echo NOTE! There is a different batch script for building PU SISXs! + +call makesis -v PIProfilerUI_S60-30_PU.pkg +call signsis -v -s PIProfilerUI_S60-30_PU.sis PIProfilerUI_S60-30.sisx ..\..\..\cert\RDTest_02.der ..\..\..\cert\RDTest_02.key + +dir .\ diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/sis/PIProfilerUI_S60-30.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/sis/PIProfilerUI_S60-30.pkg Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,37 @@ +; +; 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: +; +&EN + +; Standard SIS file header +#{"PIProfilerUI"},(0x2001E5AE),2,0,0,TYPE=SA + +; Supports S60 v 3.0 +[0x101F7961], 0, 0, 0, {"S60ProductID"} + +; Non-localised vendor name +:"Nokia Corporation" + +; Localised vendor names +%{"Nokia Corporation"} + +; normal stuff: +"\epoc32\RELEASE\armv5\urel\PIProfilerUI.exe"-"!:\sys\bin\PIProfilerUI.exe" +"\epoc32\data\z\Resource\apps\piprofilerui_aif.mif"-"!:\Resource\Apps\piprofilerui_aif.mif" +"\epoc32\data\z\Resource\apps\piprofilerui_ExtraIcons.mif"-"!:\Resource\Apps\piprofilerui_ExtraIcons.mif" +"\epoc32\data\z\Resource\apps\piprofilerui.rsc"-"!:\Resource\Apps\piprofilerui.rsc" +"\epoc32\data\z\PRIVATE\10003A3F\APPS\piprofilerui_reg.rsc"-"!:\private\10003a3f\import\apps\piprofilerui_reg.rsc" +"..\piprofilerui\gui\group\backup_registration.xml"-"!:\private\2001E5AE\backup_registration.xml" + diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/sis/PIProfilerUI_S60-31.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/sis/PIProfilerUI_S60-31.pkg Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,37 @@ +; +; 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: +; +&EN + +; Standard SIS file header +#{"PIProfilerUI"},(0x2001E5AE),2,0,0,TYPE=SA + +; Supports S60 v 3.0 +[0x102032BE], 0, 0, 0, {"S60ProductID"} + +; Non-localised vendor name +:"Nokia Corporation" + +; Localised vendor names +%{"Nokia Corporation"} + +; normal stuff: +"\epoc32\RELEASE\armv5\urel\PIProfilerUI.exe"-"!:\sys\bin\PIProfilerUI.exe" +"\epoc32\data\z\Resource\apps\piprofilerui_aif.mif"-"!:\Resource\Apps\piprofilerui_aif.mif" +"\epoc32\data\z\Resource\apps\piprofilerui_ExtraIcons.mif"-"!:\Resource\Apps\piprofilerui_ExtraIcons.mif" +"\epoc32\data\z\Resource\apps\piprofilerui.rsc"-"!:\Resource\Apps\piprofilerui.rsc" +"\epoc32\data\z\PRIVATE\10003A3F\APPS\piprofilerui_reg.rsc"-"!:\private\10003a3f\import\apps\piprofilerui_reg.rsc" +"..\piprofilerui\gui\group\backup_registration.xml"-"!:\private\2001E5AE\backup_registration.xml" + diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/sis/PIProfilerUI_S60-32.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/sis/PIProfilerUI_S60-32.pkg Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,37 @@ +; +; 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: +; +&EN + +; Standard SIS file header +#{"PIProfilerUI"},(0x2001E5AE),2,0,0,TYPE=SA + +; Supports S60 v 3.0 +[0x102752AE], 0, 0, 0, {"S60ProductID"} + +; Non-localised vendor name +:"Nokia Corporation" + +; Localised vendor names +%{"Nokia Corporation"} + +; normal stuff: +"\epoc32\RELEASE\armv5\urel\PIProfilerUI.exe"-"!:\sys\bin\PIProfilerUI.exe" +"\epoc32\data\z\Resource\apps\piprofilerui_aif.mif"-"!:\Resource\Apps\piprofilerui_aif.mif" +"\epoc32\data\z\Resource\apps\piprofilerui_ExtraIcons.mif"-"!:\Resource\Apps\piprofilerui_ExtraIcons.mif" +"\epoc32\data\z\Resource\apps\piprofilerui.rsc"-"!:\Resource\Apps\piprofilerui.rsc" +"\epoc32\data\z\PRIVATE\10003A3F\APPS\piprofilerui_reg.rsc"-"!:\private\10003a3f\import\apps\piprofilerui_reg.rsc" +"..\piprofilerui\gui\group\backup_registration.xml"-"!:\private\2001E5AE\backup_registration.xml" + diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/sis/PIProfilerUI_S60-50.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/sis/PIProfilerUI_S60-50.pkg Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,37 @@ +; +; 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: +; +&EN + +; Standard SIS file header +#{"PIProfilerUI"},(0x2001E5AE),2,0,0,TYPE=SA + +; Supports S60 v 3.0 +[0x1028315F], 0, 0, 0, {"S60ProductID"} + +; Non-localised vendor name +:"Nokia Corporation" + +; Localised vendor names +%{"Nokia Corporation"} + +; normal stuff: +"\epoc32\RELEASE\armv5\urel\PIProfilerUI.exe"-"!:\sys\bin\PIProfilerUI.exe" +"\epoc32\data\z\Resource\apps\piprofilerui_aif.mif"-"!:\Resource\Apps\piprofilerui_aif.mif" +"\epoc32\data\z\Resource\apps\piprofilerui_ExtraIcons.mif"-"!:\Resource\Apps\piprofilerui_ExtraIcons.mif" +"\epoc32\data\z\Resource\apps\piprofilerui.rsc"-"!:\Resource\Apps\piprofilerui.rsc" +"\epoc32\data\z\PRIVATE\10003A3F\APPS\piprofilerui_reg.rsc"-"!:\private\10003a3f\import\apps\piprofilerui_reg.rsc" +"..\piprofilerui\gui\group\backup_registration.xml"-"!:\private\2001E5AE\backup_registration.xml" + diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/sis/PIProfiler_S60-30.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/sis/PIProfiler_S60-30.pkg Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,47 @@ +; +; 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: +; +;Languages +&EN + +;Header +#{"PIProfiler"}, (0x2001E5AD), 2,00,0,TYPE=SA + +; Supports S60 v 3.0 +[0x101F7961], 0, 0, 0, {"S60ProductID"} + +; Non-localised vendor name +:"Nokia Corporation" + +; Localised vendor names +%{"Nokia Corporation"} + +; engine +"\epoc32\release\armv5\urel\PIProfilerEngine.exe" -"!:\sys\bin\PIProfilerEngine.exe" +"\epoc32\release\armv5\urel\PIProfiler.exe" -"!:\sys\bin\PIProfiler.exe" + +; basic sampler plugins +"\epoc32\release\armv5\urel\PIProfilerGenerals.dll" -"!:\sys\bin\PIProfilerGenerals.dll" +"\epoc32\data\Z\Resource\plugins\PIProfilerGenerals.rsc" - "!:\Resource\Plugins\PIProfilerGenerals.RSC" +"\epoc32\release\armv5\urel\PIProfilerGeneralsSampler.ldd" -"!:\sys\bin\PIProfilerGeneralsSampler.ldd" +"\epoc32\release\armv5\urel\PIProfilerBUP.dll" -"!:\sys\bin\PIProfilerBUP.dll" +"\epoc32\data\Z\Resource\plugins\PIProfilerBUP.rsc" - "!:\Resource\Plugins\PIProfilerBUP.RSC" +"\epoc32\RELEASE\armv5\urel\PIProfilerTouchEventAnim.dll"-"!:\sys\bin\PIProfilerTouchEventAnim.dll" + +; writer plugins +"\epoc32\release\armv5\urel\piprofilerdebugwriter.dll" -"!:\sys\bin\piprofilerdebugwriter.dll" +"\epoc32\data\Z\Resource\plugins\piprofilerdebugwriter.rsc" - "!:\Resource\Plugins\piprofilerdebugwriter.rsc" +"\epoc32\release\armv5\urel\piprofilerdiskwriter.dll" -"!:\sys\bin\piprofilerdiskwriter.dll" +"\epoc32\data\Z\Resource\plugins\piprofilerdiskwriter.rsc" - "!:\Resource\Plugins\piprofilerdiskwriter.rsc" diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/sis/PIProfiler_S60-31.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/sis/PIProfiler_S60-31.pkg Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,47 @@ +; +; 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: +; +;Languages +&EN + +;Header +#{"PIProfiler"}, (0x2001E5AD), 2,00,0,TYPE=SA + +; Supports S60 v 3.0 +[0x102032BE], 0, 0, 0, {"S60ProductID"} + +; Non-localised vendor name +:"Nokia Corporation" + +; Localised vendor names +%{"Nokia Corporation"} + +; engine +"\epoc32\release\armv5\urel\PIProfilerEngine.exe" -"!:\sys\bin\PIProfilerEngine.exe" +"\epoc32\release\armv5\urel\PIProfiler.exe" -"!:\sys\bin\PIProfiler.exe" + +; basic sampler plugins +"\epoc32\release\armv5\urel\PIProfilerGenerals.dll" -"!:\sys\bin\PIProfilerGenerals.dll" +"\epoc32\data\Z\Resource\plugins\PIProfilerGenerals.rsc" - "!:\Resource\Plugins\PIProfilerGenerals.RSC" +"\epoc32\release\armv5\urel\PIProfilerGeneralsSampler.ldd" -"!:\sys\bin\PIProfilerGeneralsSampler.ldd" +"\epoc32\release\armv5\urel\PIProfilerBUP.dll" -"!:\sys\bin\PIProfilerBUP.dll" +"\epoc32\data\Z\Resource\plugins\PIProfilerBUP.rsc" - "!:\Resource\Plugins\PIProfilerBUP.RSC" +"\epoc32\RELEASE\armv5\urel\PIProfilerTouchEventAnim.dll"-"!:\sys\bin\PIProfilerTouchEventAnim.dll" + +; writer plugins +"\epoc32\release\armv5\urel\piprofilerdebugwriter.dll" -"!:\sys\bin\piprofilerdebugwriter.dll" +"\epoc32\data\Z\Resource\plugins\piprofilerdebugwriter.rsc" - "!:\Resource\Plugins\piprofilerdebugwriter.rsc" +"\epoc32\release\armv5\urel\piprofilerdiskwriter.dll" -"!:\sys\bin\piprofilerdiskwriter.dll" +"\epoc32\data\Z\Resource\plugins\piprofilerdiskwriter.rsc" - "!:\Resource\Plugins\piprofilerdiskwriter.rsc" diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/sis/PIProfiler_S60-32.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/sis/PIProfiler_S60-32.pkg Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,47 @@ +; +; 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: +; +;Languages +&EN + +;Header +#{"PIProfiler"}, (0x2001E5AD), 2,00,0,TYPE=SA + +; Supports S60 v 3.0 +[0x102752AE], 0, 0, 0, {"S60ProductID"} + +; Non-localised vendor name +:"Nokia Corporation" + +; Localised vendor names +%{"Nokia Corporation"} + +; engine +"\epoc32\release\armv5\urel\PIProfilerEngine.exe" -"!:\sys\bin\PIProfilerEngine.exe" +"\epoc32\release\armv5\urel\PIProfiler.exe" -"!:\sys\bin\PIProfiler.exe" + +; basic sampler plugins +"\epoc32\release\armv5\urel\PIProfilerGenerals.dll" -"!:\sys\bin\PIProfilerGenerals.dll" +"\epoc32\data\Z\Resource\plugins\PIProfilerGenerals.rsc" - "!:\Resource\Plugins\PIProfilerGenerals.RSC" +"\epoc32\release\armv5\urel\PIProfilerGeneralsSampler.ldd" -"!:\sys\bin\PIProfilerGeneralsSampler.ldd" +"\epoc32\release\armv5\urel\PIProfilerBUP.dll" -"!:\sys\bin\PIProfilerBUP.dll" +"\epoc32\data\Z\Resource\plugins\PIProfilerBUP.rsc" - "!:\Resource\Plugins\PIProfilerBUP.RSC" +"\epoc32\RELEASE\armv5\urel\PIProfilerTouchEventAnim.dll"-"!:\sys\bin\PIProfilerTouchEventAnim.dll" + +; writer plugins +"\epoc32\release\armv5\urel\piprofilerdebugwriter.dll" -"!:\sys\bin\piprofilerdebugwriter.dll" +"\epoc32\data\Z\Resource\plugins\piprofilerdebugwriter.rsc" - "!:\Resource\Plugins\piprofilerdebugwriter.rsc" +"\epoc32\release\armv5\urel\piprofilerdiskwriter.dll" -"!:\sys\bin\piprofilerdiskwriter.dll" +"\epoc32\data\Z\Resource\plugins\piprofilerdiskwriter.rsc" - "!:\Resource\Plugins\piprofilerdiskwriter.rsc" diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/sis/PIProfiler_S60-50.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/sis/PIProfiler_S60-50.pkg Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,47 @@ +; +; 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: +; +;Languages +&EN + +;Header +#{"PIProfiler"}, (0x2001E5AD), 2,00,0,TYPE=SA + +; Supports S60 v 3.0 +[0x1028315F], 0, 0, 0, {"S60ProductID"} + +; Non-localised vendor name +:"Nokia Corporation" + +; Localised vendor names +%{"Nokia Corporation"} + +; engine +"\epoc32\release\armv5\urel\PIProfilerEngine.exe" -"!:\sys\bin\PIProfilerEngine.exe" +"\epoc32\release\armv5\urel\PIProfiler.exe" -"!:\sys\bin\PIProfiler.exe" + +; basic sampler plugins +"\epoc32\release\armv5\urel\PIProfilerGenerals.dll" -"!:\sys\bin\PIProfilerGenerals.dll" +"\epoc32\data\Z\Resource\plugins\PIProfilerGenerals.rsc" - "!:\Resource\Plugins\PIProfilerGenerals.RSC" +"\epoc32\release\armv5\urel\PIProfilerGeneralsSampler.ldd" -"!:\sys\bin\PIProfilerGeneralsSampler.ldd" +"\epoc32\release\armv5\urel\PIProfilerBUP.dll" -"!:\sys\bin\PIProfilerBUP.dll" +"\epoc32\data\Z\Resource\plugins\PIProfilerBUP.rsc" - "!:\Resource\Plugins\PIProfilerBUP.RSC" +"\epoc32\RELEASE\armv5\urel\PIProfilerTouchEventAnim.dll"-"!:\sys\bin\PIProfilerTouchEventAnim.dll" + +; writer plugins +"\epoc32\release\armv5\urel\piprofilerdebugwriter.dll" -"!:\sys\bin\piprofilerdebugwriter.dll" +"\epoc32\data\Z\Resource\plugins\piprofilerdebugwriter.rsc" - "!:\Resource\Plugins\piprofilerdebugwriter.rsc" +"\epoc32\release\armv5\urel\piprofilerdiskwriter.dll" -"!:\sys\bin\piprofilerdiskwriter.dll" +"\epoc32\data\Z\Resource\plugins\piprofilerdiskwriter.rsc" - "!:\Resource\Plugins\piprofilerdiskwriter.rsc" diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/sis/make_sisx_30.bat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/sis/make_sisx_30.bat Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,27 @@ +rem +rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +rem All rights reserved. +rem This component and the accompanying materials are made available +rem under the terms of "Eclipse Public License v1.0" +rem which accompanies this distribution, and is available +rem at the URL "http://www.eclipse.org/legal/epl-v10.html". +rem +rem Initial Contributors: +rem Nokia Corporation - initial contribution. +rem +rem Contributors: +rem +rem Description: +rem + +@echo off + +echo Making SISX installation packages for PI Profiler Engine + +call makesis -v PIProfiler_S60-30.pkg +call signsis -v -s PIProfiler_S60-30.sis PIProfiler_S60-30.sisx RDTest_02.der RDTest_02.key + +call makesis -v PIProfilerUI_S60-30.pkg +call signsis -v -s PIProfilerUI_S60-30.sis PIProfilerUI_S60-30.sisx RDTest_02.der RDTest_02.key + +dir .\ diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/sis/make_sisx_31.bat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/sis/make_sisx_31.bat Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,27 @@ +rem +rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +rem All rights reserved. +rem This component and the accompanying materials are made available +rem under the terms of "Eclipse Public License v1.0" +rem which accompanies this distribution, and is available +rem at the URL "http://www.eclipse.org/legal/epl-v10.html". +rem +rem Initial Contributors: +rem Nokia Corporation - initial contribution. +rem +rem Contributors: +rem +rem Description: +rem + +@echo off + +echo Making SISX installation packages for PI Profiler Engine + +call makesis -v PIProfiler_S60-31.pkg +call signsis -v -s PIProfiler_S60-31.sis PIProfiler_S60-31.sisx RDTest_02.der RDTest_02.key + +call makesis -v PIProfilerUI_S60-31.pkg +call signsis -v -s PIProfilerUI_S60-31.sis PIProfilerUI_S60-31.sisx RDTest_02.der RDTest_02.key + +dir .\ diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/sis/make_sisx_32.bat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/sis/make_sisx_32.bat Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,27 @@ +rem +rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +rem All rights reserved. +rem This component and the accompanying materials are made available +rem under the terms of "Eclipse Public License v1.0" +rem which accompanies this distribution, and is available +rem at the URL "http://www.eclipse.org/legal/epl-v10.html". +rem +rem Initial Contributors: +rem Nokia Corporation - initial contribution. +rem +rem Contributors: +rem +rem Description: +rem + +@echo off + +echo Making SISX installation packages for PI Profiler Engine + +call makesis -v PIProfiler_S60-32.pkg +call signsis -v -s PIProfiler_S60-32.sis PIProfiler_S60-32.sisx RDTest_02.der RDTest_02.key + +call makesis -v PIProfilerUI_S60-32.pkg +call signsis -v -s PIProfilerUI_S60-32.sis PIProfilerUI_S60-32.sisx RDTest_02.der RDTest_02.key + +dir .\ diff -r f0f2b8682603 -r 3ff3fecb12fe sysanadatacapture/piprofiler/sis/make_sisx_50.bat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sysanadatacapture/piprofiler/sis/make_sisx_50.bat Thu Feb 11 15:52:57 2010 +0200 @@ -0,0 +1,27 @@ +rem +rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +rem All rights reserved. +rem This component and the accompanying materials are made available +rem under the terms of "Eclipse Public License v1.0" +rem which accompanies this distribution, and is available +rem at the URL "http://www.eclipse.org/legal/epl-v10.html". +rem +rem Initial Contributors: +rem Nokia Corporation - initial contribution. +rem +rem Contributors: +rem +rem Description: +rem + +@echo off + +echo Making SISX installation packages for PI Profiler Engine + +call makesis -v PIProfiler_S60-50.pkg +call signsis -v -s PIProfiler_S60-50.sis PIProfiler_S60-50.sisx RDTest_02.der RDTest_02.key + +call makesis -v PIProfilerUI_S60-50.pkg +call signsis -v -s PIProfilerUI_S60-50.sis PIProfilerUI_S60-50.sisx RDTest_02.der RDTest_02.key + +dir .\