summaryrefslogtreecommitdiffstats
path: root/tester/covoar/CoverageWriterTSIM.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/CoverageWriterTSIM.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/CoverageWriterTSIM.cc')
-rw-r--r--tester/covoar/CoverageWriterTSIM.cc51
1 files changed, 25 insertions, 26 deletions
diff --git a/tester/covoar/CoverageWriterTSIM.cc b/tester/covoar/CoverageWriterTSIM.cc
index ec7c5b4..a4731a9 100644
--- a/tester/covoar/CoverageWriterTSIM.cc
+++ b/tester/covoar/CoverageWriterTSIM.cc
@@ -8,10 +8,15 @@
#include <stdio.h>
#include <stdlib.h>
+#include <iostream>
+#include <iomanip>
+
+#include <rld.h>
+
#include "CoverageWriterTSIM.h"
namespace Coverage {
-
+
CoverageWriterTSIM::CoverageWriterTSIM()
{
}
@@ -20,7 +25,7 @@ namespace Coverage {
{
}
-
+
void CoverageWriterTSIM::writeFile(
const char* const file,
CoverageMapBase* coverage,
@@ -37,42 +42,36 @@ namespace Coverage {
/*
* read the file and update the coverage map passed in
*/
- coverageFile = fopen( file, "w" );
+ coverageFile = ::fopen( file, "w" );
if ( !coverageFile ) {
- fprintf(
- stderr,
- "ERROR: CoverageWriterTSIM::writeFile - unable to open %s\n",
- file
- );
- exit(-1);
+ std::ostringstream what;
+ what << "Unable to open " << file;
+ throw rld::error( what, "CoverageWriterTSIM::writeFile" );
}
- for ( a=lowAddress ; a < highAddress ; a+= 0x80 ) {
+ for ( a = lowAddress; a < highAddress; a += 0x80 ) {
status = fprintf( coverageFile, "%x : ", a );
if ( status == EOF || status == 0 ) {
break;
}
- // fprintf( stderr, "%08x : ", baseAddress );
- for ( i=0 ; i < 0x80 ; i+=4 ) {
+ for ( i = 0; i < 0x80; i += 4 ) {
cover = ((coverage->wasExecuted( a + i )) ? 1 : 0);
- status = fprintf( coverageFile, "%d ", cover );
+ status = ::fprintf( coverageFile, "%d ", cover );
if ( status == EOF || status == 0 ) {
- fprintf(
- stderr,
- "ERROR: CoverageWriterTSIM:writeFile - write to %s "
- "at address 0x%08x failed\n",
- file,
- a
- );
- exit( -1 );
+ ::fclose( coverageFile );
+ std::ostringstream what;
+ what << "write to " << file
+ << " at address 0x"
+ << std::hex << std::setfill('0')
+ << std::setw(8) << a
+ << std::setfill(' ') << std::dec
+ << "failed";
+ throw rld::error( what, "CoverageWriterTSIM::writeFile" );
}
- // fprintf( stderr, "%d ", cover );
}
- fprintf( coverageFile, "\n" );
- // fprintf( stderr, "\n" );
-
+ ::fprintf( coverageFile, "\n" );
}
- fclose( coverageFile );
+ ::fclose( coverageFile );
}
}