<div dir="auto">Looks ok on a phone.</div><br><div class="gmail_quote"><div dir="ltr">On Sat, Apr 28, 2018, 4:15 AM Chris Johns <<a href="mailto:chrisj@rtems.org">chrisj@rtems.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This is a clean up.<br>
---<br>
tester/covoar/covoar.cc | 243 +++++++++++++++++++-----------------------------<br>
1 file changed, 98 insertions(+), 145 deletions(-)<br>
<br>
diff --git a/tester/covoar/covoar.cc b/tester/covoar/covoar.cc<br>
index 81c90d2..5c87402 100644<br>
--- a/tester/covoar/covoar.cc<br>
+++ b/tester/covoar/covoar.cc<br>
@@ -116,30 +116,26 @@ static void createBuildPath(Executables& executablesToAnalyze,<br>
*/<br>
void usage(const std::string& progname)<br>
{<br>
- fprintf(<br>
- stderr,<br>
- "Usage: %s [-v] -T TARGET -f FORMAT [-E EXPLANATIONS] -1 EXECUTABLE coverage1 ... coverageN\n"<br>
- "--OR--\n"<br>
- "Usage: %s [-v] -T TARGET -f FORMAT [-E EXPLANATIONS] -e EXE_EXTENSION -c COVERAGEFILE_EXTENSION EXECUTABLE1 ... EXECUTABLE2\n"<br>
- "\n"<br>
- " -v - verbose at initialization\n"<br>
- " -T TARGET - target name\n"<br>
- " -f FORMAT - coverage file format "<br>
- "(RTEMS, QEMU, TSIM or Skyeye)\n"<br>
- " -E EXPLANATIONS - name of file with explanations\n"<br>
- " -s SYMBOL_SET_FILE - path to the INI format symbol sets\n"<br>
- " -1 EXECUTABLE - name of executable to get symbols from\n"<br>
- " -e EXE_EXTENSION - extension of the executables to analyze\n"<br>
- " -c COVERAGEFILE_EXTENSION - extension of the coverage files to analyze\n"<br>
- " -g GCNOS_LIST - name of file with list of *.gcno files\n"<br>
- " -p PROJECT_NAME - name of the project\n"<br>
- " -C ConfigurationFileName - name of configuration file\n"<br>
- " -O Output_Directory - name of output directory (default=.\n"<br>
- " -d debug - disable cleaning of tempfiles."<br>
- "\n",<br>
- progname.c_str(),<br>
- progname.c_str()<br>
- );<br>
+ std::cerr <<"Usage: " << progname<br>
+ <<" [-v] -T TARGET -f FORMAT [-E EXPLANATIONS] -1 EXECUTABLE coverage1 ... coverageN" << std::endl<br>
+ << "--OR--" << std::endl<br>
+ << "Usage: " << progname<br>
+ << " [-v] -T TARGET -f FORMAT [-E EXPLANATIONS] -e EXE_EXTENSION -c COVERAGEFILE_EXTENSION EXECUTABLE1 ... EXECUTABLE2" << std::endl<br>
+ << std::endl<br>
+ << " -v - verbose at initialization" << std::endl<br>
+ << " -T TARGET - target name" << std::endl<br>
+ << " -f FORMAT - coverage file format (RTEMS, QEMU, TSIM or Skyeye)" << std::endl<br>
+ << " -E EXPLANATIONS - name of file with explanations" << std::endl<br>
+ << " -s SYMBOL_SET_FILE - path to the INI format symbol sets" << std::endl<br>
+ << " -1 EXECUTABLE - name of executable to get symbols from" << std::endl<br>
+ << " -e EXE_EXTENSION - extension of the executables to analyze" << std::endl<br>
+ << " -c COVERAGEFILE_EXTENSION - extension of the coverage files to analyze" << std::endl<br>
+ << " -g GCNOS_LIST - name of file with list of *.gcno files" << std::endl<br>
+ << " -p PROJECT_NAME - name of the project" << std::endl<br>
+ << " -C ConfigurationFileName - name of configuration file" << std::endl<br>
+ << " -O Output_Directory - name of output directory (default=." << std::endl<br>
+ << " -d debug - disable cleaning of tempfile" << std::endl<br>
+ << std::endl;<br>
}<br>
<br>
#define PrintableString(_s) \<br>
@@ -282,21 +278,15 @@ int main(<br>
<br>
// Ensure that the executable is readable.<br>
if (!FileIsReadable( singleExecutable )) {<br>
- fprintf(<br>
- stderr,<br>
- "WARNING: Unable to read executable %s\n",<br>
- singleExecutable<br>
- );<br>
+ std::cerr << "warning: Unable to read executable: " << singleExecutable<br>
+ << std::endl;<br>
} else {<br>
<br>
for (int i = optind; i < argc; i++) {<br>
// Ensure that the coverage file is readable.<br>
if (!FileIsReadable( argv[i] )) {<br>
- fprintf(<br>
- stderr,<br>
- "WARNING: Unable to read coverage file %s\n",<br>
- argv[i]<br>
- );<br>
+ std::cerr << "warning: Unable to read coverage file: " << argv[i]<br>
+ << std::endl;<br>
} else {<br>
coverageFileNames.push_back( argv[i] );<br>
}<br>
@@ -321,14 +311,9 @@ int main(<br>
// If not invoked with a single executable, process the remaining<br>
// arguments as executables and derive the coverage file names.<br>
for (int i = optind; i < argc; i++) {<br>
-<br>
// Ensure that the executable is readable.<br>
if (!FileIsReadable( argv[i] )) {<br>
- fprintf(<br>
- stderr,<br>
- "WARNING: Unable to read executable %s\n",<br>
- argv[i]<br>
- );<br>
+ std::cerr << "warning: Unable to read executable: " << argv[i] << std::endl;<br>
} else {<br>
coverageFileName = argv[i];<br>
coverageFileName.replace(<br>
@@ -338,11 +323,8 @@ int main(<br>
);<br>
<br>
if (!FileIsReadable( coverageFileName.c_str() )) {<br>
- fprintf(<br>
- stderr,<br>
- "WARNING: Unable to read coverage file %s\n",<br>
- coverageFileName.c_str()<br>
- );<br>
+ std::cerr << "warning: Unable to read coverage file: " << coverageFileName<br>
+ << std::endl;<br>
} else {<br>
executableInfo = new Coverage::ExecutableInfo( argv[i] );<br>
executablesToAnalyze.push_back( executableInfo );<br>
@@ -354,9 +336,7 @@ int main(<br>
<br>
// Ensure that there is at least one executable to process.<br>
if (executablesToAnalyze.empty()) {<br>
- fprintf(<br>
- stderr, "ERROR: No information to analyze\n"<br>
- );<br>
+ std::cerr << "error: No information to analyze" << std::endl;<br>
exit(EXIT_FAILURE);<br>
}<br>
<br>
@@ -389,33 +369,20 @@ int main(<br>
<br>
if (Verbose) {<br>
if (singleExecutable) {<br>
- fprintf(<br>
- stderr,<br>
- "Processing a single executable and multiple coverage files\n"<br>
- );<br>
+ std::cerr << "Processing a single executable and multiple coverage files"<br>
+ << std::endl;<br>
} else {<br>
- fprintf(<br>
- stderr,<br>
- "Processing multiple executable/coverage file pairs\n"<br>
- );<br>
+ std::cerr << "Processing multiple executable/coverage file pairs" << std::endl;<br>
}<br>
- fprintf( stderr, "Coverage Format : %s\n", format );<br>
- fprintf( stderr, "Target : %s\n", buildTarget.c_str() );<br>
- fprintf( stderr, "\n" );<br>
+ std::cerr << "Coverage Format : " << format << std::endl<br>
+ << "Target : " << buildTarget.c_str() << std::endl<br>
+ << std::endl;<br>
<br>
// Process each executable/coverage file pair.<br>
Executables::iterator eitr = executablesToAnalyze.begin();<br>
- for (CoverageNames::iterator citr = coverageFileNames.begin();<br>
- citr != coverageFileNames.end();<br>
- citr++) {<br>
-<br>
- fprintf(<br>
- stderr,<br>
- "Coverage file %s for executable %s\n",<br>
- (*citr).c_str(),<br>
- ((*eitr)->getFileName()).c_str()<br>
- );<br>
-<br>
+ for (const auto& cname : coverageFileNames) {<br>
+ std::cerr << "Coverage file " << cname<br>
+ << " for executable: " << (*eitr)->getFileName() << std::endl;<br>
if (!singleExecutable)<br>
eitr++;<br>
}<br>
@@ -439,7 +406,7 @@ int main(<br>
}<br>
<br>
if ( Verbose )<br>
- std::cout << "Analyzing " << SymbolsToAnalyze->set.size()<br>
+ std::cerr << "Analyzing " << SymbolsToAnalyze->set.size()<br>
<< " symbols" << std::endl;<br>
<br>
// Create explanations.<br>
@@ -450,7 +417,7 @@ int main(<br>
// Create coverage map reader.<br>
coverageReader = Coverage::CreateCoverageReader(coverageFormat);<br>
if (!coverageReader) {<br>
- fprintf( stderr, "ERROR: Unable to create coverage file reader\n" );<br>
+ std::cerr << "error: Unable to create coverage file reader" << std::endl;<br>
exit(EXIT_FAILURE);<br>
}<br>
<br>
@@ -458,27 +425,18 @@ int main(<br>
objdumpProcessor = new Coverage::ObjdumpProcessor();<br>
<br>
// Prepare each executable for analysis.<br>
- for (Executables::iterator eitr = executablesToAnalyze.begin();<br>
- eitr != executablesToAnalyze.end();<br>
- eitr++) {<br>
-<br>
- if (Verbose) {<br>
- fprintf(<br>
- stderr,<br>
- "Extracting information from %s\n",<br>
- ((*eitr)->getFileName()).c_str()<br>
- );<br>
- }<br>
+ for (auto& exe : executablesToAnalyze) {<br>
+ if (Verbose)<br>
+ std::cerr << "Extracting information from: " << exe->getFileName()<br>
+ << std::endl;<br>
<br>
// If a dynamic library was specified, determine the load address.<br>
if (dynamicLibrary) {<br>
- (*eitr)->setLoadAddress(<br>
- objdumpProcessor->determineLoadAddress( *eitr )<br>
- );<br>
+ exe->setLoadAddress( objdumpProcessor->determineLoadAddress( exe ) );<br>
}<br>
<br>
// Load the objdump for the symbols in this executable.<br>
- objdumpProcessor->load( *eitr, objdumpFile, err );<br>
+ objdumpProcessor->load( exe, objdumpFile, err );<br>
}<br>
<br>
//<br>
@@ -488,23 +446,20 @@ int main(<br>
// Process each executable/coverage file pair.<br>
Executables::iterator eitr = executablesToAnalyze.begin();<br>
for (const auto& cname : coverageFileNames) {<br>
- if (Verbose) {<br>
- fprintf(<br>
- stderr,<br>
- "Processing coverage file %s for executable %s\n",<br>
- cname.c_str(),<br>
- ((*eitr)->getFileName()).c_str()<br>
- );<br>
- }<br>
+ Coverage::ExecutableInfo* exe = *eitr;<br>
+ if (Verbose)<br>
+ std::cerr << "Processing coverage file " << cname<br>
+ << " for executable " << exe->getFileName()<br>
+ << std::endl;<br>
<br>
// Process its coverage file.<br>
- coverageReader->processFile( cname.c_str(), *eitr );<br>
+ coverageReader->processFile( cname.c_str(), exe );<br>
<br>
// Merge each symbols coverage map into a unified coverage map.<br>
- (*eitr)->mergeCoverage();<br>
+ exe->mergeCoverage();<br>
<br>
// DEBUG Print ExecutableInfo content<br>
- //(*eitr)->dumpExecutableInfo();<br>
+ //exe->dumpExecutableInfo();<br>
<br>
if (!singleExecutable) {<br>
eitr++;<br>
@@ -512,72 +467,69 @@ int main(<br>
}<br>
<br>
// Do necessary preprocessing of uncovered ranges and branches<br>
- if (Verbose) {<br>
- fprintf( stderr, "Preprocess uncovered ranges and branches\n" );<br>
- }<br>
+ if (Verbose)<br>
+ std::cerr << "Preprocess uncovered ranges and branches" << std::endl;<br>
+<br>
SymbolsToAnalyze->preprocess();<br>
<br>
//<br>
// Generate Gcov reports<br>
//<br>
- if (Verbose) {<br>
- fprintf( stderr, "Generating Gcov reports...\n");<br>
- }<br>
- gcnosFile = fopen ( gcnosFileName , "r" );<br>
-<br>
- if ( !gcnosFile ) {<br>
- fprintf( stderr, "Unable to open %s\n", gcnosFileName );<br>
- }<br>
- else {<br>
- while ( fscanf( gcnosFile, "%s", inputBuffer ) != EOF) {<br>
- gcovFile = new Gcov::GcovData();<br>
- strcpy( gcnoFileName, inputBuffer );<br>
-<br>
- if ( Verbose ) {<br>
- fprintf( stderr, "Processing file: %s\n", gcnoFileName );<br>
- }<br>
+ if (gcnosFileName) {<br>
+ if (Verbose)<br>
+ std::cerr << "Generating Gcov reports..." << std::endl;<br>
+<br>
+ gcnosFile = fopen ( gcnosFileName , "r" );<br>
+<br>
+ if ( !gcnosFile )<br>
+ std::cerr << "Unable to open " << gcnosFileName << std::endl;<br>
+ else {<br>
+ while ( fscanf( gcnosFile, "%s", inputBuffer ) != EOF) {<br>
+ gcovFile = new Gcov::GcovData();<br>
+ strcpy( gcnoFileName, inputBuffer );<br>
+<br>
+ if ( Verbose )<br>
+ std::cerr << "Processing file: " << gcnoFileName << std::endl;<br>
+<br>
+ if ( gcovFile->readGcnoFile( gcnoFileName ) ) {<br>
+ // Those need to be in this order<br>
+ gcovFile->processCounters();<br>
+ gcovFile->writeReportFile();<br>
+ gcovFile->writeGcdaFile();<br>
+ gcovFile->writeGcovFile();<br>
+ }<br>
<br>
- if ( gcovFile->readGcnoFile( gcnoFileName ) ) {<br>
- // Those need to be in this order<br>
- gcovFile->processCounters();<br>
- gcovFile->writeReportFile();<br>
- gcovFile->writeGcdaFile();<br>
- gcovFile->writeGcovFile();<br>
+ delete gcovFile;<br>
}<br>
-<br>
- delete gcovFile;<br>
+ fclose( gcnosFile );<br>
}<br>
- fclose( gcnosFile );<br>
}<br>
<br>
// Determine the uncovered ranges and branches.<br>
- if (Verbose) {<br>
- fprintf( stderr, "Computing uncovered ranges and branches\n" );<br>
- }<br>
+ if (Verbose)<br>
+ std::cerr << "Computing uncovered ranges and branches" << std::endl;<br>
+<br>
SymbolsToAnalyze->computeUncovered();<br>
<br>
// Calculate remainder of statistics.<br>
- if (Verbose) {<br>
- fprintf( stderr, "Calculate statistics\n" );<br>
- }<br>
+ if (Verbose)<br>
+ std::cerr << "Calculate statistics" << std::endl;<br>
+<br>
SymbolsToAnalyze->calculateStatistics();<br>
<br>
// Look up the source lines for any uncovered ranges and branches.<br>
- if (Verbose) {<br>
- fprintf(<br>
- stderr, "Looking up source lines for uncovered ranges and branches\n"<br>
- );<br>
- }<br>
+ if (Verbose)<br>
+ std::cerr << "Looking up source lines for uncovered ranges and branches"<br>
+ << std::endl;<br>
+<br>
SymbolsToAnalyze->findSourceForUncovered();<br>
<br>
//<br>
// Report the coverage data.<br>
//<br>
- if (Verbose) {<br>
- fprintf(<br>
- stderr, "Generate Reports\n"<br>
- );<br>
- }<br>
+ if (Verbose)<br>
+ std::cerr << "Generate Reports" << std::endl;<br>
+<br>
Coverage::GenerateReports();<br>
<br>
// Write explanations that were not found.<br>
@@ -588,9 +540,9 @@ int main(<br>
notFound += "/";<br>
notFound += "ExplanationsNotFound.txt";<br>
<br>
- if (Verbose) {<br>
- fprintf( stderr, "Writing Not Found Report (%s)\n", notFound.c_str() );<br>
- }<br>
+ if (Verbose)<br>
+ std::cerr << "Writing Not Found Report (" << notFound<< ')' << std::endl;<br>
+<br>
AllExplanations->writeNotFound( notFound.c_str() );<br>
}<br>
<br>
@@ -603,5 +555,6 @@ int main(<br>
syms.override( "symbols_list" );<br>
syms.keep();<br>
}<br>
+<br>
return 0;<br>
}<br>
-- <br>
2.15.1<br>
<br>
_______________________________________________<br>
devel mailing list<br>
<a href="mailto:devel@rtems.org" target="_blank" rel="noreferrer">devel@rtems.org</a><br>
<a href="http://lists.rtems.org/mailman/listinfo/devel" rel="noreferrer noreferrer" target="_blank">http://lists.rtems.org/mailman/listinfo/devel</a><br>
</blockquote></div>