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: Windows debug api implementation for IAddressToLine interface. |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef __CATADDR2LINE_H__ |
|
19 #define __CATADDR2LINE_H__ |
|
20 |
|
21 #include "iaddresstoline.h" |
|
22 #include "../inc/cataddr2lineserver.h" |
|
23 |
|
24 // Allowed characters in output. |
|
25 //const char ADDR2LINEALLOWEDCHARS[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 :/\\_.-"; |
|
26 |
|
27 /** |
|
28 * Implements addresstoline interface using one of the GNU binutils tool called addr2line. |
|
29 * This is used on gcce platform. In release build type also map files are used. |
|
30 */ |
|
31 class CATAddr2line : public IAddressToLine |
|
32 { |
|
33 |
|
34 public: |
|
35 |
|
36 /** |
|
37 * Constructor |
|
38 */ |
|
39 CATAddr2line(); |
|
40 |
|
41 /** |
|
42 * Open binary. |
|
43 * @sString Full filename with path to binary. |
|
44 * @iLong base address of binary. |
|
45 * @return true if successful. |
|
46 */ |
|
47 bool Open( const string& sString, const unsigned long iLong); |
|
48 |
|
49 /** |
|
50 * Get error string. In case of any method failed use this to acquire details on error. |
|
51 * @return error string. |
|
52 */ |
|
53 string GetError( void ); |
|
54 |
|
55 /** |
|
56 * Close binary. |
|
57 * @return true if succesful. |
|
58 */ |
|
59 bool Close( void ); |
|
60 |
|
61 /** |
|
62 * Locate code line and file for given address. |
|
63 * @result |
|
64 * @return true if successful. |
|
65 */ |
|
66 bool AddressToLine( CATMemoryAddress* result ); |
|
67 |
|
68 #ifndef MODULE_TEST |
|
69 private: |
|
70 #endif |
|
71 |
|
72 // Modules map data (symbols). |
|
73 vector<MAP_FUNC_INFO> m_vMapFileFuncList; |
|
74 |
|
75 //Map file name |
|
76 string m_sMapFileName; |
|
77 |
|
78 //Addr2line server class |
|
79 CATAddr2lineServer server; |
|
80 |
|
81 /** |
|
82 * Get function name for given address. |
|
83 * @iAddress Memory address as unsigned long. |
|
84 * @return Function name as string or empty string if not found. |
|
85 */ |
|
86 string GetFunctionNameUsingAddress( unsigned long iAddress ); |
|
87 |
|
88 /** |
|
89 * Read map file (armv5 platform). |
|
90 * @return true if map file read successfully. |
|
91 */ |
|
92 bool ReadMapFileArmv5(); |
|
93 |
|
94 //Note: New filtering functions commented out until they are taken into use. |
|
95 //These were part of task which would filter unwanted characters, etc.. from results. |
|
96 |
|
97 /** |
|
98 * Filter any char not defined in constant |
|
99 * ADDR2LINEALLOWEDCHARS from given string. |
|
100 * @param sString string to be filtered. |
|
101 */ |
|
102 //void FilterString( string &sString ); |
|
103 |
|
104 /** |
|
105 * Find first occurence of LF/CR from string. |
|
106 * @param sString string to find LF/CR. |
|
107 * @return position of first occurence. |
|
108 */ |
|
109 //size_t FindLineFeed( const string& sString ); |
|
110 |
|
111 /** |
|
112 * Erase all LF/CR from start of the string until other |
|
113 * characters are found. |
|
114 * @param sString string to erase LF/CR. |
|
115 */ |
|
116 //void EraseUntilNoLineFeed( string& sString ); |
|
117 |
|
118 /** |
|
119 * Split string containing multiple lines with mixed line feeds to |
|
120 * vector of lines. |
|
121 * @sMultiLineString string containing multiple lines. |
|
122 * @return vector containing one line per cell. |
|
123 */ |
|
124 //vector<string> SplitToStrings( string& sMultiLineString ); |
|
125 |
|
126 //Debugging for addr2line task. |
|
127 //ofstream debug; |
|
128 }; |
|
129 |
|
130 #endif |
|