1 | /*! @file SymbolTable.h |
---|
2 | * @brief SymbolTable Specification |
---|
3 | * |
---|
4 | * This file contains the specification of the SymbolTable class. |
---|
5 | */ |
---|
6 | |
---|
7 | #ifndef __SYMBOLTABLE_H__ |
---|
8 | #define __SYMBOLTABLE_H__ |
---|
9 | |
---|
10 | #include <stdint.h> |
---|
11 | #include <string> |
---|
12 | #include <map> |
---|
13 | #include <list> |
---|
14 | |
---|
15 | namespace Coverage { |
---|
16 | |
---|
17 | /*! @class SymbolTable |
---|
18 | * |
---|
19 | * This class maintains information for each desired symbol within an |
---|
20 | * executable. A desired symbol is a symbol for which analysis is to |
---|
21 | * be performed. |
---|
22 | */ |
---|
23 | class SymbolTable { |
---|
24 | |
---|
25 | public: |
---|
26 | |
---|
27 | /*! |
---|
28 | * This structure defines the information kept for each symbol. |
---|
29 | */ |
---|
30 | typedef struct { |
---|
31 | uint32_t startingAddress; |
---|
32 | uint32_t length; |
---|
33 | } symbolInfo_t; |
---|
34 | |
---|
35 | typedef std::list< symbolInfo_t > symbolInfo; |
---|
36 | typedef std::list< symbolInfo_t >::iterator symbolInfoIterator_t; |
---|
37 | |
---|
38 | /*! |
---|
39 | * This method constructs a SymbolTable instance. |
---|
40 | */ |
---|
41 | SymbolTable(); |
---|
42 | |
---|
43 | /*! |
---|
44 | * This method destructs a SymbolTable instance. |
---|
45 | */ |
---|
46 | virtual ~SymbolTable(); |
---|
47 | |
---|
48 | /*! |
---|
49 | * This method adds the specified symbol information to the |
---|
50 | * symbol table. |
---|
51 | * |
---|
52 | * @param[in] symbol specifies the symbol to add |
---|
53 | * @param[in] start specifies the symbol's start address |
---|
54 | * @param[in] length specifies the symbol's length |
---|
55 | * |
---|
56 | */ |
---|
57 | void addSymbol( |
---|
58 | const std::string& symbol, |
---|
59 | const uint32_t start, |
---|
60 | const uint32_t length |
---|
61 | ); |
---|
62 | |
---|
63 | /*! |
---|
64 | * This method returns the symbol information for the specified symbol. |
---|
65 | * |
---|
66 | * @param[in] symbol specifies the symbol for which to obtain information |
---|
67 | * |
---|
68 | * @return Returns a pointer to the symbol information |
---|
69 | */ |
---|
70 | symbolInfo* getInfo( |
---|
71 | const std::string& symbol |
---|
72 | ); |
---|
73 | |
---|
74 | /*! |
---|
75 | * This method returns the length in bytes of the specified symbol. |
---|
76 | * |
---|
77 | * @param[in] symbol specifies the symbol for which to obtain the length |
---|
78 | * |
---|
79 | * @return Returns the length of the symbol |
---|
80 | */ |
---|
81 | uint32_t getLength( |
---|
82 | const std::string& symbol |
---|
83 | ); |
---|
84 | |
---|
85 | /*! |
---|
86 | * This method returns the symbol that contains the specified address. |
---|
87 | * |
---|
88 | * @param[in] address specifies the address for which to obtain the symbol |
---|
89 | * |
---|
90 | * @return Returns the symbol containing the address |
---|
91 | */ |
---|
92 | std::string getSymbol( |
---|
93 | uint32_t address |
---|
94 | ); |
---|
95 | |
---|
96 | /*! |
---|
97 | * This method prints SymbolTable content to stdout |
---|
98 | * |
---|
99 | */ |
---|
100 | void dumpSymbolTable( void ); |
---|
101 | |
---|
102 | private: |
---|
103 | |
---|
104 | /*! |
---|
105 | * This map associates the end address of a symbol's address |
---|
106 | * range with the symbol's address range definition. |
---|
107 | */ |
---|
108 | typedef struct { |
---|
109 | uint32_t low; |
---|
110 | uint32_t high; |
---|
111 | std::string symbol; |
---|
112 | } symbol_entry_t; |
---|
113 | typedef std::map< uint32_t, symbol_entry_t > contents_t; |
---|
114 | contents_t contents; |
---|
115 | |
---|
116 | /*! |
---|
117 | * This map associates each symbol from an executable with |
---|
118 | * the symbol's information. |
---|
119 | */ |
---|
120 | typedef std::map<std::string, symbolInfo> info_t; |
---|
121 | typedef std::map<std::string, symbolInfo>::iterator infoIterator_t; |
---|
122 | info_t info; |
---|
123 | |
---|
124 | }; |
---|
125 | } |
---|
126 | #endif |
---|