os/kernelhwsrv/kerneltest/e32test/debug/d_eventtracker.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of the License "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 // e32test/debug/d_eventtracker.h
    15 // 
    16 //
    17 
    18 #ifndef __D_EVENTTRACKER_H__
    19 #define __D_EVENTTRACKER_H__
    20 
    21 #include "platform.h"
    22 
    23 
    24 /** Base class for representing objects being tracked.  */
    25 
    26 class TTrackedItem
    27 	{
    28 public:
    29 	TTrackedItem(const DBase* aObject);
    30 	
    31 public:
    32 	SDblQueLink iLink;
    33 	const DBase* const iObject; 		// key
    34 	TBool iAccountedFor;
    35 	};
    36 
    37 /** Subclass for representing DObjects being tracked.  */
    38 
    39 class TTrackedObject : public TTrackedItem
    40 	{
    41 public:
    42 	TTrackedObject(DObject* aObject, TObjectType aType);
    43 	TBool CheckIntegrity(const TDesC& aName, TObjectType aType) const;
    44 
    45 public:
    46 	TFullName iFullName;
    47 	const TObjectType iType;
    48 	};
    49 
    50 /** Subclass for representing DCodeSegs being tracked.  */
    51 
    52 class TTrackedCodeSeg : public TTrackedItem
    53 	{
    54 public:
    55 	TTrackedCodeSeg(const DCodeSeg* aCodeSeg);
    56 	TBool CheckIntegrity(TInt aAccessCount) const;
    57 
    58 public:
    59 	TInt iAccessCount;
    60 	};
    61 
    62 
    63 /** Event handler and container for all objects being tracked.  */
    64 
    65 class DEventTracker : public DKernelEventHandler
    66 	{
    67 public:
    68 	DEventTracker();
    69 	TInt Create(DLogicalDevice* aDevice, TBool aUseHook);
    70 	~DEventTracker();
    71 	TInt Start();
    72 	TInt Stop();
    73 
    74 private:
    75 	static TUint EventHandler(TKernelEvent aEvent, TAny* a1, TAny* a2, TAny* aThis);
    76 	TUint HandleEvent(TKernelEvent aType, TAny* a1, TAny* a2);
    77 	TInt AddExistingObjects();
    78 	TInt AddObjectsFromContainer(TObjectType aType);
    79 	TInt AddCodeSegsFromList();
    80 	TInt CheckIntegrity();
    81 	void CheckContainerIntegrity(TObjectType aType);
    82 	void CheckCodeSegListIntegrity();
    83 	void CheckAllAccountedFor();
    84 
    85 	TTrackedItem* LookupItem(DBase* aItem) const;
    86 
    87 	void AddObject(TObjectType aType, DObject* aObject);
    88 	void RemoveObject(TObjectType aType, DObject* aObject);
    89 	void UpdateObject(TObjectType aType, DObject* aObject, TBool aMustBeRenamed);
    90 	void AddCodeSeg(DCodeSeg* aCodeSeg, DProcess* aProcess);
    91 	void RemoveCodeSeg(DCodeSeg* aCodeSeg, DProcess* aProcess);
    92 	void ProcessLoaded(DProcess* aProcess);
    93 
    94 	void StopTracking();
    95 	void DumpCounters() const;
    96 
    97 	static void BranchToEventHandler();
    98 	static TUint BreakPointSize();
    99 
   100 	// Dummy handler to be copied into RAM
   101 	static TUint DummyHandler(TKernelEvent aEvent, TAny* a1, TAny* a2);
   102 
   103 	// Size of dummy handler
   104 	static TUint DummyHandlerSize();
   105 
   106 	// Copy the default handler
   107 	static void CopyDummyHandler(TLinAddr aLinAddr);
   108 
   109 private:
   110 	/** Lock serialising calls to event handler */
   111 	DMutex* iLock;
   112 	TBool iTracking;
   113 	/** Tracking list (of TTrackedItem).
   114 		Must be accessed only when tracking is disabled or with iLock held.
   115 		Object addresses are used as keys and so must be unique.
   116 	 */
   117 	SDblQue iItems;
   118 	TInt iOOM;
   119 	TInt iErrorCount;
   120 	TInt iCounters[EEventLimit];
   121 	DLogicalDevice* iDevice;	// open reference to LDD for avoiding lifetime issues
   122 	};
   123 
   124 GLREF_D DEventTracker* TheEventTracker;
   125 
   126 #endif // __D_EVENTTRACKER_H__