source: rtems-tools/tester/covoar/TargetBase.cc @ 100f517

4.104.115
Last change on this file since 100f517 was 100f517, checked in by Chris Johns <chrisj@…>, on 05/09/14 at 11:50:37

covoar: Merger the covoar source from rtems-testing.git.

Use waf to build covoar.

  • Property mode set to 100644
File size: 2.7 KB
Line 
1/*! @file TargetBase.cc
2 *  @brief TargetBase Implementation
3 *
4 *  This file contains the implementation of the base class for
5 *  functions supporting target unique functionallity.
6 */
7
8#include "TargetBase.h"
9#include "qemu-traces.h"
10
11#include <algorithm>
12#include <stdio.h>
13#include <stdlib.h>
14
15namespace Target {
16
17  TargetBase::TargetBase(
18    std::string targetName
19  ):
20    targetName_m( targetName )
21  {
22    int i;
23    std::string front = "";
24
25    for (i=0 ; targetName_m[i] && targetName_m[i] != '-' ; ) {
26      cpu_m[i]   = targetName_m[i];
27      cpu_m[++i] = '\0';
28    }
29    if (targetName_m[i] == '-')
30      front = targetName_m + "-";
31
32
33    addr2line_m = front + "addr2line";
34    objdump_m   = front + "objdump";
35  }
36
37  TargetBase::~TargetBase()
38  {
39  }
40
41  const char* TargetBase::getAddr2line() const
42  {
43    return addr2line_m.c_str();
44  }
45
46  const char* TargetBase::getCPU( void ) const
47  {
48    return cpu_m.c_str();
49  }
50
51  const char* TargetBase::getObjdump() const
52  {
53    return objdump_m.c_str();
54  }
55
56  const char* TargetBase::getTarget( void ) const
57  {
58    return targetName_m.c_str();
59  }
60
61  bool TargetBase::isBranch(
62      const char* const instruction
63  )
64  {
65    std::list <std::string>::iterator i;
66
67    if (branchInstructions.empty()) {
68      fprintf(
69        stderr,
70        "DETERMINE BRANCH INSTRUCTIONS FOR THIS ARCHITECTURE! -- fix me\n"
71       );
72       exit( -1 );   
73    }
74   
75    i = find(branchInstructions.begin(), branchInstructions.end(), instruction);
76    if ( i  == branchInstructions.end() )
77      return false;
78
79    return true;
80  }
81
82  bool TargetBase::isBranchLine(
83    const char* const line
84  )
85  {
86    #define WARNING \
87        "WARNING: TargetBase::isBranchLine - (%d) " \
88        "Unable to find instruction in: %s\n"
89    const char *ch;
90    char instruction[120];
91    int  result;
92
93   
94    ch = &(line[0]);
95
96    // Increment to the first tab in the line
97    while ((*ch != '\t') && (*ch != '\0')) {
98      ch++;
99    }
100    if (*ch != '\t') {
101      fprintf( stderr, WARNING, 1, line );
102      return false;
103    }
104    ch++;
105
106    // Increment to the second tab in the line
107    while ((*ch != '\t') && (*ch != '\0'))
108      ch++;
109    if (*ch != '\t') {
110      fprintf( stderr, WARNING, 2, line) ;
111      return false;
112    }
113    ch++;
114
115    // Grab the instruction which is the next word in the buffer
116    // after the second tab.
117    result = sscanf( ch, "%s", instruction );
118    if (result != 1) {
119        fprintf( stderr, WARNING, 3, line );
120        return false;
121    }
122
123    return isBranch( instruction );
124  }
125
126  uint8_t TargetBase::qemuTakenBit(void)
127  {
128    return TRACE_OP_BR0;
129  }
130
131  uint8_t TargetBase::qemuNotTakenBit(void)
132  {
133    return TRACE_OP_BR1;
134  }
135
136}
Note: See TracBrowser for help on using the repository browser.