|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Defines CATDatParser class and its used enumerations. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __CATDatParser_H__ |
|
20 #define __CATDatParser_H__ |
|
21 |
|
22 // Includes. |
|
23 #include "ATCommonDefines.h" |
|
24 #include "CATBase.h" |
|
25 #include "CATDataSaver.h" |
|
26 |
|
27 // Forward declarations. |
|
28 class CATModule2; |
|
29 class CATMemoryAddress; |
|
30 class CATRomSymbol; |
|
31 |
|
32 /** |
|
33 * Provides the analyze feature for AnalyzeTool specific data file. |
|
34 * Is used by CATProject. Uses CATModule2 and/or CATRomSymbol to locate symbols or |
|
35 * codelines of memory addressses. Uses CATDataSaver to create report. |
|
36 */ |
|
37 class CATDatParser : public CATBase |
|
38 { |
|
39 |
|
40 public: |
|
41 /** |
|
42 * enumeration representing the "mode" depending on build system |
|
43 */ |
|
44 enum ANALYZE_MODE |
|
45 { |
|
46 SBS_1 = 0, |
|
47 SBS_2 = 1 |
|
48 }; |
|
49 /** |
|
50 * Representing current process state |
|
51 */ |
|
52 enum PROCESS_STATE |
|
53 { |
|
54 not_started = 0, |
|
55 ongoing = 1, |
|
56 stopped = 2 |
|
57 }; |
|
58 |
|
59 /** |
|
60 * Constructor. |
|
61 */ |
|
62 CATDatParser(); |
|
63 |
|
64 #ifndef MODULE_TEST |
|
65 private: |
|
66 #endif |
|
67 /** |
|
68 * Real constructor. |
|
69 */ |
|
70 void Construct(); |
|
71 |
|
72 /** |
|
73 * Prevent copy |
|
74 */ |
|
75 CATDatParser& operator =( const CATDatParser& /*other*/ ) { } |
|
76 CATDatParser( const CATDatParser& /*other*/ ) { } |
|
77 |
|
78 public: |
|
79 /** |
|
80 * Constructor for SBS2 |
|
81 * @param pModules pointer to vector containing project modules |
|
82 */ |
|
83 CATDatParser( vector<CATModule2*>* pModules ); |
|
84 |
|
85 /** |
|
86 * Destructor |
|
87 */ |
|
88 ~CATDatParser(); |
|
89 |
|
90 /** |
|
91 * Set offset to be used with mapfiles |
|
92 * @param iOffSet |
|
93 */ |
|
94 void SetOffSet( int iOffSet ); |
|
95 |
|
96 /** |
|
97 * Get offset value |
|
98 * @return int |
|
99 */ |
|
100 int GetOffSet( ) const; |
|
101 |
|
102 /** |
|
103 * Analyze data file set |
|
104 * This method includes try/catch in parsing |
|
105 * @return int error codes specified in CATProject (0=OK) |
|
106 */ |
|
107 int Analyze(); |
|
108 |
|
109 /** |
|
110 * Set log level |
|
111 * @param iLogLevel |
|
112 */ |
|
113 void SetLogLevel(int iLogLevel); |
|
114 /** |
|
115 * Get Log level |
|
116 * @return int |
|
117 */ |
|
118 int GetLogLevel() const ; |
|
119 |
|
120 /** |
|
121 * Set data file to be analyzed |
|
122 * @param sInputFile |
|
123 */ |
|
124 void SetInputFile(const string& sInputFile); |
|
125 |
|
126 /** |
|
127 * Set output file |
|
128 * @param sOutputFile |
|
129 */ |
|
130 void SetOutputFile(const string& sOutputFile); |
|
131 |
|
132 /** |
|
133 * Set rom symbol file(s). |
|
134 * @param sRomSymbolFile |
|
135 */ |
|
136 void SetRomSymbolFiles(const vector<string>& vRomSymbolFile); |
|
137 |
|
138 /** |
|
139 * Set print flag |
|
140 * @param pPringFlag |
|
141 */ |
|
142 void SetPringFlag( bool bPrintFlag ); |
|
143 |
|
144 /** |
|
145 * Set addr2line.exe pinpoint state |
|
146 * @param bInput |
|
147 */ |
|
148 void SetAddr2lineExeState( bool bInput ); |
|
149 |
|
150 /** |
|
151 * Set project platform. |
|
152 * @param sPlatform platform. |
|
153 */ |
|
154 void SetProjectPlatform( const string& sPlatform ); |
|
155 |
|
156 /** |
|
157 * Set projects build type. Use enumeration defined in CATProject. |
|
158 * @param eBuildType. |
|
159 */ |
|
160 void SetProjectBuildType( int eBuildType ); |
|
161 |
|
162 #ifndef MODULE_TEST |
|
163 private: |
|
164 #endif |
|
165 |
|
166 /** |
|
167 * Start parsing datafile |
|
168 * @return error codes defined in CATProject |
|
169 */ |
|
170 int Parse(); |
|
171 |
|
172 /** |
|
173 * Helper functio to print header of report |
|
174 */ |
|
175 void Header(); |
|
176 |
|
177 /** |
|
178 * Helper functio to print footer of report |
|
179 */ |
|
180 void Footer(); |
|
181 |
|
182 /** |
|
183 * Helper function reseting/clearing all |
|
184 * member variables related to parsing |
|
185 */ |
|
186 void ClearParsingVariables(); |
|
187 |
|
188 // Helpers for data file tags |
|
189 bool ParseProcessStart( string& sLine ); |
|
190 bool ParseDllLoad( string& sLine ); |
|
191 bool ParseDllUnload( string& sLine ); |
|
192 bool ParseMemLeak( string& sLine ); |
|
193 bool ParseProcessEnd( string& sLine ); |
|
194 bool ParseHandleLeak( string& sLine ); |
|
195 bool ParseTestStart( string& sLine ); |
|
196 bool ParseTestEnd( string& sLine ); |
|
197 bool ParseLoggingCancelled( string& sLine ); |
|
198 bool ParseErrorOccured( string& sLine ); |
|
199 |
|
200 void PrintMemLeak(const string& sTime, |
|
201 const string& sLeakSize, |
|
202 const string& sLeakAddr, |
|
203 const string& sModuleName); |
|
204 |
|
205 // Utilities |
|
206 string ConvertTimeToLocalTime( string sInputTime ); |
|
207 |
|
208 /** |
|
209 * Create a winscw module into pModules vector. |
|
210 * Used when we have dll load of module not in project to create them |
|
211 * after this they are used in locating code lines. |
|
212 * @param sBinaryName name of the binary with extension. |
|
213 * @return true if successful. |
|
214 */ |
|
215 bool CreateWinscwModule( const string& sBinaryName ); |
|
216 |
|
217 #ifndef MODULE_TEST |
|
218 private: |
|
219 #endif |
|
220 |
|
221 void CleanMemoryAddresses(); |
|
222 |
|
223 // Members |
|
224 unsigned int m_iDataVersion; // Version of data file. |
|
225 int m_eProcess_state; // is process started, etc.. |
|
226 bool m_bProcessStartFound; |
|
227 bool m_bDllLoadFound; |
|
228 int m_iLogLevel; // specified logging level |
|
229 string m_sInputFile; // input file |
|
230 vector<string> m_vRomSymbolFiles; // Rom symbol file. |
|
231 string m_sOutputFile; // output file |
|
232 string m_sInputFileTemp; // temporary input file (parsed from trace) |
|
233 ifstream m_In; // Handle to input file |
|
234 // Datasaver |
|
235 CATDataSaver m_DataSaver; |
|
236 |
|
237 // Modules to be used in pinpointing |
|
238 vector<CATModule2*>* m_pModules; |
|
239 |
|
240 // Rom symbol file. |
|
241 CATRomSymbol* m_pRomSymbol; |
|
242 |
|
243 // Build type from dat. |
|
244 int m_eBuildType; |
|
245 // Build type from project. |
|
246 int m_eProjectBuildType; |
|
247 // Offset of map file. |
|
248 int m_iOffSet; |
|
249 // Platform of project. |
|
250 string m_sProjectPlatform; |
|
251 |
|
252 // Process related |
|
253 unsigned long m_iCurrentProcessId; |
|
254 string m_sCurrentProcessName; |
|
255 int m_iTotalRuns; |
|
256 int m_iSuccesfullRuns; |
|
257 |
|
258 // Leak counting related |
|
259 int m_iTotalNumberOfLeaks; |
|
260 bool m_bSubtestOnGoing; |
|
261 int m_iPinPointedLeaks; |
|
262 int m_iPinPointedSubTestLeaks; |
|
263 int m_iLeakNumber; |
|
264 |
|
265 // Handle count related |
|
266 int m_iSubtestStartHandleCount; |
|
267 vector<string> m_vHandleLeaks; |
|
268 |
|
269 // Module related |
|
270 vector<DLL_LOAD_INFO> m_vDllLoadModList; |
|
271 vector<DLL_LOAD_INFO> m_vDllLoadModListSubTest; |
|
272 |
|
273 // Sbs 1 support functions |
|
274 int FindModuleUsingAddress( unsigned long iAddress ) const; |
|
275 //int FindModuleUsingPID( unsigned long iPID ) const; |
|
276 int FindModuleUsingName( const char* pModName ); |
|
277 |
|
278 // Memory addresses |
|
279 vector<CATMemoryAddress*> m_vMemoryAddress; |
|
280 |
|
281 }; |
|
282 #endif |
|
283 //EOF |