Replaced Verbose in app_common with local variables that are passed as a parameter into numerous functions --- tester/covoar/DesiredSymbols.cc | 17 ++++++++-------- tester/covoar/DesiredSymbols.h | 13 +++++++++--- tester/covoar/ExecutableInfo.h | 1 + tester/covoar/ObjdumpProcessor.cc | 23 ++++++++++++++------- tester/covoar/ObjdumpProcessor.h | 5 +++-- tester/covoar/ReportsBase.cc | 15 +++++++------- tester/covoar/ReportsBase.h | 4 +++- tester/covoar/TraceConverter.cc | 5 +++-- tester/covoar/TraceWriterBase.h | 4 +++- tester/covoar/TraceWriterQEMU.cc | 7 ++++--- tester/covoar/TraceWriterQEMU.h | 4 +++- tester/covoar/app_common.cc | 1 - tester/covoar/app_common.h | 1 - tester/covoar/covoar.cc | 43 ++++++++++++++++++++------------------- 14 files changed, 85 insertions(+), 58 deletions(-)
diff --git a/tester/covoar/DesiredSymbols.cc b/tester/covoar/DesiredSymbols.cc index caa6acd..5d5e637 100644 --- a/tester/covoar/DesiredSymbols.cc +++ b/tester/covoar/DesiredSymbols.cc @@ -189,7 +189,7 @@ namespace Coverage { } - void DesiredSymbols::computeUncovered( void ) + void DesiredSymbols::computeUncovered( bool verbose ) { // Look at each symbol set. for (const auto& kv : setNamesToSymbols) { @@ -308,7 +308,7 @@ namespace Coverage { CoverageRanges::UNCOVERED_REASON_BRANCH_ALWAYS_TAKEN, 1 ); - if (Verbose) + if (verbose) std::cerr << "Branch always taken found in" << symbol << std::hex << " (0x" << info.baseAddress + la @@ -326,7 +326,7 @@ namespace Coverage { CoverageRanges::UNCOVERED_REASON_BRANCH_NEVER_TAKEN, 1 ); - if (Verbose) + if (verbose) std::cerr << "Branch never taken found in " << symbol << std::hex << " (0x" << info.baseAddress + la @@ -350,7 +350,8 @@ namespace Coverage { const std::string& exefileName, const std::string& symbolName, uint32_t size, - uint32_t sizeWithoutNops + uint32_t sizeWithoutNops, + bool verbose ) { CoverageMapBase* aCoverageMap; @@ -403,7 +404,7 @@ namespace Coverage { aCoverageMap = new CoverageMap( exefileName, 0, highAddress ); - if ( Verbose ) + if ( verbose ) fprintf( stderr, "Created unified coverage map for %s (0x%x - 0x%x)\n", @@ -440,7 +441,7 @@ namespace Coverage { return &set[ symbolName ]; } - void DesiredSymbols::findSourceForUncovered( void ) + void DesiredSymbols::findSourceForUncovered( bool verbose ) { // Process uncovered ranges and/or branches for each symbol. for (auto& d : SymbolsToAnalyze->set) { @@ -448,7 +449,7 @@ namespace Coverage { CoverageRanges* theRanges = d.second.uncoveredRanges; if (theRanges != nullptr) { if (!theRanges->set.empty()) { - if (Verbose) + if (verbose) std::cerr << "Looking up source lines for uncovered ranges in " << d.first << std::endl; @@ -459,7 +460,7 @@ namespace Coverage { CoverageRanges* theBranches = d.second.uncoveredBranches; if (theBranches != nullptr) { if (!theBranches->set.empty()) { - if (Verbose) + if (verbose) std::cerr << "Looking up source lines for uncovered branches in " << d.first << std::endl; diff --git a/tester/covoar/DesiredSymbols.h b/tester/covoar/DesiredSymbols.h index 411b818..791b4ea 100644 --- a/tester/covoar/DesiredSymbols.h +++ b/tester/covoar/DesiredSymbols.h @@ -222,8 +222,10 @@ namespace Coverage { /*! * This method analyzes each symbols coverage map to determine any * uncovered ranges or branches. + * + * @param[in] verbose specifies whether to be verbose with output */ - void computeUncovered( void ); + void computeUncovered( bool verbose ); /*! * This method creates a coverage map for the specified symbol @@ -234,12 +236,15 @@ namespace Coverage { * @param[in] symbolName specifies the symbol for which to create * a coverage map * @param[in] size specifies the size of the coverage map to create + * @param[in] sizeWithoutNops specifies the size without no ops + * @param[in] verbose specifies whether to be verbose with output */ void createCoverageMap( const std::string& exefileName, const std::string& symbolName, uint32_t size, - uint32_t sizeWithoutNops + uint32_t sizeWithoutNops, + bool verbose ); /*! @@ -256,8 +261,10 @@ namespace Coverage { /*! * This method determines the source lines that correspond to any * uncovered ranges or branches. + * + * @param[in] verbose specifies whether to be verbose with output */ - void findSourceForUncovered( void ); + void findSourceForUncovered( bool verbose ); /*! * This method returns the total number of branches always taken diff --git a/tester/covoar/ExecutableInfo.h b/tester/covoar/ExecutableInfo.h index dfc71aa..1f977a0 100644 --- a/tester/covoar/ExecutableInfo.h +++ b/tester/covoar/ExecutableInfo.h @@ -40,6 +40,7 @@ namespace Coverage { * * @param[in] theExecutableName specifies the name of the executable * @param[in] theLibraryName specifies the name of the executable + * @param[in] verbose specifies whether to be verbose with output */ ExecutableInfo( const char* const theExecutableName, diff --git a/tester/covoar/ObjdumpProcessor.cc b/tester/covoar/ObjdumpProcessor.cc index c2ed3d5..2bf1685 100644 --- a/tester/covoar/ObjdumpProcessor.cc +++ b/tester/covoar/ObjdumpProcessor.cc @@ -29,7 +29,8 @@ namespace Coverage { void finalizeSymbol( ExecutableInfo* const executableInfo, std::string& symbolName, - ObjdumpProcessor::objdumpLines_t instructions + ObjdumpProcessor::objdumpLines_t instructions, + bool verbose ) { // Find the symbol's coverage map. try { @@ -105,7 +106,11 @@ namespace Coverage { // Create a unified coverage map for the symbol. SymbolsToAnalyze->createCoverageMap( - executableInfo->getFileName().c_str(), symbolName, size, sizeWithoutNops + executableInfo->getFileName().c_str(), + symbolName, + size, + sizeWithoutNops, + verbose ); } catch (const ExecutableInfo::CoverageMapNotFoundError& e) { // Allow execution to continue even if a coverage map could not be @@ -317,7 +322,8 @@ namespace Coverage { void ObjdumpProcessor::load( ExecutableInfo* const executableInformation, rld::process::tempfile& objdumpFile, - rld::process::tempfile& err + rld::process::tempfile& err, + bool verbose ) { std::string currentSymbol = ""; @@ -353,7 +359,8 @@ namespace Coverage { finalizeSymbol( executableInformation, currentSymbol, - theInstructions + theInstructions, + verbose ); fprintf( stderr, @@ -408,7 +415,8 @@ namespace Coverage { finalizeSymbol( executableInformation, currentSymbol, - theInstructions + theInstructions, + verbose ); } @@ -450,8 +458,9 @@ namespace Coverage { finalizeSymbol( executableInformation, currentSymbol, - theInstructions - ); + theInstructions, + verbose + ); } processSymbol = false; } diff --git a/tester/covoar/ObjdumpProcessor.h b/tester/covoar/ObjdumpProcessor.h index c75755d..d60a768 100644 --- a/tester/covoar/ObjdumpProcessor.h +++ b/tester/covoar/ObjdumpProcessor.h @@ -120,9 +120,10 @@ namespace Coverage { * the specified executable. */ void load( - ExecutableInfo* const executableInformation, + ExecutableInfo* const executableInformation, rld::process::tempfile& dmp, - rld::process::tempfile& err + rld::process::tempfile& err, + bool verbose ); /*! diff --git a/tester/covoar/ReportsBase.cc b/tester/covoar/ReportsBase.cc index 62229c0..8947f58 100644 --- a/tester/covoar/ReportsBase.cc +++ b/tester/covoar/ReportsBase.cc @@ -564,7 +564,8 @@ void ReportsBase::WriteSummaryReport( void GenerateReports( const std::string& symbolSetName, - Coverage::Explanations& allExplanations + Coverage::Explanations& allExplanations, + bool verbose ) { typedef std::list<ReportsBase *> reportList_t; @@ -586,37 +587,37 @@ void GenerateReports( reports = *ritr; reportName = "index" + reports->ReportExtension(); - if ( Verbose ) { + if ( verbose ) { std::cerr << "Generate " << reportName << std::endl; } reports->WriteIndex( reportName ); reportName = "annotated" + reports->ReportExtension(); - if ( Verbose ) { + if ( verbose ) { std::cerr << "Generate " << reportName << std::endl; } reports->WriteAnnotatedReport( reportName ); reportName = "branch" + reports->ReportExtension(); - if ( Verbose ) { + if ( verbose ) { std::cerr << "Generate " << reportName << std::endl; } reports->WriteBranchReport( reportName ); reportName = "uncovered" + reports->ReportExtension(); - if ( Verbose ) { + if ( verbose ) { std::cerr << "Generate " << reportName << std::endl; } reports->WriteCoverageReport( reportName ); reportName = "sizes" + reports->ReportExtension(); - if ( Verbose ) { + if ( verbose ) { std::cerr << "Generate " << reportName << std::endl; } reports->WriteSizeReport( reportName ); reportName = "symbolSummary" + reports->ReportExtension(); - if ( Verbose ) { + if ( verbose ) { std::cerr << "Generate " << reportName << std::endl; } reports->WriteSymbolSummaryReport( reportName ); diff --git a/tester/covoar/ReportsBase.h b/tester/covoar/ReportsBase.h index efc110d..41ac7ef 100644 --- a/tester/covoar/ReportsBase.h +++ b/tester/covoar/ReportsBase.h @@ -400,10 +400,12 @@ class ReportsBase { * * @param[in] symbolSetName is the name of the symbol set to report on. * @param[in] allExplanations is the explanations to report on. + * @param[in] verbose specifies whether to be verbose with output */ void GenerateReports( const std::string& symbolSetName, - Coverage::Explanations& allExplanations + Coverage::Explanations& allExplanations, + bool verbose ); } diff --git a/tester/covoar/TraceConverter.cc b/tester/covoar/TraceConverter.cc index cd64faf..89e0736 100644 --- a/tester/covoar/TraceConverter.cc +++ b/tester/covoar/TraceConverter.cc @@ -90,6 +90,7 @@ int main( rld::process::tempfile objdumpFile( ".dmp" ); rld::process::tempfile err( ".err" ); Coverage::ObjdumpProcessor objdumpProcessor; + bool verbose = false; setup_signals(); @@ -105,7 +106,7 @@ int main( case 'l': logname = optarg; break; case 'L': dynamicLibrary = optarg; break; case 't': tracefile = optarg; break; - case 'v': Verbose = true; break; + case 'v': verbose = true; break; default: usage(); } } @@ -141,5 +142,5 @@ int main( ); objdumpProcessor.loadAddressTable( executableInfo, objdumpFile, err ); log.processFile( logname, objdumpProcessor ); - trace.writeFile( tracefile, &log ); + trace.writeFile( tracefile, &log, verbose ); } diff --git a/tester/covoar/TraceWriterBase.h b/tester/covoar/TraceWriterBase.h index 41307d1..070dcca 100644 --- a/tester/covoar/TraceWriterBase.h +++ b/tester/covoar/TraceWriterBase.h @@ -36,12 +36,14 @@ namespace Trace { * * @param[in] file specifies the name of the file to write * @param[in] log structure where the trace data was read into + * @param[in] verbose specifies whether to be verbose with output * * @return Returns TRUE if the method succeeded and FALSE if it failed. */ virtual bool writeFile( const char* const file, - Trace::TraceReaderBase *log + Trace::TraceReaderBase *log, + bool verbose ) = 0; }; diff --git a/tester/covoar/TraceWriterQEMU.cc b/tester/covoar/TraceWriterQEMU.cc index 26447af..01d9cbc 100644 --- a/tester/covoar/TraceWriterQEMU.cc +++ b/tester/covoar/TraceWriterQEMU.cc @@ -73,7 +73,8 @@ namespace Trace { bool TraceWriterQEMU::writeFile( const char* const file, - Trace::TraceReaderBase *log + Trace::TraceReaderBase *log, + bool verbose ) { struct trace_header header; @@ -120,7 +121,7 @@ namespace Trace { return false; } - if (Verbose) + if (verbose) std::cerr << "magic = " << header.magic << std::endl << "version = " << header.version << std::endl << "kind = " << header.kind << std::endl @@ -157,7 +158,7 @@ namespace Trace { break; } - if ( Verbose ) + if ( verbose ) std::cerr << std::hex << std::setfill('0') << entry.pc << ' ' << entry.size << ' ' << entry.op << std::dec << std::setfill(' ') diff --git a/tester/covoar/TraceWriterQEMU.h b/tester/covoar/TraceWriterQEMU.h index 89fca5e..09c2ddf 100644 --- a/tester/covoar/TraceWriterQEMU.h +++ b/tester/covoar/TraceWriterQEMU.h @@ -39,12 +39,14 @@ namespace Trace { * * @param[in] file specifies the name of the file to write * @param[in] log structure where the trace data was read into + * @param[in] verbose specifies whether to be verbose with output * * @return Returns TRUE if the method succeeded and FALSE if it failed. */ bool writeFile( const char* const file, - Trace::TraceReaderBase *log + Trace::TraceReaderBase *log, + bool verbose ); }; diff --git a/tester/covoar/app_common.cc b/tester/covoar/app_common.cc index 1c49c72..9dfe81e 100644 --- a/tester/covoar/app_common.cc +++ b/tester/covoar/app_common.cc @@ -57,7 +57,6 @@ * Global variables for the program */ Coverage::DesiredSymbols* SymbolsToAnalyze = NULL; -bool Verbose = false; const char* outputDirectory = "."; bool BranchInfoAvailable = false; Target::TargetBase* TargetInfo = NULL; diff --git a/tester/covoar/app_common.h b/tester/covoar/app_common.h index eb250e8..ac66eda 100644 --- a/tester/covoar/app_common.h +++ b/tester/covoar/app_common.h @@ -13,7 +13,6 @@ #include "TargetBase.h" extern Coverage::DesiredSymbols* SymbolsToAnalyze; -extern bool Verbose; extern const char* outputDirectory; extern bool BranchInfoAvailable; extern Target::TargetBase* TargetInfo; diff --git a/tester/covoar/covoar.cc b/tester/covoar/covoar.cc index 46ba348..9c88b00 100644 --- a/tester/covoar/covoar.cc +++ b/tester/covoar/covoar.cc @@ -176,6 +176,7 @@ int covoar( int opt; Coverage::Explanations allExplanations; Coverage::ObjdumpProcessor objdumpProcessor; + bool verbose = false; // // Process command line options. @@ -193,7 +194,7 @@ int covoar( case 'S': symbolSet = optarg; break; case 'T': target = optarg; break; case 'O': outputDirectory = optarg; break; - case 'v': Verbose = true; + case 'v': verbose = true; rld::verbose_inc (); break; case 'p': projectName = optarg; break; case 'd': debug = true; break; @@ -243,7 +244,7 @@ int covoar( buildTarget = target; } - if (Verbose) { + if (verbose) { if (singleExecutable) { std::cerr << "Processing a single executable and multiple coverage files" << std::endl; @@ -277,7 +278,7 @@ int covoar( // // Read symbol configuration file and load needed symbols. // - SymbolsToAnalyze->load( symbolSet, buildTarget, buildBSP, Verbose ); + SymbolsToAnalyze->load( symbolSet, buildTarget, buildBSP, verbose ); // If a single executable was specified, process the remaining // arguments as coverage file names. @@ -304,11 +305,11 @@ int covoar( if (!coverageFileNames.empty()) { if (dynamicLibrary) { executableInfo = new Coverage::ExecutableInfo( - singleExecutable, dynamicLibrary, Verbose + singleExecutable, dynamicLibrary, verbose ); } else { executableInfo = new Coverage::ExecutableInfo( - singleExecutable, nullptr, Verbose + singleExecutable, nullptr, verbose ); } @@ -332,7 +333,7 @@ int covoar( << std::endl; } else { executableInfo = new Coverage::ExecutableInfo( - argv[i], nullptr, Verbose + argv[i], nullptr, verbose ); executablesToAnalyze.push_back( executableInfo ); coverageFileNames.push_back( coverageFileName ); @@ -351,7 +352,7 @@ int covoar( if (executablesToAnalyze.size() != coverageFileNames.size()) throw rld::error( "executables and coverage name size mismatch", "covoar" ); - if ( Verbose ) + if ( verbose ) std::cerr << "Analyzing " << SymbolsToAnalyze->allSymbols().size() << " symbols" << std::endl; @@ -367,7 +368,7 @@ int covoar( // Prepare each executable for analysis. for (auto& exe : executablesToAnalyze) { - if (Verbose) + if (verbose) std::cerr << "Extracting information from: " << exe->getFileName() << std::endl; @@ -377,7 +378,7 @@ int covoar( } // Load the objdump for the symbols in this executable. - objdumpProcessor.load( exe, objdumpFile, err ); + objdumpProcessor.load( exe, objdumpFile, err, verbose ); } // @@ -388,7 +389,7 @@ int covoar( Executables::iterator eitr = executablesToAnalyze.begin(); for (const auto& cname : coverageFileNames) { Coverage::ExecutableInfo* exe = *eitr; - if (Verbose) + if (verbose) std::cerr << "Processing coverage file " << cname << " for executable " << exe->getFileName() << std::endl; @@ -408,7 +409,7 @@ int covoar( } // Do necessary preprocessing of uncovered ranges and branches - if (Verbose) + if (verbose) std::cerr << "Preprocess uncovered ranges and branches" << std::endl; SymbolsToAnalyze->preprocess(); @@ -417,7 +418,7 @@ int covoar( // Generate Gcov reports // if (gcnosFileName) { - if (Verbose) + if (verbose) std::cerr << "Generating Gcov reports..." << std::endl; gcnosFile = fopen ( gcnosFileName , "r" ); @@ -429,7 +430,7 @@ int covoar( gcovFile = new Gcov::GcovData(); strcpy( gcnoFileName, inputBuffer ); - if ( Verbose ) + if ( verbose ) std::cerr << "Processing file: " << gcnoFileName << std::endl; if ( gcovFile->readGcnoFile( gcnoFileName ) ) { @@ -447,32 +448,32 @@ int covoar( } // Determine the uncovered ranges and branches. - if (Verbose) + if (verbose) std::cerr << "Computing uncovered ranges and branches" << std::endl; - SymbolsToAnalyze->computeUncovered(); + SymbolsToAnalyze->computeUncovered( verbose ); // Calculate remainder of statistics. - if (Verbose) + if (verbose) std::cerr << "Calculate statistics" << std::endl; SymbolsToAnalyze->calculateStatistics(); // Look up the source lines for any uncovered ranges and branches. - if (Verbose) + if (verbose) std::cerr << "Looking up source lines for uncovered ranges and branches" << std::endl; - SymbolsToAnalyze->findSourceForUncovered(); + SymbolsToAnalyze->findSourceForUncovered( verbose ); // // Report the coverage data. // - if (Verbose) + if (verbose) std::cerr << "Generate Reports" << std::endl; for (const auto& setName : SymbolsToAnalyze->getSetNames()) { - Coverage::GenerateReports( setName, allExplanations ); + Coverage::GenerateReports( setName, allExplanations, verbose ); } // Write explanations that were not found. @@ -483,7 +484,7 @@ int covoar( notFound += "/"; notFound += "ExplanationsNotFound.txt"; - if (Verbose) + if (verbose) std::cerr << "Writing Not Found Report (" << notFound<< ')' << std::endl; allExplanations.writeNotFound( notFound.c_str() ); -- 1.8.3.1 _______________________________________________ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel