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