source: rtems-tools/tester/covoar/ExecutableInfo.h @ f450227

5
Last change on this file since f450227 was fb987e8, checked in by Chris Johns <chrisj@…>, on 05/08/18 at 05:09:39

covoar: Use DWARF to map addresses to source files and lines.

  • Property mode set to 100644
File size: 4.7 KB
Line 
1/*! @file ExecutableInfo.h
2 *  @brief ExecutableInfo Specification
3 *
4 *  This file contains the specification of the ExecutableInfo class.
5 */
6
7#ifndef __EXECUTABLEINFO_H__
8#define __EXECUTABLEINFO_H__
9
10#include <map>
11#include <stdint.h>
12#include <string>
13
14#include <rld-dwarf.h>
15#include <rld-files.h>
16#include <rld-symbols.h>
17
18#include "CoverageMapBase.h"
19#include "SymbolTable.h"
20
21namespace Coverage {
22
23  /*! @class ExecutableInfo
24   *
25   *  This class holds a collection of information for an executable
26   *  that is to be analyzed.
27   */
28  class ExecutableInfo {
29
30  public:
31
32    /*!
33     *  This method constructs an ExecutableInfo instance.
34     *
35     *  @param[in] theExecutableName specifies the name of the executable
36     *  @param[in] theLibraryName specifies the name of the executable
37     */
38    ExecutableInfo(
39      const char* const theExecutableName,
40      const char* const theLibraryName = NULL
41    );
42
43    /*!
44     *  This method destructs an ExecutableInfo instance.
45     */
46    virtual ~ExecutableInfo();
47
48    /*!
49     *  This method prints the contents of all coverage maps for
50     *  this executable.
51     */
52    void dumpCoverageMaps( void );
53
54    /*!
55     *  This method prints the contents of Executable info containers
56     */
57    void dumpExecutableInfo( void );
58
59    /*!
60     *  This method returns a pointer to the executable's coverage map
61     *  that contains the specified address.
62     *
63     *  @param[in] address specifies the desired address
64     *
65     *  @return Returns a pointer to the coverage map
66     */
67    CoverageMapBase* getCoverageMap( uint32_t address );
68
69    /*!
70     *  This method returns the file name of the executable.
71     *
72     *  @return Returns the executable's file name
73     */
74    const std::string getFileName( void ) const;
75
76    /*!
77     *  This method returns the library name associated with the executable.
78     *
79     *  @return Returns the executable's library name
80     */
81    const std::string getLibraryName( void ) const;
82
83    /*!
84     *  This method returns the load address of the dynamic library
85     *
86     *  @return Returns the load address of the dynamic library
87     */
88    uint32_t getLoadAddress( void ) const;
89
90    /*!
91     *  This method returns a pointer to the executable's symbol table.
92     *
93     *  @return Returns a pointer to the symbol table.
94     */
95    SymbolTable* getSymbolTable( void );
96
97    /*!
98     *  This method creates a coverage map for the specified symbol.
99     *
100     *  @param[in] exefileName specifies the source of the information
101     *  @param[in] symbolName specifies the name of the symbol
102     *  @param[in] lowAddress specifies the low address of the coverage map
103     *  @param[in] highAddress specifies the high address of the coverage map
104     *
105     *  @return Returns a pointer to the coverage map
106     */
107    CoverageMapBase* createCoverageMap (
108      const std::string& exefileName,
109      const std::string& symbolName,
110      uint32_t           lowAddress,
111      uint32_t           highAddress
112    );
113
114    /*!
115     *  This method gets the source location, the file and line number given an
116     *  address.
117     */
118    void getSourceAndLine(
119      const unsigned int address,
120      std::string&       location
121    );
122
123    /*!
124     *  This method indicates whether a dynamic library has been
125     *  associated with the executable.
126     *
127     *  @return Returns TRUE if
128     */
129    bool hasDynamicLibrary( void );
130
131    /*!
132     *  This method merges the coverage maps for this executable into
133     *  the unified coverage map.
134     */
135    void mergeCoverage( void );
136
137    /*!
138     *  This method sets the load address of the dynamic library
139     *
140     *  @param[in] address specifies the load address of the dynamic
141     *             library
142     */
143    void setLoadAddress( uint32_t address );
144
145  private:
146
147    /*!
148     *  The ELF executable.
149     */
150    rld::files::object executable;
151
152    /*!
153     *  The DWARF data to the ELF executable.
154     */
155    rld::dwarf::file debug;
156
157    /*!
158     *  The executable's symbol table.
159     */
160    rld::symbols::table symbols;
161
162    /*!
163     *  This map associates a symbol with its coverage map.
164     */
165    typedef std::map<std::string, CoverageMapBase *> CoverageMaps;
166    CoverageMaps coverageMaps;
167
168    /*!
169     *  This member variable contains the name of a dynamic library
170     *  associated with the executable.
171     */
172    std::string libraryName;
173
174    /*!
175     *  This member variable contains the load address of a dynamic library
176     *  if one has been specified for the executable.
177     */
178    uint32_t loadAddress;
179
180    /*!
181     *  This member variable contains a pointer to the symbol table
182     *  of the executable or library.
183     */
184    SymbolTable theSymbolTable;
185
186  };
187}
188#endif
Note: See TracBrowser for help on using the repository browser.