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