[rtems-tools commit] Remove SymbolsToAnalyze global variable

Joel Sherrill joel at rtems.org
Tue Aug 3 21:00:44 UTC 2021


Module:    rtems-tools
Branch:    master
Commit:    a1d0e5515e0eb706cb530ce1b9f285a6b8afc821
Changeset: http://git.rtems.org/rtems-tools/commit/?id=a1d0e5515e0eb706cb530ce1b9f285a6b8afc821

Author:    Ryan Long <ryan.long at oarcorp.com>
Date:      Wed Jul 28 13:20:34 2021 -0400

Remove SymbolsToAnalyze global variable

- Removed SymbolsToAnalyze from app_common and replaced it with the
  symbolsToAnalyze_m member variable in DesiredSymbols, GcovData, and
  ObjdumpProcessor
- Added a parameter to constructors to initialize symbolsToAnalyze_m
- Moved the definition of objdumpLine_t out of ObjdumpProcessor to make
  it work with DesiredSymbols

---

 tester/covoar/DesiredSymbols.cc   | 12 +++--
 tester/covoar/DesiredSymbols.h    | 16 +++++--
 tester/covoar/ExecutableInfo.cc   | 14 +++---
 tester/covoar/ExecutableInfo.h    | 14 +++++-
 tester/covoar/GcovData.cc         |  7 +--
 tester/covoar/GcovData.h          | 12 ++++-
 tester/covoar/GcovFunctionData.cc | 14 ++++--
 tester/covoar/GcovFunctionData.h  |  6 ++-
 tester/covoar/ObjdumpProcessor.cc | 22 +++++----
 tester/covoar/ObjdumpProcessor.h  | 90 +++++++++++++++++++----------------
 tester/covoar/ReportsBase.cc      | 98 +++++++++++++++++++++------------------
 tester/covoar/ReportsBase.h       | 33 +++++++++----
 tester/covoar/ReportsHtml.cc      | 16 ++++---
 tester/covoar/ReportsHtml.h       | 11 +++--
 tester/covoar/ReportsText.cc      |  8 ++--
 tester/covoar/ReportsText.h       |  3 +-
 tester/covoar/TraceConverter.cc   | 17 +++++--
 tester/covoar/app_common.cc       |  1 -
 tester/covoar/app_common.h        |  1 -
 tester/covoar/covoar.cc           | 40 +++++++++-------
 20 files changed, 270 insertions(+), 165 deletions(-)

diff --git a/tester/covoar/DesiredSymbols.cc b/tester/covoar/DesiredSymbols.cc
index 5d5e637..d76c5af 100644
--- a/tester/covoar/DesiredSymbols.cc
+++ b/tester/covoar/DesiredSymbols.cc
@@ -25,7 +25,6 @@
 #include "DesiredSymbols.h"
 #include "app_common.h"
 #include "CoverageMap.h"
-#include "ObjdumpProcessor.h"
 
 namespace Coverage {
 
@@ -116,10 +115,10 @@ namespace Coverage {
     }
   }
 
-  void DesiredSymbols::preprocess( void )
+  void DesiredSymbols::preprocess( const DesiredSymbols& symbolsToAnalyze )
   {
     // Look at each symbol.
-    for (auto& s : SymbolsToAnalyze->set) {
+    for (auto& s : symbolsToAnalyze.set) {
       // If the unified coverage map does not exist, the symbol was
       // never referenced by any executable.  Just skip it.
       CoverageMapBase* theCoverageMap = s.second.unifiedCoverageMap;
@@ -441,10 +440,13 @@ namespace Coverage {
       return &set[ symbolName ];
   }
 
-  void DesiredSymbols::findSourceForUncovered( bool verbose )
+  void DesiredSymbols::findSourceForUncovered(
+    bool                  verbose,
+    const DesiredSymbols& symbolsToAnalyze
+  )
   {
     // Process uncovered ranges and/or branches for each symbol.
-    for (auto& d : SymbolsToAnalyze->set) {
+    for (auto& d : symbolsToAnalyze.set) {
       // First the unexecuted ranges, ...
       CoverageRanges* theRanges = d.second.uncoveredRanges;
       if (theRanges != nullptr) {
diff --git a/tester/covoar/DesiredSymbols.h b/tester/covoar/DesiredSymbols.h
index 791b4ea..7ea3a9a 100644
--- a/tester/covoar/DesiredSymbols.h
+++ b/tester/covoar/DesiredSymbols.h
@@ -19,6 +19,10 @@
 
 namespace Coverage {
 
+  class ObjdumpProcessor;
+  struct objdumpLine_t;
+  class ExecutableInfo;
+
 
   /*!
    *
@@ -139,7 +143,7 @@ namespace Coverage {
     /*!
      *  This member contains the disassembly associated with a symbol.
      */
-    std::list<ObjdumpProcessor::objdumpLine_t> instructions;
+    std::list<objdumpLine_t> instructions;
 
     /*!
      *  This member contains the executable that was used to
@@ -263,8 +267,12 @@ namespace Coverage {
      *  uncovered ranges or branches.
      *
      *  @param[in] verbose specifies whether to be verbose with output
+     *  @param[in] symbolsToAnalyze the symbols to be analyzed
      */
-    void findSourceForUncovered( bool verbose );
+    void findSourceForUncovered(
+      bool verbose,
+      const DesiredSymbols& symbolsToAnalyze
+    );
 
     /*!
      *  This method returns the total number of branches always taken
@@ -398,8 +406,10 @@ namespace Coverage {
     /*!
      *  This method preprocesses each symbol's coverage map to mark nop
      *  and branch information.
+     *
+     *  @param[in] symbolsToAnalyze the symbols to be analyzed
      */
-    void preprocess( void );
+    void preprocess( const DesiredSymbols& symbolsToAnalyze );
 
   private:
 
diff --git a/tester/covoar/ExecutableInfo.cc b/tester/covoar/ExecutableInfo.cc
index 9c3031e..328f970 100644
--- a/tester/covoar/ExecutableInfo.cc
+++ b/tester/covoar/ExecutableInfo.cc
@@ -10,9 +10,9 @@
 #include <rld.h>
 
 #include "ExecutableInfo.h"
+#include "ObjdumpProcessor.h"
 #include "app_common.h"
 #include "CoverageMap.h"
-#include "DesiredSymbols.h"
 #include "SymbolTable.h"
 
 namespace Coverage {
@@ -20,9 +20,11 @@ namespace Coverage {
   ExecutableInfo::ExecutableInfo(
     const char* const  theExecutableName,
     const std::string& theLibraryName,
-    bool               verbose
+    bool               verbose,
+    DesiredSymbols&    symbolsToAnalyze
     ) : fileName(theExecutableName),
-        loadAddress(0)
+        loadAddress(0),
+        symbolsToAnalyze_m(symbolsToAnalyze)
   {
     if ( !theLibraryName.empty() )
       libraryName = theLibraryName;
@@ -59,7 +61,7 @@ namespace Coverage {
           continue;
         }
 
-        if (!SymbolsToAnalyze->isDesired(func.name())) {
+        if (!symbolsToAnalyze_m.isDesired(func.name())) {
           continue;
         }
 
@@ -209,8 +211,8 @@ namespace Coverage {
 
   void ExecutableInfo::mergeCoverage( void ) {
     for (auto& cm : coverageMaps) {
-      if (SymbolsToAnalyze->isDesired( cm.first ))
-        SymbolsToAnalyze->mergeCoverageMap( cm.first, cm.second );
+      if (symbolsToAnalyze_m.isDesired( cm.first ))
+        symbolsToAnalyze_m.mergeCoverageMap( cm.first, cm.second );
     }
   }
 
diff --git a/tester/covoar/ExecutableInfo.h b/tester/covoar/ExecutableInfo.h
index 851a59d..0adebcb 100644
--- a/tester/covoar/ExecutableInfo.h
+++ b/tester/covoar/ExecutableInfo.h
@@ -18,9 +18,12 @@
 #include "AddressToLineMapper.h"
 #include "CoverageMapBase.h"
 #include "SymbolTable.h"
+#include "DesiredSymbols.h"
 
 namespace Coverage {
 
+class DesiredSymbols;
+
   /*! @class ExecutableInfo
    *
    *  This class holds a collection of information for an executable
@@ -41,11 +44,13 @@ 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
+     *  @param[in] symbolsToAnalyze the symbols to be analyzed
      */
     ExecutableInfo(
       const char* const  theExecutableName,
-      const std::string& theLibraryName = "",
-      bool               verbose = false
+      const std::string& theLibraryName,
+      bool               verbose,
+      DesiredSymbols&    symbolsToAnalyze
     );
 
     /*!
@@ -198,6 +203,11 @@ namespace Coverage {
      */
     SymbolTable theSymbolTable;
 
+    /*!
+     * This member variable contains the symbols to be analyzed.
+     */
+    DesiredSymbols& symbolsToAnalyze_m;
+
   };
 }
 #endif
diff --git a/tester/covoar/GcovData.cc b/tester/covoar/GcovData.cc
index e8b8573..11c26ce 100644
--- a/tester/covoar/GcovData.cc
+++ b/tester/covoar/GcovData.cc
@@ -25,9 +25,10 @@
 
 namespace Gcov {
 
-  GcovData::GcovData()
+  GcovData::GcovData( Coverage::DesiredSymbols& symbolsToAnalyze ):
+    numberOfFunctions( 0 ),
+    symbolsToAnalyze_m( symbolsToAnalyze )
   {
-    numberOfFunctions = 0;
   }
 
   GcovData::~GcovData()
@@ -416,7 +417,7 @@ namespace Gcov {
     function->setChecksum( intBuffer[1] );
 
     header.length -= readString( buffer, gcovFile );
-    function->setFunctionName( buffer );
+    function->setFunctionName( buffer, symbolsToAnalyze_m );
     header.length -= readString( buffer, gcovFile );
     function->setFileName( buffer );
     status = fread( &intBuffer, 4, header.length, gcovFile );
diff --git a/tester/covoar/GcovData.h b/tester/covoar/GcovData.h
index 0e74b02..b00b27a 100644
--- a/tester/covoar/GcovData.h
+++ b/tester/covoar/GcovData.h
@@ -11,6 +11,7 @@
 #include <list>
 #include <iostream>
 #include "GcovFunctionData.h"
+#include "DesiredSymbols.h"
 
 namespace Gcov {
 
@@ -56,6 +57,8 @@ struct gcov_statistics
   uint64_t sumMax;            // sum of individual runs max values
 };
 
+class DesiredSymbols;
+
   /*! @class GcovData
    *
    *  This is the specification of the GcovData class.
@@ -66,8 +69,10 @@ struct gcov_statistics
 
     /*!
      *  This method constructs a GcnoReader instance.
+     *
+     *  @param[in] symbolsToAnalyze the symbols to be analyzed
      */
-    GcovData();
+    GcovData( Coverage::DesiredSymbols& symbolsToAnalyze );
 
     /*!
      *  This method destructs a GcnoReader instance.
@@ -194,6 +199,11 @@ struct gcov_statistics
      *  to a specified report file
      */
     void printGcnoFileInfo( FILE * textFile );
+
+    /*!
+     * This member variable contains the symbols to be analyzed
+     */
+    Coverage::DesiredSymbols& symbolsToAnalyze_m;
   };
 }
 #endif
diff --git a/tester/covoar/GcovFunctionData.cc b/tester/covoar/GcovFunctionData.cc
index 90b1be0..1767f18 100644
--- a/tester/covoar/GcovFunctionData.cc
+++ b/tester/covoar/GcovFunctionData.cc
@@ -13,6 +13,7 @@
 #include "GcovFunctionData.h"
 #include "ObjdumpProcessor.h"
 #include "CoverageMapBase.h"
+#include "DesiredSymbols.h"
 
 
 namespace Gcov {
@@ -44,7 +45,10 @@ namespace Gcov {
     firstLineNumber = lineNo;
   }
 
-  bool GcovFunctionData::setFunctionName( const char* fcnName )
+  bool GcovFunctionData::setFunctionName(
+    const char*               fcnName,
+    Coverage::DesiredSymbols& symbolsToAnalyze
+  )
   {
     std::string   symbolName;
 
@@ -62,7 +66,7 @@ namespace Gcov {
     strcpy (functionName, fcnName);
 
     // Tie function to its coverage map
-    symbolInfo = SymbolsToAnalyze->find( symbolName );
+    symbolInfo = symbolsToAnalyze.find( symbolName );
     if ( symbolInfo != NULL )
       coverageMap = symbolInfo->unifiedCoverageMap;
 
@@ -237,7 +241,7 @@ namespace Gcov {
     uint32_t        baseAddress = 0;
     uint32_t        baseSize;
     uint32_t        currentAddress;
-    std::list<Coverage::ObjdumpProcessor::objdumpLine_t>::iterator   instruction;
+    std::list<Coverage::objdumpLine_t>::iterator   instruction;
 
     if ( coverageMap != NULL ) {
 
@@ -399,7 +403,7 @@ namespace Gcov {
 
     uint32_t               baseAddress = 0;
     uint32_t               currentAddress = 0;
-    std::list<Coverage::ObjdumpProcessor::objdumpLine_t>::iterator  instruction;
+    std::list<Coverage::objdumpLine_t>::iterator  instruction;
     blocks_iterator_t      blockIterator;
     blocks_iterator_t      blockIterator2;
     arcs_iterator_t        arcIterator;
@@ -567,7 +571,7 @@ namespace Gcov {
   {
     uint32_t        baseAddress = 0;
     uint32_t        currentAddress;
-    std::list<Coverage::ObjdumpProcessor::objdumpLine_t>::iterator   instruction;
+    std::list<Coverage::objdumpLine_t>::iterator   instruction;
 
     if ( coverageMap == NULL )
       return false;
diff --git a/tester/covoar/GcovFunctionData.h b/tester/covoar/GcovFunctionData.h
index 812b45c..7d87b55 100644
--- a/tester/covoar/GcovFunctionData.h
+++ b/tester/covoar/GcovFunctionData.h
@@ -44,6 +44,8 @@ typedef std::list<gcov_arc_info>::iterator      arcs_iterator_t;
 typedef std::list<gcov_block_info>              blocks_t;
 typedef std::list<gcov_block_info>::iterator    blocks_iterator_t;
 
+class DesiredSymbols;
+
   /*! @class GcovFunctionData
    *
    *  This is the specification of the GcovFunctionData class.
@@ -94,11 +96,13 @@ typedef std::list<gcov_block_info>::iterator    blocks_iterator_t;
      *  unified coverage map.
      *
      *  @param[in] functionName passes name of the the function
+     *  @param[in] symbolsToAnalyze the symbols to be analyzed
      *
      *  @return Returns TRUE if the method succeeded and FALSE if it failed.
      */
     bool setFunctionName(
-      const char*                 fcnName
+      const char*               fcnName,
+      Coverage::DesiredSymbols& symbolsToAnalyze
     );
 
     /*!
diff --git a/tester/covoar/ObjdumpProcessor.cc b/tester/covoar/ObjdumpProcessor.cc
index d324440..f590ece 100644
--- a/tester/covoar/ObjdumpProcessor.cc
+++ b/tester/covoar/ObjdumpProcessor.cc
@@ -32,7 +32,8 @@ namespace Coverage {
     ExecutableInfo* const            executableInfo,
     std::string&                     symbolName,
     ObjdumpProcessor::objdumpLines_t instructions,
-    bool                             verbose
+    bool                             verbose,
+    DesiredSymbols&                  symbolsToAnalyze
   ) {
     // Find the symbol's coverage map.
     try {
@@ -88,7 +89,7 @@ namespace Coverage {
       }
 
       // If there are NOT already saved instructions, save them.
-      SymbolInformation* symbolInfo = SymbolsToAnalyze->find( symbolName );
+      SymbolInformation* symbolInfo = symbolsToAnalyze.find( symbolName );
       if (symbolInfo->instructions.empty()) {
         symbolInfo->sourceFile = executableInfo;
         symbolInfo->baseAddress = lowAddress;
@@ -107,7 +108,7 @@ namespace Coverage {
       }
 
       // Create a unified coverage map for the symbol.
-      SymbolsToAnalyze->createCoverageMap(
+      symbolsToAnalyze.createCoverageMap(
         executableInfo->getFileName().c_str(),
         symbolName,
         size,
@@ -122,7 +123,9 @@ namespace Coverage {
     }
   }
 
-  ObjdumpProcessor::ObjdumpProcessor()
+  ObjdumpProcessor::ObjdumpProcessor(
+    DesiredSymbols& symbolsToAnalyze
+  ): symbolsToAnalyze_m( symbolsToAnalyze )
   {
   }
 
@@ -363,7 +366,8 @@ namespace Coverage {
             executableInformation,
             currentSymbol,
             theInstructions,
-            verbose
+            verbose,
+            symbolsToAnalyze_m
           );
           fprintf(
             stderr,
@@ -419,7 +423,8 @@ namespace Coverage {
             executableInformation,
             currentSymbol,
             theInstructions,
-            verbose
+            verbose,
+            symbolsToAnalyze_m
           );
         }
 
@@ -444,7 +449,7 @@ namespace Coverage {
         }
 
         // See if the new symbol is one that we care about.
-        if (SymbolsToAnalyze->isDesired( symbol )) {
+        if (symbolsToAnalyze_m.isDesired( symbol )) {
           currentSymbol = symbol;
           processSymbol = true;
           theInstructions.push_back( lineInfo );
@@ -462,7 +467,8 @@ namespace Coverage {
             executableInformation,
             currentSymbol,
             theInstructions,
-            verbose
+            verbose,
+            symbolsToAnalyze_m
           );
         }
         processSymbol = false;
diff --git a/tester/covoar/ObjdumpProcessor.h b/tester/covoar/ObjdumpProcessor.h
index d60a768..53671c6 100644
--- a/tester/covoar/ObjdumpProcessor.h
+++ b/tester/covoar/ObjdumpProcessor.h
@@ -12,11 +12,54 @@
 
 #include "ExecutableInfo.h"
 #include "TargetBase.h"
+#include "DesiredSymbols.h"
 
 #include "rld-process.h"
 
 namespace Coverage {
 
+  class DesiredSymbols;
+  class ExecutableInfo;
+
+  /*!
+   *  This type defines the elements of an objdump line.
+   */
+  struct objdumpLine_t {
+    /*!
+     *  This member variable contains the actual line from the object dump.
+     */
+    std::string line;
+
+    /*!
+     *  This member variable contains the address from the object dump line.
+     */
+    uint32_t address;
+
+    /*!
+     *  This member variable contains an indication of whether the line
+     *  is an instruction.
+     */
+    bool isInstruction;
+
+    /*!
+     *  This member variable contains an indication of whether the line
+     *  is a nop instruction.
+     */
+    bool isNop;
+
+    /*!
+     *  This member variable contains the size of the nop instruction.
+     */
+    int nopSize;
+
+    /*!
+     *  This member variable contains an indication of whether the line
+     *  is a branch instruction.
+     */
+    bool isBranch;
+
+  };
+
   /*! @class ObjdumpProcessor
    *
    *  This class implements the functionality which reads the output of
@@ -32,45 +75,6 @@ namespace Coverage {
   public:
 
     /*!
-     *  This type defines the elements of an objdump line.
-     */
-    typedef struct {
-      /*!
-       *  This member variable contains the actual line from the object dump.
-       */
-      std::string line;
-
-      /*!
-       *  This member variable contains the address from the object dump line.
-       */
-      uint32_t address;
-
-      /*!
-       *  This member variable contains an indication of whether the line
-       *  is an instruction.
-       */
-      bool isInstruction;
-
-      /*!
-       *  This member variable contains an indication of whether the line
-       *  is a nop instruction.
-       */
-      bool isNop;
-
-      /*!
-       *  This member variable contains the size of the nop instruction.
-       */
-      int nopSize;
-
-      /*!
-       *  This member variable contains an indication of whether the line
-       *  is a branch instruction.
-       */
-      bool isBranch;
-
-    } objdumpLine_t;
-
-    /*!
      *  This object defines a list of object dump lines
      *  for a file.
      */
@@ -86,7 +90,9 @@ namespace Coverage {
     /*!
      *  This method constructs an ObjdumpProcessor instance.
      */
-    ObjdumpProcessor();
+    ObjdumpProcessor(
+      DesiredSymbols& symbolsToAnalyze
+    );
 
     /*!
      *  This method destructs an ObjdumpProcessor instance.
@@ -169,6 +175,10 @@ namespace Coverage {
       int&              size
     );
 
+    /*!
+     * This member variable contains the symbols to be analyzed
+     */
+    DesiredSymbols& symbolsToAnalyze_m;
   };
 }
 #endif
diff --git a/tester/covoar/ReportsBase.cc b/tester/covoar/ReportsBase.cc
index 266a6ea..11c22c9 100644
--- a/tester/covoar/ReportsBase.cc
+++ b/tester/covoar/ReportsBase.cc
@@ -28,13 +28,15 @@ ReportsBase::ReportsBase(
   const std::string&      symbolSetName,
   Coverage::Explanations& allExplanations,
   const std::string&      projectName,
-  const std::string&      outputDirectory
+  const std::string&      outputDirectory,
+  const DesiredSymbols&   symbolsToAnalyze
 ): reportExtension_m( "" ),
    symbolSetName_m( symbolSetName ),
    timestamp_m( timestamp ),
    allExplanations_m( allExplanations ),
    projectName_m( projectName ),
-   outputDirectory_m( outputDirectory )
+   outputDirectory_m( outputDirectory ),
+   symbolsToAnalyze_m( symbolsToAnalyze )
 {
 }
 
@@ -213,11 +215,11 @@ void ReportsBase::WriteAnnotatedReport( const std::string& fileName )
 
   // Process uncovered branches for each symbol.
   const std::vector<std::string>& symbols =
-    SymbolsToAnalyze->getSymbolsForSet( symbolSetName_m );
+    symbolsToAnalyze_m.getSymbolsForSet( symbolSetName_m );
 
   for ( const auto& symbol : symbols ) {
     const SymbolInformation& info =
-      SymbolsToAnalyze->allSymbols().at( symbol );
+      symbolsToAnalyze_m.allSymbols().at( symbol );
 
     // If uncoveredRanges and uncoveredBranches don't exist, then the
     // symbol was never referenced by any executable.  Just skip it.
@@ -308,7 +310,7 @@ void ReportsBase::WriteBranchReport( const std::string& fileName )
   bool                      hasBranches = true;
 
   if (
-    ( SymbolsToAnalyze->getNumberBranchesFound( symbolSetName_m ) == 0 ) ||
+    ( symbolsToAnalyze_m.getNumberBranchesFound( symbolSetName_m ) == 0 ) ||
     ( BranchInfoAvailable == false )
   ) {
      hasBranches = false;
@@ -322,17 +324,17 @@ void ReportsBase::WriteBranchReport( const std::string& fileName )
 
   // If no branches were found then branch coverage is not supported
   if (
-    ( SymbolsToAnalyze->getNumberBranchesFound( symbolSetName_m ) != 0 ) &&
+    ( symbolsToAnalyze_m.getNumberBranchesFound( symbolSetName_m ) != 0 ) &&
     ( BranchInfoAvailable == true )
   ) {
     // Process uncovered branches for each symbol in the set.
     const std::vector<std::string>& symbols =
-      SymbolsToAnalyze->getSymbolsForSet( symbolSetName_m );
+      symbolsToAnalyze_m.getSymbolsForSet( symbolSetName_m );
 
     count = 0;
     for ( const auto& symbol : symbols ) {
       const SymbolInformation& info =
-        SymbolsToAnalyze->allSymbols().at( symbol );
+        symbolsToAnalyze_m.allSymbols().at( symbol );
 
       theBranches = info.uncoveredBranches;
 
@@ -375,12 +377,12 @@ void ReportsBase::WriteCoverageReport( const std::string& fileName )
 
   // Process uncovered ranges for each symbol.
   const std::vector<std::string>& symbols =
-    SymbolsToAnalyze->getSymbolsForSet( symbolSetName_m );
+    symbolsToAnalyze_m.getSymbolsForSet( symbolSetName_m );
 
   count = 0;
   for ( const auto& symbol : symbols ) {
     const SymbolInformation& info =
-      SymbolsToAnalyze->allSymbols().at( symbol );
+      symbolsToAnalyze_m.allSymbols().at( symbol );
 
     theRanges = info.uncoveredRanges;
 
@@ -420,12 +422,12 @@ void ReportsBase::WriteSizeReport( const std::string& fileName )
 
   // Process uncovered ranges for each symbol.
   const std::vector<std::string>& symbols =
-    SymbolsToAnalyze->getSymbolsForSet( symbolSetName_m );
+    symbolsToAnalyze_m.getSymbolsForSet( symbolSetName_m );
 
   count = 0;
   for ( const auto& symbol : symbols ) {
     const SymbolInformation& info =
-      SymbolsToAnalyze->allSymbols().at( symbol );
+      symbolsToAnalyze_m.allSymbols().at( symbol );
 
     theRanges = info.uncoveredRanges;
 
@@ -440,7 +442,10 @@ void ReportsBase::WriteSizeReport( const std::string& fileName )
   CloseSizeFile( report );
 }
 
-void ReportsBase::WriteSymbolSummaryReport( const std::string& fileName )
+void ReportsBase::WriteSymbolSummaryReport(
+  const std::string&    fileName,
+  const DesiredSymbols& symbolsToAnalyze
+)
 {
   std::ofstream report;
   unsigned int  count;
@@ -453,12 +458,12 @@ void ReportsBase::WriteSymbolSummaryReport( const std::string& fileName )
 
   // Process each symbol.
   const std::vector<std::string>& symbols =
-    SymbolsToAnalyze->getSymbolsForSet( symbolSetName_m );
+    symbolsToAnalyze_m.getSymbolsForSet( symbolSetName_m );
 
   count = 0;
   for ( const auto& symbol : symbols ) {
     const SymbolInformation& info =
-      SymbolsToAnalyze->allSymbols().at( symbol );
+      symbolsToAnalyze_m.allSymbols().at( symbol );
 
     PutSymbolSummaryLine( report, count, symbol, info );
     count++;
@@ -468,9 +473,10 @@ void ReportsBase::WriteSymbolSummaryReport( const std::string& fileName )
 }
 
 void  ReportsBase::WriteSummaryReport(
-  const std::string& fileName,
-  const std::string& symbolSetName,
-  const std::string& outputDirectory
+  const std::string&              fileName,
+  const std::string&              symbolSetName,
+  const std::string&              outputDirectory,
+  const Coverage::DesiredSymbols& symbolsToAnalyze
 )
 {
     // Calculate coverage statistics and output results.
@@ -491,10 +497,10 @@ void  ReportsBase::WriteSummaryReport(
 
   // Look at each symbol.
   const std::vector<std::string>& symbols =
-    SymbolsToAnalyze->getSymbolsForSet( symbolSetName );
+    symbolsToAnalyze.getSymbolsForSet( symbolSetName );
 
   for ( const auto& symbol : symbols ) {
-    SymbolInformation info = SymbolsToAnalyze->allSymbols().at( symbol );
+    SymbolInformation info = symbolsToAnalyze.allSymbols().at( symbol );
 
     // If the symbol's unified coverage map exists, scan through it
     // and count bytes.
@@ -518,12 +524,12 @@ void  ReportsBase::WriteSummaryReport(
   }
 
   percentageBranches = (double) (
-    SymbolsToAnalyze->getNumberBranchesAlwaysTaken( symbolSetName ) +
-    SymbolsToAnalyze->getNumberBranchesNeverTaken( symbolSetName ) +
-  ( SymbolsToAnalyze->getNumberBranchesNotExecuted( symbolSetName ) * 2 )
+    symbolsToAnalyze.getNumberBranchesAlwaysTaken( symbolSetName ) +
+    symbolsToAnalyze.getNumberBranchesNeverTaken( symbolSetName ) +
+  ( symbolsToAnalyze.getNumberBranchesNotExecuted( symbolSetName ) * 2 )
   );
   percentageBranches /=
-    (double) SymbolsToAnalyze->getNumberBranchesFound( symbolSetName ) * 2;
+    (double) symbolsToAnalyze.getNumberBranchesFound( symbolSetName ) * 2;
   percentageBranches *= 100.0;
 
   report << "Bytes Analyzed                   : " << totalBytes << std::endl
@@ -533,31 +539,31 @@ void  ReportsBase::WriteSummaryReport(
          << 100.0 - percentage << std::endl
          << "Percentage Not Executed          : " << percentage << std::endl
          << "Unreferenced Symbols             : "
-         << SymbolsToAnalyze->getNumberUnreferencedSymbols( symbolSetName )
+         << symbolsToAnalyze.getNumberUnreferencedSymbols( symbolSetName )
          << std::endl << "Uncovered ranges found           : "
-         << SymbolsToAnalyze->getNumberUncoveredRanges( symbolSetName )
+         << symbolsToAnalyze.getNumberUncoveredRanges( symbolSetName )
          << std::endl << std::endl;
 
   if (
-    ( SymbolsToAnalyze->getNumberBranchesFound( symbolSetName ) == 0 ) ||
+    ( symbolsToAnalyze.getNumberBranchesFound( symbolSetName ) == 0 ) ||
     ( BranchInfoAvailable == false )
   ) {
     report << "No branch information available" << std::endl;
   } else {
     report << "Total conditional branches found : "
-           << SymbolsToAnalyze->getNumberBranchesFound( symbolSetName )
+           << symbolsToAnalyze.getNumberBranchesFound( symbolSetName )
            << std::endl << "Total branch paths found         : "
-           << SymbolsToAnalyze->getNumberBranchesFound( symbolSetName ) * 2
+           << symbolsToAnalyze.getNumberBranchesFound( symbolSetName ) * 2
            << std::endl << "Uncovered branch paths found     : "
-           << SymbolsToAnalyze->getNumberBranchesAlwaysTaken( symbolSetName ) +
-              SymbolsToAnalyze->getNumberBranchesNeverTaken( symbolSetName ) +
-            ( SymbolsToAnalyze->getNumberBranchesNotExecuted( symbolSetName ) * 2 )
+           << symbolsToAnalyze.getNumberBranchesAlwaysTaken( symbolSetName ) +
+              symbolsToAnalyze.getNumberBranchesNeverTaken( symbolSetName ) +
+            ( symbolsToAnalyze.getNumberBranchesNotExecuted( symbolSetName ) * 2 )
            << std::endl << "   "
-           << SymbolsToAnalyze->getNumberBranchesAlwaysTaken( symbolSetName )
+           << symbolsToAnalyze.getNumberBranchesAlwaysTaken( symbolSetName )
            << " branches always taken" << std::endl << "   "
-           << SymbolsToAnalyze->getNumberBranchesNeverTaken( symbolSetName )
+           << symbolsToAnalyze.getNumberBranchesNeverTaken( symbolSetName )
            << " branches never taken" << std::endl << "   "
-           << SymbolsToAnalyze->getNumberBranchesNotExecuted( symbolSetName ) * 2
+           << symbolsToAnalyze.getNumberBranchesNotExecuted( symbolSetName ) * 2
            << " branch paths not executed" << std::endl
            << "Percentage branch paths covered  : "
            << std::fixed << std::setprecision( 2 ) << std::setw( 4 )
@@ -569,11 +575,12 @@ void  ReportsBase::WriteSummaryReport(
 }
 
 void GenerateReports(
-  const std::string&      symbolSetName,
-  Coverage::Explanations& allExplanations,
-  bool                    verbose,
-  const std::string&      projectName,
-  const std::string&      outputDirectory
+  const std::string&              symbolSetName,
+  Coverage::Explanations&         allExplanations,
+  bool                            verbose,
+  const std::string&              projectName,
+  const std::string&              outputDirectory,
+  const Coverage::DesiredSymbols& symbolsToAnalyze
 )
 {
   typedef std::list<ReportsBase *> reportList_t;
@@ -591,7 +598,8 @@ void GenerateReports(
     symbolSetName,
     allExplanations,
     projectName,
-    outputDirectory
+    outputDirectory,
+    symbolsToAnalyze
   );
   reportList.push_back( reports );
   reports = new ReportsHtml(
@@ -599,7 +607,8 @@ void GenerateReports(
     symbolSetName,
     allExplanations,
     projectName,
-    outputDirectory
+    outputDirectory,
+    symbolsToAnalyze
   );
   reportList.push_back( reports );
 
@@ -640,7 +649,7 @@ void GenerateReports(
     if ( verbose ) {
       std::cerr << "Generate " << reportName << std::endl;
     }
-    reports->WriteSymbolSummaryReport( reportName );
+    reports->WriteSymbolSummaryReport( reportName, symbolsToAnalyze );
   }
 
   for ( ritr = reportList.begin(); ritr != reportList.end(); ritr++ ) {
@@ -651,7 +660,8 @@ void GenerateReports(
   ReportsBase::WriteSummaryReport(
     "summary.txt",
     symbolSetName,
-    outputDirectory
+    outputDirectory,
+    symbolsToAnalyze
   );
 }
 
diff --git a/tester/covoar/ReportsBase.h b/tester/covoar/ReportsBase.h
index a0c6a32..a6cf3bc 100644
--- a/tester/covoar/ReportsBase.h
+++ b/tester/covoar/ReportsBase.h
@@ -32,7 +32,8 @@ class ReportsBase {
       const std::string&      symbolSetName,
       Coverage::Explanations& allExplanations,
       const std::string&      projectName,
-      const std::string&      outputDirectory
+      const std::string&      outputDirectory,
+      const DesiredSymbols&   symbolsToAnalyze
     );
     virtual ~ReportsBase();
 
@@ -80,16 +81,21 @@ class ReportsBase {
      *  each symbol which did not achieve 100% coverage
      *
      *  @param[in] fileName identifies the report file name
+     *  @param[in] symbolsToAnalyze the symbols to be analyzed
      */
-    void WriteSymbolSummaryReport( const std::string& fileName );
+    void WriteSymbolSummaryReport(
+      const std::string&              fileName,
+      const Coverage::DesiredSymbols& symbolsToAnalyze
+    );
 
     /*!
      *  This method produces a sumary report for the overall test run.
      */
     static void  WriteSummaryReport(
-      const std::string& fileName,
-      const std::string& symbolSetName,
-      const std::string& outputDirectory
+      const std::string&              fileName,
+      const std::string&              symbolSetName,
+      const std::string&              outputDirectory,
+      const Coverage::DesiredSymbols& symbolsToAnalyze
     );
 
     /*!
@@ -143,6 +149,11 @@ class ReportsBase {
     std::string outputDirectory_m = "";
 
     /*!
+     * This member variable contains the symbols to be analyzed.
+     */
+    const Coverage::DesiredSymbols& symbolsToAnalyze_m;
+
+    /*!
      *  This method Opens a report file and verifies that it opened
      *  correctly.  Upon failure NULL is returned.
      *
@@ -418,13 +429,15 @@ class ReportsBase {
  *  @param[in] verbose specifies whether to be verbose with output
  *  @param[in] projectName specifies the name of the project
  *  @param[in] outputDirectory specifies the directory for the output
+ *  @param[in] symbolsToAnalyze the symbols to be analyzed
  */
 void GenerateReports(
-  const std::string&      symbolSetName,
-  Coverage::Explanations& allExplanations,
-  bool                    verbose,
-  const std::string&      projectName,
-  const std::string&      outputDirectory
+  const std::string&              symbolSetName,
+  Coverage::Explanations&         allExplanations,
+  bool                            verbose,
+  const std::string&              projectName,
+  const std::string&              outputDirectory,
+  const Coverage::DesiredSymbols& symbolsToAnalyze
 );
 
 }
diff --git a/tester/covoar/ReportsHtml.cc b/tester/covoar/ReportsHtml.cc
index 645dfcd..d6c5217 100644
--- a/tester/covoar/ReportsHtml.cc
+++ b/tester/covoar/ReportsHtml.cc
@@ -38,17 +38,19 @@ typedef rtems::utils::ostream_guard ostream_guard;
 namespace Coverage {
 
   ReportsHtml::ReportsHtml(
-    time_t                  timestamp,
-    const std::string&      symbolSetName,
-    Coverage::Explanations& allExplanations,
-    const std::string&      projectName,
-    const std::string&      outputDirectory
+    time_t                          timestamp,
+    const std::string&              symbolSetName,
+    Coverage::Explanations&         allExplanations,
+    const std::string&              projectName,
+    const std::string&              outputDirectory,
+    const Coverage::DesiredSymbols& symbolsToAnalyze
   ): ReportsBase(
        timestamp,
        symbolSetName,
        allExplanations,
        projectName,
-       outputDirectory
+       outputDirectory,
+       symbolsToAnalyze
      ),
      lastState_m( A_SOURCE )
   {
@@ -441,7 +443,7 @@ namespace Coverage {
   {
     if (
       BranchInfoAvailable &&
-      SymbolsToAnalyze->getNumberBranchesFound( symbolSetName_m ) != 0
+      symbolsToAnalyze_m.getNumberBranchesFound( symbolSetName_m ) != 0
     ) {
       report << "All branch paths taken." << std::endl;
     } else {
diff --git a/tester/covoar/ReportsHtml.h b/tester/covoar/ReportsHtml.h
index 53e1897..e9df060 100644
--- a/tester/covoar/ReportsHtml.h
+++ b/tester/covoar/ReportsHtml.h
@@ -26,11 +26,12 @@ class ReportsHtml: public ReportsBase {
 
   public:
     ReportsHtml(
-      time_t                  timestamp,
-      const std::string&      symbolSetName,
-      Coverage::Explanations& allExplanations,
-      const std::string&      projectName,
-      const std::string&      outputDirectory
+      time_t                          timestamp,
+      const std::string&              symbolSetName,
+      Coverage::Explanations&         allExplanations,
+      const std::string&              projectName,
+      const std::string&              outputDirectory,
+      const Coverage::DesiredSymbols& symbolsToAnalyze
     );
    ~ReportsHtml();
 
diff --git a/tester/covoar/ReportsText.cc b/tester/covoar/ReportsText.cc
index 535bf76..ab2b5f7 100644
--- a/tester/covoar/ReportsText.cc
+++ b/tester/covoar/ReportsText.cc
@@ -21,13 +21,15 @@ ReportsText::ReportsText(
   const std::string&      symbolSetName,
   Coverage::Explanations& allExplanations,
   const std::string&      projectName,
-  const std::string&      outputDirectory
+  const std::string&      outputDirectory,
+  const DesiredSymbols&   symbolsToAnalyze
 ): ReportsBase(
      timestamp,
      symbolSetName,
      allExplanations,
      projectName,
-     outputDirectory
+     outputDirectory,
+     symbolsToAnalyze
    )
 {
   reportExtension_m = ".txt";
@@ -61,7 +63,7 @@ bool ReportsText::PutNoBranchInfo( std::ofstream& report )
 {
   if (
     BranchInfoAvailable &&
-    SymbolsToAnalyze->getNumberBranchesFound( symbolSetName_m ) != 0
+    symbolsToAnalyze_m.getNumberBranchesFound( symbolSetName_m ) != 0
   ) {
     report << "All branch paths taken." << std::endl;
   } else {
diff --git a/tester/covoar/ReportsText.h b/tester/covoar/ReportsText.h
index b3ffd83..0d993c0 100644
--- a/tester/covoar/ReportsText.h
+++ b/tester/covoar/ReportsText.h
@@ -26,7 +26,8 @@ class ReportsText: public ReportsBase {
       const std::string&      symbolSetName,
       Coverage::Explanations& allExplanations,
       const std::string&      projectName,
-      const std::string&      outputDirectory
+      const std::string&      outputDirectory,
+      const DesiredSymbols&   symbolsToAnalyze
     );
     virtual ~ReportsText();
 
diff --git a/tester/covoar/TraceConverter.cc b/tester/covoar/TraceConverter.cc
index c997702..67edd11 100644
--- a/tester/covoar/TraceConverter.cc
+++ b/tester/covoar/TraceConverter.cc
@@ -89,9 +89,10 @@ int main(
   Coverage::ExecutableInfo*    executableInfo;
   rld::process::tempfile       objdumpFile( ".dmp" );
   rld::process::tempfile       err( ".err" );
-  Coverage::ObjdumpProcessor   objdumpProcessor;
+  Coverage::DesiredSymbols     symbolsToAnalyze;
   bool                         verbose = false;
   std::string                  dynamicLibrary;
+  Coverage::ObjdumpProcessor   objdumpProcessor( symbolsToAnalyze );
 
   setup_signals();
 
@@ -132,9 +133,19 @@ int main(
   TargetInfo = Target::TargetFactory( cpuname );
 
   if ( !dynamicLibrary.empty() )
-    executableInfo = new Coverage::ExecutableInfo( executable, dynamicLibrary );
+    executableInfo = new Coverage::ExecutableInfo(
+      executable,
+      dynamicLibrary,
+      false,
+      symbolsToAnalyze
+    );
   else
-    executableInfo = new Coverage::ExecutableInfo( executable );
+    executableInfo = new Coverage::ExecutableInfo(
+      executable,
+      "",
+      false,
+      symbolsToAnalyze
+    );
 
   // If a dynamic library was specified, determine the load address.
   if ( !dynamicLibrary.empty() )
diff --git a/tester/covoar/app_common.cc b/tester/covoar/app_common.cc
index 53b5284..847fbf8 100644
--- a/tester/covoar/app_common.cc
+++ b/tester/covoar/app_common.cc
@@ -56,7 +56,6 @@
 /*
  *  Global variables for the program
  */
-Coverage::DesiredSymbols*   SymbolsToAnalyze    = NULL;
 bool                        BranchInfoAvailable = false;
 Target::TargetBase*         TargetInfo          = NULL;
 
diff --git a/tester/covoar/app_common.h b/tester/covoar/app_common.h
index 4f3b798..0cef74a 100644
--- a/tester/covoar/app_common.h
+++ b/tester/covoar/app_common.h
@@ -12,7 +12,6 @@
 #include "Explanations.h"
 #include "TargetBase.h"
 
-extern Coverage::DesiredSymbols*    SymbolsToAnalyze;
 extern bool                         BranchInfoAvailable;
 extern Target::TargetBase*          TargetInfo;
 
diff --git a/tester/covoar/covoar.cc b/tester/covoar/covoar.cc
index 8ee3eb8..16cc4e1 100644
--- a/tester/covoar/covoar.cc
+++ b/tester/covoar/covoar.cc
@@ -178,11 +178,12 @@ int covoar(
   int                           opt;
   char                          inputBuffer[MAX_LINE_LENGTH];
   Coverage::Explanations        allExplanations;
-  Coverage::ObjdumpProcessor    objdumpProcessor;
   bool                          verbose = false;
   std::string                   dynamicLibrary;
   std::string                   projectName;
   std::string                   outputDirectory = ".";
+  Coverage::DesiredSymbols      symbolsToAnalyze;
+  Coverage::ObjdumpProcessor    objdumpProcessor( symbolsToAnalyze );
 
   //
   // Process command line options.
@@ -278,13 +279,10 @@ int covoar(
   // Create data based on target.
   TargetInfo = Target::TargetFactory( buildTarget );
 
-  // Create the set of desired symbols.
-  SymbolsToAnalyze = new Coverage::DesiredSymbols();
-
   //
   // 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.
@@ -311,11 +309,17 @@ int covoar(
       if (!coverageFileNames.empty()) {
         if ( !dynamicLibrary.empty() ) {
           executableInfo = new Coverage::ExecutableInfo(
-            singleExecutable, dynamicLibrary, verbose
+            singleExecutable,
+            dynamicLibrary,
+            verbose,
+            symbolsToAnalyze
           );
         } else {
           executableInfo = new Coverage::ExecutableInfo(
-            singleExecutable, "", verbose
+            singleExecutable,
+            "",
+            verbose,
+            symbolsToAnalyze
           );
         }
 
@@ -339,7 +343,10 @@ int covoar(
                     << std::endl;
         } else {
           executableInfo = new Coverage::ExecutableInfo(
-            argv[i], "", verbose
+            argv[i],
+            "",
+            verbose,
+            symbolsToAnalyze
           );
           executablesToAnalyze.push_back( executableInfo );
           coverageFileNames.push_back( coverageFileName );
@@ -359,7 +366,7 @@ int covoar(
     throw rld::error( "executables and coverage name size mismatch", "covoar" );
 
   if ( verbose )
-    std::cerr << "Analyzing " << SymbolsToAnalyze->allSymbols().size()
+    std::cerr << "Analyzing " << symbolsToAnalyze.allSymbols().size()
               << " symbols" << std::endl;
 
   // Create explanations.
@@ -418,7 +425,7 @@ int covoar(
   if (verbose)
     std::cerr << "Preprocess uncovered ranges and branches" << std::endl;
 
-  SymbolsToAnalyze->preprocess();
+  symbolsToAnalyze.preprocess( symbolsToAnalyze );
 
   //
   // Generate Gcov reports
@@ -433,7 +440,7 @@ int covoar(
       std::cerr << "Unable to open " << gcnosFileName << std::endl;
     else {
       while ( fscanf( gcnosFile, "%s", inputBuffer ) != EOF) {
-        gcovFile = new Gcov::GcovData();
+        gcovFile = new Gcov::GcovData( symbolsToAnalyze );
         strcpy( gcnoFileName, inputBuffer );
 
         if ( verbose )
@@ -457,20 +464,20 @@ int covoar(
   if (verbose)
     std::cerr << "Computing uncovered ranges and branches" << std::endl;
 
-  SymbolsToAnalyze->computeUncovered( verbose );
+  symbolsToAnalyze.computeUncovered( verbose );
 
   // Calculate remainder of statistics.
   if (verbose)
     std::cerr << "Calculate statistics" << std::endl;
 
-  SymbolsToAnalyze->calculateStatistics();
+  symbolsToAnalyze.calculateStatistics();
 
   // Look up the source lines for any uncovered ranges and branches.
   if (verbose)
     std::cerr << "Looking up source lines for uncovered ranges and branches"
               << std::endl;
 
-  SymbolsToAnalyze->findSourceForUncovered( verbose );
+  symbolsToAnalyze.findSourceForUncovered( verbose, symbolsToAnalyze );
 
   //
   // Report the coverage data.
@@ -478,13 +485,14 @@ int covoar(
   if (verbose)
     std::cerr << "Generate Reports" << std::endl;
 
-  for (const auto& setName : SymbolsToAnalyze->getSetNames()) {
+  for (const auto& setName : symbolsToAnalyze.getSetNames()) {
     Coverage::GenerateReports(
       setName,
       allExplanations,
       verbose,
       projectName,
-      outputDirectory
+      outputDirectory,
+      symbolsToAnalyze
     );
   }
 



More information about the vc mailing list