summaryrefslogtreecommitdiffstats
path: root/tester/covoar
diff options
context:
space:
mode:
authorRyan Long <ryan.long@oarcorp.com>2021-10-22 13:17:47 -0400
committerJoel Sherrill <joel@rtems.org>2021-12-10 11:05:16 -0600
commit2ddc3169ec174d1533ada63cdfa2b7890caae177 (patch)
tree2b482933c770cb6d939801c57f2f2e202b4edeca /tester/covoar
parentConfigFile: Convert to C++ (diff)
downloadrtems-tools-2ddc3169ec174d1533ada63cdfa2b7890caae177.tar.bz2
ObjdumpProcessor: Convert to C++
Diffstat (limited to 'tester/covoar')
-rw-r--r--tester/covoar/ObjdumpProcessor.cc27
-rw-r--r--tester/covoar/ObjdumpProcessor.h6
2 files changed, 18 insertions, 15 deletions
diff --git a/tester/covoar/ObjdumpProcessor.cc b/tester/covoar/ObjdumpProcessor.cc
index c910046..8c0e8dc 100644
--- a/tester/covoar/ObjdumpProcessor.cc
+++ b/tester/covoar/ObjdumpProcessor.cc
@@ -13,6 +13,8 @@
#include <string.h>
#include <algorithm>
#include <string>
+#include <fstream>
+#include <iomanip>
#include "ObjdumpProcessor.h"
#include "CoverageMap.h"
@@ -139,8 +141,7 @@ namespace Coverage {
)
{
#define METHOD "ERROR: ObjdumpProcessor::determineLoadAddress - "
- FILE* loadAddressFile = NULL;
- char* cStatus;
+ std::ifstream loadAddressFile;
uint32_t offset;
char inputBuffer[MAX_LINE_LENGTH];
@@ -155,8 +156,8 @@ namespace Coverage {
dlinfoName += ".dlinfo";
// Read load address.
- loadAddressFile = ::fopen( dlinfoName.c_str(), "r" );
- if (!loadAddressFile) {
+ loadAddressFile.open( dlinfoName );
+ if (!loadAddressFile.is_open()) {
std::ostringstream what;
what << "Unable to open " << dlinfoName;
throw rld::error( what, METHOD );
@@ -166,9 +167,9 @@ namespace Coverage {
while ( 1 ) {
// Get a line.
- cStatus = ::fgets( inputBuffer, MAX_LINE_LENGTH, loadAddressFile );
- if (cStatus == NULL) {
- ::fclose( loadAddressFile );
+ loadAddressFile.getline( inputBuffer, MAX_LINE_LENGTH );
+ if ( loadAddressFile.fail() && loadAddressFile.is_open() ) {
+ loadAddressFile.close();
std::ostringstream what;
what << "library " << Library << " not found in " << dlinfoName;
throw rld::error( what, METHOD );
@@ -176,13 +177,15 @@ namespace Coverage {
sscanf( inputBuffer, "%s %x", inLibName, &offset );
std::string tmp = inLibName;
if ( tmp.find( Library ) != tmp.npos ) {
- // fprintf( stderr, "%s - 0x%08x\n", inLibName, offset );
+ // std::cerr << inLibName << " - 0x"
+ // << std::setfill( '0' ) << std::setw( 8 ) << std::hex
+ // << offset << std::endl
+ // << std::dec << std::setfill( ' ' );
address = offset;
break;
}
}
- ::fclose( loadAddressFile );
return address;
#undef METHOD
@@ -203,7 +206,7 @@ namespace Coverage {
}
bool ObjdumpProcessor::isBranchLine(
- const char* const line
+ const std::string& line
)
{
if ( !targetInfo_m ) {
@@ -219,8 +222,8 @@ namespace Coverage {
}
bool ObjdumpProcessor::isNop(
- const char* const line,
- int& size
+ const std::string& line,
+ int& size
)
{
if ( !targetInfo_m ){
diff --git a/tester/covoar/ObjdumpProcessor.h b/tester/covoar/ObjdumpProcessor.h
index 05a667f..0ca14b8 100644
--- a/tester/covoar/ObjdumpProcessor.h
+++ b/tester/covoar/ObjdumpProcessor.h
@@ -151,7 +151,7 @@ namespace Coverage {
* otherwise it returns false.
*/
bool isBranchLine(
- const char* const line
+ const std::string& line
);
/*!
@@ -179,8 +179,8 @@ namespace Coverage {
* @return Returns TRUE if the instruction is a nop, FALSE otherwise.
*/
bool isNop(
- const char* const line,
- int& size
+ const std::string& line,
+ int& size
);
/*!