summaryrefslogtreecommitdiffstats
path: root/tester/covoar/TargetBase.h
blob: e5c143e962e43050e0831e21955885d3b8b0d3ac (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/*! @file TargetBase.h
 *  @brief TargetBase Specification
 *
 *  This file contains the specification of the TargetBase class.
 */

#ifndef __TARGETBASE_H__
#define __TARGETBASE_H__

#include <list>
#include <string>
#include <stdint.h>

namespace Target {

  /*! @class TargetBase
   *
   *  This class is the base class for all Target classes.  Each
   *  target class contains routines that are specific to the target
   *  in question.
   */
  class TargetBase {

  public:

    /*!
     *  This method constructs an TargetBase instance.
     *
     *  @param[in] targetName specifies the desired target
     */
    TargetBase(
      std::string targetName
    );

    /*!
     *  This method destructs an TargetBase instance.
     */
    virtual ~TargetBase();

    /*!
     *  This method returns the program name for addr2line.
     *
     *  @return Returns the target specific addr2line program name
     */
    const char* getAddr2line( void ) const;

    /*!
     *  This method returns the CPU name.
     *
     *  @return Returns the target cpu name
     */
    const char* getCPU( void ) const;

    /*!
     *  This method returns the program name for objdump.
     *
     *  @return Returns the target specific objdump program name
     */
    const char* getObjdump( void ) const;

    /*!
     *  This method returns the target name.
     *
     *  @return Returns the target name
     */
    const char* getTarget( void ) const;

    /*!
     *  This method determines whether the specified line from a
     *  objdump file is a nop instruction.
     *
     *  @param[in] line contains the object dump line to check
     *  @param[out] size is set to the size in bytes of the nop
     *
     *  @return Returns TRUE if the instruction is a nop, FALSE otherwise.
     */
    virtual bool isNopLine(
      const char* const line,
      int&              size
    ) = 0;


    /*!
     *  This method determins if the objdump line contains a
     *  branch instruction.
     *
     *  @param[in] line contains the object dump line to check
     *  @param[out] size is set to the size in bytes of the nop
     *
     *  @return Returns TRUE if the instruction is a branch, FALSE otherwise.
     */
    bool isBranchLine(
      const char* const line
    );


    /*!
     *  This method determines if the specified line from an
     *  objdump file is a branch instruction.
     */
    bool isBranch( const std::string& instruction );

    /*!
     *  This method returns the bit set by Qemu in the trace record
     *  when a branch is taken.
     */
    virtual uint8_t qemuTakenBit(void);

    /*!
     *  This method returns the bit set by Qemu in the trace record
     *  when a branch is taken.
     */
    virtual uint8_t qemuNotTakenBit(void);

  protected:

    /*!
     * This member variable contains the target name string.
     */
    std::string    targetName_m;

    /*!
     * This member variable is an array of all conditional branch instructions
     * for this target.
     */
    std::list <std::string> conditionalBranchInstructions;

  private:

    /*!
     * This member variable contains the name of the host program
     * which reports the source line for the specified program address.
     */
    std::string addr2line_m;

    /*!
     * This member variable contains the name of the target cpu architecture.
     */
    std::string cpu_m;

    /*!
     * This member variable contains the name of the host program
     * which disassembles an executable or library.
     */
    std::string objdump_m;
  };
}
#endif