|
1 // Copyright (c) 2007-2010 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 "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 // Tracks the activation of BTrace OST categories |
|
15 // |
|
16 |
|
17 #ifndef __BTRACEOSTCATEGORYBITMAP_H__ |
|
18 #define __BTRACEOSTCATEGORYBITMAP_H__ |
|
19 |
|
20 |
|
21 // Include files |
|
22 #include <opensystemtrace_types.h> |
|
23 #include "TraceCoreActivationBase.h" |
|
24 |
|
25 class DBTraceOstCategoryHandler; |
|
26 |
|
27 /** |
|
28 * OST trace component. |
|
29 */ |
|
30 class TOstComponent |
|
31 { |
|
32 public: |
|
33 TUint32 iComponentId; |
|
34 RArray< TUint > iGroups; //TODO: implement this as a bitmap rather than RArray |
|
35 }; |
|
36 |
|
37 |
|
38 /** |
|
39 * OST Trace bitmap (dynamic). This extends the subscriber base class to receive bitmap updates |
|
40 */ |
|
41 NONSHARABLE_CLASS( DBTraceOstCategoryBitmap ) : public DTraceCoreActivationBase |
|
42 { |
|
43 public: |
|
44 |
|
45 /** |
|
46 * Constructor |
|
47 * @param aBTraceOstCategoryHandler Pointer to CBTraceOstCategoryHandler |
|
48 */ |
|
49 DBTraceOstCategoryBitmap(DBTraceOstCategoryHandler* aBTraceOstCategoryHandler); |
|
50 |
|
51 /** |
|
52 * Destructor |
|
53 */ |
|
54 ~DBTraceOstCategoryBitmap(); |
|
55 |
|
56 /** |
|
57 * Initializes this bitmap. This subscribes to the bitmap update message |
|
58 */ |
|
59 TInt Init(); |
|
60 |
|
61 /** |
|
62 * Checks if trace points with a specific component ID and group ID are |
|
63 * currently active |
|
64 * |
|
65 * @param aComponentId The component ID |
|
66 * @param aTraceWord The trace word containing the group ID to check |
|
67 * @return ETrue if trace is active, EFalse if not |
|
68 */ |
|
69 TBool IsTraceActivated( const TUint32 aComponentId, TUint32 aTraceWord ); |
|
70 |
|
71 /** |
|
72 * Activate trace group |
|
73 * |
|
74 * @param aComponentId The component ID |
|
75 * @param aGroupId The group ID |
|
76 */ |
|
77 void ActivateTrace( const TUint32 aComponentId, const TUint32 aGroupId ); |
|
78 |
|
79 /** |
|
80 * Deactivate trace group |
|
81 * |
|
82 * @param aComponentId The component ID |
|
83 * @param aGroupId The group ID |
|
84 */ |
|
85 void DeactivateTrace( const TUint32 aComponentId, const TUint32 aGroupId ); |
|
86 |
|
87 /** |
|
88 * Deactivates all groups from a component |
|
89 * |
|
90 * @param aComponentId The component ID |
|
91 */ |
|
92 void DeactivateAll( const TUint32 aComponentId ); |
|
93 |
|
94 /** |
|
95 * Updates this activation object from the given settings |
|
96 * |
|
97 * @param aSettings the settings to be read |
|
98 */ |
|
99 void ReadFromSettings( DTraceCoreSettings& aSettings ); |
|
100 |
|
101 /** |
|
102 * Updates the settings with the content of this activation object |
|
103 * |
|
104 * @param aSettings the settings to be written |
|
105 */ |
|
106 void WriteToSettings( DTraceCoreSettings& aSettings ); |
|
107 |
|
108 /** |
|
109 * Gets activated groups for this component ID |
|
110 * @param aComponentId the component ID |
|
111 */ |
|
112 RArray< TUint > GetActivatedGroups( const TUint32 aComponentId ); |
|
113 |
|
114 /** |
|
115 * Reactivate all currently activated traces |
|
116 * |
|
117 * This function deactivates all groups currently active and re-activates them. |
|
118 * This results in kernel priming data being generated for all active kernel groups. |
|
119 * |
|
120 * @return KErrNone if refresh successful |
|
121 */ |
|
122 TInt RefreshActivations(); |
|
123 |
|
124 private: |
|
125 |
|
126 TInt FindComponentId( TUint32 aComponentId, RArray<TOstComponent>& aOstComponents ); |
|
127 TInt AddComponentId( TUint32 aComponentId, RArray<TOstComponent>& aOstComponents ); |
|
128 TInt RemoveComponentId( TUint32 aComponentId, TBool aNotifyActivationListeners, |
|
129 RArray<TOstComponent>& aOstComponents, RArray< TOstComponent >& aChangedArray ); |
|
130 TInt AddGroupId( TUint32 aComponentId, TGroupId aGroupId, TInt aIndex, |
|
131 RArray<TOstComponent>& aOstComponents, RArray< TOstComponent >& aChangedArray ); |
|
132 TInt RemoveGroupId( TUint32 aComponentId, TGroupId aGroupId, TInt aIndex, |
|
133 RArray<TOstComponent>& aOstComponents, RArray< TOstComponent >& aChangedArray ); |
|
134 TInt OverwriteGroups (const TUint8* aFrameStart, |
|
135 TInt aComponentIndex, TUint32 aComponentId , TUint32 numberOfGroups, |
|
136 RArray<TOstComponent>& aOstComponents, RArray< TOstComponent >& aChangedArray); |
|
137 TInt ReadOstProtocolFrame(const TDesC8& aMessage, TUint32 aFrameStartIndex); |
|
138 TInt ReadOstProtocolFrameGroups(const TDesC8& aMessage, |
|
139 TInt aFrameStartIndex, TUint8 aActivationInfo, TInt aComponentIndex, |
|
140 TUint32 aComponentId, RArray<TOstComponent>& aOstComponents, RArray< TOstComponent >& aChangedArray); |
|
141 TInt ReadOstFrame( const TDesC8& aMessage, TUint32 aFrameStartIndex ); |
|
142 TInt ReadOstFrameGroups( const TDesC8& aMessage, TInt aFrameStartIndex, |
|
143 TUint8 aActivationInfo, TInt aComponentIndex, TUint32 aComponentId, |
|
144 RArray<TOstComponent>& aOstComponents, RArray< TOstComponent >& aChangedArray ); |
|
145 void MessageReceived( TTraceMessage &aMsg ); |
|
146 void OstProtocolMessage( TTraceMessage &aMsg ); |
|
147 TBool IsComponentSupported( TUint32 /*aComponentID*/ ); |
|
148 TInt AllocateActivationBuffer(); |
|
149 TUint32 Read32FromBuffer(TUint8*& aPtr); |
|
150 TUint16 Read16FromBuffer(TUint8*& aPtr); |
|
151 void WriteToBuffer(TUint8*& aPtr, TUint32 aData32); |
|
152 void WriteToBuffer(TUint8*& aPtr, TUint16 aData16); |
|
153 void HandleTraceActivationChanges(RArray< TOstComponent >& aChangedArray); |
|
154 |
|
155 //used by locking mechanism |
|
156 template <class T> void CopyArray(RArray<T>* aSrc, RArray<T>* aDst); |
|
157 void SetNewComponentsArrayPtr(RArray<TOstComponent>*& aNewPtr); |
|
158 |
|
159 //utility methods |
|
160 void CleanupComponentsArray(RArray< TOstComponent >& aComponentArray); |
|
161 void CleanupComponentsArrays(); |
|
162 void AddGroupToChangedArray(RArray< TOstComponent >& aChangedArray, TUint32 aComponentId, TGroupId aGroupId); |
|
163 |
|
164 private: |
|
165 |
|
166 /** |
|
167 * OST Components |
|
168 */ |
|
169 RArray< TOstComponent >* iOstComponents; |
|
170 |
|
171 //temporary array used in activation/deactivation methods |
|
172 RArray< TOstComponent >* iTmpArray; |
|
173 |
|
174 //array used in to store changed components |
|
175 RArray< TOstComponent >* iChangedArray; |
|
176 |
|
177 /** |
|
178 * Buffer for saving and loading activations |
|
179 */ |
|
180 TUint8* iActivationBuffer; |
|
181 DBTraceOstCategoryHandler* iBTraceOstCategoryHandler; |
|
182 |
|
183 }; |
|
184 |
|
185 #endif // __BTRACEOSTCATEGORYBITMAP_H__ |
|
186 |
|
187 // End of File |