Changeset 881824f in rtems-tools
- Timestamp:
- 05/11/18 02:24:11 (4 years ago)
- Branches:
- 5, master
- Children:
- 1c85380
- Parents:
- 1e21ea7
- git-author:
- Chris Johns <chrisj@…> (05/11/18 02:24:11)
- git-committer:
- Chris Johns <chrisj@…> (06/18/18 02:26:16)
- Location:
- tester/covoar
- Files:
-
- 23 edited
Legend:
- Unmodified
- Added
- Removed
-
tester/covoar/CoverageFactory.cc
r1e21ea7 r881824f 10 10 #include <stdlib.h> 11 11 #include <string.h> 12 13 #include <rld.h> 12 14 13 15 #include "CoverageFactory.h" … … 36 38 return COVERAGE_FORMAT_TSIM; 37 39 38 fprintf( 39 stderr, 40 "ERROR: %s is an unknown coverage format " 41 "(supported formats - QEMU, RTEMS, Skyeye and TSIM)\n", 42 format 43 ); 44 exit( 1 ); 40 std::ostringstream what; 41 what << format << " is an unknown coverage format " 42 << "(supported formats - QEMU, RTEMS, Skyeye and TSIM)"; 43 throw rld::error( what, "Coverage" ); 45 44 } 46 45 -
tester/covoar/CoverageReaderQEMU.cc
r1e21ea7 r881824f 10 10 #include <stdio.h> 11 11 #include <stdlib.h> 12 #include <stdio.h> 12 13 #include <sys/stat.h> 14 15 #include <rld.h> 13 16 14 17 #include "app_common.h" … … 49 52 uint8_t branchInfo; 50 53 51 taken = TargetInfo->qemuTakenBit();52 notTaken = TargetInfo->qemuNotTakenBit();54 taken = TargetInfo->qemuTakenBit(); 55 notTaken = TargetInfo->qemuNotTakenBit(); 53 56 branchInfo = taken | notTaken; 54 57 … … 56 59 // Open the coverage file and read the header. 57 60 // 58 traceFile = OPEN( file, "r" );61 traceFile = ::OPEN( file, "r" ); 59 62 if (!traceFile) { 60 fprintf( 61 stderr, 62 "ERROR: CoverageReaderQEMU::processFile - Unable to open %s\n", 63 file 64 ); 65 exit( -1 ); 63 std::ostringstream what; 64 what << "Unable to open " << file; 65 throw rld::error( what, "CoverageReaderQEMU::processFile" ); 66 66 } 67 67 68 status = fread( &header, sizeof(trace_header), 1, traceFile );68 status = ::fread( &header, sizeof(trace_header), 1, traceFile ); 69 69 if (status != 1) { 70 fprintf( 71 stderr, 72 "ERROR: CoverageReaderQEMU::processFile - " 73 "Unable to read header from %s\n", 74 file 75 ); 76 exit( -1 ); 70 ::fclose( traceFile ); 71 std::ostringstream what; 72 what << "Unable to read header from " << file; 73 throw rld::error( what, "CoverageReaderQEMU::processFile" ); 77 74 } 78 79 #if 080 fprintf(81 stderr,82 "magic = %s\n"83 "version = %d\n"84 "kind = %d\n"85 "sizeof_target_pc = %d\n"86 "big_endian = %d\n"87 "machine = %02x:%02x\n",88 header.magic,89 header.version,90 header.kind,91 header.sizeof_target_pc,92 header.big_endian,93 header.machine[0], header.machine[1]94 );95 #endif96 75 97 76 // … … 99 78 // 100 79 #define ENTRIES 1024 101 while ( 1) {80 while (true) { 102 81 CoverageMapBase *aCoverageMap = NULL; 103 82 struct trace_entry entries[ENTRIES]; … … 107 86 108 87 // Read and process each line of the coverage file. 109 num_entries = fread(88 num_entries = ::fread( 110 89 entries, 111 90 sizeof(struct trace_entry), … … 150 129 } 151 130 } 152 fclose( traceFile );131 ::fclose( traceFile ); 153 132 } 154 133 } -
tester/covoar/CoverageReaderRTEMS.cc
r1e21ea7 r881824f 9 9 #include <stdlib.h> 10 10 #include <sys/stat.h> 11 12 #include <iostream> 13 #include <iomanip> 14 15 #include <rld.h> 11 16 12 17 #include "CoverageReaderRTEMS.h" … … 42 47 // Open the coverage file and read the header. 43 48 // 44 coverageFile = fopen( file, "r" );49 coverageFile = ::fopen( file, "r" ); 45 50 if (!coverageFile) { 46 fprintf( 47 stderr, 48 "ERROR: CoverageReaderRTEMS::processFile - Unable to open %s\n", 49 file 50 ); 51 exit( -1 ); 51 std::ostringstream what; 52 what << "Unable to open " << file; 53 throw rld::error( what, "CoverageReaderRTEMS::processFile" ); 52 54 } 53 55 54 status = fread( &header, sizeof(header), 1, coverageFile );56 status = ::fread( &header, sizeof(header), 1, coverageFile ); 55 57 if (status != 1) { 56 fprintf( 57 stderr, 58 "ERROR: CoverageReaderRTEMS::processFile - " 59 "Unable to read header from %s\n", 60 file 61 ); 62 exit( -1 ); 58 ::fclose( coverageFile ); 59 std::ostringstream what; 60 what << "Unable to read header from " << file; 61 throw rld::error( what, "CoverageReaderRTEMS::processFile" ); 63 62 } 64 63 65 64 baseAddress = header.start; 66 65 length = header.end - header.start; 67 68 #if 069 fprintf(70 stderr,71 "%s: 0x%08x 0x%08x 0x%08lx/%ld\n",72 file,73 header.start,74 header.end,75 (unsigned long) length,76 (unsigned long) length77 );78 #endif79 66 80 67 // 81 68 // Read and process each line of the coverage file. 82 69 // 83 for (i =0; i<length; i++) {84 status = fread( &cover, sizeof(uint8_t), 1, coverageFile );70 for (i = 0; i < length; i++) { 71 status = ::fread( &cover, sizeof(uint8_t), 1, coverageFile ); 85 72 if (status != 1) { 86 fprintf(87 stderr,88 "CoverageReaderRTEMS::ProcessFile - breaking after 0x%08x in %s\n",89 (unsigned int) i,90 file91 );73 std::cerr << "breaking after 0x" 74 << std::hex << std::setfill('0') 75 << std::setw(8) << i 76 << std::setfill(' ') << std::dec 77 << " in " << file 78 << std::endl; 92 79 break; 93 80 } … … 104 91 } 105 92 106 fclose( coverageFile );93 ::fclose( coverageFile ); 107 94 } 108 95 } -
tester/covoar/CoverageReaderSkyeye.cc
r1e21ea7 r881824f 9 9 #include <stdlib.h> 10 10 #include <sys/stat.h> 11 12 #include <iostream> 13 #include <iomanip> 11 14 12 15 #include "CoverageReaderSkyeye.h" … … 42 45 // Open the coverage file and read the header. 43 46 // 44 coverageFile = fopen( file, "r" );47 coverageFile = ::fopen( file, "r" ); 45 48 if (!coverageFile) { 46 fprintf( 47 stderr, 48 "ERROR: CoverageReaderSkyeye::processFile - Unable to open %s\n", 49 file 50 ); 51 exit( -1 ); 49 std::ostringstream what; 50 what << "Unable to open " << file; 51 throw rld::error( what, "CoverageReaderSkyeye::processFile" ); 52 52 } 53 53 54 status = fread( &header, sizeof(header), 1, coverageFile );54 status = ::fread( &header, sizeof(header), 1, coverageFile ); 55 55 if (status != 1) { 56 fprintf( 57 stderr, 58 "ERROR: CoverageReaderSkyeye::processFile - " 59 "Unable to read header from %s\n", 60 file 61 ); 62 exit( -1 ); 56 ::fclose( coverageFile ); 57 std::ostringstream what; 58 what << "Unable to read header from " << file; 59 throw rld::error( what, "CoverageReaderSkyeye::processFile" ); 63 60 } 64 61 65 62 baseAddress = header.prof_start; 66 63 length = header.prof_end - header.prof_start; 67 68 #if 069 fprintf(70 stderr,71 "%s: 0x%08x 0x%08x 0x%08lx/%ld\n",72 file,73 header.prof_start,74 header.prof_end,75 (unsigned long) length,76 (unsigned long) length77 );78 #endif79 64 80 65 // 81 66 // Read and process each line of the coverage file. 82 67 // 83 for (i =0; i<length; i+=8) {84 status = fread( &cover, sizeof(uint8_t), 1, coverageFile );68 for (i = 0; i < length; i += 8) { 69 status = ::fread( &cover, sizeof(uint8_t), 1, coverageFile ); 85 70 if (status != 1) { 86 fprintf(87 stderr, 88 "CoverageReaderSkyeye::ProcessFile - breaking after 0x%08x in %s\n", 89 (unsigned int) i, 90 file91 );71 std::cerr << "CoverageReaderSkyeye::ProcessFile - breaking after 0x" 72 << std::hex << std::setfill('0') 73 << std::setw(8) << i 74 << std::setfill(' ') << std::dec 75 << " in " << file 76 << std::endl; 92 77 break; 93 78 } … … 122 107 } 123 108 124 fclose( coverageFile );109 ::fclose( coverageFile ); 125 110 } 126 111 } -
tester/covoar/CoverageReaderTSIM.cc
r1e21ea7 r881824f 9 9 #include <stdlib.h> 10 10 #include <sys/stat.h> 11 12 #include <iostream> 13 #include <iomanip> 14 15 #include <rld.h> 11 16 12 17 #include "app_common.h" … … 41 46 // Open the coverage file. 42 47 // 43 coverageFile = fopen( file, "r" );48 coverageFile = ::fopen( file, "r" ); 44 49 if (!coverageFile) { 45 fprintf( 46 stderr, 47 "ERROR: CoverageReaderTSIM::processFile - Unable to open %s\n", 48 file 49 ); 50 exit( -1 ); 50 std::ostringstream what; 51 what << "Unable to open " << file; 52 throw rld::error( what, "CoverageReaderTSIM::processFile" ); 51 53 } 52 54 … … 54 56 // Read and process each line of the coverage file. 55 57 // 56 while ( 1) {57 status = fscanf( coverageFile, "%x : ", &baseAddress );58 while ( true ) { 59 status = ::fscanf( coverageFile, "%x : ", &baseAddress ); 58 60 if (status == EOF || status == 0) { 59 61 break; 60 62 } 61 63 62 for (i =0; i < 0x80; i+=4) {64 for (i = 0; i < 0x80; i += 4) { 63 65 unsigned int a; 64 status = fscanf( coverageFile, "%x", &cover );66 status = ::fscanf( coverageFile, "%x", &cover ); 65 67 if (status == EOF || status == 0) { 66 fprintf( 67 stderr, 68 "CoverageReaderTSIM: WARNING! Short line in %s at address 0x%08x\n", 69 file, 70 baseAddress 71 ); 68 std::cerr << "CoverageReaderTSIM: WARNING! Short line in " 69 << file 70 << " at address 0x" 71 << std::hex << std::setfill('0') 72 << baseAddress 73 << std::setfill(' ') << std::dec 74 << std::endl; 72 75 break; 73 76 } … … 98 101 } 99 102 100 fclose( coverageFile );103 ::fclose( coverageFile ); 101 104 } 102 105 } -
tester/covoar/CoverageWriterRTEMS.cc
r1e21ea7 r881824f 10 10 #include <string.h> 11 11 12 #include <iostream> 13 #include <iomanip> 14 15 #include <rld.h> 16 12 17 #include "CoverageWriterRTEMS.h" 13 18 #include "rtemscov_header.h" 14 19 15 20 namespace Coverage { 16 21 17 22 CoverageWriterRTEMS::CoverageWriterRTEMS() 18 23 { … … 39 44 * read the file and update the coverage map passed in 40 45 */ 41 coverageFile = fopen( file, "w" );46 coverageFile = ::fopen( file, "w" ); 42 47 if ( !coverageFile ) { 43 fprintf( 44 stderr, 45 "ERROR: CoverageWriterRTEMS::writeFile - unable to open %s\n", 46 file 47 ); 48 exit(-1); 48 std::ostringstream what; 49 what << "Unable to open " << file; 50 throw rld::error( what, "CoverageWriterRTEMS::writeFile" ); 49 51 } 50 52 … … 57 59 strcpy( header.desc, "RTEMS Coverage Data" ); 58 60 59 status = fwrite(&header, 1, sizeof(header), coverageFile);61 status = ::fwrite(&header, 1, sizeof(header), coverageFile); 60 62 if (status != sizeof(header)) { 61 fprintf( 62 stderr, 63 "ERROR: CoverageWriterRTEMS::writeFile - unable to write header " 64 "to %s\n", 65 file 66 ); 67 exit(-1); 63 ::fclose( coverageFile ); 64 std::ostringstream what; 65 what << "Unable to write header to " << file; 66 throw rld::error( what, "CoverageWriterRTEMS::writeFile" ); 68 67 } 69 68 … … 72 71 status = fwrite(&cover, 1, sizeof(cover), coverageFile); 73 72 if (status != sizeof(cover)) { 74 fprintf(75 stderr,76 "ERROR: CoverageWriterRTEMS::writeFile - write to %s"77 "at address 0x%08x failed\n",78 file,79 a80 );81 exit( -1 );73 std::cerr << "CoverageWriterRTEMS::writeFile - write to " 74 << file 75 << " at address 0x%" 76 << std::hex << std::setfill('0') 77 << std::setw(8) << a 78 << std::setfill(' ') << std::dec 79 << " failed" 80 << std::endl; 82 81 } 83 // fprintf( stderr, "0x%x %d\n", a, cover );84 82 } 85 83 86 fclose( coverageFile );84 ::fclose( coverageFile ); 87 85 } 88 86 } -
tester/covoar/CoverageWriterSkyeye.cc
r1e21ea7 r881824f 9 9 #include <stdio.h> 10 10 #include <stdlib.h> 11 #include <stdio.h> 11 12 #include <string.h> 13 14 #include <iostream> 15 #include <iomanip> 16 17 #include <rld.h> 12 18 13 19 #include "CoverageWriterSkyeye.h" … … 15 21 16 22 namespace Coverage { 17 23 18 24 CoverageWriterSkyeye::CoverageWriterSkyeye() 19 25 { … … 40 46 * read the file and update the coverage map passed in 41 47 */ 42 coverageFile = fopen( file, "w" );48 coverageFile = ::fopen( file, "w" ); 43 49 if ( !coverageFile ) { 44 fprintf( 45 stderr, 46 "ERROR: CoverageWriterSkyeye::writeFile - unable to open %s\n", 47 file 48 ); 49 exit(-1); 50 std::ostringstream what; 51 what << "Unable to open " << file; 52 throw rld::error( what, "CoverageWriterSkyeye::writeFile" ); 50 53 } 51 54 … … 58 61 strcpy( header.desc, "Skyeye Coverage Data" ); 59 62 60 status = fwrite(&header, 1, sizeof(header), coverageFile);63 status = ::fwrite(&header, 1, sizeof(header), coverageFile); 61 64 if (status != sizeof(header)) { 62 fprintf( 63 stderr, 64 "ERROR: CoverageWriterSkyeye::writeFile - unable to write header " 65 "to %s\n", 66 file 67 ); 68 exit(-1); 65 ::fclose( coverageFile ); 66 std::ostringstream what; 67 what << "Unable to write header to " << file; 68 throw rld::error( what, "CoverageWriterSkyeye::writeFile" ); 69 69 } 70 70 71 for ( a =lowAddress ; a < highAddress ; a+= 8 ) {71 for ( a = lowAddress; a < highAddress; a += 8 ) { 72 72 cover = ((coverage->wasExecuted( a )) ? 0x01 : 0); 73 73 cover |= ((coverage->wasExecuted( a + 4 )) ? 0x10 : 0); 74 74 status = fwrite(&cover, 1, sizeof(cover), coverageFile); 75 75 if (status != sizeof(cover)) { 76 fprintf( 77 stderr, 78 "ERROR: CoverageWriterSkyeye::writeFile - write to %s " 79 "at address 0x%08x failed\n", 80 file, 81 a 82 ); 83 exit( -1 ); 76 ::fclose( coverageFile ); 77 std::ostringstream what; 78 what << "write to " << file 79 << " at address 0x" 80 << std::hex << std::setfill('0') 81 << std::setw(8) << a 82 << std::setfill(' ') << std::dec 83 << "failed"; 84 throw rld::error( what, "CoverageWriterSkyeye::writeFile" ); 84 85 } 85 // fprintf( stderr, "0x%x %d\n", a, cover );86 86 } 87 87 88 fclose( coverageFile );88 ::fclose( coverageFile ); 89 89 } 90 90 } -
tester/covoar/CoverageWriterTSIM.cc
r1e21ea7 r881824f 9 9 #include <stdlib.h> 10 10 11 #include <iostream> 12 #include <iomanip> 13 14 #include <rld.h> 15 11 16 #include "CoverageWriterTSIM.h" 12 17 13 18 namespace Coverage { 14 19 15 20 CoverageWriterTSIM::CoverageWriterTSIM() 16 21 { … … 21 26 } 22 27 23 28 24 29 void CoverageWriterTSIM::writeFile( 25 30 const char* const file, … … 38 43 * read the file and update the coverage map passed in 39 44 */ 40 coverageFile = fopen( file, "w" );45 coverageFile = ::fopen( file, "w" ); 41 46 if ( !coverageFile ) { 42 fprintf( 43 stderr, 44 "ERROR: CoverageWriterTSIM::writeFile - unable to open %s\n", 45 file 46 ); 47 exit(-1); 47 std::ostringstream what; 48 what << "Unable to open " << file; 49 throw rld::error( what, "CoverageWriterTSIM::writeFile" ); 48 50 } 49 51 50 for ( a =lowAddress ; a < highAddress ; a+= 0x80 ) {52 for ( a = lowAddress; a < highAddress; a += 0x80 ) { 51 53 status = fprintf( coverageFile, "%x : ", a ); 52 54 if ( status == EOF || status == 0 ) { 53 55 break; 54 56 } 55 // fprintf( stderr, "%08x : ", baseAddress ); 56 for ( i=0 ; i < 0x80 ; i+=4 ) { 57 for ( i = 0; i < 0x80; i += 4 ) { 57 58 cover = ((coverage->wasExecuted( a + i )) ? 1 : 0); 58 status = fprintf( coverageFile, "%d ", cover );59 status = ::fprintf( coverageFile, "%d ", cover ); 59 60 if ( status == EOF || status == 0 ) { 60 fprintf( 61 stderr, 62 "ERROR: CoverageWriterTSIM:writeFile - write to %s " 63 "at address 0x%08x failed\n", 64 file, 65 a 66 ); 67 exit( -1 ); 61 ::fclose( coverageFile ); 62 std::ostringstream what; 63 what << "write to " << file 64 << " at address 0x" 65 << std::hex << std::setfill('0') 66 << std::setw(8) << a 67 << std::setfill(' ') << std::dec 68 << "failed"; 69 throw rld::error( what, "CoverageWriterTSIM::writeFile" ); 68 70 } 69 // fprintf( stderr, "%d ", cover );70 71 } 71 fprintf( coverageFile, "\n" ); 72 // fprintf( stderr, "\n" ); 73 72 ::fprintf( coverageFile, "\n" ); 74 73 } 75 74 76 fclose( coverageFile );75 ::fclose( coverageFile ); 77 76 } 78 77 } -
tester/covoar/DesiredSymbols.cc
r1e21ea7 r881824f 38 38 } 39 39 40 boolDesiredSymbols::load(40 void DesiredSymbols::load( 41 41 const std::string& symbolsSet, 42 42 const std::string& buildTarget, … … 46 46 { 47 47 rld::files::cache cache; 48 bool r = true;49 48 50 49 // … … 104 103 set[sym.name()] = *(new SymbolInformation); 105 104 } 106 107 } catch (rld::error re) {108 std::cerr << "error: "109 << re.where << ": " << re.what110 << std::endl;111 r = false;112 105 } catch (...) { 113 106 cache.close(); … … 116 109 117 110 cache.close(); 118 119 return r;120 111 } 121 112 … … 333 324 334 325 if (itr == set.end()) { 335 std::cerr << "ERROR: DesiredSymbols::createCoverageMap - Unable to create " 336 << "unified coverage map for " 337 << symbolName 338 << " because it is NOT a desired symbol" 339 << std::endl; 340 exit( -1 ); 326 std::ostringstream what; 327 what << "Unable to create unified coverage map for " 328 << symbolName 329 << " because it is NOT a desired symbol"; 330 throw rld::error( what, "DesiredSymbols::createCoverageMap" ); 341 331 } 342 332 … … 374 364 375 365 aCoverageMap = new CoverageMap( exefileName, 0, highAddress ); 376 if (!aCoverageMap) {377 378 fprintf(379 stderr,380 "ERROR: DesiredSymbols::createCoverageMap - Unable to allocate "381 "coverage map for %s:%s\n",382 exefileName.c_str(),383 symbolName.c_str()384 );385 exit( -1 );386 }387 366 388 367 if ( Verbose ) … … 491 470 492 471 if (itr == set.end()) { 493 std:: cerr << "ERROR: DesiredSymbols::mergeCoverageMap - Unable to merge "494 << "coverage map for %s because it is NOT a desired symbol"495 496 << std::endl;497 exit( -1);472 std::ostringstream what; 473 what << "Unable to merge coverage map for " 474 << symbolName 475 << " because it is NOT a desired symbol"; 476 throw rld::error( what, "DesiredSymbols::mergeCoverageMap" ); 498 477 } 499 478 -
tester/covoar/DesiredSymbols.h
r1e21ea7 r881824f 298 298 * @param[in] buildTarget The build target 299 299 * @param[in] buildBSP The BSP 300 * @return Returns false if the load fails. 301 */ 302 bool load( 300 */ 301 void load( 303 302 const std::string& symbolsSet, 304 303 const std::string& buildTarget, -
tester/covoar/ExecutableInfo.cc
r1e21ea7 r881824f 26 26 if (theLibraryName) 27 27 libraryName = theLibraryName; 28 try { 29 executable.open(); 30 executable.begin(); 31 executable.load_symbols(symbols); 32 debug.begin(executable.elf()); 33 debug.load_debug(); 34 } catch (rld::error re) { 35 std::cerr << "error: " 36 << re.where << ": " << re.what 37 << std::endl; 38 exit(2); 39 } catch (...) { 40 exit(2); 41 } 28 29 executable.open(); 30 executable.begin(); 31 executable.load_symbols(symbols); 32 debug.begin(executable.elf()); 33 debug.load_debug(); 42 34 } 43 35 -
tester/covoar/Explanations.cc
r1e21ea7 r881824f 2 2 * @brief Explanations Implementation 3 3 * 4 * This file contains the implementation of the functions 4 * This file contains the implementation of the functions 5 5 * which provide a base level of functionality of a Explanations. 6 6 */ … … 10 10 #include <string.h> 11 11 #include <unistd.h> 12 13 #include <rld.h> 12 14 13 15 #include "Explanations.h" … … 37 39 return; 38 40 39 explain = fopen( explanations, "r" );41 explain = ::fopen( explanations, "r" ); 40 42 if (!explain) { 41 fprintf( 42 stderr, 43 "ERROR: Explanations::load - unable to open explanations file %s\n", 44 explanations 45 ); 46 exit(-1); 43 std::ostringstream what; 44 what << "Unable to open " << explanations; 45 throw rld::error( what, "Explanations::load" ); 47 46 } 48 47 … … 63 62 // Have we already seen this one? 64 63 if (set.find( inputBuffer ) != set.end()) { 65 fprintf( 66 stderr, 67 "ERROR: Explanations::load - line %d " 68 "contains a duplicate explanation (%s)\n", 69 line, 70 inputBuffer 71 ); 72 exit( -1 ); 64 std::ostringstream what; 65 what << "line " << line 66 << "contains a duplicate explanation (" 67 << inputBuffer << ")"; 68 throw rld::error( what, "Explanations::load" ); 73 69 } 74 70 … … 77 73 e->found = false; 78 74 79 // Get the classification 75 // Get the classification 80 76 cStatus = fgets( inputBuffer, MAX_LINE_LENGTH, explain ); 81 77 if (cStatus == NULL) { 82 fprintf( 83 stderr, 84 "ERROR: Explanations::load - line %d " 85 "out of sync at the classification\n", 86 line 87 ); 88 exit( -1 ); 78 std::ostringstream what; 79 what << "line " << line 80 << "out of sync at the classification"; 81 throw rld::error( what, "Explanations::load" ); 89 82 } 90 83 inputBuffer[ strlen(inputBuffer) - 1] = '\0'; … … 92 85 line++; 93 86 94 // Get the explanation 87 // Get the explanation 95 88 while (1) { 96 89 cStatus = fgets( inputBuffer, MAX_LINE_LENGTH, explain ); 97 90 // fprintf( stderr, "%d - %s\n", line, inputBuffer ); 98 91 if (cStatus == NULL) { 99 fprintf( 100 stderr, 101 "ERROR: Explanations::load - line %d " 102 "out of sync at the explanation\n", 103 line 104 ); 105 exit( -1 ); 92 std::ostringstream what; 93 what << "line " << line 94 << "out of sync at the explanation"; 95 throw rld::error( what, "Explanations::load" ); 106 96 } 107 97 inputBuffer[ strlen(inputBuffer) - 1] = '\0'; … … 131 121 if (set.find( start ) == set.end()) { 132 122 #if 0 133 fprintf( stderr, 134 "Warning: Unable to find explanation for %s\n", 135 start.c_str() 136 ); 123 std::cerr << "Warning: Unable to find explanation for " 124 << start << std::endl; 137 125 #endif 138 126 return NULL; … … 151 139 if (!fileName) 152 140 return; 153 141 154 142 notFoundFile = fopen( fileName, "w" ); 155 143 if (!fileName) { 156 fprintf( 157 stderr, 158 "ERROR: Explanations::writeNotFound - unable to open file %s\n", 159 fileName 160 ); 161 exit( -1 ); 144 std::ostringstream what; 145 what << "Unable to open " << fileName 146 << "out of sync at the explanation"; 147 throw rld::error( what, "Explanations::writeNotFound" ); 162 148 } 163 149 164 150 for (std::map<std::string, Explanation>::iterator itr = set.begin(); 165 151 itr != set.end(); … … 167 153 Explanation e = (*itr).second; 168 154 std::string key = (*itr).first; 169 155 170 156 if (!e.found) { 171 157 notFoundOccurred = true; … … 175 161 e.startingPoint.c_str() 176 162 ); 177 } 163 } 178 164 } 179 165 fclose( notFoundFile ); … … 181 167 if (!notFoundOccurred) { 182 168 if (!unlink( fileName )) { 183 fprintf( stderr, 184 "Warning: Unable to unlink %s\n\n", 185 fileName 186 ); 169 std::cerr << "Warning: Unable to unlink " << fileName 170 << std::endl 171 << std::endl; 187 172 } 188 } 173 } 189 174 } 190 175 -
tester/covoar/ObjdumpProcessor.cc
r1e21ea7 r881824f 150 150 dlinfoName += ".dlinfo"; 151 151 // Read load address. 152 loadAddressFile = fopen( dlinfoName.c_str(), "r" );152 loadAddressFile = ::fopen( dlinfoName.c_str(), "r" ); 153 153 if (!loadAddressFile) { 154 fprintf( stderr, METHOD "unable to open %s\n", dlinfoName.c_str() ); 155 exit( -1 ); 154 std::ostringstream what; 155 what << "Unable to open " << dlinfoName; 156 throw rld::error( what, METHOD ); 156 157 } 157 158 … … 160 161 161 162 // Get a line. 162 cStatus = fgets( inputBuffer, MAX_LINE_LENGTH, loadAddressFile );163 cStatus = ::fgets( inputBuffer, MAX_LINE_LENGTH, loadAddressFile ); 163 164 if (cStatus == NULL) { 164 fprintf( 165 stderr, 166 METHOD "library %s not found in %s\n", 167 Library.c_str(), 168 dlinfoName.c_str() 169 ); 170 fclose( loadAddressFile ); 171 exit( -1 ); 165 ::fclose( loadAddressFile ); 166 std::ostringstream what; 167 what << "library " << Library << " not found in " << dlinfoName; 168 throw rld::error( what, METHOD ); 172 169 } 173 170 sscanf( inputBuffer, "%s %x", inLibName, &offset ); … … 180 177 } 181 178 182 fclose( loadAddressFile );179 ::fclose( loadAddressFile ); 183 180 return address; 184 181 -
tester/covoar/ReportsHtml.cc
r1e21ea7 r881824f 2 2 #include <stdlib.h> 3 3 #include <string.h> 4 5 #include <rld.h> 4 6 5 7 #include "ReportsHtml.h" … … 25 27 #else 26 28 #define TABLE_HEADER_CLASS 27 #define TABLE_FOOTER 29 #define TABLE_FOOTER 28 30 #endif 29 31 … … 57 59 58 60 FILE* aFile; 59 61 60 62 // Open the file 61 63 aFile = OpenFile( fileName ); … … 78 80 "Coverage Analysis Reports</div>\n" 79 81 "<div class =\"datetime\">%s</div>\n", 80 asctime( localtime(×tamp_m) ) 82 asctime( localtime(×tamp_m) ) 81 83 ); 82 84 … … 110 112 { 111 113 FILE* aFile; 112 114 113 115 // Open the file 114 116 aFile = ReportsBase::OpenFile( fileName ); … … 155 157 "<body>\n" 156 158 "<pre class=\"code\">\n", 157 asctime( localtime(×tamp_m) ) 159 asctime( localtime(×tamp_m) ) 158 160 ); 159 161 … … 207 209 "</thead>\n" 208 210 "<tbody>\n", 209 asctime( localtime(×tamp_m) ) 211 asctime( localtime(×tamp_m) ) 210 212 ); 211 213 } 212 214 213 215 return aFile; 214 216 } … … 256 258 "</thead>\n" 257 259 "<tbody>\n", 258 asctime( localtime(×tamp_m) ) 260 asctime( localtime(×tamp_m) ) 259 261 260 262 ); … … 299 301 "</thead>\n" 300 302 "<tbody>\n", 301 asctime( localtime(×tamp_m) ) 303 asctime( localtime(×tamp_m) ) 302 304 303 305 ); … … 347 349 "</thead>\n" 348 350 "<tbody>\n", 349 asctime( localtime(×tamp_m) ) 351 asctime( localtime(×tamp_m) ) 350 352 351 353 ); … … 399 401 "</thead>\n" 400 402 "<tbody>\n", 401 asctime( localtime(×tamp_m) ) 403 asctime( localtime(×tamp_m) ) 402 404 403 405 ); … … 409 411 ) 410 412 { 411 fprintf( 412 aFile, 413 "<hr>\n" 414 ); 415 } 416 413 fprintf( 414 aFile, 415 "<hr>\n" 416 ); 417 } 418 417 419 void ReportsHtml::AnnotatedEnd( 418 420 FILE* aFile … … 421 423 } 422 424 423 void ReportsHtml::PutAnnotatedLine( 424 FILE* aFile, 425 AnnotatedLineState_t state, 426 std::string line, 427 uint32_t id 425 void ReportsHtml::PutAnnotatedLine( 426 FILE* aFile, 427 AnnotatedLineState_t state, 428 std::string line, 429 uint32_t id 428 430 ) 429 431 { … … 431 433 char number[10]; 432 434 433 435 434 436 sprintf(number,"%d", id); 435 437 … … 461 463 break; 462 464 default: 463 fprintf(stderr, "ERROR: ReportsHtml::PutAnnotatedLine Unknown state\n"); 464 exit( -1 ); 465 throw rld::error( "Unknown state", "ReportsHtml::PutAnnotatedLine"); 465 466 break; 466 467 } … … 518 519 519 520 // symbol 520 fprintf( 521 report, 522 "<td class=\"covoar-td\" align=\"center\">%s</td>\n", 521 fprintf( 522 report, 523 "<td class=\"covoar-td\" align=\"center\">%s</td>\n", 523 524 symbolPtr->first.c_str() 524 525 ); 525 526 526 527 // line 527 fprintf( 528 report, 529 "<td class=\"covoar-td\" align=\"center\"><a href =\"annotated.html#range%d\">%s</td>\n", 528 fprintf( 529 report, 530 "<td class=\"covoar-td\" align=\"center\"><a href =\"annotated.html#range%d\">%s</td>\n", 530 531 rangePtr->id, 531 532 rangePtr->lowSourceLine.c_str() … … 535 536 i = rangePtr->lowSourceLine.find(":"); 536 537 temp = rangePtr->lowSourceLine.substr (0, i); 537 fprintf( 538 report, 539 "<td class=\"covoar-td\" align=\"center\">%s</td>\n", 538 fprintf( 539 report, 540 "<td class=\"covoar-td\" align=\"center\">%s</td>\n", 540 541 temp.c_str() 541 542 ); 542 543 543 544 // Size in bytes 544 fprintf( 545 report, 545 fprintf( 546 report, 546 547 "<td class=\"covoar-td\" align=\"center\">%d</td>\n", 547 548 rangePtr->highAddress - rangePtr->lowAddress + 1 … … 551 552 if (rangePtr->reason == 552 553 Coverage::CoverageRanges::UNCOVERED_REASON_BRANCH_ALWAYS_TAKEN) 553 fprintf( 554 fprintf( 554 555 report, 555 556 "<td class=\"covoar-td\" align=\"center\">Always Taken</td>\n" … … 557 558 else if (rangePtr->reason == 558 559 Coverage::CoverageRanges::UNCOVERED_REASON_BRANCH_NEVER_TAKEN) 559 fprintf( 560 report, 560 fprintf( 561 report, 561 562 "<td class=\"covoar-td\" align=\"center\">Never Taken</td>\n" 562 563 ); … … 582 583 if ( !explanation ) { 583 584 // Write Classificationditr->second.baseAddress 584 fprintf( 585 report, 585 fprintf( 586 report, 586 587 "<td class=\"covoar-td\" align=\"center\">NONE</td>\n" 587 588 "<td class=\"covoar-td\" align=\"center\">No Explanation</td>\n" … … 590 591 char explanationFile[48]; 591 592 sprintf( explanationFile, "explanation%d.html", rangePtr->id ); 592 fprintf( 593 report, 593 fprintf( 594 report, 594 595 "<td class=\"covoar-td\" align=\"center\">%s</td>\n" 595 596 "<td class=\"covoar-td\" align=\"center\">" … … 654 655 655 656 // symbol 656 fprintf( 657 report, 658 "<td class=\"covoar-td\" align=\"center\">%s</td>\n", 657 fprintf( 658 report, 659 "<td class=\"covoar-td\" align=\"center\">%s</td>\n", 659 660 symbol.c_str() 660 661 ); 661 fprintf( 662 noRangeFile, 663 "<td class=\"covoar-td\" align=\"center\">%s</td>\n", 662 fprintf( 663 noRangeFile, 664 "<td class=\"covoar-td\" align=\"center\">%s</td>\n", 664 665 symbol.c_str() 665 666 ); 666 667 667 668 // starting line 668 fprintf( 669 report, 669 fprintf( 670 report, 670 671 "<td class=\"covoar-td\" align=\"center\">unknown</td>\n" 671 672 ); 672 673 673 674 // file 674 fprintf( 675 report, 675 fprintf( 676 report, 676 677 "<td class=\"covoar-td\" align=\"center\">unknown</td>\n" 677 678 ); 678 679 679 680 // Size in bytes 680 fprintf( 681 report, 681 fprintf( 682 report, 682 683 "<td class=\"covoar-td\" align=\"center\">unknown</td>\n" 683 684 ); 684 685 685 686 // Size in instructions 686 fprintf( 687 report, 687 fprintf( 688 report, 688 689 "<td class=\"covoar-td\" align=\"center\">unknown</td>\n" 689 ); 690 ); 690 691 691 692 // See if an explanation is available 692 fprintf( 693 report, 693 fprintf( 694 report, 694 695 "<td class=\"covoar-td\" align=\"center\">Unknown</td>\n" 695 696 "<td class=\"covoar-td\" align=\"center\">" … … 720 721 721 722 // symbol 722 fprintf( 723 report, 724 "<td class=\"covoar-td\" align=\"center\">%s</td>\n", 723 fprintf( 724 report, 725 "<td class=\"covoar-td\" align=\"center\">%s</td>\n", 725 726 symbolPtr->first.c_str() 726 727 ); 727 728 728 729 // Range 729 fprintf( 730 report, 730 fprintf( 731 report, 731 732 "<td class=\"covoar-td\" align=\"center\"><a href =\"annotated.html#range%d\">%s <br>%s</td>\n", 732 rangePtr->id, 733 rangePtr->id, 733 734 rangePtr->lowSourceLine.c_str(), 734 735 rangePtr->highSourceLine.c_str() … … 738 739 i = rangePtr->lowSourceLine.find(":"); 739 740 temp = rangePtr->lowSourceLine.substr (0, i); 740 fprintf( 741 report, 742 "<td class=\"covoar-td\" align=\"center\">%s</td>\n", 741 fprintf( 742 report, 743 "<td class=\"covoar-td\" align=\"center\">%s</td>\n", 743 744 temp.c_str() 744 745 ); 745 746 746 747 // Size in bytes 747 fprintf( 748 report, 748 fprintf( 749 report, 749 750 "<td class=\"covoar-td\" align=\"center\">%d</td>\n", 750 751 rangePtr->highAddress - rangePtr->lowAddress + 1 … … 752 753 753 754 // Size in instructions 754 fprintf( 755 report, 755 fprintf( 756 report, 756 757 "<td class=\"covoar-td\" align=\"center\">%d</td>\n", 757 758 rangePtr->instructionCount 758 ); 759 ); 759 760 760 761 // See if an explanation is available 761 762 explanation = AllExplanations->lookupExplanation( rangePtr->lowSourceLine ); 762 763 if ( !explanation ) { 763 fprintf( 764 report, 764 fprintf( 765 report, 765 766 "<td class=\"covoar-td\" align=\"center\">NONE</td>\n" 766 767 ); 767 fprintf( 768 report, 768 fprintf( 769 report, 769 770 "<td class=\"covoar-td\" align=\"center\">No Explanation</td>\n" 770 771 ); … … 773 774 774 775 sprintf( explanationFile, "explanation%d.html", rangePtr->id ); 775 fprintf( 776 report, 776 fprintf( 777 report, 777 778 "<td class=\"covoar-td\" align=\"center\">%s</td>\n" 778 779 "<td class=\"covoar-td\" align=\"center\">" … … 806 807 807 808 // size 808 fprintf( 809 report, 809 fprintf( 810 report, 810 811 "<td class=\"covoar-td\" align=\"center\">%d</td>\n", 811 812 range->highAddress - range->lowAddress + 1 … … 813 814 814 815 // symbol 815 fprintf( 816 report, 817 "<td class=\"covoar-td\" align=\"center\">%s</td>\n", 816 fprintf( 817 report, 818 "<td class=\"covoar-td\" align=\"center\">%s</td>\n", 818 819 symbol->first.c_str() 819 820 ); 820 821 821 822 // line 822 fprintf( 823 report, 824 "<td class=\"covoar-td\" align=\"center\"><a href =\"annotated.html#range%d\">%s</td>\n", 823 fprintf( 824 report, 825 "<td class=\"covoar-td\" align=\"center\"><a href =\"annotated.html#range%d\">%s</td>\n", 825 826 range->id, 826 827 range->lowSourceLine.c_str() … … 830 831 i = range->lowSourceLine.find(":"); 831 832 temp = range->lowSourceLine.substr (0, i); 832 fprintf( 833 report, 834 "<td class=\"covoar-td\" align=\"center\">%s</td>\n", 833 fprintf( 834 report, 835 "<td class=\"covoar-td\" align=\"center\">%s</td>\n", 835 836 temp.c_str() 836 837 ); 837 838 838 839 fprintf( report, "</tr>\n"); 839 840 … … 847 848 ) 848 849 { 849 850 850 851 // Mark the background color different for odd and even lines. 851 852 if ( ( count%2 ) != 0 ) … … 855 856 856 857 // symbol 857 fprintf( 858 report, 859 "<td class=\"covoar-td\" align=\"center\">%s</td>\n", 858 fprintf( 859 report, 860 "<td class=\"covoar-td\" align=\"center\">%s</td>\n", 860 861 symbol->first.c_str() 861 862 ); 862 863 863 864 // Total Size in Bytes 864 fprintf( 865 report, 865 fprintf( 866 report, 866 867 "<td class=\"covoar-td\" align=\"center\">%d</td>\n", 867 868 symbol->second.stats.sizeInBytes 868 869 ); 869 870 870 // Total Size in Instructions 871 fprintf( 872 report, 871 // Total Size in Instructions 872 fprintf( 873 report, 873 874 "<td class=\"covoar-td\" align=\"center\">%d</td>\n", 874 875 symbol->second.stats.sizeInInstructions … … 876 877 877 878 // Total Uncovered Ranges 878 fprintf( 879 report, 880 "<td class=\"covoar-td\" align=\"center\">%d</td>\n", 879 fprintf( 880 report, 881 "<td class=\"covoar-td\" align=\"center\">%d</td>\n", 881 882 symbol->second.stats.uncoveredRanges 882 883 ); 883 884 884 885 // Uncovered Size in Bytes 885 fprintf( 886 report, 886 fprintf( 887 report, 887 888 "<td class=\"covoar-td\" align=\"center\">%d</td>\n", 888 889 symbol->second.stats.uncoveredBytes 889 890 ); 890 891 891 // Uncovered Size in Instructions 892 fprintf( 893 report, 892 // Uncovered Size in Instructions 893 fprintf( 894 report, 894 895 "<td class=\"covoar-td\" align=\"center\">%d</td>\n", 895 896 symbol->second.stats.uncoveredInstructions … … 897 898 898 899 // Total number of branches 899 fprintf( 900 report, 901 "<td class=\"covoar-td\" align=\"center\">%d</td>\n", 900 fprintf( 901 report, 902 "<td class=\"covoar-td\" align=\"center\">%d</td>\n", 902 903 symbol->second.stats.branchesNotExecuted + symbol->second.stats.branchesExecuted 903 904 ); 904 905 905 906 // Total Always Taken 906 fprintf( 907 report, 907 fprintf( 908 report, 908 909 "<td class=\"covoar-td\" align=\"center\">%d</td>\n", 909 910 symbol->second.stats.branchesAlwaysTaken … … 911 912 912 913 // Total Never Taken 913 fprintf( 914 report, 914 fprintf( 915 report, 915 916 "<td class=\"covoar-td\" align=\"center\">%d</td>\n", 916 917 symbol->second.stats.branchesNeverTaken … … 919 920 // % Uncovered Instructions 920 921 if ( symbol->second.stats.sizeInInstructions == 0 ) 921 fprintf( 922 report, 922 fprintf( 923 report, 923 924 "<td class=\"covoar-td\" align=\"center\">100.00</td>\n" 924 925 ); 925 else 926 fprintf( 927 report, 926 else 927 fprintf( 928 report, 928 929 "<td class=\"covoar-td\" align=\"center\">%.2f</td>\n", 929 930 (symbol->second.stats.uncoveredInstructions*100.0)/ … … 933 934 // % Uncovered Bytes 934 935 if ( symbol->second.stats.sizeInBytes == 0 ) 935 fprintf( 936 report, 936 fprintf( 937 report, 937 938 "<td class=\"covoar-td\" align=\"center\">100.00</td>\n" 938 939 ); 939 else 940 fprintf( 941 report, 940 else 941 fprintf( 942 report, 942 943 "<td class=\"covoar-td\" align=\"center\">%.2f</td>\n", 943 944 (symbol->second.stats.uncoveredBytes*100.0)/ … … 973 974 TABLE_FOOTER 974 975 "</tbody>\n" 975 "</table>\n" 976 "</table>\n" 976 977 ); 977 978 } 978 979 fprintf( 979 980 aFile, 980 "</pre>\n" 981 "</pre>\n" 981 982 "</body>\n" 982 983 "</html>" … … 994 995 TABLE_FOOTER 995 996 "</tbody>\n" 996 "</table>\n" 997 "</pre>\n" 997 "</table>\n" 998 "</pre>\n" 998 999 "</body>\n" 999 1000 "</html>" … … 1011 1012 TABLE_FOOTER 1012 1013 "</tbody>\n" 1013 "</table>\n" 1014 "</pre>\n" 1014 "</table>\n" 1015 "</pre>\n" 1015 1016 "</body>\n" 1016 1017 "</html>" … … 1029 1030 TABLE_FOOTER 1030 1031 "</tbody>\n" 1031 "</table>\n" 1032 "</pre>\n" 1032 "</table>\n" 1033 "</pre>\n" 1033 1034 "</body>\n" 1034 1035 "</html>" … … 1046 1047 TABLE_FOOTER 1047 1048 "</tbody>\n" 1048 "</table>\n" 1049 "</pre>\n" 1049 "</table>\n" 1050 "</pre>\n" 1050 1051 "</body>\n" 1051 1052 "</html>" -
tester/covoar/SymbolTable.cc
r1e21ea7 r881824f 10 10 #include <stdlib.h> 11 11 #include <string.h> 12 13 #include <rld.h> 12 14 13 15 #include "SymbolTable.h" … … 44 46 symbolData.startingAddress = start; 45 47 symbolData.length = length; 46 48 47 49 if ( info[ symbol ].empty() == false ) { 48 50 if ( info[ symbol ].front().length != length ) { 49 fprintf(stderr,50 "ERROR==> Different lengths for the symbol %s (%d and %d)\n",51 symbol.c_str(),52 info[ symbol ].front().length,53 length54 );55 exit( 0);51 std::ostringstream what; 52 what << "Different lengths for the symbol " 53 << symbol 54 << " (" << info[ symbol ].front().length 55 << " and " << length 56 << ")"; 57 throw rld::error( what, "SymbolTable::addSymbol" ); 56 58 } 57 59 } -
tester/covoar/TargetBase.cc
r1e21ea7 r881824f 2 2 * @brief TargetBase Implementation 3 3 * 4 * This file contains the implementation of the base class for 4 * This file contains the implementation of the base class for 5 5 * functions supporting target unique functionallity. 6 6 */ 7 8 #include "TargetBase.h"9 #include "qemu-traces.h"10 7 11 8 #include <algorithm> … … 13 10 #include <stdlib.h> 14 11 12 #include <rld.h> 13 14 #include "TargetBase.h" 15 #include "qemu-traces.h" 16 15 17 namespace Target { 16 18 17 TargetBase::TargetBase( 19 TargetBase::TargetBase( 18 20 std::string targetName 19 21 ): … … 66 68 67 69 if (branchInstructions.empty()) { 68 fprintf( 69 stderr, 70 "DETERMINE BRANCH INSTRUCTIONS FOR THIS ARCHITECTURE! -- fix me\n" 71 ); 72 exit( -1 ); 70 throw rld::error( 71 "DETERMINE BRANCH INSTRUCTIONS FOR THIS ARCHITECTURE! -- fix me", 72 "TargetBase::isBranch" 73 ); 73 74 } 74 75 75 76 i = find(branchInstructions.begin(), branchInstructions.end(), instruction); 76 77 if ( i == branchInstructions.end() ) … … 91 92 int result; 92 93 93 94 94 95 ch = &(line[0]); 95 96 96 97 // Increment to the first tab in the line 97 while ((*ch != '\t') && (*ch != '\0')) { 98 while ((*ch != '\t') && (*ch != '\0')) { 98 99 ch++; 99 100 } … … 105 106 106 107 // Increment to the second tab in the line 107 while ((*ch != '\t') && (*ch != '\0')) 108 while ((*ch != '\t') && (*ch != '\0')) 108 109 ch++; 109 110 if (*ch != '\t') { -
tester/covoar/TargetFactory.cc
r1e21ea7 r881824f 9 9 //! 10 10 11 #include <stdio.h> 12 #include <stdlib.h> 13 #include <string.h> 14 #include <unistd.h> 15 16 #include <rld.h> 17 11 18 #include "TargetFactory.h" 12 19 … … 17 24 #include "Target_lm32.h" 18 25 #include "Target_sparc.h" 19 #include <stdio.h>20 #include <stdlib.h>21 #include <string.h>22 #include <unistd.h>23 26 24 27 namespace Target { … … 35 38 const char *theTarget; 36 39 //! This is the static wrapper for the constructor. 37 TargetBase *(*theCtor)( 40 TargetBase *(*theCtor)( 38 41 std::string 39 42 ); … … 77 80 } 78 81 79 fprintf( 80 stderr, 81 "ERROR!!! %s is not a known architecture!!!\n", 82 cpu.c_str() 83 ); 84 fprintf( stderr, "-- fix me\n" ); 85 exit( 1 ); 82 std::ostringstream what; 83 what << cpu << "is not a known architecture!!! - fix me" << std::endl; 84 throw rld::error( what, "TargetFactory" ); 86 85 87 86 return NULL; -
tester/covoar/Target_arm.cc
r1e21ea7 r881824f 2 2 * @brief Target_arm Implementation 3 3 * 4 * This file contains the implementation of the base class for 4 * This file contains the implementation of the base class for 5 5 * functions supporting target unique functionallity. 6 6 */ 7 #include "Target_arm.h" 7 8 8 #include <stdio.h> 9 9 #include <stdlib.h> 10 10 #include <string.h> 11 11 #include <unistd.h> 12 13 #include <rld.h> 14 15 #include "Target_arm.h" 12 16 13 17 namespace Target { … … 32 36 branchInstructions.push_back("bvc"); 33 37 branchInstructions.push_back("bvs"); 34 38 35 39 branchInstructions.sort(); 36 40 … … 47 51 { 48 52 if (!strcmp( &line[strlen(line)-3], "nop")) { 49 size = 4; 53 size = 4; 50 54 return true; 51 55 } … … 67 71 68 72 return false; 69 73 70 74 } 71 75 72 76 bool Target_arm::isBranch( 73 77 const char* instruction 74 ) 78 ) 75 79 { 76 fprintf( stderr, "DETERMINE BRANCH INSTRUCTIONS FOR THIS ARCHITECTURE! -- fix me\n" ); 77 exit( -1 ); 80 throw rld::error( 81 "DETERMINE BRANCH INSTRUCTIONS FOR THIS ARCHITECTURE! -- fix me", 82 "Target_arm::isBranch" 83 ); 78 84 } 79 85 -
tester/covoar/Target_m68k.cc
r1e21ea7 r881824f 2 2 * @brief Target_m68k Implementation 3 3 * 4 * This file contains the implementation of the base class for 4 * This file contains the implementation of the base class for 5 5 * functions supporting target unique functionallity. 6 6 */ 7 #include "Target_m68k.h"8 #include "qemu-traces.h"9 7 #include <stdio.h> 10 8 #include <stdlib.h> 11 9 #include <string.h> 12 10 #include <unistd.h> 11 12 #include <rld.h> 13 14 #include "Target_m68k.h" 15 #include "qemu-traces.h" 13 16 14 17 namespace Target { … … 65 68 branchInstructions.push_back("bvss"); 66 69 branchInstructions.push_back("bvsl"); 67 70 68 71 branchInstructions.sort(); 69 72 … … 80 83 { 81 84 if (!strcmp( &line[strlen(line)-3], "nop")) { 82 size = 2; 85 size = 2; 83 86 return true; 84 87 } … … 88 91 // Until binutils 2.20, binutils would fill with rts not nop 89 92 if (!strcmp( &line[strlen(line)-3], "rts")) { 90 size = 4; 93 size = 4; 91 94 return true; 92 } 95 } 93 96 #endif 94 97 … … 100 103 ) 101 104 { 102 fprintf(103 stderr,104 " DETERMINE BRANCH INSTRUCTIONS FOR THIS ARCHITECTURE! -- fix me\n"105 throw rld::error( 106 "DETERMINE BRANCH INSTRUCTIONS FOR THIS ARCHITECTURE! -- fix me", 107 "Target_m68k::isBranch" 105 108 ); 106 exit( -1 );107 109 } 108 110 -
tester/covoar/Target_powerpc.cc
r1e21ea7 r881824f 2 2 * @brief Target_powerpc Implementation 3 3 * 4 * This file contains the implementation of the base class for 4 * This file contains the implementation of the base class for 5 5 * functions supporting target unique functionallity. 6 6 */ 7 #include "Target_powerpc.h"8 7 #include <stdio.h> 9 8 #include <stdlib.h> 10 9 #include <string.h> 11 10 #include <unistd.h> 11 12 #include <rld.h> 13 14 #include "Target_powerpc.h" 12 15 13 16 namespace Target { … … 47 50 branchInstructions.push_back("bclrl"); 48 51 49 50 branchInstructions.sort(); 52 53 branchInstructions.sort(); 51 54 } 52 55 … … 61 64 { 62 65 if (!strcmp( &line[strlen(line)-3], "nop")) { 63 size = 4; 66 size = 4; 64 67 return true; 65 68 } … … 72 75 ) 73 76 { 74 fprintf( stderr, "DETERMINE BRANCH INSTRUCTIONS FOR THIS ARCHITECTURE! -- fix me\n" ); 75 exit( -1 ); 77 throw rld::error( 78 "DETERMINE BRANCH INSTRUCTIONS FOR THIS ARCHITECTURE! -- fix me", 79 "Target_powerpc::isBranch" 80 ); 76 81 } 77 82 -
tester/covoar/TraceConverter.cc
r1e21ea7 r881824f 14 14 #include <unistd.h> 15 15 16 #include <rld.h> 17 #include <rld-process.h> 18 16 19 #include "qemu-log.h" 17 20 #include "TraceReaderLogQEMU.h" … … 21 24 #include "app_common.h" 22 25 #include "TargetFactory.h" 23 24 #include "rld.h"25 #include "rld-process.h"26 26 27 27 #ifdef _WIN32 -
tester/covoar/TraceWriterQEMU.cc
r1e21ea7 r881824f 39 39 #include <sys/stat.h> 40 40 41 #include <iostream> 42 #include <iomanip> 43 44 #include <rld-process.h> 45 41 46 #include "app_common.h" 42 47 #include "TraceWriterQEMU.h" … … 44 49 #include "CoverageMap.h" 45 50 #include "qemu-traces.h" 46 47 #include "rld-process.h"48 51 49 52 #if HAVE_STAT64 … … 95 98 // Open the trace file. 96 99 // 97 traceFile = OPEN( file, "w" );100 traceFile = ::OPEN( file, "w" ); 98 101 if (!traceFile) { 99 fprintf( stderr, "Unable to open %s\n", file ); 102 std::ostringstream what; 103 std::cerr << "Unable to open " << file << std::endl; 100 104 return false; 101 105 } … … 111 115 header.machine[0] = 0; // XXX ?? 112 116 header.machine[1] = 0; // XXX ?? 113 status = fwrite( &header, sizeof(trace_header), 1, traceFile );117 status = ::fwrite( &header, sizeof(trace_header), 1, traceFile ); 114 118 if (status != 1) { 115 fprintf( stderr, "Unable to write header to %s\n", file );119 std::cerr << "Unable to write header to " << file << std::endl; 116 120 return false; 117 121 } 118 122 119 123 if (Verbose) 120 fprintf( 121 stderr, 122 "magic = %s\n" 123 "version = %d\n" 124 "kind = %d\n" 125 "sizeof_target_pc = %d\n" 126 "big_endian = %d\n" 127 "machine = %02x:%02x\n", 128 header.magic, 129 header.version, 130 header.kind, 131 header.sizeof_target_pc, 132 header.big_endian, 133 header.machine[0], header.machine[1] 134 ); 124 std::cerr << "magic = " << header.magic << std::endl 125 << "version = " << header.version << std::endl 126 << "kind = " << header.kind << std::endl 127 << "sizeof_target_pc = " << header.sizeof_target_pc << std::endl 128 << "big_endian = " << header.big_endian << std::endl 129 << std::hex << std::setfill('0') 130 << "machine = " << std::setw(2) << header.machine[0] 131 << ':' << header.machine[1] 132 << std::dec << std::setfill(' ') 133 << std::endl; 135 134 136 135 // … … 154 153 break; 155 154 default: 156 fprintf(stderr, "Unknown exit Reason\n"); 157 exit(1); 155 throw rld::error( "Unknown exit Reason", "TraceWriterQEMU::writeFile" ); 158 156 break; 159 157 } 160 158 161 159 if ( Verbose ) 162 fprintf(stderr, "%x %x %x\n", entry.pc, entry.size, entry.op); 160 std::cerr << std::hex << std::setfill('0') 161 << entry.pc << ' ' << entry.size << ' ' << entry.op 162 << std::dec << std::setfill(' ') 163 << std::endl; 163 164 164 status = fwrite( &entry, sizeof(entry), 1, traceFile );165 status = ::fwrite( &entry, sizeof(entry), 1, traceFile ); 165 166 if (status != 1) { 166 fprintf( stderr, "Unable to write entry to %s\n", file );167 std::cerr << "Unable to write entry to " << file << std::endl; 167 168 return false; 168 169 } 169 170 } 170 171 171 fclose( traceFile );172 ::fclose( traceFile ); 172 173 return true; 173 174 } -
tester/covoar/covoar.cc
r1e21ea7 r881824f 1 #include <iostream> 2 #include <iomanip> 3 4 #include <cxxabi.h> 1 5 #include <ctype.h> 2 6 #include <errno.h> … … 13 17 #include <list> 14 18 19 #include <rld.h> 20 #include <rld-process.h> 21 15 22 #include "app_common.h" 16 23 #include "CoverageFactory.h" … … 24 31 #include "GcovData.h" 25 32 26 #include "rld-process.h"27 28 33 #ifdef _WIN32 29 34 #define kill(p,s) raise(s) … … 32 37 typedef std::list<std::string> CoverageNames; 33 38 typedef std::list<Coverage::ExecutableInfo*> Executables; 39 typedef std::string option_error; 34 40 35 41 /* … … 106 112 } 107 113 if (!fail.empty()) { 108 std::cerr << "ERROR: " << fail << std::endl; 109 exit(EXIT_FAILURE); 114 throw rld::error( fail, "createBuildPath" ); 110 115 } 111 116 } … … 139 144 } 140 145 141 #define PrintableString(_s) \ 142 ((!(_s)) ? "NOT SET" : (_s)) 143 144 static void 145 fatal_signal( int signum ) 146 { 147 signal( signum, SIG_DFL ); 148 149 rld::process::temporaries_clean_up(); 150 151 /* 152 * Get the same signal again, this time not handled, so its normal effect 153 * occurs. 154 */ 155 kill( getpid(), signum ); 156 } 157 158 static void 159 setup_signals( void ) 160 { 161 if ( signal( SIGINT, SIG_IGN ) != SIG_IGN ) 162 signal( SIGINT, fatal_signal ); 163 #ifdef SIGHUP 164 if ( signal( SIGHUP, SIG_IGN ) != SIG_IGN ) 165 signal( SIGHUP, fatal_signal ); 166 #endif 167 if ( signal( SIGTERM, SIG_IGN ) != SIG_IGN ) 168 signal( SIGTERM, fatal_signal ); 169 #ifdef SIGPIPE 170 if ( signal( SIGPIPE, SIG_IGN ) != SIG_IGN ) 171 signal( SIGPIPE, fatal_signal ); 172 #endif 173 #ifdef SIGCHLD 174 signal( SIGCHLD, SIG_DFL ); 175 #endif 176 } 177 178 int main( 146 int covoar( 179 147 int argc, 180 148 char** argv … … 205 173 bool debug = false; 206 174 std::string symbolSet; 207 std::string progname;208 175 std::string option; 209 176 int opt; 210 177 211 setup_signals();212 213 178 // 214 179 // Process command line options. 215 180 // 216 progname = rld::path::basename(argv[0]);217 181 218 182 while ((opt = getopt(argc, argv, "1:L:e:c:g:E:f:s:S:T:O:p:vd")) != -1) { … … 233 197 case 'd': debug = true; break; 234 198 default: /* '?' */ 235 usage(progname); 236 exit(EXIT_FAILURE); 237 } 238 } 239 try 240 { 241 /* 242 * Validate inputs. 243 */ 244 245 /* 246 * Validate that we have a symbols of interest file. 247 */ 248 if ( symbolSet.empty() ) { 249 option = "symbol set file -S"; 250 throw option; 251 } 252 253 /* 254 * Has path to explanations.txt been specified. 255 */ 256 if ( !explanations ) { 257 option = "explanations -E"; 258 throw option; 259 } 260 261 /* 262 * Check for project name. 263 */ 264 if ( !projectName ) { 265 option = "project name -p"; 266 throw option; 267 } 268 } 269 catch( std::string option ) 270 { 271 std::cerr << "error missing option: " + option << std::endl; 272 usage(progname); 273 exit(EXIT_FAILURE); 274 } 199 throw option_error( "unknown option" ); 200 } 201 } 202 203 /* 204 * Validate inputs. 205 */ 206 207 /* 208 * Validate that we have a symbols of interest file. 209 */ 210 if ( symbolSet.empty() ) 211 throw option_error( "symbol set file -S" ); 212 213 /* 214 * Has path to explanations.txt been specified. 215 */ 216 if ( !explanations ) 217 throw option_error( "explanations -E" ); 218 219 /* 220 * Check for project name. 221 */ 222 if ( !projectName ) 223 throw option_error( "project name -p" ); 275 224 276 225 // If a single executable was specified, process the remaining … … 333 282 334 283 // Ensure that there is at least one executable to process. 335 if (executablesToAnalyze.empty()) { 336 std::cerr << "error: No information to analyze" << std::endl; 337 exit(EXIT_FAILURE); 338 } 284 if (executablesToAnalyze.empty()) 285 throw rld::error( "No information to analyze", "covoar" ); 339 286 340 287 // The executablesToAnalyze and coverageFileNames containers need 341 288 // to be the name size of some of the code below breaks. Lets 342 289 // check and make sure. 343 if (executablesToAnalyze.size() != coverageFileNames.size()) { 344 std::cerr << "ERROR: executables and coverage name size mismatch" << std::endl; 345 exit(EXIT_FAILURE); 346 } 290 if (executablesToAnalyze.size() != coverageFileNames.size()) 291 throw rld::error( "executables and coverage name size mismatch", "covoar" ); 347 292 348 293 // … … 399 344 // Read symbol configuration file and load needed symbols. 400 345 // 401 if (!SymbolsToAnalyze->load( symbolSet, buildTarget, buildBSP, Verbose )) { 402 exit(EXIT_FAILURE); 403 } 346 SymbolsToAnalyze->load( symbolSet, buildTarget, buildBSP, Verbose ); 404 347 405 348 if ( Verbose ) … … 414 357 // Create coverage map reader. 415 358 coverageReader = Coverage::CreateCoverageReader(coverageFormat); 416 if (!coverageReader) { 417 std::cerr << "error: Unable to create coverage file reader" << std::endl; 418 exit(EXIT_FAILURE); 419 } 359 if (!coverageReader) 360 throw rld::error( "Unable to create coverage file reader", "covoar" ); 420 361 421 362 // Create the objdump processor. … … 556 497 return 0; 557 498 } 499 500 #define PrintableString(_s) \ 501 ((!(_s)) ? "NOT SET" : (_s)) 502 503 static void 504 fatal_signal( int signum ) 505 { 506 signal( signum, SIG_DFL ); 507 508 rld::process::temporaries_clean_up(); 509 510 /* 511 * Get the same signal again, this time not handled, so its normal effect 512 * occurs. 513 */ 514 kill( getpid(), signum ); 515 } 516 517 static void 518 setup_signals( void ) 519 { 520 if ( signal( SIGINT, SIG_IGN ) != SIG_IGN ) 521 signal( SIGINT, fatal_signal ); 522 #ifdef SIGHUP 523 if ( signal( SIGHUP, SIG_IGN ) != SIG_IGN ) 524 signal( SIGHUP, fatal_signal ); 525 #endif 526 if ( signal( SIGTERM, SIG_IGN ) != SIG_IGN ) 527 signal( SIGTERM, fatal_signal ); 528 #ifdef SIGPIPE 529 if ( signal( SIGPIPE, SIG_IGN ) != SIG_IGN ) 530 signal( SIGPIPE, fatal_signal ); 531 #endif 532 #ifdef SIGCHLD 533 signal( SIGCHLD, SIG_DFL ); 534 #endif 535 } 536 537 void 538 unhandled_exception (void) 539 { 540 std::cerr << "error: exception handling error, please report" << std::endl; 541 exit (1); 542 } 543 544 int main( 545 int argc, 546 char** argv 547 ) 548 { 549 std::string progname( argv[0] ); 550 int ec = 0; 551 552 setup_signals(); 553 554 std::set_terminate(unhandled_exception); 555 556 try 557 { 558 progname = rld::path::basename(argv[0]); 559 covoar( argc, argv ); 560 } 561 catch ( option_error oe ) 562 { 563 std::cerr << "error: missing option: " + oe << std::endl; 564 usage(progname); 565 ec = EXIT_FAILURE; 566 } 567 catch (rld::error re) 568 { 569 std::cerr << "error: " 570 << re.where << ": " << re.what 571 << std::endl; 572 ec = 10; 573 } 574 catch (std::exception e) 575 { 576 int status; 577 char* realname; 578 realname = abi::__cxa_demangle (e.what(), 0, 0, &status); 579 std::cerr << "error: exception: " << realname << " ["; 580 ::free (realname); 581 const std::type_info &ti = typeid (e); 582 realname = abi::__cxa_demangle (ti.name(), 0, 0, &status); 583 std::cerr << realname << "] " << e.what () << std::endl << std::flush; 584 ::free (realname); 585 ec = 11; 586 } 587 catch (...) 588 { 589 /* 590 * Helps to know if this happens. 591 */ 592 std::cerr << "error: unhandled exception" << std::endl; 593 ec = 12; 594 } 595 596 return ec; 597 }
Note: See TracChangeset
for help on using the changeset viewer.