sl@0: // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // e32test/debug/d_eventtracker.h sl@0: // sl@0: // sl@0: sl@0: #ifndef __D_EVENTTRACKER_H__ sl@0: #define __D_EVENTTRACKER_H__ sl@0: sl@0: #include "platform.h" sl@0: sl@0: sl@0: /** Base class for representing objects being tracked. */ sl@0: sl@0: class TTrackedItem sl@0: { sl@0: public: sl@0: TTrackedItem(const DBase* aObject); sl@0: sl@0: public: sl@0: SDblQueLink iLink; sl@0: const DBase* const iObject; // key sl@0: TBool iAccountedFor; sl@0: }; sl@0: sl@0: /** Subclass for representing DObjects being tracked. */ sl@0: sl@0: class TTrackedObject : public TTrackedItem sl@0: { sl@0: public: sl@0: TTrackedObject(DObject* aObject, TObjectType aType); sl@0: TBool CheckIntegrity(const TDesC& aName, TObjectType aType) const; sl@0: sl@0: public: sl@0: TFullName iFullName; sl@0: const TObjectType iType; sl@0: }; sl@0: sl@0: /** Subclass for representing DCodeSegs being tracked. */ sl@0: sl@0: class TTrackedCodeSeg : public TTrackedItem sl@0: { sl@0: public: sl@0: TTrackedCodeSeg(const DCodeSeg* aCodeSeg); sl@0: TBool CheckIntegrity(TInt aAccessCount) const; sl@0: sl@0: public: sl@0: TInt iAccessCount; sl@0: }; sl@0: sl@0: sl@0: /** Event handler and container for all objects being tracked. */ sl@0: sl@0: class DEventTracker : public DKernelEventHandler sl@0: { sl@0: public: sl@0: DEventTracker(); sl@0: TInt Create(DLogicalDevice* aDevice, TBool aUseHook); sl@0: ~DEventTracker(); sl@0: TInt Start(); sl@0: TInt Stop(); sl@0: sl@0: private: sl@0: static TUint EventHandler(TKernelEvent aEvent, TAny* a1, TAny* a2, TAny* aThis); sl@0: TUint HandleEvent(TKernelEvent aType, TAny* a1, TAny* a2); sl@0: TInt AddExistingObjects(); sl@0: TInt AddObjectsFromContainer(TObjectType aType); sl@0: TInt AddCodeSegsFromList(); sl@0: TInt CheckIntegrity(); sl@0: void CheckContainerIntegrity(TObjectType aType); sl@0: void CheckCodeSegListIntegrity(); sl@0: void CheckAllAccountedFor(); sl@0: sl@0: TTrackedItem* LookupItem(DBase* aItem) const; sl@0: sl@0: void AddObject(TObjectType aType, DObject* aObject); sl@0: void RemoveObject(TObjectType aType, DObject* aObject); sl@0: void UpdateObject(TObjectType aType, DObject* aObject, TBool aMustBeRenamed); sl@0: void AddCodeSeg(DCodeSeg* aCodeSeg, DProcess* aProcess); sl@0: void RemoveCodeSeg(DCodeSeg* aCodeSeg, DProcess* aProcess); sl@0: void ProcessLoaded(DProcess* aProcess); sl@0: sl@0: void StopTracking(); sl@0: void DumpCounters() const; sl@0: sl@0: static void BranchToEventHandler(); sl@0: static TUint BreakPointSize(); sl@0: sl@0: // Dummy handler to be copied into RAM sl@0: static TUint DummyHandler(TKernelEvent aEvent, TAny* a1, TAny* a2); sl@0: sl@0: // Size of dummy handler sl@0: static TUint DummyHandlerSize(); sl@0: sl@0: // Copy the default handler sl@0: static void CopyDummyHandler(TLinAddr aLinAddr); sl@0: sl@0: private: sl@0: /** Lock serialising calls to event handler */ sl@0: DMutex* iLock; sl@0: TBool iTracking; sl@0: /** Tracking list (of TTrackedItem). sl@0: Must be accessed only when tracking is disabled or with iLock held. sl@0: Object addresses are used as keys and so must be unique. sl@0: */ sl@0: SDblQue iItems; sl@0: TInt iOOM; sl@0: TInt iErrorCount; sl@0: TInt iCounters[EEventLimit]; sl@0: DLogicalDevice* iDevice; // open reference to LDD for avoiding lifetime issues sl@0: }; sl@0: sl@0: GLREF_D DEventTracker* TheEventTracker; sl@0: sl@0: #endif // __D_EVENTTRACKER_H__