0
|
1 |
// Copyright (c) 1994-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 |
// e32\include\kernel\monitor.h
|
|
15 |
// Kernel crash debugger header file
|
|
16 |
//
|
|
17 |
// WARNING: This file contains some APIs which are internal and are subject
|
|
18 |
// to change without notice. Such APIs should therefore not be used
|
|
19 |
// outside the Kernel and Hardware Services package.
|
|
20 |
//
|
|
21 |
|
|
22 |
/**
|
|
23 |
@file
|
|
24 |
@internalComponent
|
|
25 |
*/
|
|
26 |
|
|
27 |
#ifndef __M32MON_H__
|
|
28 |
#define __M32MON_H__
|
|
29 |
#include <plat_priv.h>
|
|
30 |
|
|
31 |
|
|
32 |
class TCrashLogGzip;
|
|
33 |
class TCrashDebugGzip;
|
|
34 |
|
|
35 |
|
|
36 |
// Maximum number of monitors that can be added - only 4*n bytes to store it.
|
|
37 |
// Actually it's this plus one as the first monitor is stored seperately.
|
|
38 |
#define MONITOR_MAXCOUNT 8
|
|
39 |
|
|
40 |
class TTrapM
|
|
41 |
{
|
|
42 |
public:
|
|
43 |
IMPORT_C TInt Trap(TInt& aResult);
|
|
44 |
IMPORT_C static void UnTrap();
|
|
45 |
public:
|
|
46 |
TInt iState[EXC_TRAP_CTX_SZ];
|
|
47 |
TTrapM* iNext;
|
|
48 |
TInt* iResult;
|
|
49 |
};
|
|
50 |
|
|
51 |
#define MTRAP(_r,_s) {TTrapM __t;if (__t.Trap(_r)==0){_s;TTrapM::UnTrap();}}
|
|
52 |
#define MTRAPD(_r,_s) TInt _r;{TTrapM __t;if (__t.Trap(_r)==0){_s;TTrapM::UnTrap();}}
|
|
53 |
|
|
54 |
class Monitor;
|
|
55 |
|
|
56 |
class DMonObject
|
|
57 |
{
|
|
58 |
public:
|
279
|
59 |
#if defined(__GCC32__) && !defined(__EABI__) && defined(__MARM__) // old GCC uses a different class layout
|
0
|
60 |
DBase* iAsyncDeleteNext;
|
|
61 |
TAny* iVptr;
|
|
62 |
#else
|
|
63 |
TAny* iVptr;
|
|
64 |
DBase* iAsyncDeleteNext;
|
|
65 |
#endif
|
|
66 |
TInt iAccessCount;
|
|
67 |
DMonObject* iOwner;
|
|
68 |
TUint8 iContainerID; // TObjectType+1
|
|
69 |
TUint8 iProtection; // TObjectProtection
|
|
70 |
TUint8 iSpare[2];
|
|
71 |
HBuf* iName;
|
|
72 |
public:
|
|
73 |
void AppendName(TDes8& aDes);
|
|
74 |
void FullName(TDes8& aDes);
|
|
75 |
void DumpData();
|
|
76 |
DMonObject* Owner();
|
|
77 |
TInt Type();
|
|
78 |
};
|
|
79 |
|
|
80 |
class DMsgQueue;
|
|
81 |
|
|
82 |
class Monitor
|
|
83 |
{
|
|
84 |
public:
|
|
85 |
// KP
|
|
86 |
virtual void Print(const TDesC8& aDes) = 0;
|
|
87 |
IMPORT_C virtual void Pause(TBool aPause);
|
|
88 |
IMPORT_C void PrintLine(const TDesC8& aDes);
|
|
89 |
IMPORT_C void Printf(const char* aFmt, ...);
|
|
90 |
IMPORT_C void Print(const char* s);
|
|
91 |
IMPORT_C void PrintLine(const char* s);
|
|
92 |
IMPORT_C void NewLine();
|
|
93 |
IMPORT_C void ObjectDump(TUint aIndex);
|
|
94 |
IMPORT_C void ObjectFullDump(TUint aIndex);
|
|
95 |
IMPORT_C void DoMemoryDumpL(TUint aStart, TInt aLength);
|
|
96 |
IMPORT_C void DoDiscontiguousMemoryDumpL(TUint aStart, TInt aLength);
|
|
97 |
IMPORT_C void DisplayFaultInfo();
|
|
98 |
IMPORT_C void DumpObjectContainer(TUint aIndex, TBool aPause);
|
|
99 |
IMPORT_C void ProcessInfoCommand(const TDesC8& aDes, TInt& i);
|
|
100 |
IMPORT_C void ProcessError(TInt anError);
|
|
101 |
IMPORT_C void DumpThreadStack(DThread* aThread);
|
|
102 |
IMPORT_C void DumpThreadStacks(TBool aIncludeCurrent);
|
|
103 |
IMPORT_C static void RegisterMonitorImpl(Monitor* aImpl);
|
|
104 |
IMPORT_C void DoMemoryDumpL(TUint aStart, TInt aLength, TUint aReadSize);
|
|
105 |
IMPORT_C void DoDiscontiguousMemoryDumpL(TUint aStart, TInt aLength ,TUint aReadSize);
|
|
106 |
IMPORT_C void DumpExceptionStacks();
|
|
107 |
static void GetObjectTypeName(TDes8& aDes, TInt aType, TBool aPlural);
|
|
108 |
void DumpObjectData(DMonObject* pO, TInt type);
|
|
109 |
void DumpThreadData(DThread* pT);
|
|
110 |
void DoStackDumpL(TUint aStart, TUint aEnd);
|
|
111 |
void DoDumpThreadStack(DThread* aThread);
|
|
112 |
void DumpProcessData(DProcess* pP);
|
|
113 |
void DumpChunkData(DChunk* pC);
|
|
114 |
DObjectCon* Container(TInt anIndex);
|
|
115 |
void DumpMessageQueueData(DMsgQueue* aQueue);
|
|
116 |
void Init(TAny* aCategory, TInt aReason);
|
|
117 |
virtual TInt Init2(TAny* aCategory, TInt aReason) = 0;
|
|
118 |
public:
|
|
119 |
// KM
|
|
120 |
void DumpMemModelProcessData(DProcess* aProcess);
|
|
121 |
void MMProcessInfoCommand();
|
|
122 |
IMPORT_C TUint MapAndLocateUserStack(DThread* aThread);
|
|
123 |
public:
|
|
124 |
// NK/KC
|
|
125 |
IMPORT_C static void Entry(TAny* aRegs);
|
|
126 |
|
|
127 |
/**
|
|
128 |
@publishedPartner
|
|
129 |
@released
|
|
130 |
*/
|
|
131 |
IMPORT_C static void Leave(TInt aReason);
|
|
132 |
|
|
133 |
IMPORT_C static void HandleException();
|
|
134 |
|
|
135 |
IMPORT_C void CpuInit();
|
|
136 |
IMPORT_C void DumpCpuThreadData(DThread* pT);
|
|
137 |
IMPORT_C void DumpCpuRegisters();
|
|
138 |
IMPORT_C void DisplayCpuFaultInfo();
|
|
139 |
IMPORT_C void DisplayCodeSeg(DCodeSeg* aSeg,TBool aFull);
|
|
140 |
IMPORT_C void DisplayCodeSeg(TBool aFull);
|
|
141 |
void MDisplayCodeSeg(DCodeSeg* aSeg);
|
|
142 |
void DisplaySRamCodeInfo(SRamCodeInfo* aS);
|
|
143 |
void DisplayTRomImageHeader(TRomImageHeader* aS);
|
|
144 |
void DumpCpuProcessData(DProcess* pP);
|
|
145 |
void DumpCpuChunkData(DChunk* pC);
|
|
146 |
#ifdef __SMP__
|
|
147 |
void DisplayNSchedulableInfo(NSchedulable* aS);
|
|
148 |
void DisplaySpinLock(const char* aTitle, TSpinLock* aLock);
|
|
149 |
#endif
|
|
150 |
IMPORT_C void DisplayNThreadInfo(NThread* pT);
|
|
151 |
void DisplayNFastSemInfo(NFastSemaphore* pS);
|
|
152 |
void DisplayNFastMutexInfo(NFastMutex* pM);
|
|
153 |
void DisplaySchedulerInfo();
|
|
154 |
void DisplayDebugMaskInfo();
|
|
155 |
IMPORT_C void GetStackPointers(NThread* aThread, TUint& aSupSP, TUint& aUsrSP);
|
|
156 |
IMPORT_C TInt SwitchAddressSpace(DProcess* aProcess, TBool aForce);
|
|
157 |
public:
|
|
158 |
TTrapM* iFrame;
|
|
159 |
TUint32 iExceptionInfo[4];
|
|
160 |
TBuf8<80> iFaultCategory;
|
|
161 |
TInt iFaultReason;
|
|
162 |
TAny* iRegs;
|
|
163 |
TInt iPageSize;
|
|
164 |
public:
|
|
165 |
enum TRestartType
|
|
166 |
{
|
|
167 |
ESoftRestart=1,
|
|
168 |
EHardRestart=2
|
|
169 |
//EMoreSevereRestartType=4
|
|
170 |
};
|
|
171 |
protected:
|
|
172 |
IMPORT_C Monitor();
|
|
173 |
};
|
|
174 |
|
|
175 |
NONSHARABLE_CLASS(CrashDebugger) : public Monitor
|
|
176 |
{
|
|
177 |
public:
|
|
178 |
CrashDebugger();
|
|
179 |
// KP -- from Monitor
|
|
180 |
virtual void Print(const TDesC8& aDes);
|
|
181 |
virtual void Pause(TBool aPause);
|
|
182 |
virtual TInt Init2(TAny* aCategory, TInt aReason);
|
|
183 |
// KP
|
|
184 |
void Input(TDes8& aDes, const char* aPrompt);
|
|
185 |
void WaitForSensibleInput();
|
|
186 |
TBool DoCommandL();
|
|
187 |
void ProcessMemDumpCommand(const TDesC8& aDes, TInt& i, TBool aDiscontiguous);
|
|
188 |
void ProcessObjectDumpCommand(const TDesC8& aDes, TInt& i);
|
|
189 |
void ProcessObjectFullDumpCommand(const TDesC8& aDes, TInt& i);
|
|
190 |
void ProcessNThreadDumpCommand(const TDesC8& aDes, TInt& i);
|
|
191 |
void ProcessDumpObjectContainer(const TDesC8& aDes, TInt& i, TBool aPause);
|
|
192 |
void ProcessStackDumpCommand(const TDesC8& aDes, TInt& i);
|
|
193 |
void ProcessAddressSpaceSwitchCommand(const TDesC8& aDes, TInt& i, TBool aForce);
|
|
194 |
void SkipSpaces(const TDesC8& in, TInt& i);
|
|
195 |
TInt ReadHex(const TDesC8& in, TInt& i, TUint& r);
|
|
196 |
void SyntaxError();
|
|
197 |
void DisplayHelp();
|
|
198 |
void UnknownCommand();
|
|
199 |
void DisplayCodeSegCommand(const TDesC8& aDes, TInt& i, TBool aFull);
|
|
200 |
void ProcessBTrace(const TDesC8& aDes, TInt& i);
|
|
201 |
// KC
|
|
202 |
void QuadrupleBeepAndPowerDown();
|
|
203 |
public:
|
|
204 |
// KA or variant
|
|
205 |
|
|
206 |
/**
|
|
207 |
@publishedPartner
|
|
208 |
@released
|
|
209 |
*/
|
|
210 |
void InitUart();
|
|
211 |
|
|
212 |
/**
|
|
213 |
@publishedPartner
|
|
214 |
@released
|
|
215 |
*/
|
|
216 |
void UartOut(TUint aChar);
|
|
217 |
|
|
218 |
/**
|
|
219 |
@publishedPartner
|
|
220 |
@released
|
|
221 |
*/
|
|
222 |
TUint8 UartIn();
|
|
223 |
|
|
224 |
/**
|
|
225 |
@publishedPartner
|
|
226 |
@released
|
|
227 |
*/
|
|
228 |
TBool CheckPower();
|
|
229 |
|
|
230 |
protected:
|
|
231 |
/** object that performs the compression of the output*/
|
|
232 |
TCrashDebugGzip* iEncoder;
|
|
233 |
|
|
234 |
};
|
|
235 |
|
|
236 |
class CrashFlash;
|
|
237 |
|
|
238 |
NONSHARABLE_CLASS(CrashLogger) : public Monitor
|
|
239 |
{
|
|
240 |
public:
|
|
241 |
CrashLogger();
|
|
242 |
// KP -- from Monitor
|
|
243 |
virtual void Print(const TDesC8& aDes);
|
|
244 |
virtual TInt Init2(TAny* aCategory, TInt aReason);
|
|
245 |
/**
|
|
246 |
@publishedPartner
|
|
247 |
@released
|
|
248 |
*/
|
|
249 |
void VariantInit();
|
|
250 |
/**
|
|
251 |
@publishedPartner
|
|
252 |
@released
|
|
253 |
*/
|
|
254 |
TInt InitFlash();
|
|
255 |
CrashFlash* iFlash;
|
|
256 |
|
|
257 |
protected:
|
|
258 |
TBool SignatureExists();
|
|
259 |
void DumpRomInfo();
|
|
260 |
void DumpCrashTime();
|
|
261 |
void DumpCrashInfo();
|
|
262 |
void DoDumpCrashInfo(volatile TInt& aState);
|
|
263 |
void WriteSignature();
|
|
264 |
void DumpVariantSpecific();
|
|
265 |
void DumpExceptionStacks();
|
|
266 |
void DumpOtherThreadStacks();
|
|
267 |
|
|
268 |
#ifdef _CRASHLOG_COMPR
|
|
269 |
/** object that performs the compression of the output*/
|
|
270 |
TCrashLogGzip* iEncoder;
|
|
271 |
/** ETrue when iEncoder is not limiting the output*/
|
|
272 |
TBool iTruncated;
|
|
273 |
#endif //_CRASHLOG_COMPR
|
|
274 |
|
|
275 |
private:
|
|
276 |
enum TLogState
|
|
277 |
{
|
|
278 |
ERomInfo = 0,
|
|
279 |
ECrashTime,
|
|
280 |
EFaultInfo,
|
|
281 |
EGeneralInfo,
|
|
282 |
ERegisters,
|
|
283 |
ECurrentThreadStack,
|
|
284 |
EExceptionStacks,
|
|
285 |
EVariantSpecific,
|
|
286 |
ECodeSegs,
|
|
287 |
EOtherThreadStacks,
|
|
288 |
EObjectContainers,
|
|
289 |
EFinished
|
|
290 |
};
|
|
291 |
};
|
|
292 |
|
|
293 |
GLREF_D Monitor* TheMonitorPtr;
|
|
294 |
|
|
295 |
#endif
|