diff options
author | Chris Johns <chrisj@rtems.org> | 2014-05-09 21:50:37 +1000 |
---|---|---|
committer | Chris Johns <chrisj@rtems.org> | 2014-06-18 16:48:08 +1200 |
commit | 100f517ab37265acdf067e36b6860020ec8b2184 (patch) | |
tree | 2316c8b888e11dcbcfbfc66a0c1e31991ea20656 /tester/covoar/TargetBase.cc | |
parent | 4.11: Add ntp patch. (diff) | |
download | rtems-tools-100f517ab37265acdf067e36b6860020ec8b2184.tar.bz2 |
covoar: Merger the covoar source from rtems-testing.git.
Use waf to build covoar.
Diffstat (limited to 'tester/covoar/TargetBase.cc')
-rw-r--r-- | tester/covoar/TargetBase.cc | 136 |
1 files changed, 136 insertions, 0 deletions
diff --git a/tester/covoar/TargetBase.cc b/tester/covoar/TargetBase.cc new file mode 100644 index 0000000..e5a0ee6 --- /dev/null +++ b/tester/covoar/TargetBase.cc @@ -0,0 +1,136 @@ +/*! @file TargetBase.cc + * @brief TargetBase Implementation + * + * This file contains the implementation of the base class for + * functions supporting target unique functionallity. + */ + +#include "TargetBase.h" +#include "qemu-traces.h" + +#include <algorithm> +#include <stdio.h> +#include <stdlib.h> + +namespace Target { + + TargetBase::TargetBase( + std::string targetName + ): + targetName_m( targetName ) + { + int i; + std::string front = ""; + + for (i=0 ; targetName_m[i] && targetName_m[i] != '-' ; ) { + cpu_m[i] = targetName_m[i]; + cpu_m[++i] = '\0'; + } + if (targetName_m[i] == '-') + front = targetName_m + "-"; + + + addr2line_m = front + "addr2line"; + objdump_m = front + "objdump"; + } + + TargetBase::~TargetBase() + { + } + + const char* TargetBase::getAddr2line() const + { + return addr2line_m.c_str(); + } + + const char* TargetBase::getCPU( void ) const + { + return cpu_m.c_str(); + } + + const char* TargetBase::getObjdump() const + { + return objdump_m.c_str(); + } + + const char* TargetBase::getTarget( void ) const + { + return targetName_m.c_str(); + } + + bool TargetBase::isBranch( + const char* const instruction + ) + { + std::list <std::string>::iterator i; + + if (branchInstructions.empty()) { + fprintf( + stderr, + "DETERMINE BRANCH INSTRUCTIONS FOR THIS ARCHITECTURE! -- fix me\n" + ); + exit( -1 ); + } + + i = find(branchInstructions.begin(), branchInstructions.end(), instruction); + if ( i == branchInstructions.end() ) + return false; + + return true; + } + + bool TargetBase::isBranchLine( + const char* const line + ) + { + #define WARNING \ + "WARNING: TargetBase::isBranchLine - (%d) " \ + "Unable to find instruction in: %s\n" + const char *ch; + char instruction[120]; + int result; + + + ch = &(line[0]); + + // Increment to the first tab in the line + while ((*ch != '\t') && (*ch != '\0')) { + ch++; + } + if (*ch != '\t') { + fprintf( stderr, WARNING, 1, line ); + return false; + } + ch++; + + // Increment to the second tab in the line + while ((*ch != '\t') && (*ch != '\0')) + ch++; + if (*ch != '\t') { + fprintf( stderr, WARNING, 2, line) ; + return false; + } + ch++; + + // Grab the instruction which is the next word in the buffer + // after the second tab. + result = sscanf( ch, "%s", instruction ); + if (result != 1) { + fprintf( stderr, WARNING, 3, line ); + return false; + } + + return isBranch( instruction ); + } + + uint8_t TargetBase::qemuTakenBit(void) + { + return TRACE_OP_BR0; + } + + uint8_t TargetBase::qemuNotTakenBit(void) + { + return TRACE_OP_BR1; + } + +} |