Index: tester/covoar/CoverageFactory.cc
===================================================================
--- tester/covoar/CoverageFactory.cc	(revision 1e21ea76b743f29b7c17952f5f19d15b53dc5afd)
+++ tester/covoar/CoverageFactory.cc	(revision 881824f766937a47fb494f97f4ebcd44c99135cc)
@@ -10,4 +10,6 @@
 #include <stdlib.h>
 #include <string.h>
+
+#include <rld.h>
 
 #include "CoverageFactory.h"
@@ -36,11 +38,8 @@
     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" );
 }
 
Index: tester/covoar/CoverageReaderQEMU.cc
===================================================================
--- tester/covoar/CoverageReaderQEMU.cc	(revision 1e21ea76b743f29b7c17952f5f19d15b53dc5afd)
+++ tester/covoar/CoverageReaderQEMU.cc	(revision 881824f766937a47fb494f97f4ebcd44c99135cc)
@@ -10,5 +10,8 @@
 #include <stdio.h>
 #include <stdlib.h>
+#include <stdio.h>
 #include <sys/stat.h>
+
+#include <rld.h>
 
 #include "app_common.h"
@@ -49,6 +52,6 @@
     uint8_t             branchInfo;
 
-    taken    = TargetInfo->qemuTakenBit();
-    notTaken = TargetInfo->qemuNotTakenBit();
+    taken      = TargetInfo->qemuTakenBit();
+    notTaken   = TargetInfo->qemuNotTakenBit();
     branchInfo = taken | notTaken;
 
@@ -56,42 +59,18 @@
     // 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
 
     //
@@ -99,5 +78,5 @@
     //
 #define ENTRIES 1024
-    while (1) {
+    while (true) {
       CoverageMapBase     *aCoverageMap = NULL;
       struct trace_entry  entries[ENTRIES];
@@ -107,5 +86,5 @@
 
       // Read and process each line of the coverage file.
-      num_entries = fread(
+      num_entries = ::fread(
         entries,
         sizeof(struct trace_entry),
@@ -150,5 +129,5 @@
       }
     }
-    fclose( traceFile );
+    ::fclose( traceFile );
   }
 }
Index: tester/covoar/CoverageReaderRTEMS.cc
===================================================================
--- tester/covoar/CoverageReaderRTEMS.cc	(revision 1e21ea76b743f29b7c17952f5f19d15b53dc5afd)
+++ tester/covoar/CoverageReaderRTEMS.cc	(revision 881824f766937a47fb494f97f4ebcd44c99135cc)
@@ -9,4 +9,9 @@
 #include <stdlib.h>
 #include <sys/stat.h>
+
+#include <iostream>
+#include <iomanip>
+
+#include <rld.h>
 
 #include "CoverageReaderRTEMS.h"
@@ -42,52 +47,34 @@
     // 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;
       }
@@ -104,5 +91,5 @@
     }
 
-    fclose( coverageFile );
+    ::fclose( coverageFile );
   }
 }
Index: tester/covoar/CoverageReaderSkyeye.cc
===================================================================
--- tester/covoar/CoverageReaderSkyeye.cc	(revision 1e21ea76b743f29b7c17952f5f19d15b53dc5afd)
+++ tester/covoar/CoverageReaderSkyeye.cc	(revision 881824f766937a47fb494f97f4ebcd44c99135cc)
@@ -9,4 +9,7 @@
 #include <stdlib.h>
 #include <sys/stat.h>
+
+#include <iostream>
+#include <iomanip>
 
 #include "CoverageReaderSkyeye.h"
@@ -42,52 +45,34 @@
     // 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;
       }
@@ -122,5 +107,5 @@
     }
 
-    fclose( coverageFile );
+    ::fclose( coverageFile );
   }
 }
Index: tester/covoar/CoverageReaderTSIM.cc
===================================================================
--- tester/covoar/CoverageReaderTSIM.cc	(revision 1e21ea76b743f29b7c17952f5f19d15b53dc5afd)
+++ tester/covoar/CoverageReaderTSIM.cc	(revision 881824f766937a47fb494f97f4ebcd44c99135cc)
@@ -9,4 +9,9 @@
 #include <stdlib.h>
 #include <sys/stat.h>
+
+#include <iostream>
+#include <iomanip>
+
+#include <rld.h>
 
 #include "app_common.h"
@@ -41,12 +46,9 @@
     // 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" );
     }
 
@@ -54,20 +56,21 @@
     // 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;
 	}
@@ -98,5 +101,5 @@
     }
 
-    fclose( coverageFile );
+    ::fclose( coverageFile );
   }
 }
Index: tester/covoar/CoverageWriterRTEMS.cc
===================================================================
--- tester/covoar/CoverageWriterRTEMS.cc	(revision 1e21ea76b743f29b7c17952f5f19d15b53dc5afd)
+++ tester/covoar/CoverageWriterRTEMS.cc	(revision 881824f766937a47fb494f97f4ebcd44c99135cc)
@@ -10,9 +10,14 @@
 #include <string.h>
 
+#include <iostream>
+#include <iomanip>
+
+#include <rld.h>
+
 #include "CoverageWriterRTEMS.h"
 #include "rtemscov_header.h"
 
 namespace Coverage {
-  
+
   CoverageWriterRTEMS::CoverageWriterRTEMS()
   {
@@ -39,12 +44,9 @@
      *  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" );
     }
 
@@ -57,13 +59,10 @@
     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" );
     }
 
@@ -72,17 +71,16 @@
       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 );
   }
 }
Index: tester/covoar/CoverageWriterSkyeye.cc
===================================================================
--- tester/covoar/CoverageWriterSkyeye.cc	(revision 1e21ea76b743f29b7c17952f5f19d15b53dc5afd)
+++ tester/covoar/CoverageWriterSkyeye.cc	(revision 881824f766937a47fb494f97f4ebcd44c99135cc)
@@ -9,5 +9,11 @@
 #include <stdio.h>
 #include <stdlib.h>
+#include <stdio.h>
 #include <string.h>
+
+#include <iostream>
+#include <iomanip>
+
+#include <rld.h>
 
 #include "CoverageWriterSkyeye.h"
@@ -15,5 +21,5 @@
 
 namespace Coverage {
-  
+
   CoverageWriterSkyeye::CoverageWriterSkyeye()
   {
@@ -40,12 +46,9 @@
      *  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" );
     }
 
@@ -58,33 +61,30 @@
     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 );
   }
 }
Index: tester/covoar/CoverageWriterTSIM.cc
===================================================================
--- tester/covoar/CoverageWriterTSIM.cc	(revision 1e21ea76b743f29b7c17952f5f19d15b53dc5afd)
+++ tester/covoar/CoverageWriterTSIM.cc	(revision 881824f766937a47fb494f97f4ebcd44c99135cc)
@@ -9,8 +9,13 @@
 #include <stdlib.h>
 
+#include <iostream>
+#include <iomanip>
+
+#include <rld.h>
+
 #include "CoverageWriterTSIM.h"
 
 namespace Coverage {
-  
+
   CoverageWriterTSIM::CoverageWriterTSIM()
   {
@@ -21,5 +26,5 @@
   }
 
-  
+
   void CoverageWriterTSIM::writeFile(
     const char* const file,
@@ -38,41 +43,35 @@
      *  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 );
   }
 }
Index: tester/covoar/DesiredSymbols.cc
===================================================================
--- tester/covoar/DesiredSymbols.cc	(revision 1e21ea76b743f29b7c17952f5f19d15b53dc5afd)
+++ tester/covoar/DesiredSymbols.cc	(revision 881824f766937a47fb494f97f4ebcd44c99135cc)
@@ -38,5 +38,5 @@
   }
 
-  bool DesiredSymbols::load(
+  void DesiredSymbols::load(
     const std::string& symbolsSet,
     const std::string& buildTarget,
@@ -46,5 +46,4 @@
   {
     rld::files::cache cache;
-    bool              r = true;
 
     //
@@ -104,10 +103,4 @@
         set[sym.name()] = *(new SymbolInformation);
       }
-
-    } catch (rld::error re) {
-      std::cerr << "error: "
-                << re.where << ": " << re.what
-                << std::endl;
-      r = false;
     } catch (...) {
       cache.close();
@@ -116,6 +109,4 @@
 
     cache.close();
-
-    return r;
   }
 
@@ -333,10 +324,9 @@
 
     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" );
     }
 
@@ -374,15 +364,4 @@
 
       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 )
@@ -491,9 +470,9 @@
 
     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" );
     }
 
Index: tester/covoar/DesiredSymbols.h
===================================================================
--- tester/covoar/DesiredSymbols.h	(revision 1e21ea76b743f29b7c17952f5f19d15b53dc5afd)
+++ tester/covoar/DesiredSymbols.h	(revision 881824f766937a47fb494f97f4ebcd44c99135cc)
@@ -298,7 +298,6 @@
      *  @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,
Index: tester/covoar/ExecutableInfo.cc
===================================================================
--- tester/covoar/ExecutableInfo.cc	(revision 1e21ea76b743f29b7c17952f5f19d15b53dc5afd)
+++ tester/covoar/ExecutableInfo.cc	(revision 881824f766937a47fb494f97f4ebcd44c99135cc)
@@ -26,18 +26,10 @@
     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();
   }
 
Index: tester/covoar/Explanations.cc
===================================================================
--- tester/covoar/Explanations.cc	(revision 1e21ea76b743f29b7c17952f5f19d15b53dc5afd)
+++ tester/covoar/Explanations.cc	(revision 881824f766937a47fb494f97f4ebcd44c99135cc)
@@ -2,5 +2,5 @@
  *  @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,4 +10,6 @@
 #include <string.h>
 #include <unistd.h>
+
+#include <rld.h>
 
 #include "Explanations.h"
@@ -37,12 +39,9 @@
       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" );
     }
 
@@ -63,12 +62,9 @@
       // 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" );
       }
 
@@ -77,14 +73,11 @@
       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';
@@ -92,16 +85,13 @@
       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';
@@ -131,8 +121,6 @@
     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;
@@ -151,15 +139,13 @@
     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();
@@ -167,5 +153,5 @@
       Explanation e = (*itr).second;
       std::string key = (*itr).first;
- 
+
       if (!e.found) {
         notFoundOccurred = true;
@@ -175,5 +161,5 @@
           e.startingPoint.c_str()
         );
-      } 
+      }
     }
     fclose( notFoundFile );
@@ -181,10 +167,9 @@
     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;
       }
-    } 
+    }
   }
 
Index: tester/covoar/ObjdumpProcessor.cc
===================================================================
--- tester/covoar/ObjdumpProcessor.cc	(revision 1e21ea76b743f29b7c17952f5f19d15b53dc5afd)
+++ tester/covoar/ObjdumpProcessor.cc	(revision 881824f766937a47fb494f97f4ebcd44c99135cc)
@@ -150,8 +150,9 @@
     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 );
     }
 
@@ -160,14 +161,10 @@
 
       // 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 );
@@ -180,5 +177,5 @@
     }
 
-    fclose( loadAddressFile );
+    ::fclose( loadAddressFile );
     return address;
 
Index: tester/covoar/ReportsHtml.cc
===================================================================
--- tester/covoar/ReportsHtml.cc	(revision 1e21ea76b743f29b7c17952f5f19d15b53dc5afd)
+++ tester/covoar/ReportsHtml.cc	(revision 881824f766937a47fb494f97f4ebcd44c99135cc)
@@ -2,4 +2,6 @@
 #include <stdlib.h>
 #include <string.h>
+
+#include <rld.h>
 
 #include "ReportsHtml.h"
@@ -25,5 +27,5 @@
 #else
 #define TABLE_HEADER_CLASS
-#define TABLE_FOOTER 
+#define TABLE_FOOTER
 #endif
 
@@ -57,5 +59,5 @@
 
     FILE*  aFile;
-    
+
     // Open the file
     aFile = OpenFile( fileName );
@@ -78,5 +80,5 @@
       "Coverage Analysis Reports</div>\n"
       "<div class =\"datetime\">%s</div>\n",
-      asctime( localtime(&timestamp_m) ) 
+      asctime( localtime(&timestamp_m) )
     );
 
@@ -110,5 +112,5 @@
   {
     FILE*  aFile;
-    
+
     // Open the file
     aFile = ReportsBase::OpenFile( fileName );
@@ -155,5 +157,5 @@
       "<body>\n"
       "<pre class=\"code\">\n",
-      asctime( localtime(&timestamp_m) ) 
+      asctime( localtime(&timestamp_m) )
     );
 
@@ -207,8 +209,8 @@
         "</thead>\n"
         "<tbody>\n",
-        asctime( localtime(&timestamp_m) ) 
+        asctime( localtime(&timestamp_m) )
       );
     }
-   
+
     return aFile;
   }
@@ -256,5 +258,5 @@
       "</thead>\n"
       "<tbody>\n",
-        asctime( localtime(&timestamp_m) ) 
+        asctime( localtime(&timestamp_m) )
 
      );
@@ -299,5 +301,5 @@
       "</thead>\n"
       "<tbody>\n",
-        asctime( localtime(&timestamp_m) ) 
+        asctime( localtime(&timestamp_m) )
 
      );
@@ -347,5 +349,5 @@
       "</thead>\n"
       "<tbody>\n",
-        asctime( localtime(&timestamp_m) ) 
+        asctime( localtime(&timestamp_m) )
 
     );
@@ -399,5 +401,5 @@
       "</thead>\n"
       "<tbody>\n",
-        asctime( localtime(&timestamp_m) ) 
+        asctime( localtime(&timestamp_m) )
 
     );
@@ -409,10 +411,10 @@
   )
   {
-    fprintf( 
-      aFile,
-      "<hr>\n" 
-    );
-  }
- 
+    fprintf(
+      aFile,
+      "<hr>\n"
+    );
+  }
+
   void ReportsHtml::AnnotatedEnd(
     FILE*                aFile
@@ -421,9 +423,9 @@
   }
 
-  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
   )
   {
@@ -431,5 +433,5 @@
     char        number[10];
 
-    
+
     sprintf(number,"%d", id);
 
@@ -461,6 +463,5 @@
         break;
       default:
-        fprintf(stderr, "ERROR:  ReportsHtml::PutAnnotatedLine Unknown state\n");
-        exit( -1 );
+        throw rld::error( "Unknown state", "ReportsHtml::PutAnnotatedLine");
         break;
     }
@@ -518,14 +519,14 @@
 
     // 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()
@@ -535,13 +536,13 @@
     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
@@ -551,5 +552,5 @@
     if (rangePtr->reason ==
       Coverage::CoverageRanges::UNCOVERED_REASON_BRANCH_ALWAYS_TAKEN)
-      fprintf( 
+      fprintf(
         report,
         "<td class=\"covoar-td\" align=\"center\">Always Taken</td>\n"
@@ -557,6 +558,6 @@
     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"
       );
@@ -582,6 +583,6 @@
     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"
@@ -590,6 +591,6 @@
       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\">"
@@ -654,42 +655,42 @@
 
     // 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\">"
@@ -720,15 +721,15 @@
 
     // 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()
@@ -738,13 +739,13 @@
     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
@@ -752,19 +753,19 @@
 
     // 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"
       );
@@ -773,6 +774,6 @@
 
       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\">"
@@ -806,6 +807,6 @@
 
     // size
-    fprintf( 
-      report, 
+    fprintf(
+      report,
       "<td class=\"covoar-td\" align=\"center\">%d</td>\n",
       range->highAddress - range->lowAddress + 1
@@ -813,14 +814,14 @@
 
     // 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()
@@ -830,10 +831,10 @@
     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");
 
@@ -847,5 +848,5 @@
   )
   {
- 
+
     // Mark the background color different for odd and even lines.
     if ( ( count%2 ) != 0 )
@@ -855,20 +856,20 @@
 
     // 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
@@ -876,20 +877,20 @@
 
     // 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
@@ -897,13 +898,13 @@
 
     // 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
@@ -911,6 +912,6 @@
 
     // Total Never Taken
-    fprintf( 
-      report, 
+    fprintf(
+      report,
       "<td class=\"covoar-td\" align=\"center\">%d</td>\n",
       symbol->second.stats.branchesNeverTaken
@@ -919,11 +920,11 @@
     // % 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)/
@@ -933,11 +934,11 @@
     // % 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)/
@@ -973,10 +974,10 @@
         TABLE_FOOTER
         "</tbody>\n"
-        "</table>\n" 
+        "</table>\n"
       );
     }
     fprintf(
       aFile,
-      "</pre>\n" 
+      "</pre>\n"
       "</body>\n"
       "</html>"
@@ -994,6 +995,6 @@
       TABLE_FOOTER
       "</tbody>\n"
-      "</table>\n" 
-      "</pre>\n" 
+      "</table>\n"
+      "</pre>\n"
       "</body>\n"
       "</html>"
@@ -1011,6 +1012,6 @@
       TABLE_FOOTER
       "</tbody>\n"
-      "</table>\n" 
-      "</pre>\n" 
+      "</table>\n"
+      "</pre>\n"
       "</body>\n"
       "</html>"
@@ -1029,6 +1030,6 @@
       TABLE_FOOTER
       "</tbody>\n"
-      "</table>\n" 
-      "</pre>\n" 
+      "</table>\n"
+      "</pre>\n"
       "</body>\n"
       "</html>"
@@ -1046,6 +1047,6 @@
       TABLE_FOOTER
        "</tbody>\n"
-      "</table>\n" 
-      "</pre>\n" 
+      "</table>\n"
+      "</pre>\n"
       "</body>\n"
       "</html>"
Index: tester/covoar/SymbolTable.cc
===================================================================
--- tester/covoar/SymbolTable.cc	(revision 1e21ea76b743f29b7c17952f5f19d15b53dc5afd)
+++ tester/covoar/SymbolTable.cc	(revision 881824f766937a47fb494f97f4ebcd44c99135cc)
@@ -10,4 +10,6 @@
 #include <stdlib.h>
 #include <string.h>
+
+#include <rld.h>
 
 #include "SymbolTable.h"
@@ -44,14 +46,14 @@
     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" );
       }
     }
Index: tester/covoar/TargetBase.cc
===================================================================
--- tester/covoar/TargetBase.cc	(revision 1e21ea76b743f29b7c17952f5f19d15b53dc5afd)
+++ tester/covoar/TargetBase.cc	(revision 881824f766937a47fb494f97f4ebcd44c99135cc)
@@ -2,10 +2,7 @@
  *  @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>
@@ -13,7 +10,12 @@
 #include <stdlib.h>
 
+#include <rld.h>
+
+#include "TargetBase.h"
+#include "qemu-traces.h"
+
 namespace Target {
 
-  TargetBase::TargetBase( 
+  TargetBase::TargetBase(
     std::string targetName
   ):
@@ -66,11 +68,10 @@
 
     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() )
@@ -91,9 +92,9 @@
     int  result;
 
-    
+
     ch = &(line[0]);
 
     // Increment to the first tab in the line
-    while ((*ch != '\t') && (*ch != '\0')) { 
+    while ((*ch != '\t') && (*ch != '\0')) {
       ch++;
     }
@@ -105,5 +106,5 @@
 
     // Increment to the second tab in the line
-    while ((*ch != '\t') && (*ch != '\0')) 
+    while ((*ch != '\t') && (*ch != '\0'))
       ch++;
     if (*ch != '\t') {
Index: tester/covoar/TargetFactory.cc
===================================================================
--- tester/covoar/TargetFactory.cc	(revision 1e21ea76b743f29b7c17952f5f19d15b53dc5afd)
+++ tester/covoar/TargetFactory.cc	(revision 881824f766937a47fb494f97f4ebcd44c99135cc)
@@ -9,4 +9,11 @@
 //!
 
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <rld.h>
+
 #include "TargetFactory.h"
 
@@ -17,8 +24,4 @@
 #include "Target_lm32.h"
 #include "Target_sparc.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
 
 namespace Target {
@@ -35,5 +38,5 @@
      const char    *theTarget;
      //! This is the static wrapper for the constructor.
-     TargetBase *(*theCtor)( 
+     TargetBase *(*theCtor)(
        std::string
      );
@@ -77,11 +80,7 @@
     }
 
-    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;
Index: tester/covoar/Target_arm.cc
===================================================================
--- tester/covoar/Target_arm.cc	(revision 1e21ea76b743f29b7c17952f5f19d15b53dc5afd)
+++ tester/covoar/Target_arm.cc	(revision 881824f766937a47fb494f97f4ebcd44c99135cc)
@@ -2,12 +2,16 @@
  *  @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 {
@@ -32,5 +36,5 @@
     branchInstructions.push_back("bvc");
     branchInstructions.push_back("bvs");
-  
+
     branchInstructions.sort();
 
@@ -47,5 +51,5 @@
   {
     if (!strcmp( &line[strlen(line)-3], "nop")) {
-      size = 4; 
+      size = 4;
       return true;
     }
@@ -67,13 +71,15 @@
 
     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"
+    );
   }
 
Index: tester/covoar/Target_m68k.cc
===================================================================
--- tester/covoar/Target_m68k.cc	(revision 1e21ea76b743f29b7c17952f5f19d15b53dc5afd)
+++ tester/covoar/Target_m68k.cc	(revision 881824f766937a47fb494f97f4ebcd44c99135cc)
@@ -2,13 +2,16 @@
  *  @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 {
@@ -65,5 +68,5 @@
     branchInstructions.push_back("bvss");
     branchInstructions.push_back("bvsl");
-  
+
     branchInstructions.sort();
 
@@ -80,5 +83,5 @@
   {
     if (!strcmp( &line[strlen(line)-3], "nop")) {
-      size = 2; 
+      size = 2;
       return true;
     }
@@ -88,7 +91,7 @@
       // 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
 
@@ -100,9 +103,8 @@
   )
   {
-    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 );    
   }
 
Index: tester/covoar/Target_powerpc.cc
===================================================================
--- tester/covoar/Target_powerpc.cc	(revision 1e21ea76b743f29b7c17952f5f19d15b53dc5afd)
+++ tester/covoar/Target_powerpc.cc	(revision 881824f766937a47fb494f97f4ebcd44c99135cc)
@@ -2,12 +2,15 @@
  *  @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 {
@@ -47,6 +50,6 @@
     branchInstructions.push_back("bclrl");
 
-  
-    branchInstructions.sort();    
+
+    branchInstructions.sort();
   }
 
@@ -61,5 +64,5 @@
   {
     if (!strcmp( &line[strlen(line)-3], "nop")) {
-      size = 4; 
+      size = 4;
       return true;
     }
@@ -72,6 +75,8 @@
   )
   {
-    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"
+    );
   }
 
Index: tester/covoar/TraceConverter.cc
===================================================================
--- tester/covoar/TraceConverter.cc	(revision 1e21ea76b743f29b7c17952f5f19d15b53dc5afd)
+++ tester/covoar/TraceConverter.cc	(revision 881824f766937a47fb494f97f4ebcd44c99135cc)
@@ -14,4 +14,7 @@
 #include <unistd.h>
 
+#include <rld.h>
+#include <rld-process.h>
+
 #include "qemu-log.h"
 #include "TraceReaderLogQEMU.h"
@@ -21,7 +24,4 @@
 #include "app_common.h"
 #include "TargetFactory.h"
-
-#include "rld.h"
-#include "rld-process.h"
 
 #ifdef _WIN32
Index: tester/covoar/TraceWriterQEMU.cc
===================================================================
--- tester/covoar/TraceWriterQEMU.cc	(revision 1e21ea76b743f29b7c17952f5f19d15b53dc5afd)
+++ tester/covoar/TraceWriterQEMU.cc	(revision 881824f766937a47fb494f97f4ebcd44c99135cc)
@@ -39,4 +39,9 @@
 #include <sys/stat.h>
 
+#include <iostream>
+#include <iomanip>
+
+#include <rld-process.h>
+
 #include "app_common.h"
 #include "TraceWriterQEMU.h"
@@ -44,6 +49,4 @@
 #include "CoverageMap.h"
 #include "qemu-traces.h"
-
-#include "rld-process.h"
 
 #if HAVE_STAT64
@@ -95,7 +98,8 @@
     // 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;
     }
@@ -111,26 +115,21 @@
     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;
 
     //
@@ -154,20 +153,22 @@
           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;
   }
Index: tester/covoar/covoar.cc
===================================================================
--- tester/covoar/covoar.cc	(revision 1e21ea76b743f29b7c17952f5f19d15b53dc5afd)
+++ tester/covoar/covoar.cc	(revision 881824f766937a47fb494f97f4ebcd44c99135cc)
@@ -1,2 +1,6 @@
+#include <iostream>
+#include <iomanip>
+
+#include <cxxabi.h>
 #include <ctype.h>
 #include <errno.h>
@@ -13,4 +17,7 @@
 #include <list>
 
+#include <rld.h>
+#include <rld-process.h>
+
 #include "app_common.h"
 #include "CoverageFactory.h"
@@ -24,6 +31,4 @@
 #include "GcovData.h"
 
-#include "rld-process.h"
-
 #ifdef _WIN32
   #define kill(p,s) raise(s)
@@ -32,4 +37,5 @@
 typedef std::list<std::string> CoverageNames;
 typedef std::list<Coverage::ExecutableInfo*> Executables;
+typedef std::string option_error;
 
 /*
@@ -106,6 +112,5 @@
     }
     if (!fail.empty()) {
-      std::cerr << "ERROR: " << fail << std::endl;
-      exit(EXIT_FAILURE);
+      throw rld::error( fail, "createBuildPath" );
     }
   }
@@ -139,42 +144,5 @@
 }
 
-#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
@@ -205,14 +173,10 @@
   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) {
@@ -233,44 +197,29 @@
       case 'd': debug               = true;   break;
       default: /* '?' */
-        usage(progname);
-        exit(EXIT_FAILURE);
-    }
-  }
-  try
-  {
-    /*
-     * Validate inputs.
-     */
-
-    /*
-     * Validate that we have a symbols of interest file.
-     */
-    if ( symbolSet.empty() ) {
-      option = "symbol set file -S";
-      throw option;
-    }
-
-    /*
-     * Has path to explanations.txt been specified.
-     */
-    if ( !explanations ) {
-      option = "explanations -E";
-      throw option;
-    }
-
-    /*
-     * 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);
-  }
+        throw option_error( "unknown option" );
+    }
+  }
+
+  /*
+   * Validate inputs.
+   */
+
+  /*
+   * Validate that we have a symbols of interest file.
+   */
+  if ( symbolSet.empty() )
+    throw option_error( "symbol set file -S" );
+
+  /*
+   * 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
@@ -333,16 +282,12 @@
 
   // 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" );
 
   //
@@ -399,7 +344,5 @@
   // 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 )
@@ -414,8 +357,6 @@
   // 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.
@@ -556,2 +497,101 @@
   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;
+}
