|
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: Class representing a module in project (sbs2). |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __CATMODULE2_H__ |
|
20 #define __CATMODULE2_H__ |
|
21 |
|
22 // Includes. |
|
23 #include "ATCommonDefines.h" |
|
24 #include "CATBase.h" |
|
25 #include "CATMmp.h" |
|
26 |
|
27 // Forward declarations. |
|
28 class CATMemoryAddress; |
|
29 class IAddressToLine; |
|
30 |
|
31 /** |
|
32 * CATModule2 represents a module/component (single binary) in project. |
|
33 * CATProject contains a collection of these. |
|
34 */ |
|
35 class CATModule2 : public CATBase |
|
36 { |
|
37 |
|
38 public: |
|
39 /** |
|
40 * Constructor. |
|
41 */ |
|
42 CATModule2(void); |
|
43 |
|
44 /** |
|
45 * Destructor. |
|
46 */ |
|
47 ~CATModule2(void); |
|
48 |
|
49 /** |
|
50 * Read modules attributes from SBS v.1 makefile. |
|
51 * Also copies makefile to temporary directory if successful. |
|
52 */ |
|
53 bool ReadMakeFile(); |
|
54 |
|
55 /** |
|
56 * Read modules attributes from SBS v.1 makefile. |
|
57 * From make file which is in modules temporary directory. |
|
58 */ |
|
59 bool ReadMakeFileFromTemp(); |
|
60 |
|
61 /** |
|
62 * Add sources using line where source files separated by spaces. |
|
63 * @param sSourceLine. |
|
64 */ |
|
65 void AddSources(string& sSourceLine); |
|
66 |
|
67 /** |
|
68 * Add sources by giving source file and its corresponding listing file. |
|
69 * @param sSourceFile |
|
70 * @param sLstFile |
|
71 */ |
|
72 void AddSource(const string& sSourceFile, const string& sLstFile); |
|
73 |
|
74 /** |
|
75 * Create AT temporary cpp file for module. |
|
76 * @param sS60FileName. |
|
77 * @param sS60FileName. |
|
78 * @param eLoggingMode. |
|
79 * @param eBuildType. |
|
80 * @param iAllocCallStackSize. |
|
81 * @param iFreeCallStackSize. |
|
82 * @return true if successful. |
|
83 */ |
|
84 bool CreateTempCpp(const string& sS60FileName |
|
85 , const string& sS60FilePath |
|
86 , int eLoggingMode |
|
87 , int eBuildType |
|
88 , int iAllocCallStackSize |
|
89 , int iFreeCallStackSize ); |
|
90 |
|
91 /** |
|
92 * returns default data file name without extension in format processName.targetType |
|
93 * @return string with default file name |
|
94 */ |
|
95 string GetDefaultFileName(); |
|
96 |
|
97 /** |
|
98 * Add AT changes to modules mmp file. |
|
99 * @return true if successful. |
|
100 */ |
|
101 bool ModifyMmp(); |
|
102 |
|
103 /** |
|
104 * Restore any changes made to modules mmp file. |
|
105 * @return true if successful. |
|
106 */ |
|
107 bool RestoreMmp(); |
|
108 |
|
109 /** |
|
110 * Verify tha mmp does not contain AnalyzeTool made changes. |
|
111 * If it does contain them will remove them manually or using backup. |
|
112 * @return true if successful. |
|
113 */ |
|
114 bool VerifyAndRecoverMmp(); |
|
115 |
|
116 /** |
|
117 * Copy modules releasables to its temporary dir. |
|
118 * This includes map & lst files. |
|
119 * @return true if successful. |
|
120 */ |
|
121 bool CopyReleasables(); |
|
122 |
|
123 /** |
|
124 * Copy modules listing files to given directory. |
|
125 * After copy they will be deleted. |
|
126 * @param sDir target directory. |
|
127 * @return true if successful. |
|
128 */ |
|
129 bool CopyLstFilesToDir( const string& sDir ); |
|
130 |
|
131 /** |
|
132 * Delete modules lst files from their source |
|
133 * directories. |
|
134 * @return true if succesfful. |
|
135 */ |
|
136 bool DeleteLstFilesFromSrc(); |
|
137 |
|
138 /** |
|
139 * Clean modules temporary directory of files, |
|
140 * not defined in UNDELETE list. |
|
141 * @return true if successful |
|
142 */ |
|
143 bool CleanTemporaryDir(); |
|
144 |
|
145 /** |
|
146 * Delete modules temporary directory. |
|
147 * @return true if successful. |
|
148 */ |
|
149 bool DeleteTemporaryDir(); |
|
150 |
|
151 /** |
|
152 * Locate codeline of given memory address. |
|
153 * Given address must be calculated to correspond map file addresses. |
|
154 * @param pMemoryAddress object where to store results. |
|
155 * @return true if successful. |
|
156 */ |
|
157 bool AddressToLine(CATMemoryAddress* pMemoryAddress); |
|
158 |
|
159 /** |
|
160 * Check does modules symbol file(s) exist. |
|
161 * @return true if it exists. |
|
162 */ |
|
163 bool SymbolFileExist( void ); |
|
164 |
|
165 /** |
|
166 * Check does modules map file(s) exists. |
|
167 * @return true if it exists. |
|
168 */ |
|
169 bool MapFileExist( void ); |
|
170 |
|
171 /** |
|
172 * Check does modules binary file(s) exist. |
|
173 * @return true if it exists. |
|
174 */ |
|
175 bool BinaryFileExist( void ); |
|
176 |
|
177 #ifndef MODULE_TEST |
|
178 private: |
|
179 #endif |
|
180 |
|
181 /** |
|
182 * Read modules attributes from make file. |
|
183 */ |
|
184 bool ReadMakeFilePrivate(); |
|
185 |
|
186 /** |
|
187 * Locate codeline of given memory address (winscw platform). |
|
188 * Given address must be calculated to correspond map file addresses. |
|
189 * @param pMemoryAddress object where to store results. |
|
190 * @return true if successful. |
|
191 */ |
|
192 bool AddressToLineWinscw(CATMemoryAddress* pMemoryAddress ); |
|
193 |
|
194 /** |
|
195 * Locate codeline of given memory address (armv5 platform). |
|
196 * Given address must be calculated to correspond map file addresses. |
|
197 * @param pMemoryAddress object where to store results. |
|
198 * @return true if successful. |
|
199 */ |
|
200 bool AddressToLineArmv5(CATMemoryAddress* pMemoryAddress ); |
|
201 |
|
202 /** |
|
203 * Locate codeline of given memory address. |
|
204 * Given address must be calculated to correspond map file addresses. |
|
205 * @param pMemoryAddress object where to store results. |
|
206 * @return true if successful. |
|
207 */ |
|
208 bool AddressToLineAddr2lineExe( CATMemoryAddress* pMemoryAddress ); |
|
209 |
|
210 /** |
|
211 * Search map file data (symbols) using given address. |
|
212 * @param iAddress memory address. |
|
213 * @return index of the symbol or -1 if not found. |
|
214 */ |
|
215 int GetSymbolIndexUsingAddress(unsigned long iAddress) const; |
|
216 |
|
217 /** |
|
218 * Search listing files data using the given symbol name. |
|
219 * @param sSymbolName symbols name to find. |
|
220 * @return index of the found lst data or -1 if not found. |
|
221 */ |
|
222 int GetLineInFileIndexUsingSymbolName(const string& sSymbolName) const; |
|
223 |
|
224 /** |
|
225 * Search the exact code line from given file. |
|
226 * @param sFileName listing file to search from. |
|
227 * @param iLine functions line number. |
|
228 * @param iFromFuncAddress how many bytes from functions start. |
|
229 * @return line number or -1 if not found. |
|
230 */ |
|
231 int FindLeakCodeLine( string& sFileName, int iLine, unsigned long iFromFuncAddress ) const; |
|
232 |
|
233 public: |
|
234 |
|
235 /** |
|
236 * Set used build system (CATProject::BUILD_SYSTEM). |
|
237 * @param eBuildSystem. |
|
238 */ |
|
239 void SetBuildSystem( int eBuildSystem ); |
|
240 |
|
241 /** |
|
242 * Get defined build system. |
|
243 * @return int CATProject::BUILD_SYSTEM |
|
244 */ |
|
245 int GetBuildSystem( void ) const ; |
|
246 |
|
247 /** |
|
248 * Set SBS v.1 makefile. |
|
249 * @param sMakeFile |
|
250 */ |
|
251 void SetMakeFile( const string& sMakeFile ); |
|
252 |
|
253 /** |
|
254 * Get SBS v.1 makefile. |
|
255 * @return string makefile. |
|
256 */ |
|
257 string GetMakeFile( void ) const; |
|
258 |
|
259 /** |
|
260 * Initialize module ready for locating code lines. |
|
261 * with memory addresses (reads map and listing files). |
|
262 * return true if successful. |
|
263 */ |
|
264 bool InitializeAddressToLine(); |
|
265 |
|
266 /** |
|
267 * Set modules mmp file. |
|
268 * This also creates temporary dir if it is missing. |
|
269 * @return true if successful. |
|
270 */ |
|
271 bool SetMmpFile(const string& sMmpFile); |
|
272 |
|
273 /** |
|
274 * Create modules own temporary directory. |
|
275 * @return true if successful. |
|
276 */ |
|
277 bool CreateTemporaryDirectory(); |
|
278 |
|
279 /** |
|
280 * Get modules mmp file. |
|
281 * @return mmp file. |
|
282 */ |
|
283 string GetMmpFile() const; |
|
284 |
|
285 /** |
|
286 * Get modules atool_temp directory path. |
|
287 * @return atool_temp directory path. |
|
288 */ |
|
289 string GetTempPath() const; |
|
290 |
|
291 /** |
|
292 * Get S60 logging file name. |
|
293 * @return s60 logging file name. |
|
294 */ |
|
295 string GetS60FileName() const; |
|
296 |
|
297 /** |
|
298 * Set S60 logging file name. |
|
299 * @param aFileName s60 logging file name. |
|
300 */ |
|
301 void SetS60FileName( const string& aFileName ); |
|
302 |
|
303 /** |
|
304 * Set target binary name. |
|
305 * @param sTarget binary file name. |
|
306 */ |
|
307 void SetTarget(const string& sTarget); |
|
308 |
|
309 /** |
|
310 * Get target binary name. |
|
311 * @return modules binary file name. |
|
312 */ |
|
313 string GetTarget() const; |
|
314 |
|
315 /** |
|
316 * Set binary target type. |
|
317 * @param sTargetType binary target type. |
|
318 */ |
|
319 void SetTargetType(const string& sTargetType); |
|
320 |
|
321 /** |
|
322 * Get binary target type. |
|
323 * @return binary target type. |
|
324 */ |
|
325 string GetTargetType() const; |
|
326 |
|
327 /** |
|
328 * Set requested binary target file extension. |
|
329 * @param sRequestedTargetExt binary target file extension. |
|
330 */ |
|
331 void SetRequestedTargetExt( const string& sRequestedTargetExt ); |
|
332 |
|
333 /** |
|
334 * Get requested binary target file extension. |
|
335 * @return binary target file extension. |
|
336 */ |
|
337 string GetRequestedTargetExt() const; |
|
338 |
|
339 /** |
|
340 * Get full name of modules binary. |
|
341 * @return modules binary files full name. |
|
342 */ |
|
343 string GetBinaryName() const; |
|
344 |
|
345 /** |
|
346 * Set variant platform. |
|
347 * @param sVariantPlatform variant platform. |
|
348 */ |
|
349 void SetVariantPlatform(const string& sVariantPlatform); |
|
350 |
|
351 /** |
|
352 * Get variant platform. |
|
353 * @return variant platform. |
|
354 */ |
|
355 string GetVariantPlatform() const; |
|
356 |
|
357 /** |
|
358 * Set variant type. |
|
359 * @param sVariantType variant type. |
|
360 */ |
|
361 void SetVariantType(const string& sVariantType); |
|
362 |
|
363 /** |
|
364 * Get variant type. |
|
365 * @return variant type. |
|
366 */ |
|
367 string GetVariantType() const; |
|
368 |
|
369 /** |
|
370 * Set feature variant. |
|
371 * @param sFeatureVariant feature variant. |
|
372 */ |
|
373 void SetFeatureVariant(const string& sFeatureVariant); |
|
374 |
|
375 /** |
|
376 * Get feature variant. |
|
377 * @return feature variant. |
|
378 */ |
|
379 string GetFeatureVariant() const; |
|
380 |
|
381 /** |
|
382 * Set feature variant name. |
|
383 * @param sFeatureVariantName feature variant name. |
|
384 */ |
|
385 void SetFeatureVariantName(const string& sFeatureVariantName); |
|
386 |
|
387 /** |
|
388 * Get feature variant name. |
|
389 * @return feature variant name. |
|
390 */ |
|
391 string GetFeatureVariantName() const; |
|
392 |
|
393 /** |
|
394 * Set release path. |
|
395 * @param sReleasePath release path. |
|
396 */ |
|
397 void SetReleasePath(const string& sReleasePath); |
|
398 |
|
399 /** |
|
400 * Get release path. |
|
401 * @return release path. |
|
402 */ |
|
403 string GetReleasePath() const; |
|
404 |
|
405 /** |
|
406 * Set full variant path. |
|
407 * @param sFullVariantPath full variant path. |
|
408 */ |
|
409 void SetFullVariantPath(const string& sFullVariantPath); |
|
410 |
|
411 /** |
|
412 * Get full variant path. |
|
413 * @return full variant path. |
|
414 */ |
|
415 string GetFullVariantPath() const; |
|
416 |
|
417 /** |
|
418 * Set compile definition(s) of the module. |
|
419 * @param sCompileDefinitions |
|
420 */ |
|
421 void SetCompileDefinitions( const string& sCompileDefinitions ); |
|
422 |
|
423 /** |
|
424 * Get compile definition(s) of the module. |
|
425 * @return compile definition(s). |
|
426 */ |
|
427 string GetCompileDefinitions() const; |
|
428 |
|
429 /** |
|
430 * Is modules target type udeb? |
|
431 * @return true if modules target type is udeb. |
|
432 */ |
|
433 bool IsUDEB() const; |
|
434 |
|
435 /** |
|
436 * Is module build successfully? |
|
437 * This includes check of listing and map files from temporary directory. |
|
438 * @return true if module build successfully. |
|
439 */ |
|
440 bool IsMakeSuccessfull(); |
|
441 |
|
442 /** |
|
443 * Get error string. This includes possible erros what are generated when |
|
444 * IsMakeSuccesfull is called. |
|
445 * @return error string. |
|
446 */ |
|
447 string GetErrors() const; |
|
448 |
|
449 /** |
|
450 * Create build complete file to modules temporary directory. |
|
451 * @return true if build complete file created successfully. |
|
452 */ |
|
453 bool CreateBuildCompleteFile( void ); |
|
454 |
|
455 /** |
|
456 * Read map file (armv5 platform). |
|
457 * @return true if map file read successfully. |
|
458 */ |
|
459 bool ReadMapFileArmv5(); |
|
460 |
|
461 /** |
|
462 * Set compile info text |
|
463 * @param sCompileInfoText |
|
464 */ |
|
465 void SetCompileInfoText( string sCompileInfoText ); |
|
466 |
|
467 /** |
|
468 * Get compile info text |
|
469 * @return compile info text |
|
470 */ |
|
471 string GetCompileInfoText() const; |
|
472 |
|
473 #ifndef MODULE_TEST |
|
474 private: |
|
475 #endif |
|
476 |
|
477 /** |
|
478 * Struct for saving source information |
|
479 * sCpp is source file. |
|
480 * sLst sources corresponding lst file. |
|
481 * bStatic true if source information from static library. |
|
482 */ |
|
483 struct SOURCE |
|
484 { |
|
485 bool bStatic; |
|
486 string sCpp; |
|
487 string sLst; |
|
488 SOURCE() : bStatic(false), sCpp(""), sLst("") {} |
|
489 }; |
|
490 |
|
491 // Build system |
|
492 int m_eBuildSystem; |
|
493 // Sbs v.1 makefile |
|
494 string m_sMakeFile; |
|
495 // Mmp file. |
|
496 CATMmp m_Mmp; |
|
497 // Temporary directory with path. |
|
498 string m_sTempPath; |
|
499 // Target. |
|
500 string m_sTarget; |
|
501 // Target type. |
|
502 string m_sTargetType; |
|
503 // True target extension. |
|
504 string m_sRequestedTargetExt; |
|
505 // Variant platform. |
|
506 string m_sVariantPlatform; |
|
507 // Variant type. |
|
508 string m_sVariantType; |
|
509 // Feature variant. |
|
510 string m_sFeatureVariant; |
|
511 // Feature variant name. |
|
512 string m_sFeatureVariantName; |
|
513 // Release path (releasables). |
|
514 string m_sReleasePath; |
|
515 // Full variant path (path to releasables). |
|
516 string m_sFullVariantPath; |
|
517 // String to store information of compile |
|
518 string m_sCompileInfoText; |
|
519 // String to store possible error messages. |
|
520 string m_sErrors; |
|
521 // Compile definition(s) |
|
522 string m_sCompileDefinitions; |
|
523 // Source files. |
|
524 vector<SOURCE> m_vSources; |
|
525 // Listing data. |
|
526 vector<LINE_IN_FILE> m_vLineInFile; |
|
527 // Modules map data (symbols). |
|
528 vector<MAP_FUNC_INFO> m_vMapFileFuncList; |
|
529 // File logging mode filename. |
|
530 string m_sS60FileName; |
|
531 // true if file name not empty and %processname% string replaced |
|
532 bool m_bS60FileNameResolved; |
|
533 // File logging mode file path. |
|
534 string m_sS60FilePath; |
|
535 // Is all data loaded for address to code line functions. |
|
536 bool m_bAddressToLineInitialized; |
|
537 // Read listing files (armv5 platform). |
|
538 bool ReadListingFilesArmv5(); |
|
539 // Get listing file name of given source file. |
|
540 string GetLstNameOfSource(string sSource) const; |
|
541 // Copy listing files to temporary directory. |
|
542 bool CopyLstFilesToTemp(); |
|
543 // Copy map file to temporary directory. |
|
544 bool CopyMapFileToTemp(); |
|
545 // Get full map file name. |
|
546 string GetMapFile() const; |
|
547 // Get full symbol file name. |
|
548 string GetSymbolFile() const; |
|
549 // Get full binary file name. |
|
550 string GetBinaryFile() const; |
|
551 // Helper function to check is platform armv5. |
|
552 bool IsPlatformArmv5() const; |
|
553 // Get "unique" id of module |
|
554 string GetUniqueId() const; |
|
555 // Sbs v.1 variant urel label. |
|
556 string m_sFeatureVariantURELLabel; |
|
557 // Sbs v.1 variant udeb label. |
|
558 string m_sFeatureVariantUDEBLabel; |
|
559 // Object used to get codelines of memory addresses. |
|
560 IAddressToLine* m_pAddressToLine; |
|
561 }; |
|
562 #endif |
|
563 //EOF |