[rtems-tools commit] Fix covoar so it builds for Windows.

Chris Johns chrisj at rtems.org
Mon Jan 19 21:56:50 UTC 2015


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

Author:    Chris Johns <chrisj at rtems.org>
Date:      Tue Jan 20 08:56:14 2015 +1100

Fix covoar so it builds for Windows.

---

 tester/covoar/DesiredSymbols.cc | 27 +++++++++++++++------------
 tester/covoar/ReportsBase.cc    | 24 ++++++++++++++++--------
 tester/covoar/covoar.cc         | 10 +++++-----
 3 files changed, 36 insertions(+), 25 deletions(-)

diff --git a/tester/covoar/DesiredSymbols.cc b/tester/covoar/DesiredSymbols.cc
index 6b780dd..b5032b4 100644
--- a/tester/covoar/DesiredSymbols.cc
+++ b/tester/covoar/DesiredSymbols.cc
@@ -1,7 +1,7 @@
 /*! @file DesiredSymbols.cc
  *  @brief DesiredSymbols Implementation
  *
- *  This file contains the implementation of the functions 
+ *  This file contains the implementation of the functions
  *  which provide the functionality of the DesiredSymbols.
  */
 
@@ -64,7 +64,7 @@ namespace Coverage {
       symInfo = new SymbolInformation;
 
       // Skip blank lines between symbols
-      do { 
+      do {
         inputBuffer[0] = '\0';
         inputBuffer2[0] = '\0';
         cStatus = fscanf( sFile, "%s %s", inputBuffer, inputBuffer2 );
@@ -92,7 +92,7 @@ namespace Coverage {
         }
 
         // Add this to the set of symbols.
-        else 
+        else
           set[ inputBuffer ] = *symInfo;
       }
     }
@@ -162,7 +162,7 @@ namespace Coverage {
       while (a <= endAddress) {
 
         // If we are at the start of instruction increment
-        // instruction type counters as needed. 
+        // instruction type counters as needed.
         if ( theCoverageMap->isStartOfInstruction( a ) ) {
 
           stats.sizeInInstructions++;
@@ -180,13 +180,13 @@ namespace Coverage {
             stats.branchesExecuted++;
             sitr->second.stats.branchesExecuted++;
           }
- 
+
         }
- 
+
         if (!theCoverageMap->wasExecuted( a )) {
           stats.uncoveredBytes++;
           sitr->second.stats.uncoveredBytes++;
-        }       
+        }
         a++;
 
       }
@@ -251,7 +251,7 @@ namespace Coverage {
       endAddress = sitr->second.stats.sizeInBytes - 1;
       a = 0;
       while (a <= endAddress) {
-        
+
         // If an address was NOT executed, find consecutive unexecuted
         // addresses and add them to the uncovered ranges.
         if (!theCoverageMap->wasExecuted( a )) {
@@ -501,6 +501,9 @@ namespace Coverage {
       inputBuffer[ strlen(inputBuffer) - 1] = '\0';
 
       // Use only the base filename without directory path.
+#if WIN32
+      #define realpath(N,R) _fullpath((R),(N),_MAX_PATH)
+#endif
       realpath( inputBuffer, rpath );
       base = basename( rpath );
 
@@ -610,9 +613,9 @@ namespace Coverage {
   {
     if (set.find( symbolName ) == set.end()) {
       #if 0
-        fprintf( stderr, 
-          "Warning: Unable to find symbol %s\n", 
-          symbolName.c_str() 
+        fprintf( stderr,
+          "Warning: Unable to find symbol %s\n",
+          symbolName.c_str()
         );
       #endif
       return false;
@@ -633,7 +636,7 @@ namespace Coverage {
     uint32_t              sBaseAddress;
     uint32_t              sMapSize;
     uint32_t              executionCount;
-    
+
     // Ensure that the symbol is a desired symbol.
     itr = set.find( symbolName );
 
diff --git a/tester/covoar/ReportsBase.cc b/tester/covoar/ReportsBase.cc
index d401bdd..b9dcc51 100644
--- a/tester/covoar/ReportsBase.cc
+++ b/tester/covoar/ReportsBase.cc
@@ -14,6 +14,10 @@
 #include "ReportsText.h"
 #include "ReportsHtml.h"
 
+#if WIN32
+#include <io.h>
+#endif
+
 namespace Coverage {
 
 ReportsBase::ReportsBase( time_t timestamp ):
@@ -35,7 +39,11 @@ FILE* ReportsBase::OpenFile(
   std::string  file;
 
   // Create the output directory if it does not already exist
+#if WIN32
+  sc = _mkdir( outputDirectory );
+#else
   sc = mkdir( outputDirectory,0755 );
+#endif
   if ( (sc == -1) && (errno != EEXIST) ) {
     fprintf(stderr, "Unable to create output directory %s\n", outputDirectory);
     return NULL;
@@ -211,7 +219,7 @@ void ReportsBase::WriteAnnotatedReport(
 
       if ( itr->isInstruction ) {
         if (!theCoverageMap->wasExecuted( itr->address - bAddress )){
-          annotation = "<== NOT EXECUTED";           
+          annotation = "<== NOT EXECUTED";
           state = A_NEVER_EXECUTED;
           id = theRanges->getId( itr->address );
         } else if (theCoverageMap->isBranch( itr->address - bAddress )) {
@@ -230,8 +238,8 @@ void ReportsBase::WriteAnnotatedReport(
 
       sprintf( textLine, "%-70s", itr->line.c_str() );
       line = textLine + annotation;
-      
-      PutAnnotatedLine( aFile, state, line, id); 
+
+      PutAnnotatedLine( aFile, state, line, id);
     }
 
     AnnotatedEnd( aFile );
@@ -253,7 +261,7 @@ void ReportsBase::WriteBranchReport(
   unsigned int                                    count;
   bool                                            hasBranches = true;
 
-  if ((SymbolsToAnalyze->getNumberBranchesFound() == 0) || 
+  if ((SymbolsToAnalyze->getNumberBranchesFound() == 0) ||
       (BranchInfoAvailable == false) )
      hasBranches = false;
 
@@ -263,7 +271,7 @@ void ReportsBase::WriteBranchReport(
     return;
 
   // If no branches were found of branch coverage is not supported
-  if ((SymbolsToAnalyze->getNumberBranchesFound() == 0) || 
+  if ((SymbolsToAnalyze->getNumberBranchesFound() == 0) ||
       (BranchInfoAvailable == false) ) {
 
     PutNoBranchInfo(report);
@@ -359,7 +367,7 @@ void ReportsBase::WriteCoverageReport(
  */
 void ReportsBase::WriteSizeReport(
   const char* const fileName
-) 
+)
 {
   Coverage::DesiredSymbols::symbolSet_t::iterator ditr;
   FILE*                                           report;
@@ -475,7 +483,7 @@ void  ReportsBase::WriteSummaryReport(
     "Uncovered ranges found   : %d\n",
     SymbolsToAnalyze->getNumberUncoveredRanges()
   );
-  if ((SymbolsToAnalyze->getNumberBranchesFound() == 0) || 
+  if ((SymbolsToAnalyze->getNumberBranchesFound() == 0) ||
       (BranchInfoAvailable == false) ) {
     fprintf( report, "No branch information available\n" );
   } else {
@@ -514,7 +522,7 @@ void GenerateReports()
 
   time_t timestamp;
 
- 
+
   timestamp = time(NULL); /* get current cal time */
   reports = new ReportsText(timestamp);
   reportList.push_back(reports);
diff --git a/tester/covoar/covoar.cc b/tester/covoar/covoar.cc
index 78954fd..a3f137e 100644
--- a/tester/covoar/covoar.cc
+++ b/tester/covoar/covoar.cc
@@ -2,8 +2,6 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <limits.h>
-#include <list>
-#include <netdb.h>
 #include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -12,6 +10,8 @@
 #include <sys/stat.h>
 #include <unistd.h>
 
+#include <list>
+
 #include "app_common.h"
 #include "CoverageFactory.h"
 #include "CoverageMap.h"
@@ -119,7 +119,7 @@ bool isTrue(const char *value)
     _t = CoverageConfiguration->getOption(_opt); \
     if ( _t ) _val = _t; \
   } while(0)
-  
+
 
 void check_configuration(void)
 {
@@ -160,7 +160,7 @@ int main(
   const char*                                    singleExecutable = NULL;
 
   CoverageConfiguration = new Configuration::FileReader(Options);
-  
+
   //
   // Process command line options.
   //
@@ -438,7 +438,7 @@ int main(
   //
   if (Verbose)
     fprintf( stderr, "Generating Gcov reports...\n");
-  gcnosFile = fopen ( gcnosFileName , "r" );	
+  gcnosFile = fopen ( gcnosFileName , "r" );
 
   if ( !gcnosFile ) {
     fprintf( stderr, "Unable to open %s\n", gcnosFileName );



More information about the vc mailing list