source: rtems-tools/tester/covoar/ObjdumpProcessor.h @ 6a4859e

5
Last change on this file since 6a4859e was 6a4859e, checked in by Cillian O'Donnell <cpodonnell8@…>, on 08/26/17 at 08:15:56

covoar: Use rld tempfile and add signals to clean up in event of crash.

Use rld tempfile for temporary files and add fatal signal handling to clean
them up in the event of a crash.

  • Property mode set to 100644
File size: 4.3 KB
Line 
1/*! @file ObjdumpProcessor.h
2 *  @brief ObjdumpProcessor Specification
3 *
4 *  This file contains the specification of the ObjdumpProcessor class.
5 */
6
7#ifndef __OBJDUMP_PROCESSOR_H__
8#define __OBJDUMP_PROCESSOR_H__
9
10#include <list>
11#include <string>
12
13#include "ExecutableInfo.h"
14#include "TargetBase.h"
15
16#include "rld-process.h"
17
18namespace Coverage {
19
20  /*! @class ObjdumpProcessor
21   *
22   *  This class implements the functionality which reads the output of
23   *  an objdump.  Various information is extracted from the objdump line
24   *  to support analysis and report writing.  Analysis of the objdump line
25   *  also allows for identification of "nops".  For the purpose of coverage
26   *  analysis, nops in the executable may be ignored.  Compilers often
27   *  produce nops to align functions on particular alignment boundaries
28   *  and the nop between functions can not possibly be executed.
29   */
30  class ObjdumpProcessor {
31
32  public:
33
34    /*!
35     *  This type defines the elements of an objdump line.
36     */
37    typedef struct {
38      /*!
39       *  This member variable contains the actual line from the object dump.
40       */
41      std::string line;
42
43      /*!
44       *  This member variable contains the address from the object dump line.
45       */
46      uint32_t address;
47
48      /*!
49       *  This member variable contains an indication of whether the line
50       *  is an instruction.
51       */
52      bool isInstruction;
53
54      /*!
55       *  This member variable contains an indication of whether the line
56       *  is a nop instruction.
57       */
58      bool isNop;
59
60      /*!
61       *  This member variable contains the size of the nop instruction.
62       */
63      int nopSize;
64
65      /*!
66       *  This member variable contains an indication of whether the line
67       *  is a branch instruction.
68       */
69      bool isBranch;
70
71    } objdumpLine_t;
72
73    /*!
74     *  This object defines a list of object dump lines
75     *  for a file.
76     */
77    typedef std::list<objdumpLine_t> objdumpLines_t;
78
79
80    /*!
81     *  This object defines a list of instruction addresses
82     *  that will be extracted from the objdump file.
83     */
84    typedef std::list<uint32_t> objdumpFile_t;
85
86    /*!
87     *  This method constructs an ObjdumpProcessor instance.
88     */
89    ObjdumpProcessor();
90
91    /*!
92     *  This method destructs an ObjdumpProcessor instance.
93     */
94    virtual ~ObjdumpProcessor();
95
96    uint32_t determineLoadAddress(
97      ExecutableInfo* theExecutable
98    );
99
100    /*!
101     *  This method fills a tempfile with the .text section of objdump
102     *  for the given file name.
103     */
104    void getFile( std::string fileName,
105                  rld::process::tempfile& dmp,
106                  rld::process::tempfile& err );
107
108    /*!
109     *  This method fills the objdumpList list with all the
110     *  instruction addresses in the object dump file.
111     */
112    void loadAddressTable (
113      ExecutableInfo* const executableInformation,
114      rld::process::tempfile& dmp,
115      rld::process::tempfile& err
116    );
117
118    /*!
119     *  This method generates and processes an object dump for
120     *  the specified executable.
121     */
122    void load(
123      ExecutableInfo* const executableInformation,
124      rld::process::tempfile& dmp,
125      rld::process::tempfile& err
126    );
127
128    /*!
129     *  This method returns the next address in the objdumpList.
130     */
131    uint32_t getAddressAfter( uint32_t address );
132
133    /*!
134     *  This method returns true if the instruction is
135     *  an instruction that results in a code branch, otherwise
136     *  it returns false.
137     */
138    bool IsBranch( const char *instruction );
139
140    /*!
141     *  This method returns true if the instruction from
142     *  the given line in the objdmp file is a branch instruction,
143     *  otherwise it returns false.
144     */
145    bool isBranchLine(
146      const char* const line
147    );
148
149  private:
150
151    /*!
152     *  This variable consists of a list of all instruction addresses
153     *  extracted from the obj dump file.
154     */
155    objdumpFile_t       objdumpList;
156
157    /*!
158     *  This method determines whether the specified line is a
159     *  nop instruction.
160     *
161     *  @param[in] line contains the object dump line to check
162     *  @param[out] size is set to the size in bytes of the nop
163     *
164     *  @return Returns TRUE if the instruction is a nop, FALSE otherwise.
165     */
166    bool isNop(
167      const char* const line,
168      int&              size
169    );
170
171  };
172}
173#endif
Note: See TracBrowser for help on using the repository browser.