[rtems-tools commit] Remove BranchInfoAvailable global variable

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


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

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

Remove BranchInfoAvailable global variable

- Removed BranchInfoAvailable from app_common
- Created member variable in CoverageReaderBase and ReportsBase and a function
  to get the value of the member variable

---

 tester/covoar/CoverageReaderBase.cc |  5 +++++
 tester/covoar/CoverageReaderBase.h  | 10 ++++++++++
 tester/covoar/CoverageReaderQEMU.cc |  2 +-
 tester/covoar/CoverageReaderTSIM.cc |  4 ++--
 tester/covoar/ReportsBase.cc        | 27 +++++++++++++++++----------
 tester/covoar/ReportsBase.h         | 15 ++++++++++++---
 tester/covoar/ReportsHtml.cc        |  8 +++++---
 tester/covoar/ReportsHtml.h         |  3 ++-
 tester/covoar/ReportsText.cc        |  8 +++++---
 tester/covoar/ReportsText.h         |  3 ++-
 tester/covoar/app_common.cc         |  1 -
 tester/covoar/app_common.h          |  1 -
 tester/covoar/covoar.cc             |  6 +++++-
 13 files changed, 66 insertions(+), 27 deletions(-)

diff --git a/tester/covoar/CoverageReaderBase.cc b/tester/covoar/CoverageReaderBase.cc
index 3ebcc8d..e226964 100644
--- a/tester/covoar/CoverageReaderBase.cc
+++ b/tester/covoar/CoverageReaderBase.cc
@@ -16,4 +16,9 @@ namespace Coverage {
   CoverageReaderBase::~CoverageReaderBase()
   {
   }
+
+  bool CoverageReaderBase::getBranchInfoAvailable() const
+  {
+    return branchInfoAvailable_m;
+  }
 }
diff --git a/tester/covoar/CoverageReaderBase.h b/tester/covoar/CoverageReaderBase.h
index 81090c0..ba909e6 100644
--- a/tester/covoar/CoverageReaderBase.h
+++ b/tester/covoar/CoverageReaderBase.h
@@ -42,6 +42,16 @@ namespace Coverage {
       const char* const     file,
       ExecutableInfo* const executableInformation
     ) = 0;
+
+  /*!
+   *  This method retrieves the branchInfoAvailable_m variable
+   */
+  bool getBranchInfoAvailable() const;
+
+  /*!
+   * This member variable tells whether the branch info is available.
+   */
+  bool branchInfoAvailable_m = false;
   };
 
 }
diff --git a/tester/covoar/CoverageReaderQEMU.cc b/tester/covoar/CoverageReaderQEMU.cc
index d3c6abe..802d862 100644
--- a/tester/covoar/CoverageReaderQEMU.cc
+++ b/tester/covoar/CoverageReaderQEMU.cc
@@ -31,7 +31,7 @@ namespace Coverage {
 
   CoverageReaderQEMU::CoverageReaderQEMU()
   {
-    BranchInfoAvailable = true;
+    branchInfoAvailable_m = true;
   }
 
   CoverageReaderQEMU::~CoverageReaderQEMU()
diff --git a/tester/covoar/CoverageReaderTSIM.cc b/tester/covoar/CoverageReaderTSIM.cc
index 03bf7a8..32e3aa7 100644
--- a/tester/covoar/CoverageReaderTSIM.cc
+++ b/tester/covoar/CoverageReaderTSIM.cc
@@ -90,11 +90,11 @@ namespace Coverage {
           aCoverageMap->setWasExecuted( a + 3 );
           if ( cover & 0x08 ) {
             aCoverageMap->setWasTaken( a );
-            BranchInfoAvailable = true;
+            branchInfoAvailable_m = true;
           }
           if ( cover & 0x10 ) {
             aCoverageMap->setWasNotTaken( a );
-            BranchInfoAvailable = true;
+            branchInfoAvailable_m = true;
           }
         }
       }
diff --git a/tester/covoar/ReportsBase.cc b/tester/covoar/ReportsBase.cc
index 11c22c9..f4df64c 100644
--- a/tester/covoar/ReportsBase.cc
+++ b/tester/covoar/ReportsBase.cc
@@ -29,14 +29,16 @@ ReportsBase::ReportsBase(
   Coverage::Explanations& allExplanations,
   const std::string&      projectName,
   const std::string&      outputDirectory,
-  const DesiredSymbols&   symbolsToAnalyze
+  const DesiredSymbols&   symbolsToAnalyze,
+  bool                    branchInfoAvailable
 ): reportExtension_m( "" ),
    symbolSetName_m( symbolSetName ),
    timestamp_m( timestamp ),
    allExplanations_m( allExplanations ),
    projectName_m( projectName ),
    outputDirectory_m( outputDirectory ),
-   symbolsToAnalyze_m( symbolsToAnalyze )
+   symbolsToAnalyze_m( symbolsToAnalyze ),
+   branchInfoAvailable_m( branchInfoAvailable )
 {
 }
 
@@ -311,7 +313,7 @@ void ReportsBase::WriteBranchReport( const std::string& fileName )
 
   if (
     ( symbolsToAnalyze_m.getNumberBranchesFound( symbolSetName_m ) == 0 ) ||
-    ( BranchInfoAvailable == false )
+    ( branchInfoAvailable_m == false )
   ) {
      hasBranches = false;
   }
@@ -325,7 +327,7 @@ void ReportsBase::WriteBranchReport( const std::string& fileName )
   // If no branches were found then branch coverage is not supported
   if (
     ( symbolsToAnalyze_m.getNumberBranchesFound( symbolSetName_m ) != 0 ) &&
-    ( BranchInfoAvailable == true )
+    ( branchInfoAvailable_m == true )
   ) {
     // Process uncovered branches for each symbol in the set.
     const std::vector<std::string>& symbols =
@@ -476,7 +478,8 @@ void  ReportsBase::WriteSummaryReport(
   const std::string&              fileName,
   const std::string&              symbolSetName,
   const std::string&              outputDirectory,
-  const Coverage::DesiredSymbols& symbolsToAnalyze
+  const Coverage::DesiredSymbols& symbolsToAnalyze,
+  bool                            branchInfoAvailable
 )
 {
     // Calculate coverage statistics and output results.
@@ -546,7 +549,7 @@ void  ReportsBase::WriteSummaryReport(
 
   if (
     ( symbolsToAnalyze.getNumberBranchesFound( symbolSetName ) == 0 ) ||
-    ( BranchInfoAvailable == false )
+    ( branchInfoAvailable == false )
   ) {
     report << "No branch information available" << std::endl;
   } else {
@@ -580,7 +583,8 @@ void GenerateReports(
   bool                            verbose,
   const std::string&              projectName,
   const std::string&              outputDirectory,
-  const Coverage::DesiredSymbols& symbolsToAnalyze
+  const Coverage::DesiredSymbols& symbolsToAnalyze,
+  bool                            branchInfoAvailable
 )
 {
   typedef std::list<ReportsBase *> reportList_t;
@@ -599,7 +603,8 @@ void GenerateReports(
     allExplanations,
     projectName,
     outputDirectory,
-    symbolsToAnalyze
+    symbolsToAnalyze,
+    branchInfoAvailable
   );
   reportList.push_back( reports );
   reports = new ReportsHtml(
@@ -608,7 +613,8 @@ void GenerateReports(
     allExplanations,
     projectName,
     outputDirectory,
-    symbolsToAnalyze
+    symbolsToAnalyze,
+    branchInfoAvailable
   );
   reportList.push_back( reports );
 
@@ -661,7 +667,8 @@ void GenerateReports(
     "summary.txt",
     symbolSetName,
     outputDirectory,
-    symbolsToAnalyze
+    symbolsToAnalyze,
+    branchInfoAvailable
   );
 }
 
diff --git a/tester/covoar/ReportsBase.h b/tester/covoar/ReportsBase.h
index a6cf3bc..8883ccb 100644
--- a/tester/covoar/ReportsBase.h
+++ b/tester/covoar/ReportsBase.h
@@ -33,7 +33,8 @@ class ReportsBase {
       Coverage::Explanations& allExplanations,
       const std::string&      projectName,
       const std::string&      outputDirectory,
-      const DesiredSymbols&   symbolsToAnalyze
+      const DesiredSymbols&   symbolsToAnalyze,
+      bool                    branchInfoAvailable
     );
     virtual ~ReportsBase();
 
@@ -95,7 +96,8 @@ class ReportsBase {
       const std::string&              fileName,
       const std::string&              symbolSetName,
       const std::string&              outputDirectory,
-      const Coverage::DesiredSymbols& symbolsToAnalyze
+      const Coverage::DesiredSymbols& symbolsToAnalyze,
+      bool                            branchInfoAvailable
     );
 
     /*!
@@ -154,6 +156,11 @@ class ReportsBase {
     const Coverage::DesiredSymbols& symbolsToAnalyze_m;
 
     /*!
+     * This member variable tells whether the branch info is available
+     */
+    bool branchInfoAvailable_m = false;
+
+    /*!
      *  This method Opens a report file and verifies that it opened
      *  correctly.  Upon failure NULL is returned.
      *
@@ -430,6 +437,7 @@ class ReportsBase {
  *  @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
+ *  @param[in] branchInfoAvailable tells if branch info is available
  */
 void GenerateReports(
   const std::string&              symbolSetName,
@@ -437,7 +445,8 @@ void GenerateReports(
   bool                            verbose,
   const std::string&              projectName,
   const std::string&              outputDirectory,
-  const Coverage::DesiredSymbols& symbolsToAnalyze
+  const Coverage::DesiredSymbols& symbolsToAnalyze,
+  bool                            branchInfoAvailable
 );
 
 }
diff --git a/tester/covoar/ReportsHtml.cc b/tester/covoar/ReportsHtml.cc
index d6c5217..1b75eb0 100644
--- a/tester/covoar/ReportsHtml.cc
+++ b/tester/covoar/ReportsHtml.cc
@@ -43,14 +43,16 @@ namespace Coverage {
     Coverage::Explanations&         allExplanations,
     const std::string&              projectName,
     const std::string&              outputDirectory,
-    const Coverage::DesiredSymbols& symbolsToAnalyze
+    const Coverage::DesiredSymbols& symbolsToAnalyze,
+    bool                            branchInfoAvailable
   ): ReportsBase(
        timestamp,
        symbolSetName,
        allExplanations,
        projectName,
        outputDirectory,
-       symbolsToAnalyze
+       symbolsToAnalyze,
+       branchInfoAvailable
      ),
      lastState_m( A_SOURCE )
   {
@@ -442,7 +444,7 @@ namespace Coverage {
   bool ReportsHtml::PutNoBranchInfo( std::ofstream& report )
   {
     if (
-      BranchInfoAvailable &&
+      branchInfoAvailable_m &&
       symbolsToAnalyze_m.getNumberBranchesFound( symbolSetName_m ) != 0
     ) {
       report << "All branch paths taken." << std::endl;
diff --git a/tester/covoar/ReportsHtml.h b/tester/covoar/ReportsHtml.h
index e9df060..406eefc 100644
--- a/tester/covoar/ReportsHtml.h
+++ b/tester/covoar/ReportsHtml.h
@@ -31,7 +31,8 @@ class ReportsHtml: public ReportsBase {
       Coverage::Explanations&         allExplanations,
       const std::string&              projectName,
       const std::string&              outputDirectory,
-      const Coverage::DesiredSymbols& symbolsToAnalyze
+      const Coverage::DesiredSymbols& symbolsToAnalyze,
+      bool                            branchInfoAvailable
     );
    ~ReportsHtml();
 
diff --git a/tester/covoar/ReportsText.cc b/tester/covoar/ReportsText.cc
index ab2b5f7..6541be2 100644
--- a/tester/covoar/ReportsText.cc
+++ b/tester/covoar/ReportsText.cc
@@ -22,14 +22,16 @@ ReportsText::ReportsText(
   Coverage::Explanations& allExplanations,
   const std::string&      projectName,
   const std::string&      outputDirectory,
-  const DesiredSymbols&   symbolsToAnalyze
+  const DesiredSymbols&   symbolsToAnalyze,
+  bool                    branchInfoAvailable
 ): ReportsBase(
      timestamp,
      symbolSetName,
      allExplanations,
      projectName,
      outputDirectory,
-     symbolsToAnalyze
+     symbolsToAnalyze,
+     branchInfoAvailable
    )
 {
   reportExtension_m = ".txt";
@@ -62,7 +64,7 @@ void ReportsText::PutAnnotatedLine(
 bool ReportsText::PutNoBranchInfo( std::ofstream& report )
 {
   if (
-    BranchInfoAvailable &&
+    branchInfoAvailable_m &&
     symbolsToAnalyze_m.getNumberBranchesFound( symbolSetName_m ) != 0
   ) {
     report << "All branch paths taken." << std::endl;
diff --git a/tester/covoar/ReportsText.h b/tester/covoar/ReportsText.h
index 0d993c0..1aa30b0 100644
--- a/tester/covoar/ReportsText.h
+++ b/tester/covoar/ReportsText.h
@@ -27,7 +27,8 @@ class ReportsText: public ReportsBase {
       Coverage::Explanations& allExplanations,
       const std::string&      projectName,
       const std::string&      outputDirectory,
-      const DesiredSymbols&   symbolsToAnalyze
+      const DesiredSymbols&   symbolsToAnalyze,
+      bool                    branchInfoAvailable
     );
     virtual ~ReportsText();
 
diff --git a/tester/covoar/app_common.cc b/tester/covoar/app_common.cc
index 847fbf8..8f05464 100644
--- a/tester/covoar/app_common.cc
+++ b/tester/covoar/app_common.cc
@@ -56,7 +56,6 @@
 /*
  *  Global variables for the program
  */
-bool                        BranchInfoAvailable = false;
 Target::TargetBase*         TargetInfo          = NULL;
 
 
diff --git a/tester/covoar/app_common.h b/tester/covoar/app_common.h
index 0cef74a..6649905 100644
--- a/tester/covoar/app_common.h
+++ b/tester/covoar/app_common.h
@@ -12,7 +12,6 @@
 #include "Explanations.h"
 #include "TargetBase.h"
 
-extern bool                         BranchInfoAvailable;
 extern Target::TargetBase*          TargetInfo;
 
 
diff --git a/tester/covoar/covoar.cc b/tester/covoar/covoar.cc
index 16cc4e1..ef22362 100644
--- a/tester/covoar/covoar.cc
+++ b/tester/covoar/covoar.cc
@@ -183,6 +183,7 @@ int covoar(
   std::string                   projectName;
   std::string                   outputDirectory = ".";
   Coverage::DesiredSymbols      symbolsToAnalyze;
+  bool                          branchInfoAvailable = false;
   Coverage::ObjdumpProcessor    objdumpProcessor( symbolsToAnalyze );
 
   //
@@ -486,13 +487,16 @@ int covoar(
     std::cerr << "Generate Reports" << std::endl;
 
   for (const auto& setName : symbolsToAnalyze.getSetNames()) {
+    branchInfoAvailable = coverageReader->getBranchInfoAvailable();
+
     Coverage::GenerateReports(
       setName,
       allExplanations,
       verbose,
       projectName,
       outputDirectory,
-      symbolsToAnalyze
+      symbolsToAnalyze,
+      branchInfoAvailable
     );
   }
 



More information about the vc mailing list