|
1 // Copyright (c) 2006-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 "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 // Implements two examples of the ECOM Symbian Elf Core Dump API |
|
15 // |
|
16 |
|
17 /** |
|
18 @file |
|
19 @internalTechnology |
|
20 @released |
|
21 */ |
|
22 |
|
23 #ifndef __SYMBIAN_ELF_FORMATTERV2_H__ |
|
24 #define __SYMBIAN_ELF_FORMATTERV2_H__ |
|
25 |
|
26 #include <e32property.h> |
|
27 |
|
28 // Abstract ECOM API definition |
|
29 #include <formatterapi.h> |
|
30 #include <symbianelfdefs.h> |
|
31 #include <crashdatasource.h> |
|
32 #include <crashdatasave.h> |
|
33 |
|
34 #include "symbianelfoptionsv2.h" |
|
35 #include "tsymbianelfformatter.h" |
|
36 #include "symbianelfstringinfov2.h" |
|
37 |
|
38 const TUint32 KSymbianELFFormatterV2Uid = { 0x102836bb }; |
|
39 const TUint32 KCPSRUsrMode = 0x10; |
|
40 |
|
41 _LIT(KPluginDescriptionV2, "Symbian Elf Core Dump formatter V2"); |
|
42 |
|
43 /** |
|
44 @internalTechnology |
|
45 @released |
|
46 Symbian ELF formatter plugin is loaded by the core dump server and notified about the crash event. |
|
47 Then it dupms crash data in the ELF file format. |
|
48 @see CCrashDataSave |
|
49 */ |
|
50 class CSymbianElfFormatterV2 : public CCoreDumpFormatter |
|
51 { |
|
52 friend void CSymbianElfFormatterTest::TestSuiteL(TSuite aSuite); //test harness |
|
53 enum { KElfDumpFileLength = 23 }; |
|
54 public: |
|
55 static CSymbianElfFormatterV2* NewL(); |
|
56 static CSymbianElfFormatterV2* NewLC(); |
|
57 virtual ~CSymbianElfFormatterV2(); |
|
58 |
|
59 public: |
|
60 |
|
61 virtual void ConfigureDataSaveL( CCrashDataSave * aDataSave ); |
|
62 virtual void ConfigureDataSourceL( CCrashDataSource * aDataSource ); |
|
63 virtual void GetDescription( TDes & aPluginDescription ); |
|
64 virtual void CrashEventL( TCrashInfo* aCrashInfo ); |
|
65 virtual TInt GetNumberConfigParametersL( ); |
|
66 virtual COptionConfig * GetConfigParameterL( const TInt aIndex ); |
|
67 virtual void SetConfigParameterL( const TInt aIndex, const TInt32 & aValue, const TDesC & aDescValue ); |
|
68 |
|
69 public: |
|
70 |
|
71 private: |
|
72 |
|
73 /** Helper structure for creating data segs for stacks and .rodata/.bss/.data sections */ |
|
74 struct TSegmentInfo |
|
75 { |
|
76 /** base memory address of the segment */ |
|
77 TUint32 iSegBase; |
|
78 /** size of the segment data */ |
|
79 TUint32 iSegSize; |
|
80 /** access rights to the segment data */ |
|
81 TUint32 iFlags; |
|
82 |
|
83 /** reserved for future */ |
|
84 TUint32 iSpare1; |
|
85 /** reserved for future */ |
|
86 TUint32 iSpare2; |
|
87 }; |
|
88 |
|
89 /** |
|
90 * @publishedPartner |
|
91 * @released |
|
92 * List of TSegmentInfo structures |
|
93 * @see TSegmentInfo |
|
94 * @see RArray |
|
95 */ |
|
96 typedef RArray<TSegmentInfo> RSegmentList; |
|
97 |
|
98 void ConstructL(); |
|
99 CSymbianElfFormatterV2(); |
|
100 void FindAllOfSameClassRepresentation( RRegisterList &aRegs, |
|
101 RRegisterList &aRegsOfSameClassRepr, |
|
102 ESYM_REGCLASS aClass, |
|
103 ESYM_REGREP aRepr ); |
|
104 |
|
105 TUint WriteSymbianInfoL(const TCrashInfo &aCrashInfo, const TUint32 aCrc32); |
|
106 |
|
107 TUint WriteDataSegmentsL( const TUint64 & aThreadId, |
|
108 const TUint64 & aPid, |
|
109 const RThreadPointerList &aThreadList, |
|
110 const RCodeSegPointerList &aCodeSegs, |
|
111 RSegmentList &aDataSegs, |
|
112 RArray<TUint> &aDataSegOffsets ); |
|
113 |
|
114 TUint WriteCodeSegmentsL( const TUint64 & aThreadId, |
|
115 const RCodeSegPointerList &aCodeSegs, |
|
116 RArray<TUint> &aCodeSegOffsets ); |
|
117 |
|
118 TUint WriteThreadInfoL(const TUint64 & aPid, const RThreadPointerList &aThreadList); |
|
119 |
|
120 TUint WriteProcessInfoL(const TUint64 & aPid, const RProcessPointerList &aProcessList); |
|
121 TUint WriteExecutableInfoL(const RCodeSegPointerList &aCodeSegs, const TUint64 &aTime, const TUint64 &aTid); |
|
122 |
|
123 void WriteRegisterInfoL( const TUint64 & aTid, |
|
124 const TUint64 & aPid, |
|
125 RArray<TUint>& aOffsets, |
|
126 RRegisterList &aArmExcRegs, |
|
127 const RThreadPointerList &aThreadList); |
|
128 TUint WriteStringInfoL(); |
|
129 |
|
130 void SetArmRegsFromCrashDataL(const TCrashInfo &aCrashInfo, RRegisterList &aArmExcRegs); |
|
131 |
|
132 TBool GetArmExcReg(const TCrashInfo &aCrashInfo, const TRegisterData & aReg, TRegisterValue32 & aVal); |
|
133 |
|
134 void UpdateCrashProgressL( const TDesC &aProgress ); |
|
135 void UpdateMediaNameL(const TDesC &aMediaFileName, const TDesC &aStatus); |
|
136 |
|
137 TUint32 CalcExecCrcL(const TUint64 &aTid, const TCodeSegInfo &aExecInfo ); |
|
138 |
|
139 void PrepareFileNameL(TUint64 aStamp); |
|
140 |
|
141 TUint WriteTraceBufferL(); |
|
142 TUint WriteLockDataL(); |
|
143 TUint WriteRomBuildInfoL(); |
|
144 TUint WriteVariantSpecificDataL(); |
|
145 |
|
146 void WriteRawMemoryToFileL(const TUint64 aThreadId, const TUint32 aAddress, const TUint32 aLength); |
|
147 void HelpWriteRawMemoryToFileL(const TUint64 aThreadId, const TUint32 aAddress, const TUint32 aLength); |
|
148 |
|
149 TBool IsSystemCrash(); |
|
150 |
|
151 static void CleanupCodeSegList(TAny *aArray); |
|
152 static void CleanupProcessList(TAny *aArray); |
|
153 static void CleanupThreadList(TAny *aArray); |
|
154 |
|
155 private: |
|
156 |
|
157 /** Pointer to data source object created and managed by core dump server, provides API to gather necessary info about the crash */ |
|
158 CCrashDataSource* iDataSource; |
|
159 |
|
160 /** Pointer to writer plugin created and managed by core dump server, provides API to store the dump information*/ |
|
161 CCrashDataSave* iDataSave; |
|
162 |
|
163 /** Keep track of the current media-position indicator */ |
|
164 TUint iOffset; |
|
165 |
|
166 /** Responsible for holding all the strings required to be stored in ELF string info segment */ |
|
167 CStringInfoTableV2* iStrInfoTbl; |
|
168 |
|
169 /** Symbian ELF formatter configuration parameter list */ |
|
170 CElfOptionsV2* iElfOptions; |
|
171 |
|
172 /** Records the CPSR */ |
|
173 TUint32 iCPSR; |
|
174 |
|
175 /** Dump file Name */ |
|
176 RBuf iElfFileName; |
|
177 |
|
178 /** Crash UID lower 32 bits of crash time uniquely identifies the crash*/ |
|
179 TUid iCrashUID; |
|
180 |
|
181 /** Crash UID Property Buffer */ |
|
182 RBuf iCrashIDBuffer; |
|
183 |
|
184 /** @see ECrashprogress |
|
185 * Crash Progress Buffer |
|
186 */ |
|
187 RBuf iCrashProgressBuffer; |
|
188 |
|
189 /** RProperty for reporting crash processing progress */ |
|
190 RProperty iCrashProgress; |
|
191 |
|
192 /** RProperty for canceling crash processing */ |
|
193 RProperty iCancelCrash; |
|
194 |
|
195 /** @see ECrashMediaName |
|
196 * RProperty for reporting the crash media name |
|
197 */ |
|
198 RProperty iCrashMediaName; |
|
199 |
|
200 private: |
|
201 |
|
202 void HandleCrashEventL(TCrashInfo* aCrashInfo); |
|
203 TUint HelpWriteTraceBufferL(TUint aTraceAvailable, TUint aTraceWanted, TUint aOffset); |
|
204 TUint HelpWriteTraceBufferWithTraceFrameWorkL(TUint aTraceWanted, TUint aOffset); |
|
205 }; |
|
206 |
|
207 #endif // __SYMBIAN_ELF_FORMATTERV2_H__ |