summaryrefslogtreecommitdiffstats
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
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.
-rw-r--r--tester/covoar/CoverageFactory.cc13
-rw-r--r--tester/covoar/CoverageReaderQEMU.cc55
-rw-r--r--tester/covoar/CoverageReaderRTEMS.cc59
-rw-r--r--tester/covoar/CoverageReaderSkyeye.cc57
-rw-r--r--tester/covoar/CoverageReaderTSIM.cc39
-rw-r--r--tester/covoar/CoverageWriterRTEMS.cc50
-rw-r--r--tester/covoar/CoverageWriterSkyeye.cc54
-rw-r--r--tester/covoar/CoverageWriterTSIM.cc51
-rw-r--r--tester/covoar/DesiredSymbols.cc43
-rw-r--r--tester/covoar/DesiredSymbols.h3
-rw-r--r--tester/covoar/ExecutableInfo.cc20
-rw-r--r--tester/covoar/Explanations.cc87
-rw-r--r--tester/covoar/ObjdumpProcessor.cc23
-rw-r--r--tester/covoar/ReportsHtml.cc275
-rw-r--r--tester/covoar/SymbolTable.cc18
-rw-r--r--tester/covoar/TargetBase.cc29
-rw-r--r--tester/covoar/TargetFactory.cc23
-rw-r--r--tester/covoar/Target_arm.cc22
-rw-r--r--tester/covoar/Target_m68k.cc24
-rw-r--r--tester/covoar/Target_powerpc.cc19
-rw-r--r--tester/covoar/TraceConverter.cc6
-rw-r--r--tester/covoar/TraceWriterQEMU.cc55
-rw-r--r--tester/covoar/covoar.cc232
23 files changed, 608 insertions, 649 deletions
diff --git a/tester/covoar/CoverageFactory.cc b/tester/covoar/CoverageFactory.cc
index 8b30371..991ba8f 100644
--- a/tester/covoar/CoverageFactory.cc
+++ b/tester/covoar/CoverageFactory.cc
@@ -10,6 +10,8 @@
#include <stdlib.h>
#include <string.h>
+#include <rld.h>
+
#include "CoverageFactory.h"
#include "CoverageReaderQEMU.h"
#include "CoverageReaderRTEMS.h"
@@ -35,13 +37,10 @@ Coverage::CoverageFormats_t Coverage::CoverageFormatToEnum(
if (!strcmp( format, "TSIM" ))
return COVERAGE_FORMAT_TSIM;
- fprintf(
- stderr,
- "ERROR: %s is an unknown coverage format "
- "(supported formats - QEMU, RTEMS, Skyeye and TSIM)\n",
- format
- );
- exit( 1 );
+ std::ostringstream what;
+ what << format << " is an unknown coverage format "
+ << "(supported formats - QEMU, RTEMS, Skyeye and TSIM)";
+ throw rld::error( what, "Coverage" );
}
Coverage::CoverageReaderBase* Coverage::CreateCoverageReader(
diff --git a/tester/covoar/CoverageReaderQEMU.cc b/tester/covoar/CoverageReaderQEMU.cc
index 37718ec..3d3b50f 100644
--- a/tester/covoar/CoverageReaderQEMU.cc
+++ b/tester/covoar/CoverageReaderQEMU.cc
@@ -9,8 +9,11 @@
#include <stdio.h>
#include <stdlib.h>
+#include <stdio.h>
#include <sys/stat.h>
+#include <rld.h>
+
#include "app_common.h"
#include "CoverageReaderQEMU.h"
#include "CoverageMap.h"
@@ -48,57 +51,33 @@ namespace Coverage {
uint8_t notTaken;
uint8_t branchInfo;
- taken = TargetInfo->qemuTakenBit();
- notTaken = TargetInfo->qemuNotTakenBit();
+ taken = TargetInfo->qemuTakenBit();
+ notTaken = TargetInfo->qemuNotTakenBit();
branchInfo = taken | notTaken;
//
// Open the coverage file and read the header.
//
- traceFile = OPEN( file, "r" );
+ traceFile = ::OPEN( file, "r" );
if (!traceFile) {
- fprintf(
- stderr,
- "ERROR: CoverageReaderQEMU::processFile - Unable to open %s\n",
- file
- );
- exit( -1 );
+ std::ostringstream what;
+ what << "Unable to open " << file;
+ throw rld::error( what, "CoverageReaderQEMU::processFile" );
}
- status = fread( &header, sizeof(trace_header), 1, traceFile );
+ status = ::fread( &header, sizeof(trace_header), 1, traceFile );
if (status != 1) {
- fprintf(
- stderr,
- "ERROR: CoverageReaderQEMU::processFile - "
- "Unable to read header from %s\n",
- file
- );
- exit( -1 );
+ ::fclose( traceFile );
+ std::ostringstream what;
+ what << "Unable to read header from " << file;
+ throw rld::error( what, "CoverageReaderQEMU::processFile" );
}
- #if 0
- fprintf(
- stderr,
- "magic = %s\n"
- "version = %d\n"
- "kind = %d\n"
- "sizeof_target_pc = %d\n"
- "big_endian = %d\n"
- "machine = %02x:%02x\n",
- header.magic,
- header.version,
- header.kind,
- header.sizeof_target_pc,
- header.big_endian,
- header.machine[0], header.machine[1]
- );
- #endif
-
//
// Read ENTRIES number of trace entries.
//
#define ENTRIES 1024
- while (1) {
+ while (true) {
CoverageMapBase *aCoverageMap = NULL;
struct trace_entry entries[ENTRIES];
struct trace_entry *entry;
@@ -106,7 +85,7 @@ namespace Coverage {
// Read and process each line of the coverage file.
- num_entries = fread(
+ num_entries = ::fread(
entries,
sizeof(struct trace_entry),
ENTRIES,
@@ -149,6 +128,6 @@ namespace Coverage {
}
}
}
- fclose( traceFile );
+ ::fclose( traceFile );
}
}
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 );
}
}
diff --git a/tester/covoar/CoverageReaderSkyeye.cc b/tester/covoar/CoverageReaderSkyeye.cc
index 293aef3..0fe33d7 100644
--- a/tester/covoar/CoverageReaderSkyeye.cc
+++ b/tester/covoar/CoverageReaderSkyeye.cc
@@ -9,6 +9,9 @@
#include <stdlib.h>
#include <sys/stat.h>
+#include <iostream>
+#include <iomanip>
+
#include "CoverageReaderSkyeye.h"
#include "CoverageMap.h"
#include "ExecutableInfo.h"
@@ -41,54 +44,36 @@ namespace Coverage {
//
// Open the coverage file and read the header.
//
- coverageFile = fopen( file, "r" );
+ coverageFile = ::fopen( file, "r" );
if (!coverageFile) {
- fprintf(
- stderr,
- "ERROR: CoverageReaderSkyeye::processFile - Unable to open %s\n",
- file
- );
- exit( -1 );
+ std::ostringstream what;
+ what << "Unable to open " << file;
+ throw rld::error( what, "CoverageReaderSkyeye::processFile" );
}
- status = fread( &header, sizeof(header), 1, coverageFile );
+ status = ::fread( &header, sizeof(header), 1, coverageFile );
if (status != 1) {
- fprintf(
- stderr,
- "ERROR: CoverageReaderSkyeye::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, "CoverageReaderSkyeye::processFile" );
}
baseAddress = header.prof_start;
length = header.prof_end - header.prof_start;
-
- #if 0
- fprintf(
- stderr,
- "%s: 0x%08x 0x%08x 0x%08lx/%ld\n",
- file,
- header.prof_start,
- header.prof_end,
- (unsigned long) length,
- (unsigned long) length
- );
- #endif
//
// Read and process each line of the coverage file.
//
- for (i=0; i<length; i+=8) {
- status = fread( &cover, sizeof(uint8_t), 1, coverageFile );
+ for (i = 0; i < length; i += 8) {
+ status = ::fread( &cover, sizeof(uint8_t), 1, coverageFile );
if (status != 1) {
- fprintf(
- stderr,
- "CoverageReaderSkyeye::ProcessFile - breaking after 0x%08x in %s\n",
- (unsigned int) i,
- file
- );
+ std::cerr << "CoverageReaderSkyeye::ProcessFile - breaking after 0x"
+ << std::hex << std::setfill('0')
+ << std::setw(8) << i
+ << std::setfill(' ') << std::dec
+ << " in " << file
+ << std::endl;
break;
}
@@ -121,6 +106,6 @@ namespace Coverage {
}
}
- fclose( coverageFile );
+ ::fclose( coverageFile );
}
}
diff --git a/tester/covoar/CoverageReaderTSIM.cc b/tester/covoar/CoverageReaderTSIM.cc
index b1a2acb..d8b738e 100644
--- a/tester/covoar/CoverageReaderTSIM.cc
+++ b/tester/covoar/CoverageReaderTSIM.cc
@@ -9,6 +9,11 @@
#include <stdlib.h>
#include <sys/stat.h>
+#include <iostream>
+#include <iomanip>
+
+#include <rld.h>
+
#include "app_common.h"
#include "CoverageReaderTSIM.h"
#include "CoverageMap.h"
@@ -40,35 +45,33 @@ namespace Coverage {
//
// Open the coverage file.
//
- coverageFile = fopen( file, "r" );
+ coverageFile = ::fopen( file, "r" );
if (!coverageFile) {
- fprintf(
- stderr,
- "ERROR: CoverageReaderTSIM::processFile - Unable to open %s\n",
- file
- );
- exit( -1 );
+ std::ostringstream what;
+ what << "Unable to open " << file;
+ throw rld::error( what, "CoverageReaderTSIM::processFile" );
}
//
// Read and process each line of the coverage file.
//
- while ( 1 ) {
- status = fscanf( coverageFile, "%x : ", &baseAddress );
+ while ( true ) {
+ status = ::fscanf( coverageFile, "%x : ", &baseAddress );
if (status == EOF || status == 0) {
break;
}
- for (i=0; i < 0x80; i+=4) {
+ for (i = 0; i < 0x80; i += 4) {
unsigned int a;
- status = fscanf( coverageFile, "%x", &cover );
+ status = ::fscanf( coverageFile, "%x", &cover );
if (status == EOF || status == 0) {
- fprintf(
- stderr,
- "CoverageReaderTSIM: WARNING! Short line in %s at address 0x%08x\n",
- file,
- baseAddress
- );
+ std::cerr << "CoverageReaderTSIM: WARNING! Short line in "
+ << file
+ << " at address 0x"
+ << std::hex << std::setfill('0')
+ << baseAddress
+ << std::setfill(' ') << std::dec
+ << std::endl;
break;
}
@@ -97,6 +100,6 @@ namespace Coverage {
}
}
- fclose( coverageFile );
+ ::fclose( coverageFile );
}
}
diff --git a/tester/covoar/CoverageWriterRTEMS.cc b/tester/covoar/CoverageWriterRTEMS.cc
index 7a5150f..48e8fd1 100644
--- a/tester/covoar/CoverageWriterRTEMS.cc
+++ b/tester/covoar/CoverageWriterRTEMS.cc
@@ -9,11 +9,16 @@
#include <stdlib.h>
#include <string.h>
+#include <iostream>
+#include <iomanip>
+
+#include <rld.h>
+
#include "CoverageWriterRTEMS.h"
#include "rtemscov_header.h"
namespace Coverage {
-
+
CoverageWriterRTEMS::CoverageWriterRTEMS()
{
}
@@ -38,14 +43,11 @@ 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: CoverageWriterRTEMS::writeFile - unable to open %s\n",
- file
- );
- exit(-1);
+ std::ostringstream what;
+ what << "Unable to open " << file;
+ throw rld::error( what, "CoverageWriterRTEMS::writeFile" );
}
/* clear out the header and fill it in */
@@ -56,33 +58,29 @@ namespace Coverage {
header.end = highAddress;
strcpy( header.desc, "RTEMS Coverage Data" );
- status = fwrite(&header, 1, sizeof(header), coverageFile);
+ status = ::fwrite(&header, 1, sizeof(header), coverageFile);
if (status != sizeof(header)) {
- fprintf(
- stderr,
- "ERROR: CoverageWriterRTEMS::writeFile - unable to write header "
- "to %s\n",
- file
- );
- exit(-1);
+ ::fclose( coverageFile );
+ std::ostringstream what;
+ what << "Unable to write header to " << file;
+ throw rld::error( what, "CoverageWriterRTEMS::writeFile" );
}
for ( a=lowAddress ; a < highAddress ; a++ ) {
cover = ((coverage->wasExecuted( a )) ? 0x01 : 0);
status = fwrite(&cover, 1, sizeof(cover), coverageFile);
if (status != sizeof(cover)) {
- fprintf(
- stderr,
- "ERROR: CoverageWriterRTEMS::writeFile - write to %s "
- "at address 0x%08x failed\n",
- file,
- a
- );
- exit( -1 );
+ std::cerr << "CoverageWriterRTEMS::writeFile - write to "
+ << file
+ << " at address 0x%"
+ << std::hex << std::setfill('0')
+ << std::setw(8) << a
+ << std::setfill(' ') << std::dec
+ << " failed"
+ << std::endl;
}
- // fprintf( stderr, "0x%x %d\n", a, cover );
}
- fclose( coverageFile );
+ ::fclose( coverageFile );
}
}
diff --git a/tester/covoar/CoverageWriterSkyeye.cc b/tester/covoar/CoverageWriterSkyeye.cc
index e0aa943..7f78644 100644
--- a/tester/covoar/CoverageWriterSkyeye.cc
+++ b/tester/covoar/CoverageWriterSkyeye.cc
@@ -8,13 +8,19 @@
#include <stdio.h>
#include <stdlib.h>
+#include <stdio.h>
#include <string.h>
+#include <iostream>
+#include <iomanip>
+
+#include <rld.h>
+
#include "CoverageWriterSkyeye.h"
#include "skyeye_header.h"
namespace Coverage {
-
+
CoverageWriterSkyeye::CoverageWriterSkyeye()
{
}
@@ -39,14 +45,11 @@ 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: CoverageWriterSkyeye::writeFile - unable to open %s\n",
- file
- );
- exit(-1);
+ std::ostringstream what;
+ what << "Unable to open " << file;
+ throw rld::error( what, "CoverageWriterSkyeye::writeFile" );
}
/* clear out the header and fill it in */
@@ -57,34 +60,31 @@ namespace Coverage {
header.prof_end = highAddress;
strcpy( header.desc, "Skyeye Coverage Data" );
- status = fwrite(&header, 1, sizeof(header), coverageFile);
+ status = ::fwrite(&header, 1, sizeof(header), coverageFile);
if (status != sizeof(header)) {
- fprintf(
- stderr,
- "ERROR: CoverageWriterSkyeye::writeFile - unable to write header "
- "to %s\n",
- file
- );
- exit(-1);
+ ::fclose( coverageFile );
+ std::ostringstream what;
+ what << "Unable to write header to " << file;
+ throw rld::error( what, "CoverageWriterSkyeye::writeFile" );
}
- for ( a=lowAddress ; a < highAddress ; a+= 8 ) {
+ for ( a = lowAddress; a < highAddress; a += 8 ) {
cover = ((coverage->wasExecuted( a )) ? 0x01 : 0);
cover |= ((coverage->wasExecuted( a + 4 )) ? 0x10 : 0);
status = fwrite(&cover, 1, sizeof(cover), coverageFile);
if (status != sizeof(cover)) {
- fprintf(
- stderr,
- "ERROR: CoverageWriterSkyeye::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, "CoverageWriterSkyeye::writeFile" );
}
- // fprintf( stderr, "0x%x %d\n", a, cover );
}
- fclose( coverageFile );
+ ::fclose( coverageFile );
}
}
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 );
}
}
diff --git a/tester/covoar/DesiredSymbols.cc b/tester/covoar/DesiredSymbols.cc
index 84296f7..a38860a 100644
--- a/tester/covoar/DesiredSymbols.cc
+++ b/tester/covoar/DesiredSymbols.cc
@@ -37,7 +37,7 @@ namespace Coverage {
{
}
- bool DesiredSymbols::load(
+ void DesiredSymbols::load(
const std::string& symbolsSet,
const std::string& buildTarget,
const std::string& buildBSP,
@@ -45,7 +45,6 @@ namespace Coverage {
)
{
rld::files::cache cache;
- bool r = true;
//
// Load the INI file looking for a top level:
@@ -103,20 +102,12 @@ namespace Coverage {
const rld::symbols::symbol& sym = *(kv.second);
set[sym.name()] = *(new SymbolInformation);
}
-
- } catch (rld::error re) {
- std::cerr << "error: "
- << re.where << ": " << re.what
- << std::endl;
- r = false;
} catch (...) {
cache.close();
throw;
}
cache.close();
-
- return r;
}
void DesiredSymbols::preprocess( void )
@@ -332,12 +323,11 @@ namespace Coverage {
symbolSet_t::iterator itr = set.find( symbolName );
if (itr == set.end()) {
- std::cerr << "ERROR: DesiredSymbols::createCoverageMap - Unable to create "
- << "unified coverage map for "
- << symbolName
- << " because it is NOT a desired symbol"
- << std::endl;
- exit( -1 );
+ std::ostringstream what;
+ what << "Unable to create unified coverage map for "
+ << symbolName
+ << " because it is NOT a desired symbol";
+ throw rld::error( what, "DesiredSymbols::createCoverageMap" );
}
// If we have already created a coverage map, ...
@@ -373,17 +363,6 @@ namespace Coverage {
highAddress = size - 1;
aCoverageMap = new CoverageMap( exefileName, 0, highAddress );
- if (!aCoverageMap) {
-
- fprintf(
- stderr,
- "ERROR: DesiredSymbols::createCoverageMap - Unable to allocate "
- "coverage map for %s:%s\n",
- exefileName.c_str(),
- symbolName.c_str()
- );
- exit( -1 );
- }
if ( Verbose )
fprintf(
@@ -490,11 +469,11 @@ namespace Coverage {
symbolSet_t::iterator itr = set.find( symbolName );
if (itr == set.end()) {
- std::cerr << "ERROR: DesiredSymbols::mergeCoverageMap - Unable to merge "
- << "coverage map for %s because it is NOT a desired symbol"
- << symbolName
- << std::endl;
- exit( -1 );
+ std::ostringstream what;
+ what << "Unable to merge coverage map for "
+ << symbolName
+ << " because it is NOT a desired symbol";
+ throw rld::error( what, "DesiredSymbols::mergeCoverageMap" );
}
// Ensure that the source and destination coverage maps
diff --git a/tester/covoar/DesiredSymbols.h b/tester/covoar/DesiredSymbols.h
index 21c5602..5c45af8 100644
--- a/tester/covoar/DesiredSymbols.h
+++ b/tester/covoar/DesiredSymbols.h
@@ -297,9 +297,8 @@ namespace Coverage {
* @param[in] symbolsSet An INI format file of the symbols to be loaded.
* @param[in] buildTarget The build target
* @param[in] buildBSP The BSP
- * @return Returns false if the load fails.
*/
- bool load(
+ void load(
const std::string& symbolsSet,
const std::string& buildTarget,
const std::string& buildBSP,
diff --git a/tester/covoar/ExecutableInfo.cc b/tester/covoar/ExecutableInfo.cc
index 1755e93..b1eba68 100644
--- a/tester/covoar/ExecutableInfo.cc
+++ b/tester/covoar/ExecutableInfo.cc
@@ -25,20 +25,12 @@ namespace Coverage {
{
if (theLibraryName)
libraryName = theLibraryName;
- try {
- executable.open();
- executable.begin();
- executable.load_symbols(symbols);
- debug.begin(executable.elf());
- debug.load_debug();
- } catch (rld::error re) {
- std::cerr << "error: "
- << re.where << ": " << re.what
- << std::endl;
- exit(2);
- } catch (...) {
- exit(2);
- }
+
+ executable.open();
+ executable.begin();
+ executable.load_symbols(symbols);
+ debug.begin(executable.elf());
+ debug.load_debug();
}
ExecutableInfo::~ExecutableInfo()
diff --git a/tester/covoar/Explanations.cc b/tester/covoar/Explanations.cc
index c316a0b..2050b84 100644
--- a/tester/covoar/Explanations.cc
+++ b/tester/covoar/Explanations.cc
@@ -1,7 +1,7 @@
/*! @file Explanations.cc
* @brief Explanations Implementation
*
- * This file contains the implementation of the functions
+ * This file contains the implementation of the functions
* which provide a base level of functionality of a Explanations.
*/
@@ -10,6 +10,8 @@
#include <string.h>
#include <unistd.h>
+#include <rld.h>
+
#include "Explanations.h"
#include "app_common.h"
@@ -36,14 +38,11 @@ namespace Coverage {
if (!explanations)
return;
- explain = fopen( explanations, "r" );
+ explain = ::fopen( explanations, "r" );
if (!explain) {
- fprintf(
- stderr,
- "ERROR: Explanations::load - unable to open explanations file %s\n",
- explanations
- );
- exit(-1);
+ std::ostringstream what;
+ what << "Unable to open " << explanations;
+ throw rld::error( what, "Explanations::load" );
}
while ( 1 ) {
@@ -62,47 +61,38 @@ namespace Coverage {
// Have we already seen this one?
if (set.find( inputBuffer ) != set.end()) {
- fprintf(
- stderr,
- "ERROR: Explanations::load - line %d "
- "contains a duplicate explanation (%s)\n",
- line,
- inputBuffer
- );
- exit( -1 );
+ std::ostringstream what;
+ what << "line " << line
+ << "contains a duplicate explanation ("
+ << inputBuffer << ")";
+ throw rld::error( what, "Explanations::load" );
}
// Add the starting line and file
e->startingPoint = std::string(inputBuffer);
e->found = false;
- // Get the classification
+ // Get the classification
cStatus = fgets( inputBuffer, MAX_LINE_LENGTH, explain );
if (cStatus == NULL) {
- fprintf(
- stderr,
- "ERROR: Explanations::load - line %d "
- "out of sync at the classification\n",
- line
- );
- exit( -1 );
+ std::ostringstream what;
+ what << "line " << line
+ << "out of sync at the classification";
+ throw rld::error( what, "Explanations::load" );
}
inputBuffer[ strlen(inputBuffer) - 1] = '\0';
e->classification = inputBuffer;
line++;
- // Get the explanation
+ // Get the explanation
while (1) {
cStatus = fgets( inputBuffer, MAX_LINE_LENGTH, explain );
// fprintf( stderr, "%d - %s\n", line, inputBuffer );
if (cStatus == NULL) {
- fprintf(
- stderr,
- "ERROR: Explanations::load - line %d "
- "out of sync at the explanation\n",
- line
- );
- exit( -1 );
+ std::ostringstream what;
+ what << "line " << line
+ << "out of sync at the explanation";
+ throw rld::error( what, "Explanations::load" );
}
inputBuffer[ strlen(inputBuffer) - 1] = '\0';
line++;
@@ -130,10 +120,8 @@ done:
{
if (set.find( start ) == set.end()) {
#if 0
- fprintf( stderr,
- "Warning: Unable to find explanation for %s\n",
- start.c_str()
- );
+ std::cerr << "Warning: Unable to find explanation for "
+ << start << std::endl;
#endif
return NULL;
}
@@ -150,23 +138,21 @@ done:
if (!fileName)
return;
-
+
notFoundFile = fopen( fileName, "w" );
if (!fileName) {
- fprintf(
- stderr,
- "ERROR: Explanations::writeNotFound - unable to open file %s\n",
- fileName
- );
- exit( -1 );
+ std::ostringstream what;
+ what << "Unable to open " << fileName
+ << "out of sync at the explanation";
+ throw rld::error( what, "Explanations::writeNotFound" );
}
-
+
for (std::map<std::string, Explanation>::iterator itr = set.begin();
itr != set.end();
itr++) {
Explanation e = (*itr).second;
std::string key = (*itr).first;
-
+
if (!e.found) {
notFoundOccurred = true;
fprintf(
@@ -174,18 +160,17 @@ done:
"%s\n",
e.startingPoint.c_str()
);
- }
+ }
}
fclose( notFoundFile );
if (!notFoundOccurred) {
if (!unlink( fileName )) {
- fprintf( stderr,
- "Warning: Unable to unlink %s\n\n",
- fileName
- );
+ std::cerr << "Warning: Unable to unlink " << fileName
+ << std::endl
+ << std::endl;
}
- }
+ }
}
}
diff --git a/tester/covoar/ObjdumpProcessor.cc b/tester/covoar/ObjdumpProcessor.cc
index d41906c..c98dad7 100644
--- a/tester/covoar/ObjdumpProcessor.cc
+++ b/tester/covoar/ObjdumpProcessor.cc
@@ -149,26 +149,23 @@ namespace Coverage {
dlinfoName += ".dlinfo";
// Read load address.
- loadAddressFile = fopen( dlinfoName.c_str(), "r" );
+ loadAddressFile = ::fopen( dlinfoName.c_str(), "r" );
if (!loadAddressFile) {
- fprintf( stderr, METHOD "unable to open %s\n", dlinfoName.c_str() );
- exit( -1 );
+ std::ostringstream what;
+ what << "Unable to open " << dlinfoName;
+ throw rld::error( what, METHOD );
}
// Process the dlinfo file.
while ( 1 ) {
// Get a line.
- cStatus = fgets( inputBuffer, MAX_LINE_LENGTH, loadAddressFile );
+ cStatus = ::fgets( inputBuffer, MAX_LINE_LENGTH, loadAddressFile );
if (cStatus == NULL) {
- fprintf(
- stderr,
- METHOD "library %s not found in %s\n",
- Library.c_str(),
- dlinfoName.c_str()
- );
- fclose( loadAddressFile );
- exit( -1 );
+ ::fclose( loadAddressFile );
+ std::ostringstream what;
+ what << "library " << Library << " not found in " << dlinfoName;
+ throw rld::error( what, METHOD );
}
sscanf( inputBuffer, "%s %x", inLibName, &offset );
std::string tmp = inLibName;
@@ -179,7 +176,7 @@ namespace Coverage {
}
}
- fclose( loadAddressFile );
+ ::fclose( loadAddressFile );
return address;
#undef METHOD
diff --git a/tester/covoar/ReportsHtml.cc b/tester/covoar/ReportsHtml.cc
index 247253c..ebc6ee0 100644
--- a/tester/covoar/ReportsHtml.cc
+++ b/tester/covoar/ReportsHtml.cc
@@ -2,6 +2,8 @@
#include <stdlib.h>
#include <string.h>
+#include <rld.h>
+
#include "ReportsHtml.h"
#include "app_common.h"
#include "CoverageRanges.h"
@@ -24,7 +26,7 @@
"</tfoot>\n"
#else
#define TABLE_HEADER_CLASS
-#define TABLE_FOOTER
+#define TABLE_FOOTER
#endif
namespace Coverage {
@@ -56,7 +58,7 @@ namespace Coverage {
_t, _n );
FILE* aFile;
-
+
// Open the file
aFile = OpenFile( fileName );
@@ -77,7 +79,7 @@ namespace Coverage {
aFile,
"Coverage Analysis Reports</div>\n"
"<div class =\"datetime\">%s</div>\n",
- asctime( localtime(&timestamp_m) )
+ asctime( localtime(&timestamp_m) )
);
fprintf( aFile, "<ul>\n" );
@@ -109,7 +111,7 @@ namespace Coverage {
)
{
FILE* aFile;
-
+
// Open the file
aFile = ReportsBase::OpenFile( fileName );
@@ -154,7 +156,7 @@ namespace Coverage {
"<div class =\"datetime\">%s</div>\n"
"<body>\n"
"<pre class=\"code\">\n",
- asctime( localtime(&timestamp_m) )
+ asctime( localtime(&timestamp_m) )
);
return aFile;
@@ -206,10 +208,10 @@ namespace Coverage {
"</tr>\n"
"</thead>\n"
"<tbody>\n",
- asctime( localtime(&timestamp_m) )
+ asctime( localtime(&timestamp_m) )
);
}
-
+
return aFile;
}
@@ -255,7 +257,7 @@ namespace Coverage {
"</tr>\n"
"</thead>\n"
"<tbody>\n",
- asctime( localtime(&timestamp_m) )
+ asctime( localtime(&timestamp_m) )
);
@@ -298,7 +300,7 @@ namespace Coverage {
"</tr>\n"
"</thead>\n"
"<tbody>\n",
- asctime( localtime(&timestamp_m) )
+ asctime( localtime(&timestamp_m) )
);
@@ -346,7 +348,7 @@ namespace Coverage {
"</tr>\n"
"</thead>\n"
"<tbody>\n",
- asctime( localtime(&timestamp_m) )
+ asctime( localtime(&timestamp_m) )
);
return aFile;
@@ -398,7 +400,7 @@ namespace Coverage {
"</tr>\n"
"</thead>\n"
"<tbody>\n",
- asctime( localtime(&timestamp_m) )
+ asctime( localtime(&timestamp_m) )
);
return aFile;
@@ -408,29 +410,29 @@ namespace Coverage {
FILE* aFile
)
{
- fprintf(
+ fprintf(
aFile,
- "<hr>\n"
+ "<hr>\n"
);
}
-
+
void ReportsHtml::AnnotatedEnd(
FILE* aFile
)
{
}
- void ReportsHtml::PutAnnotatedLine(
- FILE* aFile,
- AnnotatedLineState_t state,
- std::string line,
- uint32_t id
+ void ReportsHtml::PutAnnotatedLine(
+ FILE* aFile,
+ AnnotatedLineState_t state,
+ std::string line,
+ uint32_t id
)
{
std::string stateText;
char number[10];
-
+
sprintf(number,"%d", id);
// Set the stateText based upon the current state.
@@ -460,8 +462,7 @@ namespace Coverage {
stateText += "\"></a><pre class=\"codeNeverTaken\">\n";
break;
default:
- fprintf(stderr, "ERROR: ReportsHtml::PutAnnotatedLine Unknown state\n");
- exit( -1 );
+ throw rld::error( "Unknown state", "ReportsHtml::PutAnnotatedLine");
break;
}
@@ -517,16 +518,16 @@ namespace Coverage {
fprintf( report, "<tr>\n");
// symbol
- fprintf(
- report,
- "<td class=\"covoar-td\" align=\"center\">%s</td>\n",
+ fprintf(
+ report,
+ "<td class=\"covoar-td\" align=\"center\">%s</td>\n",
symbolPtr->first.c_str()
);
// line
- fprintf(
- report,
- "<td class=\"covoar-td\" align=\"center\"><a href =\"annotated.html#range%d\">%s</td>\n",
+ fprintf(
+ report,
+ "<td class=\"covoar-td\" align=\"center\"><a href =\"annotated.html#range%d\">%s</td>\n",
rangePtr->id,
rangePtr->lowSourceLine.c_str()
);
@@ -534,15 +535,15 @@ namespace Coverage {
// File
i = rangePtr->lowSourceLine.find(":");
temp = rangePtr->lowSourceLine.substr (0, i);
- fprintf(
- report,
- "<td class=\"covoar-td\" align=\"center\">%s</td>\n",
+ fprintf(
+ report,
+ "<td class=\"covoar-td\" align=\"center\">%s</td>\n",
temp.c_str()
);
-
+
// Size in bytes
- fprintf(
- report,
+ fprintf(
+ report,
"<td class=\"covoar-td\" align=\"center\">%d</td>\n",
rangePtr->highAddress - rangePtr->lowAddress + 1
);
@@ -550,14 +551,14 @@ namespace Coverage {
// Reason Branch was uncovered
if (rangePtr->reason ==
Coverage::CoverageRanges::UNCOVERED_REASON_BRANCH_ALWAYS_TAKEN)
- fprintf(
+ fprintf(
report,
"<td class=\"covoar-td\" align=\"center\">Always Taken</td>\n"
);
else if (rangePtr->reason ==
Coverage::CoverageRanges::UNCOVERED_REASON_BRANCH_NEVER_TAKEN)
- fprintf(
- report,
+ fprintf(
+ report,
"<td class=\"covoar-td\" align=\"center\">Never Taken</td>\n"
);
@@ -581,16 +582,16 @@ namespace Coverage {
explanation = AllExplanations->lookupExplanation( rangePtr->lowSourceLine );
if ( !explanation ) {
// Write Classificationditr->second.baseAddress
- fprintf(
- report,
+ fprintf(
+ report,
"<td class=\"covoar-td\" align=\"center\">NONE</td>\n"
"<td class=\"covoar-td\" align=\"center\">No Explanation</td>\n"
);
} else {
char explanationFile[48];
sprintf( explanationFile, "explanation%d.html", rangePtr->id );
- fprintf(
- report,
+ fprintf(
+ report,
"<td class=\"covoar-td\" align=\"center\">%s</td>\n"
"<td class=\"covoar-td\" align=\"center\">"
"<a href=\"%s\">Explanation</a></td>\n",
@@ -653,44 +654,44 @@ namespace Coverage {
}
// symbol
- fprintf(
- report,
- "<td class=\"covoar-td\" align=\"center\">%s</td>\n",
+ fprintf(
+ report,
+ "<td class=\"covoar-td\" align=\"center\">%s</td>\n",
symbol.c_str()
);
- fprintf(
- noRangeFile,
- "<td class=\"covoar-td\" align=\"center\">%s</td>\n",
+ fprintf(
+ noRangeFile,
+ "<td class=\"covoar-td\" align=\"center\">%s</td>\n",
symbol.c_str()
);
// starting line
- fprintf(
- report,
+ fprintf(
+ report,
"<td class=\"covoar-td\" align=\"center\">unknown</td>\n"
);
-
+
// file
- fprintf(
- report,
+ fprintf(
+ report,
"<td class=\"covoar-td\" align=\"center\">unknown</td>\n"
);
-
+
// Size in bytes
- fprintf(
- report,
+ fprintf(
+ report,
"<td class=\"covoar-td\" align=\"center\">unknown</td>\n"
);
// Size in instructions
- fprintf(
- report,
+ fprintf(
+ report,
"<td class=\"covoar-td\" align=\"center\">unknown</td>\n"
- );
+ );
// See if an explanation is available
- fprintf(
- report,
+ fprintf(
+ report,
"<td class=\"covoar-td\" align=\"center\">Unknown</td>\n"
"<td class=\"covoar-td\" align=\"center\">"
"<a href=\"NotReferenced.html\">No data</a></td>\n"
@@ -719,17 +720,17 @@ namespace Coverage {
fprintf( report, "<tr>\n");
// symbol
- fprintf(
- report,
- "<td class=\"covoar-td\" align=\"center\">%s</td>\n",
+ fprintf(
+ report,
+ "<td class=\"covoar-td\" align=\"center\">%s</td>\n",
symbolPtr->first.c_str()
);
// Range
- fprintf(
- report,
+ fprintf(
+ report,
"<td class=\"covoar-td\" align=\"center\"><a href =\"annotated.html#range%d\">%s <br>%s</td>\n",
- rangePtr->id,
+ rangePtr->id,
rangePtr->lowSourceLine.c_str(),
rangePtr->highSourceLine.c_str()
);
@@ -737,43 +738,43 @@ namespace Coverage {
// File
i = rangePtr->lowSourceLine.find(":");
temp = rangePtr->lowSourceLine.substr (0, i);
- fprintf(
- report,
- "<td class=\"covoar-td\" align=\"center\">%s</td>\n",
+ fprintf(
+ report,
+ "<td class=\"covoar-td\" align=\"center\">%s</td>\n",
temp.c_str()
);
-
+
// Size in bytes
- fprintf(
- report,
+ fprintf(
+ report,
"<td class=\"covoar-td\" align=\"center\">%d</td>\n",
rangePtr->highAddress - rangePtr->lowAddress + 1
);
// Size in instructions
- fprintf(
- report,
+ fprintf(
+ report,
"<td class=\"covoar-td\" align=\"center\">%d</td>\n",
rangePtr->instructionCount
- );
+ );
// See if an explanation is available
explanation = AllExplanations->lookupExplanation( rangePtr->lowSourceLine );
if ( !explanation ) {
- fprintf(
- report,
+ fprintf(
+ report,
"<td class=\"covoar-td\" align=\"center\">NONE</td>\n"
);
- fprintf(
- report,
+ fprintf(
+ report,
"<td class=\"covoar-td\" align=\"center\">No Explanation</td>\n"
);
} else {
char explanationFile[48];
sprintf( explanationFile, "explanation%d.html", rangePtr->id );
- fprintf(
- report,
+ fprintf(
+ report,
"<td class=\"covoar-td\" align=\"center\">%s</td>\n"
"<td class=\"covoar-td\" align=\"center\">"
"<a href=\"%s\">Explanation</a></td>\n",
@@ -805,23 +806,23 @@ namespace Coverage {
fprintf( report, "<tr>\n");
// size
- fprintf(
- report,
+ fprintf(
+ report,
"<td class=\"covoar-td\" align=\"center\">%d</td>\n",
range->highAddress - range->lowAddress + 1
);
// symbol
- fprintf(
- report,
- "<td class=\"covoar-td\" align=\"center\">%s</td>\n",
+ fprintf(
+ report,
+ "<td class=\"covoar-td\" align=\"center\">%s</td>\n",
symbol->first.c_str()
);
// line
- fprintf(
- report,
- "<td class=\"covoar-td\" align=\"center\"><a href =\"annotated.html#range%d\">%s</td>\n",
+ fprintf(
+ report,
+ "<td class=\"covoar-td\" align=\"center\"><a href =\"annotated.html#range%d\">%s</td>\n",
range->id,
range->lowSourceLine.c_str()
);
@@ -829,12 +830,12 @@ namespace Coverage {
// File
i = range->lowSourceLine.find(":");
temp = range->lowSourceLine.substr (0, i);
- fprintf(
- report,
- "<td class=\"covoar-td\" align=\"center\">%s</td>\n",
+ fprintf(
+ report,
+ "<td class=\"covoar-td\" align=\"center\">%s</td>\n",
temp.c_str()
);
-
+
fprintf( report, "</tr>\n");
return true;
@@ -846,7 +847,7 @@ namespace Coverage {
Coverage::DesiredSymbols::symbolSet_t::iterator symbol
)
{
-
+
// Mark the background color different for odd and even lines.
if ( ( count%2 ) != 0 )
fprintf( report, "<tr class=\"covoar-tr-odd\">\n");
@@ -854,77 +855,77 @@ namespace Coverage {
fprintf( report, "<tr>\n");
// symbol
- fprintf(
- report,
- "<td class=\"covoar-td\" align=\"center\">%s</td>\n",
+ fprintf(
+ report,
+ "<td class=\"covoar-td\" align=\"center\">%s</td>\n",
symbol->first.c_str()
);
// Total Size in Bytes
- fprintf(
- report,
+ fprintf(
+ report,
"<td class=\"covoar-td\" align=\"center\">%d</td>\n",
symbol->second.stats.sizeInBytes
);
- // Total Size in Instructions
- fprintf(
- report,
+ // Total Size in Instructions
+ fprintf(
+ report,
"<td class=\"covoar-td\" align=\"center\">%d</td>\n",
symbol->second.stats.sizeInInstructions
);
// Total Uncovered Ranges
- fprintf(
- report,
- "<td class=\"covoar-td\" align=\"center\">%d</td>\n",
+ fprintf(
+ report,
+ "<td class=\"covoar-td\" align=\"center\">%d</td>\n",
symbol->second.stats.uncoveredRanges
);
// Uncovered Size in Bytes
- fprintf(
- report,
+ fprintf(
+ report,
"<td class=\"covoar-td\" align=\"center\">%d</td>\n",
symbol->second.stats.uncoveredBytes
);
- // Uncovered Size in Instructions
- fprintf(
- report,
+ // Uncovered Size in Instructions
+ fprintf(
+ report,
"<td class=\"covoar-td\" align=\"center\">%d</td>\n",
symbol->second.stats.uncoveredInstructions
);
// Total number of branches
- fprintf(
- report,
- "<td class=\"covoar-td\" align=\"center\">%d</td>\n",
+ fprintf(
+ report,
+ "<td class=\"covoar-td\" align=\"center\">%d</td>\n",
symbol->second.stats.branchesNotExecuted + symbol->second.stats.branchesExecuted
);
// Total Always Taken
- fprintf(
- report,
+ fprintf(
+ report,
"<td class=\"covoar-td\" align=\"center\">%d</td>\n",
symbol->second.stats.branchesAlwaysTaken
);
// Total Never Taken
- fprintf(
- report,
+ fprintf(
+ report,
"<td class=\"covoar-td\" align=\"center\">%d</td>\n",
symbol->second.stats.branchesNeverTaken
);
// % Uncovered Instructions
if ( symbol->second.stats.sizeInInstructions == 0 )
- fprintf(
- report,
+ fprintf(
+ report,
"<td class=\"covoar-td\" align=\"center\">100.00</td>\n"
);
- else
- fprintf(
- report,
+ else
+ fprintf(
+ report,
"<td class=\"covoar-td\" align=\"center\">%.2f</td>\n",
(symbol->second.stats.uncoveredInstructions*100.0)/
symbol->second.stats.sizeInInstructions
@@ -932,13 +933,13 @@ namespace Coverage {
// % Uncovered Bytes
if ( symbol->second.stats.sizeInBytes == 0 )
- fprintf(
- report,
+ fprintf(
+ report,
"<td class=\"covoar-td\" align=\"center\">100.00</td>\n"
);
- else
- fprintf(
- report,
+ else
+ fprintf(
+ report,
"<td class=\"covoar-td\" align=\"center\">%.2f</td>\n",
(symbol->second.stats.uncoveredBytes*100.0)/
symbol->second.stats.sizeInBytes
@@ -972,12 +973,12 @@ namespace Coverage {
aFile,
TABLE_FOOTER
"</tbody>\n"
- "</table>\n"
+ "</table>\n"
);
}
fprintf(
aFile,
- "</pre>\n"
+ "</pre>\n"
"</body>\n"
"</html>"
);
@@ -993,8 +994,8 @@ namespace Coverage {
aFile,
TABLE_FOOTER
"</tbody>\n"
- "</table>\n"
- "</pre>\n"
+ "</table>\n"
+ "</pre>\n"
"</body>\n"
"</html>"
);
@@ -1010,8 +1011,8 @@ namespace Coverage {
aFile,
TABLE_FOOTER
"</tbody>\n"
- "</table>\n"
- "</pre>\n"
+ "</table>\n"
+ "</pre>\n"
"</body>\n"
"</html>"
);
@@ -1028,8 +1029,8 @@ namespace Coverage {
aFile,
TABLE_FOOTER
"</tbody>\n"
- "</table>\n"
- "</pre>\n"
+ "</table>\n"
+ "</pre>\n"
"</body>\n"
"</html>"
);
@@ -1045,8 +1046,8 @@ namespace Coverage {
aFile,
TABLE_FOOTER
"</tbody>\n"
- "</table>\n"
- "</pre>\n"
+ "</table>\n"
+ "</pre>\n"
"</body>\n"
"</html>"
);
diff --git a/tester/covoar/SymbolTable.cc b/tester/covoar/SymbolTable.cc
index 062e0a3..53bc8af 100644
--- a/tester/covoar/SymbolTable.cc
+++ b/tester/covoar/SymbolTable.cc
@@ -10,6 +10,8 @@
#include <stdlib.h>
#include <string.h>
+#include <rld.h>
+
#include "SymbolTable.h"
#include "app_common.h"
@@ -43,16 +45,16 @@ namespace Coverage {
// Add an entry to the symbol information map.
symbolData.startingAddress = start;
symbolData.length = length;
-
+
if ( info[ symbol ].empty() == false ) {
if ( info[ symbol ].front().length != length ) {
- fprintf(stderr,
- "ERROR==> Different lengths for the symbol %s (%d and %d)\n",
- symbol.c_str(),
- info[ symbol ].front().length,
- length
- );
- exit( 0 );
+ std::ostringstream what;
+ what << "Different lengths for the symbol "
+ << symbol
+ << " (" << info[ symbol ].front().length
+ << " and " << length
+ << ")";
+ throw rld::error( what, "SymbolTable::addSymbol" );
}
}
diff --git a/tester/covoar/TargetBase.cc b/tester/covoar/TargetBase.cc
index e5a0ee6..354a580 100644
--- a/tester/covoar/TargetBase.cc
+++ b/tester/covoar/TargetBase.cc
@@ -1,20 +1,22 @@
/*! @file TargetBase.cc
* @brief TargetBase Implementation
*
- * This file contains the implementation of the base class for
+ * 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>
+#include <rld.h>
+
+#include "TargetBase.h"
+#include "qemu-traces.h"
+
namespace Target {
- TargetBase::TargetBase(
+ TargetBase::TargetBase(
std::string targetName
):
targetName_m( targetName )
@@ -65,13 +67,12 @@ namespace Target {
std::list <std::string>::iterator i;
if (branchInstructions.empty()) {
- fprintf(
- stderr,
- "DETERMINE BRANCH INSTRUCTIONS FOR THIS ARCHITECTURE! -- fix me\n"
- );
- exit( -1 );
+ throw rld::error(
+ "DETERMINE BRANCH INSTRUCTIONS FOR THIS ARCHITECTURE! -- fix me",
+ "TargetBase::isBranch"
+ );
}
-
+
i = find(branchInstructions.begin(), branchInstructions.end(), instruction);
if ( i == branchInstructions.end() )
return false;
@@ -90,11 +91,11 @@ namespace Target {
char instruction[120];
int result;
-
+
ch = &(line[0]);
// Increment to the first tab in the line
- while ((*ch != '\t') && (*ch != '\0')) {
+ while ((*ch != '\t') && (*ch != '\0')) {
ch++;
}
if (*ch != '\t') {
@@ -104,7 +105,7 @@ namespace Target {
ch++;
// Increment to the second tab in the line
- while ((*ch != '\t') && (*ch != '\0'))
+ while ((*ch != '\t') && (*ch != '\0'))
ch++;
if (*ch != '\t') {
fprintf( stderr, WARNING, 2, line) ;
diff --git a/tester/covoar/TargetFactory.cc b/tester/covoar/TargetFactory.cc
index 27b0bc1..fc9c30b 100644
--- a/tester/covoar/TargetFactory.cc
+++ b/tester/covoar/TargetFactory.cc
@@ -8,6 +8,13 @@
//! instances of a family of classes derived from TargetBase.
//!
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <rld.h>
+
#include "TargetFactory.h"
#include "Target_arm.h"
@@ -16,10 +23,6 @@
#include "Target_powerpc.h"
#include "Target_lm32.h"
#include "Target_sparc.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
namespace Target {
@@ -34,7 +37,7 @@ namespace Target {
//! This is the string found in configuration to match.
const char *theTarget;
//! This is the static wrapper for the constructor.
- TargetBase *(*theCtor)(
+ TargetBase *(*theCtor)(
std::string
);
} FactoryEntry_t;
@@ -76,13 +79,9 @@ namespace Target {
return FactoryTable[i].theCtor( targetName );
}
- fprintf(
- stderr,
- "ERROR!!! %s is not a known architecture!!!\n",
- cpu.c_str()
- );
- fprintf( stderr, "-- fix me\n" );
- exit( 1 );
+ std::ostringstream what;
+ what << cpu << "is not a known architecture!!! - fix me" << std::endl;
+ throw rld::error( what, "TargetFactory" );
return NULL;
}
diff --git a/tester/covoar/Target_arm.cc b/tester/covoar/Target_arm.cc
index a2b65c8..a33ec80 100644
--- a/tester/covoar/Target_arm.cc
+++ b/tester/covoar/Target_arm.cc
@@ -1,15 +1,19 @@
/*! @file Target_arm.cc
* @brief Target_arm Implementation
*
- * This file contains the implementation of the base class for
+ * This file contains the implementation of the base class for
* functions supporting target unique functionallity.
*/
-#include "Target_arm.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <rld.h>
+
+#include "Target_arm.h"
+
namespace Target {
Target_arm::Target_arm( std::string targetName ):
@@ -31,7 +35,7 @@ namespace Target {
branchInstructions.push_back("bpl");
branchInstructions.push_back("bvc");
branchInstructions.push_back("bvs");
-
+
branchInstructions.sort();
}
@@ -46,7 +50,7 @@ namespace Target {
)
{
if (!strcmp( &line[strlen(line)-3], "nop")) {
- size = 4;
+ size = 4;
return true;
}
@@ -66,15 +70,17 @@ namespace Target {
}
return false;
-
+
}
bool Target_arm::isBranch(
const char* instruction
- )
+ )
{
- fprintf( stderr, "DETERMINE BRANCH INSTRUCTIONS FOR THIS ARCHITECTURE! -- fix me\n" );
- exit( -1 );
+ throw rld::error(
+ "DETERMINE BRANCH INSTRUCTIONS FOR THIS ARCHITECTURE! -- fix me",
+ "Target_arm::isBranch"
+ );
}
TargetBase *Target_arm_Constructor(
diff --git a/tester/covoar/Target_m68k.cc b/tester/covoar/Target_m68k.cc
index 683458a..5dc7993 100644
--- a/tester/covoar/Target_m68k.cc
+++ b/tester/covoar/Target_m68k.cc
@@ -1,16 +1,19 @@
/*! @file Target_m68k.cc
* @brief Target_m68k Implementation
*
- * This file contains the implementation of the base class for
+ * This file contains the implementation of the base class for
* functions supporting target unique functionallity.
*/
-#include "Target_m68k.h"
-#include "qemu-traces.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <rld.h>
+
+#include "Target_m68k.h"
+#include "qemu-traces.h"
+
namespace Target {
Target_m68k::Target_m68k( std::string targetName ):
@@ -64,7 +67,7 @@ namespace Target {
branchInstructions.push_back("bvs");
branchInstructions.push_back("bvss");
branchInstructions.push_back("bvsl");
-
+
branchInstructions.sort();
}
@@ -79,7 +82,7 @@ namespace Target {
)
{
if (!strcmp( &line[strlen(line)-3], "nop")) {
- size = 2;
+ size = 2;
return true;
}
@@ -87,9 +90,9 @@ namespace Target {
#if defined(GNU_LD_FILLS_ALIGNMENT_WITH_RTS)
// Until binutils 2.20, binutils would fill with rts not nop
if (!strcmp( &line[strlen(line)-3], "rts")) {
- size = 4;
+ size = 4;
return true;
- }
+ }
#endif
return false;
@@ -99,11 +102,10 @@ namespace Target {
const char* const instruction
)
{
- fprintf(
- stderr,
- "DETERMINE BRANCH INSTRUCTIONS FOR THIS ARCHITECTURE! -- fix me\n"
+ throw rld::error(
+ "DETERMINE BRANCH INSTRUCTIONS FOR THIS ARCHITECTURE! -- fix me",
+ "Target_m68k::isBranch"
);
- exit( -1 );
}
uint8_t Target_m68k::qemuTakenBit(void)
diff --git a/tester/covoar/Target_powerpc.cc b/tester/covoar/Target_powerpc.cc
index f7a5acb..3444b3c 100644
--- a/tester/covoar/Target_powerpc.cc
+++ b/tester/covoar/Target_powerpc.cc
@@ -1,15 +1,18 @@
/*! @file Target_powerpc.cc
* @brief Target_powerpc Implementation
*
- * This file contains the implementation of the base class for
+ * This file contains the implementation of the base class for
* functions supporting target unique functionallity.
*/
-#include "Target_powerpc.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <rld.h>
+
+#include "Target_powerpc.h"
+
namespace Target {
Target_powerpc::Target_powerpc( std::string targetName ):
@@ -46,8 +49,8 @@ namespace Target {
branchInstructions.push_back("bclr");
branchInstructions.push_back("bclrl");
-
- branchInstructions.sort();
+
+ branchInstructions.sort();
}
Target_powerpc::~Target_powerpc()
@@ -60,7 +63,7 @@ namespace Target {
)
{
if (!strcmp( &line[strlen(line)-3], "nop")) {
- size = 4;
+ size = 4;
return true;
}
@@ -71,8 +74,10 @@ namespace Target {
const char* const instruction
)
{
- fprintf( stderr, "DETERMINE BRANCH INSTRUCTIONS FOR THIS ARCHITECTURE! -- fix me\n" );
- exit( -1 );
+ throw rld::error(
+ "DETERMINE BRANCH INSTRUCTIONS FOR THIS ARCHITECTURE! -- fix me",
+ "Target_powerpc::isBranch"
+ );
}
TargetBase *Target_powerpc_Constructor(
diff --git a/tester/covoar/TraceConverter.cc b/tester/covoar/TraceConverter.cc
index 86bc6c1..57ec6eb 100644
--- a/tester/covoar/TraceConverter.cc
+++ b/tester/covoar/TraceConverter.cc
@@ -13,6 +13,9 @@
#include <signal.h>
#include <unistd.h>
+#include <rld.h>
+#include <rld-process.h>
+
#include "qemu-log.h"
#include "TraceReaderLogQEMU.h"
#include "TraceWriterQEMU.h"
@@ -21,9 +24,6 @@
#include "app_common.h"
#include "TargetFactory.h"
-#include "rld.h"
-#include "rld-process.h"
-
#ifdef _WIN32
#define kill(p,s) raise(s)
#endif
diff --git a/tester/covoar/TraceWriterQEMU.cc b/tester/covoar/TraceWriterQEMU.cc
index 9a8affc..cd325b6 100644
--- a/tester/covoar/TraceWriterQEMU.cc
+++ b/tester/covoar/TraceWriterQEMU.cc
@@ -38,14 +38,17 @@
#include <stdlib.h>
#include <sys/stat.h>
+#include <iostream>
+#include <iomanip>
+
+#include <rld-process.h>
+
#include "app_common.h"
#include "TraceWriterQEMU.h"
#include "ExecutableInfo.h"
#include "CoverageMap.h"
#include "qemu-traces.h"
-#include "rld-process.h"
-
#if HAVE_STAT64
#define STAT stat64
#else
@@ -94,9 +97,10 @@ namespace Trace {
//
// Open the trace file.
//
- traceFile = OPEN( file, "w" );
+ traceFile = ::OPEN( file, "w" );
if (!traceFile) {
- fprintf( stderr, "Unable to open %s\n", file );
+ std::ostringstream what;
+ std::cerr << "Unable to open " << file << std::endl;
return false;
}
@@ -110,28 +114,23 @@ namespace Trace {
header.big_endian = false;
header.machine[0] = 0; // XXX ??
header.machine[1] = 0; // XXX ??
- status = fwrite( &header, sizeof(trace_header), 1, traceFile );
+ status = ::fwrite( &header, sizeof(trace_header), 1, traceFile );
if (status != 1) {
- fprintf( stderr, "Unable to write header to %s\n", file );
+ std::cerr << "Unable to write header to " << file << std::endl;
return false;
}
if (Verbose)
- fprintf(
- stderr,
- "magic = %s\n"
- "version = %d\n"
- "kind = %d\n"
- "sizeof_target_pc = %d\n"
- "big_endian = %d\n"
- "machine = %02x:%02x\n",
- header.magic,
- header.version,
- header.kind,
- header.sizeof_target_pc,
- header.big_endian,
- header.machine[0], header.machine[1]
- );
+ std::cerr << "magic = " << header.magic << std::endl
+ << "version = " << header.version << std::endl
+ << "kind = " << header.kind << std::endl
+ << "sizeof_target_pc = " << header.sizeof_target_pc << std::endl
+ << "big_endian = " << header.big_endian << std::endl
+ << std::hex << std::setfill('0')
+ << "machine = " << std::setw(2) << header.machine[0]
+ << ':' << header.machine[1]
+ << std::dec << std::setfill(' ')
+ << std::endl;
//
// Loop through log and write each entry.
@@ -153,22 +152,24 @@ namespace Trace {
case TraceList::EXIT_REASON_OTHER:
break;
default:
- fprintf(stderr, "Unknown exit Reason\n");
- exit(1);
+ throw rld::error( "Unknown exit Reason", "TraceWriterQEMU::writeFile" );
break;
}
if ( Verbose )
- fprintf(stderr, "%x %x %x\n", entry.pc, entry.size, entry.op);
+ std::cerr << std::hex << std::setfill('0')
+ << entry.pc << ' ' << entry.size << ' ' << entry.op
+ << std::dec << std::setfill(' ')
+ << std::endl;
- status = fwrite( &entry, sizeof(entry), 1, traceFile );
+ status = ::fwrite( &entry, sizeof(entry), 1, traceFile );
if (status != 1) {
- fprintf( stderr, "Unable to write entry to %s\n", file );
+ std::cerr << "Unable to write entry to " << file << std::endl;
return false;
}
}
- fclose( traceFile );
+ ::fclose( traceFile );
return true;
}
}
diff --git a/tester/covoar/covoar.cc b/tester/covoar/covoar.cc
index eadf0ec..26abf34 100644
--- a/tester/covoar/covoar.cc
+++ b/tester/covoar/covoar.cc
@@ -1,3 +1,7 @@
+#include <iostream>
+#include <iomanip>
+
+#include <cxxabi.h>
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
@@ -12,6 +16,9 @@
#include <list>
+#include <rld.h>
+#include <rld-process.h>
+
#include "app_common.h"
#include "CoverageFactory.h"
#include "CoverageMap.h"
@@ -23,14 +30,13 @@
#include "TargetFactory.h"
#include "GcovData.h"
-#include "rld-process.h"
-
#ifdef _WIN32
#define kill(p,s) raise(s)
#endif
typedef std::list<std::string> CoverageNames;
typedef std::list<Coverage::ExecutableInfo*> Executables;
+typedef std::string option_error;
/*
* Create a build path from the executable paths. Also extract the build prefix
@@ -105,8 +111,7 @@ static void createBuildPath(Executables& executablesToAnalyze,
}
}
if (!fail.empty()) {
- std::cerr << "ERROR: " << fail << std::endl;
- exit(EXIT_FAILURE);
+ throw rld::error( fail, "createBuildPath" );
}
}
}
@@ -138,44 +143,7 @@ void usage(const std::string& progname)
<< std::endl;
}
-#define PrintableString(_s) \
-((!(_s)) ? "NOT SET" : (_s))
-
-static void
-fatal_signal( int signum )
-{
- signal( signum, SIG_DFL );
-
- rld::process::temporaries_clean_up();
-
- /*
- * Get the same signal again, this time not handled, so its normal effect
- * occurs.
- */
- kill( getpid(), signum );
-}
-
-static void
-setup_signals( void )
-{
- if ( signal( SIGINT, SIG_IGN ) != SIG_IGN )
- signal( SIGINT, fatal_signal );
-#ifdef SIGHUP
- if ( signal( SIGHUP, SIG_IGN ) != SIG_IGN )
- signal( SIGHUP, fatal_signal );
-#endif
- if ( signal( SIGTERM, SIG_IGN ) != SIG_IGN )
- signal( SIGTERM, fatal_signal );
-#ifdef SIGPIPE
- if ( signal( SIGPIPE, SIG_IGN ) != SIG_IGN )
- signal( SIGPIPE, fatal_signal );
-#endif
-#ifdef SIGCHLD
- signal( SIGCHLD, SIG_DFL );
-#endif
-}
-
-int main(
+int covoar(
int argc,
char** argv
)
@@ -204,16 +172,12 @@ int main(
rld::process::tempfile syms( ".syms" );
bool debug = false;
std::string symbolSet;
- std::string progname;
std::string option;
int opt;
- setup_signals();
-
//
// Process command line options.
//
- progname = rld::path::basename(argv[0]);
while ((opt = getopt(argc, argv, "1:L:e:c:g:E:f:s:S:T:O:p:vd")) != -1) {
switch (opt) {
@@ -232,46 +196,31 @@ int main(
case 'p': projectName = optarg; break;
case 'd': debug = true; break;
default: /* '?' */
- usage(progname);
- exit(EXIT_FAILURE);
+ throw option_error( "unknown option" );
}
}
- try
- {
- /*
- * Validate inputs.
- */
- /*
- * Validate that we have a symbols of interest file.
- */
- if ( symbolSet.empty() ) {
- option = "symbol set file -S";
- throw option;
- }
+ /*
+ * Validate inputs.
+ */
- /*
- * Has path to explanations.txt been specified.
- */
- if ( !explanations ) {
- option = "explanations -E";
- throw option;
- }
+ /*
+ * Validate that we have a symbols of interest file.
+ */
+ if ( symbolSet.empty() )
+ throw option_error( "symbol set file -S" );
- /*
- * Check for project name.
- */
- if ( !projectName ) {
- option = "project name -p";
- throw option;
- }
- }
- catch( std::string option )
- {
- std::cerr << "error missing option: " + option << std::endl;
- usage(progname);
- exit(EXIT_FAILURE);
- }
+ /*
+ * Has path to explanations.txt been specified.
+ */
+ if ( !explanations )
+ throw option_error( "explanations -E" );
+
+ /*
+ * Check for project name.
+ */
+ if ( !projectName )
+ throw option_error( "project name -p" );
// If a single executable was specified, process the remaining
// arguments as coverage file names.
@@ -332,18 +281,14 @@ int main(
}
// Ensure that there is at least one executable to process.
- if (executablesToAnalyze.empty()) {
- std::cerr << "error: No information to analyze" << std::endl;
- exit(EXIT_FAILURE);
- }
+ if (executablesToAnalyze.empty())
+ throw rld::error( "No information to analyze", "covoar" );
// The executablesToAnalyze and coverageFileNames containers need
// to be the name size of some of the code below breaks. Lets
// check and make sure.
- if (executablesToAnalyze.size() != coverageFileNames.size()) {
- std::cerr << "ERROR: executables and coverage name size mismatch" << std::endl;
- exit(EXIT_FAILURE);
- }
+ if (executablesToAnalyze.size() != coverageFileNames.size())
+ throw rld::error( "executables and coverage name size mismatch", "covoar" );
//
// Find the top of the BSP's build tree and if we have found the top
@@ -398,9 +343,7 @@ int main(
//
// Read symbol configuration file and load needed symbols.
//
- if (!SymbolsToAnalyze->load( symbolSet, buildTarget, buildBSP, Verbose )) {
- exit(EXIT_FAILURE);
- }
+ SymbolsToAnalyze->load( symbolSet, buildTarget, buildBSP, Verbose );
if ( Verbose )
std::cerr << "Analyzing " << SymbolsToAnalyze->set.size()
@@ -413,10 +356,8 @@ int main(
// Create coverage map reader.
coverageReader = Coverage::CreateCoverageReader(coverageFormat);
- if (!coverageReader) {
- std::cerr << "error: Unable to create coverage file reader" << std::endl;
- exit(EXIT_FAILURE);
- }
+ if (!coverageReader)
+ throw rld::error( "Unable to create coverage file reader", "covoar" );
// Create the objdump processor.
objdumpProcessor = new Coverage::ObjdumpProcessor();
@@ -555,3 +496,102 @@ int main(
return 0;
}
+
+#define PrintableString(_s) \
+((!(_s)) ? "NOT SET" : (_s))
+
+static void
+fatal_signal( int signum )
+{
+ signal( signum, SIG_DFL );
+
+ rld::process::temporaries_clean_up();
+
+ /*
+ * Get the same signal again, this time not handled, so its normal effect
+ * occurs.
+ */
+ kill( getpid(), signum );
+}
+
+static void
+setup_signals( void )
+{
+ if ( signal( SIGINT, SIG_IGN ) != SIG_IGN )
+ signal( SIGINT, fatal_signal );
+#ifdef SIGHUP
+ if ( signal( SIGHUP, SIG_IGN ) != SIG_IGN )
+ signal( SIGHUP, fatal_signal );
+#endif
+ if ( signal( SIGTERM, SIG_IGN ) != SIG_IGN )
+ signal( SIGTERM, fatal_signal );
+#ifdef SIGPIPE
+ if ( signal( SIGPIPE, SIG_IGN ) != SIG_IGN )
+ signal( SIGPIPE, fatal_signal );
+#endif
+#ifdef SIGCHLD
+ signal( SIGCHLD, SIG_DFL );
+#endif
+}
+
+void
+unhandled_exception (void)
+{
+ std::cerr << "error: exception handling error, please report" << std::endl;
+ exit (1);
+}
+
+int main(
+ int argc,
+ char** argv
+)
+{
+ std::string progname( argv[0] );
+ int ec = 0;
+
+ setup_signals();
+
+ std::set_terminate(unhandled_exception);
+
+ try
+ {
+ progname = rld::path::basename(argv[0]);
+ covoar( argc, argv );
+ }
+ catch ( option_error oe )
+ {
+ std::cerr << "error: missing option: " + oe << std::endl;
+ usage(progname);
+ ec = EXIT_FAILURE;
+ }
+ catch (rld::error re)
+ {
+ std::cerr << "error: "
+ << re.where << ": " << re.what
+ << std::endl;
+ ec = 10;
+ }
+ catch (std::exception e)
+ {
+ int status;
+ char* realname;
+ realname = abi::__cxa_demangle (e.what(), 0, 0, &status);
+ std::cerr << "error: exception: " << realname << " [";
+ ::free (realname);
+ const std::type_info &ti = typeid (e);
+ realname = abi::__cxa_demangle (ti.name(), 0, 0, &status);
+ std::cerr << realname << "] " << e.what () << std::endl << std::flush;
+ ::free (realname);
+ ec = 11;
+ }
+ catch (...)
+ {
+ /*
+ * Helps to know if this happens.
+ */
+ std::cerr << "error: unhandled exception" << std::endl;
+ ec = 12;
+ }
+
+ return ec;
+}