|
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: Common defines for cpp files. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __ATCOMMONDEFINES_H__ |
|
20 #define __ATCOMMONDEFINES_H__ |
|
21 |
|
22 #include "../inc/stdafx.h" |
|
23 |
|
24 using namespace std; |
|
25 |
|
26 #define MAIN_ID "<AT>" |
|
27 #define ALLOC_ID "ALLOC" // < V.1.6 allocation. // todo remove |
|
28 #define ALLOCH_ID "ALH" // Header of multi message allocation. |
|
29 #define ALLOCF_ID "ALF" // Fragment of multi message allocation. |
|
30 #define REALLOCH_ID "RAH" // Header of multi message reallocation. |
|
31 #define REALLOCF_ID "RAF" // Fragment of multi message reallocation. |
|
32 #define FREE_ID "FREE" |
|
33 #define FREEH_ID "FRH" // Header of multi message free. |
|
34 #define FREEF_ID "FRF" // Fragment of multi message free. |
|
35 #define HANDLE_LEAK_ID "HANDLE_LEAK" |
|
36 |
|
37 const string ERROR_OCCURED = "ERR"; // Error messages. |
|
38 const string INCORRECT_ATOOL_VERSION = "INCORRECT_ATOOL_VERSION"; |
|
39 |
|
40 // if changed, change also in analyzetoolfilelog.h |
|
41 enum EMessageType{ |
|
42 EFileVersion = 0, |
|
43 EProcessStart, |
|
44 EProcessEnd, |
|
45 EThreadStart, |
|
46 EThreadEnd, |
|
47 EDllLoad, |
|
48 EDllUnload, |
|
49 EAllocH, |
|
50 EAllocF, |
|
51 EFreeH, |
|
52 EFreeF, |
|
53 EReallocH, |
|
54 EReallocF, |
|
55 ETestStart, |
|
56 ETestEnd, |
|
57 EHandleLeak, |
|
58 EDeviceInfo, |
|
59 EError |
|
60 }; |
|
61 |
|
62 /** |
|
63 * Invalid characters in trace file line content. |
|
64 * These will be filtered out before actuall parsing of line. |
|
65 10 = LF |
|
66 13 = CR |
|
67 124 = | |
|
68 */ |
|
69 const char cINVALID_TRACE_FILE_CHARS[] = { 10, 13, 124 }; |
|
70 |
|
71 /** |
|
72 * Atool return code. |
|
73 */ |
|
74 struct AT_RETURN_CODE { |
|
75 /** |
|
76 * Enumeration containing all return codes used by atool. |
|
77 * When error happens this value set as the exit code. |
|
78 * Note! Values can be only added not modified/deleted. |
|
79 */ |
|
80 enum RETURN_CODE { |
|
81 /* basic */ |
|
82 OK = 0, /** All ok. */ |
|
83 INVALID_ARGUMENT_ERROR = 1, /** Arguments failty. */ |
|
84 AT_LIBS_MISSING = 2, /** Missing at libraries cannot compile hooked apps. */ |
|
85 CANNOT_FIND_EPOCROOT = 3, /** Epocroot not set. */ |
|
86 UNHANDLED_EXCEPTION = 4, /** General return code when unhandled exception occurs. */ |
|
87 /* compile errors */ |
|
88 MAKEFILE_ERROR = 5, /** Cannot read/create etc makefiles sbs1/2. */ |
|
89 COMPILE_ERROR = 6, /** Some error related to compilation of code. */ |
|
90 UNKNOWN = 7, /** General compilation error not specific. */ |
|
91 NO_SUPPORTED_MODULES_ERROR = 8, /** Cannot find supported modules from project. */ |
|
92 KERNEL_SIDE_MODULE_ERROR = 9, /** Cannot find supported modules from project because kernel side. */ |
|
93 /* Analyze errors */ |
|
94 WRONG_DATA_FILE_VERSION = 10, /** Invalid data file version in internal gathering mode. */ |
|
95 INVALID_DATA_FILE = 11, /** Data file content invalid. */ |
|
96 ANALYZE_ERROR = 12, /** General error in analyze part not specific. */ |
|
97 EMPTY_DATA_FILE = 13, /** Data file is empty. */ |
|
98 SYMBOL_FILE_ERROR = 14, /** Symbol file content invalid or do not exist. */ |
|
99 /* building&releasing errors */ |
|
100 RELEASABLES_ERROR = 20, /** Cannot find the binaries of module. */ |
|
101 RESTORE_MODULES_ERROR = 21, /** Error restoring mmp file to original. */ |
|
102 CREATING_TEMP_CPP_ERROR = 22, /** Error creating temporary cpps to store variables to s60 core.*/ |
|
103 CLEANING_TEMP_ERROR = 23, /** Error cleaning atool_temp folder from module. */ |
|
104 READ_MAKEFILE_ERROR = 24, /** Some error when reading makefile of module / project (sbs1/2). */ |
|
105 MODIFY_MODULES_ERROR = 25, /** Error modifying module mmp file. */ |
|
106 INVALID_MMP_DEFINED = 27, /** Specified module does not exist in project. */ |
|
107 /* Attribute file related */ |
|
108 WRITE_ATTRIBUTES_ERROR = 30, /** Error writing the cfg file into atool_temp folder (contains arguments).*/ |
|
109 READ_ATTRIBUTES_ERROR = 31, /** Error reading hooking related arguments from cfg file. */ |
|
110 /* User issued exit */ |
|
111 USER_ISSUED_EXIT = 40, /** User aborted the run of application. */ |
|
112 }; |
|
113 }; |
|
114 |
|
115 // Debug logging to console |
|
116 extern bool g_bDebugConsole; |
|
117 // Debug logging to windows api debug |
|
118 extern bool g_bDebugDbgView; |
|
119 // Debug (low level functions). |
|
120 extern bool g_bDebugLowLevel; |
|
121 |
|
122 // Temporary directory definition's. |
|
123 const char AT_TEMP_DIR[] = "atool_temp"; |
|
124 const char AT_TEMP_LST_DIR[] = "atool_temp\\static_lsts\\"; |
|
125 |
|
126 // makefile dir is used in atool.cpp to check will we use sbs2 (in analyze and clear) |
|
127 #define RAPTOR_MAKEFILE_DIR "atool_temp\\build" |
|
128 |
|
129 //part of user defined filename to be replaced by process name |
|
130 const string AT_PROCESSNAME_TAG = "%processname%"; |
|
131 |
|
132 // Atool version number and date |
|
133 #define ATOOL_VERSION "1.10.0" // NOTE! This version number is written also to temporary cpp file. |
|
134 #define ATOOL_DATE "2nd July 2010" |
|
135 |
|
136 // Default/min/max call stack sizes |
|
137 const int AT_ALLOC_CALL_STACK_SIZE_DEFAULT = 40; |
|
138 const int AT_FREE_CALL_STACK_SIZE_DEFAULT = 0; |
|
139 const int AT_CALL_STACK_SIZE_MIN = 0; |
|
140 const int AT_CALL_STACK_SIZE_MAX = 256; |
|
141 |
|
142 // What version of data file contains timestamps in dll's. |
|
143 const int AT_DLL_TIMESTAMP_DATA_VERSION = 2; |
|
144 |
|
145 // Constant compatibility string in temporary cpp. |
|
146 // Api version ; current version. |
|
147 #define ATOOL_COMPATIBILITY_STRING "1.7.6;1.10.0" |
|
148 |
|
149 // Datafile version |
|
150 #define AT_DATA_FILE_VERSION "DATA_FILE_VERSION 12" |
|
151 |
|
152 // Latest dbghelp.dll version |
|
153 const int DBGHELP_VERSION_MAJ = 6; |
|
154 const int DBGHELP_VERSION_MIN = 3; |
|
155 const int DBGHELP_VERSION_BUILD = 0; |
|
156 const int DBGHELP_VERSION_REVIS = 0; |
|
157 const char DBGHELP_DLL_NAME[] = "dbghelp.dll"; |
|
158 |
|
159 |
|
160 // Build summary constants |
|
161 const string AT_BUILD_SUMMARY_HEADER = "\n### AnalyzeTool ###\n### Build Summary ###\n\n"; |
|
162 const string AT_BUILD_SUMMARY_INSTRUMENTED_BUILD_COMPLETE = "Instrumented build complete: "; |
|
163 const string AT_BUILD_SUMMARY_TARGET = "\tTarget: "; |
|
164 const string AT_BUILD_SUMMARY_FAILED = "Build failed: "; |
|
165 const string AT_BUILD_SUMMARY_ERRORS = "\tErrors: "; |
|
166 const string AT_BUILD_SUMMARY_DATA_FILE_NAME = "\tLog file name: "; |
|
167 const string AT_BUILD_SUMMARY_DATA_FILE_PATH = "\tLog file path: "; |
|
168 const string AT_BUILD_SUMMARY_NORMAL_BUILD_COMPLETE = "Normal build complete: "; |
|
169 const string AT_BUILD_SUMMARY_STATIC_LIBRARY = "\tModule is static library."; |
|
170 const string AT_BUILD_SUMMARY_UNSUPPORTED_TARGET_TYPE = "\tModule has unsupported target type."; |
|
171 const string AT_BUILD_SUMMARY_UNSUPPORTED_COMPILE_DEFINITION = "\tModule defined unsupported compile definition."; |
|
172 const string AT_BUILD_SUMMARY_BUILD_TYPE = "Build type: "; |
|
173 const string AT_BUILD_SUMMARY_BUILD_TARGET = "Build target: "; |
|
174 const string AT_BUILD_SUMMARY_BUILD_PLATFORM = "Build platform: "; |
|
175 const string AT_BUILD_SUMMARY_BUILD_VARIANT = "Build variant: "; |
|
176 const string AT_BUILD_SUMMARY_LOGGING_MODE = "Data gathering mode: "; |
|
177 const string AT_BUILD_SUMMARY_ALLOC_CALL_STACK_SIZE = "Allocation call stack size: "; |
|
178 const string AT_BUILD_SUMMARY_FREE_CALL_STACK_SIZE = "Free call stack size: "; |
|
179 const string AT_BUILD_SUMMARY_FILE = "log to file"; |
|
180 const string AT_BUILD_SUMMARY_TRACE = "monitored external"; |
|
181 const string AT_BUILD_SUMMARY_TRACE_FAST = "output to trace"; |
|
182 |
|
183 const string AT_UNSUPPORTED_TARGET_TYPE = "\tModule has unsupported target type."; |
|
184 const string AT_UNSUPPORTED_COMPILE_DEFINITION = "\tModule defined unsupported compile definition."; |
|
185 |
|
186 // List of locations under epocroot where analyzetool.h can be found. |
|
187 // Add all possible to this list so core version information can be read |
|
188 // from file. |
|
189 const string AT_CORE_INCLUDE_FILE_WITH_VERSION_NUMBER[] = { |
|
190 "epoc32\\include\\domain\\osextensions\\analyzetool\\analyzetool.h", |
|
191 "epoc32\\include\\oem\\analyzetool\\analyzetool.h", |
|
192 "epoc32\\include\\platform\\analyzetool\\analyzetool.h" |
|
193 }; |
|
194 const string AT_CORE_VERSION_NUMBER_TAG = "ANALYZETOOL_CORE_VERSION_FOR_CLE"; |
|
195 |
|
196 // Temporary cpp name |
|
197 const char AT_TEMP_CPP_LOWER_START[] = "0a1b2c3d_atool_temp_"; |
|
198 const char AT_TEMP_CPP_LOWER_END[] = ".cpp"; |
|
199 |
|
200 const char TAB_CHAR_VALUE = 9; |
|
201 const char SPACE_CHAR_VALUE = 32; |
|
202 |
|
203 // Bldmake error msg |
|
204 #define AT_BLDMAKE_ERROR "AnalyzeTool : bldmake bldfiles error.\n" |
|
205 |
|
206 // File copy/move/etc... message definitions |
|
207 #define AT_MSG "AnalyzeTool : " |
|
208 #define AT_MSG_SYSTEM_CALL "AnalyzeTool : System call, " |
|
209 #define AT_FILE_TO " to " |
|
210 |
|
211 // -c messages |
|
212 #define AT_CLEANING_DONE "AnalyzeTool : Cleaning done." |
|
213 #define AT_CLEANING_NOTHING_FOUND "AnalyzeTool : Nothing found to clean." |
|
214 |
|
215 // Analyzing data without process start or dll load |
|
216 #define AT_ANALYZE_INSUFFICIENT_LOGGING_DATA "Insufficient logging data to locate code lines for memory addresses.\nLogging has been started after process start." |
|
217 #define AT_ANALYZE_NO_PROCESS_START "AnalyzeTool : No processes start information found in test run data." |
|
218 #define AT_ANALYZE_NO_DLL_LOAD "AnalyzeTool : No dll load information found in test run data." |
|
219 #define AT_ANALYZE_CANNOT_PINPOINT "AnalyzeTool : Memory addresses cannot be pinpointed." |
|
220 #define AT_ANALYZE_ABNORMAL_EXIT "Abnormal process end" |
|
221 |
|
222 // Analyzing without map / lst files |
|
223 #define AT_ANALYZE_MISSING_LST_MAP_FILES "AnalyzeTool : Missing lst or map files, memory addresses shown only to module level.\n" |
|
224 //#define AT_UNINSTRUMENT_FAILED_IN_ANALYZE_MESSAGE "AnalyzeTool: Error creating map/lst files, leaks shown only to module level.\nRun atool -u to try create lst/map files again after binaries build successfully.\n" |
|
225 |
|
226 // Mmp error msg |
|
227 #define INVALID_MMP_ERROR "AnalyzeTool : Error, Specified mmp is invalid.\n" |
|
228 |
|
229 // Make error msg |
|
230 #define MAKE_ERROR "AnalyzeTool : Error, Running make.\n" |
|
231 |
|
232 #define AT_NOT_BEEN_BUILD_ERROR "AnalyzeTool : Error, project has not been build using AnalyzeTool.\n" |
|
233 |
|
234 // Makefile errors |
|
235 #define LEVEL1_MAKEFILE_ERROR "AnalyzeTool : Error, reading level 1 makefile.\n" |
|
236 #define LEVEL2_MAKEFILE_ERROR "AnalyzeTool : Error, reading level 2 makefile.\n" |
|
237 #define MAKEFILE_ERROR_TIP "AnalyzeTool : Tip, your environment might require you to use -variant [target] argument.\n"; |
|
238 |
|
239 //Variant messages |
|
240 #define INVALID_VARIANT_ERROR "AnalyzeTool : Error,Specified variant is invalid.\n" |
|
241 #define USING_DEFAULT_VARIANT_MESSAGE "AnalyzeTool : Note, Using DEFAULT variant.\n" |
|
242 #define NO_DEFAULT_VARIANT_ERROR "AnalyzeTool : Error, environment does not specify DEFAULT variant (No variant support?).\n" |
|
243 |
|
244 // Variant dir is the dir where all variants are defined |
|
245 #define VARIANT_DIR "\\epoc32\\tools\\variant\\" |
|
246 |
|
247 // Variants defined extension name of the variant must equal filename |
|
248 #define VARIANT_FILE_EXTENSION ".VAR" |
|
249 |
|
250 //Max file name length |
|
251 const int MAX_FILENAME_LENGTH = 1024; |
|
252 |
|
253 //Max line length when reading lines from text file.2048 should be enought. |
|
254 const int MAX_LINE_LENGTH = 2048*8; |
|
255 |
|
256 // ATs project file name to store project attributes |
|
257 #define AT_PROJECT_ATTRIBUTES_FILE_NAME "project.cfg" |
|
258 const string AT_PROJECT_ATTRIBUTES_SEPARATOR( ":$:" ); |
|
259 |
|
260 // ATs level1 makefile name |
|
261 #define AT_LEVEL_1_MAKEFILE_NAME "main.at" |
|
262 |
|
263 // ATs level2 makefiles extension |
|
264 #define AT_LEVEL_2_MAKEFILE_EXT "atm" |
|
265 |
|
266 //Default logging level |
|
267 const int DEFAULT_LOGGING_LEVEL = 3; |
|
268 |
|
269 //Minimun value of logging level |
|
270 const int MIN_LOGGING_LEVEL = 0; |
|
271 |
|
272 //Maximun value of logging level |
|
273 const int MAX_LOGGING_LEVEL = 3; |
|
274 |
|
275 //Const char represeting dash |
|
276 const char DASH = '\\'; |
|
277 |
|
278 /** |
|
279 * Table of file extension not to delete |
|
280 * from atools temp directory when compiling |
|
281 * note define all in lowercase |
|
282 */ |
|
283 const string TEMP_EXTENSION_NO_DELETE[] = { |
|
284 "xml", |
|
285 "dat", |
|
286 "tmp", |
|
287 "cpp", |
|
288 "at", |
|
289 "atm", |
|
290 "cfg" |
|
291 }; |
|
292 |
|
293 // Allowed characters/digits, other than these will be filtered out when using CATBase FilterString |
|
294 const char CFILTERSTRING[] = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_"; |
|
295 |
|
296 /** |
|
297 * Table of unsupported target types |
|
298 * (i.e. mmp file syntax targettype in makefile) |
|
299 * List of target types which will not be hooked: |
|
300 */ |
|
301 const string UNSUPPORTED_TARGET_TYPES[] = { |
|
302 "CTL", |
|
303 "ECOMIIC", |
|
304 "IMPLIB", |
|
305 "KDLL", |
|
306 "KEXT", |
|
307 "KLIB", |
|
308 "LDD", |
|
309 /* "LIB", currently have own vector in project.*/ |
|
310 "MDA", |
|
311 "MDL", |
|
312 "NONE", |
|
313 "NOTIFIER", |
|
314 "PDD", |
|
315 "RDL", |
|
316 "STDLIB", |
|
317 "VAR" |
|
318 }; |
|
319 |
|
320 /** |
|
321 * Kernel side target types |
|
322 */ |
|
323 const string KERNEL_SIDE_TARGET_TYPES[] = { |
|
324 "VAR", |
|
325 "LDD", |
|
326 "PDD", |
|
327 "KEXT" |
|
328 }; |
|
329 |
|
330 // Kernel mode compile definition |
|
331 const string KERNEL_MODE_COMPILE_DEFINITION = "__KERNEL_MODE__"; |
|
332 |
|
333 /** |
|
334 * MMP file changes for AT |
|
335 * Note "SOURCE 0a1b2c3d_atool_temp_TARGET.cpp" is added also. |
|
336 */ |
|
337 const string MMPFILECHANGES[] = { |
|
338 "//*** AnalyzeTool changes start ***", |
|
339 "SOURCEPATH atool_temp", |
|
340 "LIBRARY AToolMemoryHook.lib", |
|
341 "STATICLIBRARY AToolStaticLib.lib", |
|
342 "OPTION ARMCC --interleave", |
|
343 "//*** AnalyzeTool changes end ***" |
|
344 }; |
|
345 |
|
346 //MMP file changes for AT |
|
347 //For targettype Dll |
|
348 const string MMPFILECHANGES_DLL[] = { |
|
349 "//*** AnalyzeTool changes start ***", |
|
350 "OPTION ARMCC --interleave", |
|
351 "//*** AnalyzeTool changes end ***" |
|
352 }; |
|
353 |
|
354 // Trace file constants definitions |
|
355 #define LABEL_DATA_FILE_VERSION "DATA_FILE_VERSION" |
|
356 #define LABEL_PROCESS_START "PCS" |
|
357 #define LABEL_DLL_LOAD "DLL" |
|
358 #define LABEL_DLL_UNLOAD "DLU" |
|
359 #define LABEL_MEM_LEAK "MEM_LEAK" |
|
360 #define LABEL_PROCESS_END "PCE" |
|
361 #define LABEL_ERROR_OCCURED "ERR" |
|
362 #define LABEL_HANDLE_LEAK "HDL" |
|
363 #define LABEL_TEST_START "TSS" |
|
364 #define LABEL_TEST_END "TSE" |
|
365 #define LABEL_THREAD_START "TDS" |
|
366 #define LABEL_THREAD_END "TDE" |
|
367 #define LABEL_DEVICE_INFO "DEVINFO" |
|
368 #define LABEL_LOGGING_CANCELLED "LOGGING_CANCELLED" |
|
369 |
|
370 |
|
371 // AddressToLine related constants |
|
372 |
|
373 #define LABEL_ABNORMAL "ABNORMAL" |
|
374 const int FUNCTIONS_OFFSET_IN_MAP_FILE_ARMV5 = 0x8000; |
|
375 const int FUNCTIONS_OFFSET_IN_GCCE = 0x8000; |
|
376 const int FUNCTIONS_OFFSET_IN_MAP_FILE_WINSCW = 0x400000; |
|
377 #define TEXT_NO_HANDLE_LEAKS "No handle leaks." |
|
378 |
|
379 // Make file constant labels |
|
380 #define MAKEFILE_TARGETTYPE_STRING "# TargetType " |
|
381 #define MAKEFILE_BASIC_TARGETTYPE_STRING "# BasicTargetType " |
|
382 #define MAKEFILE_TARGET_STRING "# Target " |
|
383 #define MAKEFILE_FEATURE_VARIANT_NAME "# FeatureVariantName " |
|
384 #define MAKEFILE_FEATURE_VARIANT_UREL_LABEL "# FeatureVariantURELLabel " |
|
385 #define MAKEFILE_FEATURE_VARIANT_UDEB_LABEL "# FeatureVariantUDEBLabel " |
|
386 #define UDEB_OPTIMIZATION_LEVEL 0 |
|
387 |
|
388 // Listing file contant labels |
|
389 #define LST_FILE_SOURCE_FILE_LABEL "Source file:" |
|
390 |
|
391 /** |
|
392 * Struct for saving module info from .dat file and number of leaks in module. |
|
393 */ |
|
394 struct DLL_LOAD_INFO |
|
395 { |
|
396 string sModuleName; /** name of the code segment/binary */ |
|
397 unsigned long iStartAddress; /** start address of code segment (in memory) */ |
|
398 unsigned long iEndAddress; /** end address of code segment (in memory) */ |
|
399 int iLeaks; /** leak count in this code segment */ |
|
400 unsigned long iPID; /** process id which loaded this code segment */ |
|
401 int iSubTestStartOpenHandles; /** open handle count when sub test started */ |
|
402 int iSubTestEndOpenHandles; /** open handle count when sub test ended */ |
|
403 // Load/Unload times, note these are micro seconds from 1970 so size is huge. |
|
404 unsigned long long iLoadTime; /** code segment load time */ |
|
405 unsigned long long iUnloadTime; /** code segment unload time */ |
|
406 /** |
|
407 * Default constructor to set default values |
|
408 */ |
|
409 DLL_LOAD_INFO() { |
|
410 iStartAddress = 0; |
|
411 iEndAddress = 0; |
|
412 iLeaks = 0; |
|
413 iPID = 0; |
|
414 iSubTestStartOpenHandles = 0; |
|
415 iSubTestEndOpenHandles = 0; |
|
416 iLoadTime = 0; |
|
417 iUnloadTime = 0; |
|
418 }; |
|
419 }; |
|
420 |
|
421 /** |
|
422 * Struct for saving symbol information from listing file |
|
423 */ |
|
424 struct LINE_IN_FILE |
|
425 { |
|
426 int iLine; /** line number */ |
|
427 string sFileName; /** filename */ |
|
428 string sFunction; /** function / symbol */ |
|
429 string sMangledName; /** function / symbol name in mangled / coded form */ |
|
430 string sLstName; /** listing filename */ |
|
431 }; |
|
432 |
|
433 /** |
|
434 * Struct for saving symbol information from map file |
|
435 */ |
|
436 struct MAP_FUNC_INFO |
|
437 { |
|
438 int iAddress; /** memory address (start of symbol) */ |
|
439 int iFuncLength; /** symbol length */ |
|
440 string sMangledName;/** symbol name in mangled / coded form */ |
|
441 string sWholeLine; /** whole symbol line from map file */ |
|
442 string sFunctionName; /** symbol clear name */ |
|
443 }; |
|
444 |
|
445 /** |
|
446 * State that represents the outcome |
|
447 * of locating memory address code line from module |
|
448 */ |
|
449 enum ADDRESS_TO_LINE_STATE { |
|
450 no_map_data = 0, /** Map data was missing */ |
|
451 out_of_function_range, /** Could not locate it to any function */ |
|
452 mangled_symbol_name, /** symbol name but mangled / coded form */ |
|
453 only_function_name, /** Only got function name not code line */ |
|
454 succesfull /** Have line number, function, etc...*/ |
|
455 }; |
|
456 |
|
457 /** |
|
458 * Struct to store detail data and state when |
|
459 * locating memory addresses code lines |
|
460 */ |
|
461 struct ADDRESS_TO_LINE_ITEM { |
|
462 ADDRESS_TO_LINE_STATE eState; /** outcome */ |
|
463 string sFileName; /** Filename of address */ |
|
464 string sFunctionName; /** Function name of address */ |
|
465 string sMangledFunctionName; /** function/Symbol name */ |
|
466 int iFunctionLineNumber; /** Functions line number */ |
|
467 int iExactLineNumber; /** Exact line number of address */ |
|
468 }; |
|
469 |
|
470 /** |
|
471 * Struct to store memory leaks |
|
472 * call stack entry data |
|
473 */ |
|
474 struct CALL_STACK_ITEM { |
|
475 string sAddress; /** Address in string */ |
|
476 int iAddress; /** Address in number (converted)*/ |
|
477 int iLocation; /** Location. i.e. corresponds m_vDllLoadModList's index*/ |
|
478 int iCalculatedLeakAddress; /** calculated address from code segment start */ |
|
479 bool bBuildUdeb; /** Optimization level */ |
|
480 string sModuleName; /** Modules name were leak is*/ |
|
481 ADDRESS_TO_LINE_ITEM addressToLine; /** Data from locating code line for memory address */ |
|
482 }; |
|
483 |
|
484 /** |
|
485 * Enumerations used in argument structure. |
|
486 */ |
|
487 enum MAIN_SWITCH |
|
488 { |
|
489 SWITCH_UNKNOWN = 0, /** not defined */ |
|
490 SWITCH_ANALYZE = 1, /** analyze */ |
|
491 SWITCH_HOOK = 2, /** compile/instrument */ |
|
492 SWITCH_UNHOOK = 3, /** uninstrument */ |
|
493 SWITCH_PARSE_TRACE = 5, /** parse raw data */ |
|
494 SWITCH_CLEAN = 6, /** clean AT changes */ |
|
495 SWITCH_VERSION = 9, /** display version infromation */ |
|
496 SWITCH_HELP = 10, /** show help with syntax examples */ |
|
497 SWITCH_DBGHELP_VERSION = 11 |
|
498 }; |
|
499 |
|
500 /** |
|
501 * Enumeration used when hooking project. |
|
502 */ |
|
503 enum HOOK_SWITCH |
|
504 { |
|
505 HOOK_UNKNOWN = 0, /** not defined */ |
|
506 HOOK_INTERNAL, /** monitored internal data gathering */ |
|
507 HOOK_EXTERNAL, /** monitored external data gathering */ |
|
508 HOOK_EXTERNAL_FAST, /** external data gathering */ |
|
509 HOOK_EXTENSION_INTERNAL, /** Extension call, monitored internal data gathering */ |
|
510 HOOK_EXTENSION_EXTERNAL, /** Extension call, monitored external data gathering */ |
|
511 HOOK_EXTENSION_EXTERNAL_FAST, /** Extension call, external data gathering */ |
|
512 HOOK_EXTENSION_UNINSTRUMENT, /** Extension call, uninstrument (post-build)*/ |
|
513 HOOK_EXTENSION_FAILED, /** Extension call, build failed, cleanup */ |
|
514 HOOK_OLD_EXTENSION_INSTRUMENT, /** Old extension call, instrument project */ |
|
515 HOOK_OLD_EXTENSION_UNINSTRUMENT, /** Old extension call, uninstrument project */ |
|
516 HOOK_OLD_EXTENSION_FAILED /** Old extension call, cleanup */ |
|
517 }; |
|
518 |
|
519 /** |
|
520 * Represents hooking parameters, these are set |
|
521 * by the user arguments from command line. |
|
522 */ |
|
523 struct ARGUMENTS_HOOK |
|
524 { |
|
525 bool bNoBuild; /** Only intrument project? (no build) */ |
|
526 bool bDataFileName; /** Is internal data gathering filename defined */ |
|
527 bool bDataFilePath; /** Is internal data gathering file path defined */ |
|
528 bool bAbldTest; /** Is build only for test modules (abld test build.. */ |
|
529 string sDataFileName; /** Internal data gathering filename */ |
|
530 string sDataFilePath; /** Path to internal data gathering file */ |
|
531 int iBuildSystem; /** 1 = sbs, 2 = raptor */ |
|
532 int iLoggingMode; /** Just for old parameter parsing. 1=trace, 2=file, 0=? */ |
|
533 int iAllocCallStackSize; /** Call stack size when memory allocated */ |
|
534 int iFreeCallStackSize; /** Call stack size when memory freed */ |
|
535 string sBuildCmd; /** Original build command / user defined or given */ |
|
536 vector<string> vBuildCmd; /** Build command split in vector */ |
|
537 string sPlatform; /** Build platform */ |
|
538 string sBuildType; /** Build type (udeb/urel) */ |
|
539 string sFeatureVariant; /** Build variant defined */ |
|
540 vector<string> vTargetPrograms; /** User defined single or multiple modules from project? */ |
|
541 /** |
|
542 * Default constructor to set default values. |
|
543 */ |
|
544 ARGUMENTS_HOOK() |
|
545 { |
|
546 bNoBuild = false; |
|
547 bAbldTest = false; |
|
548 bDataFileName = false; |
|
549 bDataFilePath = false; |
|
550 sDataFileName = ""; |
|
551 sDataFilePath = ""; |
|
552 iBuildSystem = 0; |
|
553 iLoggingMode = 0; |
|
554 iAllocCallStackSize = AT_ALLOC_CALL_STACK_SIZE_DEFAULT; |
|
555 iFreeCallStackSize = AT_FREE_CALL_STACK_SIZE_DEFAULT; |
|
556 sBuildCmd = ""; |
|
557 sPlatform = ""; |
|
558 sBuildType = ""; |
|
559 sFeatureVariant = ""; |
|
560 vTargetPrograms.clear(); |
|
561 }; |
|
562 }; |
|
563 |
|
564 /** |
|
565 * Represents analyze parameters, these are set |
|
566 * by the user arguments from command line. |
|
567 */ |
|
568 struct ARGUMENTS_ANALYZE |
|
569 { |
|
570 string sDataFile; /** Data file to be analyzed */ |
|
571 string sOutputFile; /** Output file */ |
|
572 bool bSymbolFile; /** Is rom/rofs symbol file(s) defined? */ |
|
573 vector<string> vSymbolFiles; /** Collection of symbol files */ |
|
574 int iLoggingLevel; /** Logging level of report */ |
|
575 /** |
|
576 * Default constructor to set default values. |
|
577 */ |
|
578 ARGUMENTS_ANALYZE() |
|
579 { |
|
580 sDataFile = ""; |
|
581 sOutputFile = ""; |
|
582 bSymbolFile = false; |
|
583 iLoggingLevel = 3; |
|
584 }; |
|
585 }; |
|
586 |
|
587 /** |
|
588 * Represents raw trace parsing parameters, these are set |
|
589 * by the user arguments from command line. |
|
590 */ |
|
591 struct ARGUMENTS_PARSE |
|
592 { |
|
593 bool bDataFile; /** Is raw data file defined */ |
|
594 string sDataFile; /** Raw data file (input) */ |
|
595 bool bOutputFile; /** Is output file defined */ |
|
596 string sOutputFile; /** Output (AT specific data file)*/ |
|
597 /** |
|
598 * Default constructor to set default values. |
|
599 */ |
|
600 ARGUMENTS_PARSE() |
|
601 { |
|
602 bDataFile = false; |
|
603 sDataFile = ""; |
|
604 bOutputFile = false; |
|
605 sOutputFile = ""; |
|
606 }; |
|
607 }; |
|
608 |
|
609 |
|
610 /** |
|
611 * Represents main parameters, these are set |
|
612 * by the user arguments from command line. |
|
613 */ |
|
614 struct ARGUMENTS |
|
615 { |
|
616 // Base arguments. |
|
617 MAIN_SWITCH eMainSwitch; /** mandatory/main parameter */ |
|
618 HOOK_SWITCH eHookSwitch; /** if compile/instrument its "mode" */ |
|
619 bool bHelp; /** show help? */ |
|
620 bool bDebugConsole; /** enable debug logging to console? */ |
|
621 bool bDebugDbgView; /** enable debug logging to win api? */ |
|
622 bool bDebugLowLevel; /** enable debug logging for also low level functions? */ |
|
623 bool bEnableSbs2; /** use raptor as build system? */ |
|
624 ARGUMENTS_HOOK HOOK; /** hooking/instrument/compiling attributes */ |
|
625 ARGUMENTS_ANALYZE ANALYZE; /** analyze related attributes */ |
|
626 ARGUMENTS_PARSE PARSE; /** parsing related attributes */ |
|
627 /** |
|
628 * Default constructor to set default values. |
|
629 */ |
|
630 ARGUMENTS() |
|
631 { |
|
632 eMainSwitch = SWITCH_UNKNOWN; |
|
633 eHookSwitch = HOOK_UNKNOWN; |
|
634 bHelp = false; |
|
635 bDebugConsole = false; |
|
636 bDebugDbgView = false; |
|
637 bEnableSbs2 = false; |
|
638 }; |
|
639 }; |
|
640 |
|
641 // DEBUG MACROS |
|
642 // constant string for all beginning of all debug messages |
|
643 const char START_LOG_MESSAGE[] = "*** CLE "; |
|
644 // Log normal function entry (AAA = class::function ) |
|
645 #define LOG_FUNC_ENTRY( AAA ) { if( g_bDebugDbgView) { stringstream strs; strs << START_LOG_MESSAGE << "ENTRY: " << AAA << endl; OutputDebugString( strs.str().c_str() ); } else if ( g_bDebugConsole ) { stringstream strs; strs << START_LOG_MESSAGE << "ENTRY: " << AAA << endl; cout << strs.str(); } } |
|
646 // Log normal function exit |
|
647 #define LOG_FUNC_EXIT( AAA ){ if( g_bDebugDbgView) { stringstream strs; strs << START_LOG_MESSAGE << "EXIT: " << AAA << endl; OutputDebugString( strs.str().c_str() ); } else if ( g_bDebugConsole ) { stringstream strs; strs << START_LOG_MESSAGE << "EXIT: " << AAA << endl; cout << strs.str(); } } |
|
648 // Log low level function entry |
|
649 #define LOG_LOW_FUNC_ENTRY( AAA ) { if ( g_bDebugLowLevel ) { if( g_bDebugDbgView) { stringstream strs; strs << START_LOG_MESSAGE << AAA << endl; OutputDebugString( strs.str().c_str() ); } else if ( g_bDebugConsole ) { stringstream strs; strs << START_LOG_MESSAGE << AAA << endl; cout << strs.str(); } } } |
|
650 // Log low level function exit |
|
651 #define LOG_LOW_FUNC_EXIT( AAA ) { if ( g_bDebugLowLevel ) { if( g_bDebugDbgView) { stringstream strs; strs << START_LOG_MESSAGE << AAA << endl; OutputDebugString( strs.str().c_str() ); } else if ( g_bDebugConsole ) { stringstream strs; strs << START_LOG_MESSAGE << AAA << endl; cout << strs.str(); } } } |
|
652 // Log stringstream (string, int, etc..) i.e. string1 << int1 << "log this" |
|
653 #define LOG_STRING( AAA ) { if( g_bDebugDbgView) { stringstream strs; strs << START_LOG_MESSAGE << AAA << endl; OutputDebugString( strs.str().c_str() ); } else if ( g_bDebugConsole ) { stringstream strs; strs << START_LOG_MESSAGE << AAA << endl; cout << strs.str(); } } |
|
654 |
|
655 #endif |