summaryrefslogtreecommitdiffstats
path: root/tester/covoar/CoverageReaderRTEMS.cc
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2018-05-11 14:24:11 +1200
committerChris Johns <chrisj@rtems.org>2018-06-18 12:26:16 +1000
commit881824f766937a47fb494f97f4ebcd44c99135cc (patch)
tree0af3d9422ba8e0eae6df8458cc08d4aafacff301 /tester/covoar/CoverageReaderRTEMS.cc
parentlinkers/exe-info: Add DWARF support to gather and check producer details. (diff)
downloadrtems-tools-881824f766937a47fb494f97f4ebcd44c99135cc.tar.bz2
tester/covoar: Remove all exit() calls and throw an rld::error exception.
Add a suitable catch to covoar's main.
Diffstat (limited to 'tester/covoar/CoverageReaderRTEMS.cc')
-rw-r--r--tester/covoar/CoverageReaderRTEMS.cc59
1 files changed, 23 insertions, 36 deletions
diff --git a/tester/covoar/CoverageReaderRTEMS.cc b/tester/covoar/CoverageReaderRTEMS.cc
index 8439c41..a9e8ae8 100644
--- a/tester/covoar/CoverageReaderRTEMS.cc
+++ b/tester/covoar/CoverageReaderRTEMS.cc
@@ -9,6 +9,11 @@
#include <stdlib.h>
#include <sys/stat.h>
+#include <iostream>
+#include <iomanip>
+
+#include <rld.h>
+
#include "CoverageReaderRTEMS.h"
#include "CoverageMap.h"
#include "ExecutableInfo.h"
@@ -41,54 +46,36 @@ namespace Coverage {
//
// Open the coverage file and read the header.
//
- coverageFile = fopen( file, "r" );
+ coverageFile = ::fopen( file, "r" );
if (!coverageFile) {
- fprintf(
- stderr,
- "ERROR: CoverageReaderRTEMS::processFile - Unable to open %s\n",
- file
- );
- exit( -1 );
+ std::ostringstream what;
+ what << "Unable to open " << file;
+ throw rld::error( what, "CoverageReaderRTEMS::processFile" );
}
- status = fread( &header, sizeof(header), 1, coverageFile );
+ status = ::fread( &header, sizeof(header), 1, coverageFile );
if (status != 1) {
- fprintf(
- stderr,
- "ERROR: CoverageReaderRTEMS::processFile - "
- "Unable to read header from %s\n",
- file
- );
- exit( -1 );
+ ::fclose( coverageFile );
+ std::ostringstream what;
+ what << "Unable to read header from " << file;
+ throw rld::error( what, "CoverageReaderRTEMS::processFile" );
}
baseAddress = header.start;
length = header.end - header.start;
-
- #if 0
- fprintf(
- stderr,
- "%s: 0x%08x 0x%08x 0x%08lx/%ld\n",
- file,
- header.start,
- header.end,
- (unsigned long) length,
- (unsigned long) length
- );
- #endif
//
// Read and process each line of the coverage file.
//
- for (i=0; i<length; i++) {
- status = fread( &cover, sizeof(uint8_t), 1, coverageFile );
+ for (i = 0; i < length; i++) {
+ status = ::fread( &cover, sizeof(uint8_t), 1, coverageFile );
if (status != 1) {
- fprintf(
- stderr,
- "CoverageReaderRTEMS::ProcessFile - breaking after 0x%08x in %s\n",
- (unsigned int) i,
- file
- );
+ std::cerr << "breaking after 0x"
+ << std::hex << std::setfill('0')
+ << std::setw(8) << i
+ << std::setfill(' ') << std::dec
+ << " in " << file
+ << std::endl;
break;
}
@@ -103,6 +90,6 @@ namespace Coverage {
}
}
- fclose( coverageFile );
+ ::fclose( coverageFile );
}
}