change log for gcc-testing (2010-05-07)

rtems-vc at rtems.org rtems-vc at rtems.org
Fri May 7 19:10:04 UTC 2010


 *humph*:
2010-05-07	Glenn Humphrey

	* CoverageReaderQEMU.cc, CoverageReaderRTEMS.cc,
	CoverageReaderSkyeye.cc, CoverageReaderTSIM.cc, DesiredSymbols.cc,
	DesiredSymbols.h, ExecutableInfo.cc, ExecutableInfo.h,
	ObjdumpProcessor.cc, ObjdumpProcessor.h, SymbolTable.cc,
	SymbolTable.h, covoar.cc: Removed the use of nm to generate the
	symbol for each executable. Modified the ObjdumpProcessor to populate
	the symbol table and create the coverage maps.

M  1.206  rtems-coverage/ChangeLog
M   1.12  rtems-coverage/CoverageReaderQEMU.cc
M    1.5  rtems-coverage/CoverageReaderRTEMS.cc
M    1.9  rtems-coverage/CoverageReaderSkyeye.cc
M    1.7  rtems-coverage/CoverageReaderTSIM.cc
M    1.3  rtems-coverage/DesiredSymbols.h
M    1.6  rtems-coverage/DesiredSymbols.cc
M    1.2  rtems-coverage/ExecutableInfo.h
M    1.3  rtems-coverage/ExecutableInfo.cc
M    1.9  rtems-coverage/ObjdumpProcessor.h
M   1.29  rtems-coverage/ObjdumpProcessor.cc
M    1.3  rtems-coverage/SymbolTable.h
M    1.6  rtems-coverage/SymbolTable.cc
M   1.14  rtems-coverage/covoar.cc

diff -u gcc-testing/rtems-coverage/ChangeLog:1.205 gcc-testing/rtems-coverage/ChangeLog:1.206
--- gcc-testing/rtems-coverage/ChangeLog:1.205	Fri May  7 13:29:44 2010
+++ gcc-testing/rtems-coverage/ChangeLog	Fri May  7 13:53:58 2010
@@ -1,3 +1,13 @@
+2010-05-07	Glenn Humphrey
+
+	* CoverageReaderQEMU.cc, CoverageReaderRTEMS.cc,
+	CoverageReaderSkyeye.cc, CoverageReaderTSIM.cc, DesiredSymbols.cc,
+	DesiredSymbols.h, ExecutableInfo.cc, ExecutableInfo.h,
+	ObjdumpProcessor.cc, ObjdumpProcessor.h, SymbolTable.cc,
+	SymbolTable.h, covoar.cc: Removed the use of nm to generate the
+	symbol for each executable. Modified the ObjdumpProcessor to populate
+	the symbol table and create the coverage maps.
+
 2010-05-07	Joel Sherrill <joel.sherrill at oarcorp.com>
 
 	* do_coverage: Pick up style sheet for reports.

diff -u gcc-testing/rtems-coverage/CoverageReaderQEMU.cc:1.11 gcc-testing/rtems-coverage/CoverageReaderQEMU.cc:1.12
--- gcc-testing/rtems-coverage/CoverageReaderQEMU.cc:1.11	Thu Apr 29 14:12:31 2010
+++ gcc-testing/rtems-coverage/CoverageReaderQEMU.cc	Fri May  7 13:53:58 2010
@@ -14,8 +14,8 @@
 #include <sys/stat.h>
 
 #include "CoverageReaderQEMU.h"
-#include "ExecutableInfo.h"
 #include "CoverageMap.h"
+#include "ExecutableInfo.h"
 
 /* XXX really not always right */
 typedef uint32_t target_ulong;

diff -u gcc-testing/rtems-coverage/CoverageReaderRTEMS.cc:1.4 gcc-testing/rtems-coverage/CoverageReaderRTEMS.cc:1.5
--- gcc-testing/rtems-coverage/CoverageReaderRTEMS.cc:1.4	Fri Mar  5 10:45:37 2010
+++ gcc-testing/rtems-coverage/CoverageReaderRTEMS.cc	Fri May  7 13:53:58 2010
@@ -14,6 +14,7 @@
 #include <sys/stat.h>
 
 #include "CoverageReaderRTEMS.h"
+#include "CoverageMap.h"
 #include "ExecutableInfo.h"
 #include "rtemscov_header.h"
 
@@ -32,25 +33,26 @@
     ExecutableInfo* const executableInformation
   )
   {
-    FILE                        *coverageFile;
+    CoverageMapBase*             aCoverageMap = NULL;
     uintptr_t                    baseAddress;
-    uintptr_t                    length;
-    int                          status;
-    uintptr_t                    i;
     uint8_t                      cover;
+    FILE*                        coverageFile;
     rtems_coverage_map_header_t  header;
+    uintptr_t                    i;
+    uintptr_t                    length;
     struct stat                  statbuf;
+    int                          status;
 
     //
     // Verify that the coverage file has a non-zero size.
     //
     status = stat( file, &statbuf );
-    if ( status == -1 ) {
+    if (status == -1) {
       fprintf( stderr, "Unable to stat %s\n", file );
       return false;
     }
 
-    if ( statbuf.st_size == 0 ) {
+    if (statbuf.st_size == 0) {
       fprintf( stderr, "%s is 0 bytes long\n", file );
       return false;
     }
@@ -59,13 +61,13 @@
     // Open the coverage file and read the header.
     //
     coverageFile = fopen( file, "r" );
-    if ( !coverageFile ) {
+    if (!coverageFile) {
       fprintf( stderr, "Unable to open %s\n", file );
       return false;
     }
 
     status = fread( &header, sizeof(header), 1, coverageFile );
-    if ( status != 1 ) {
+    if (status != 1) {
       fprintf( stderr, "Unable to read header from %s\n", file );
       return false;
     }
@@ -88,9 +90,9 @@
     //
     // Read and process each line of the coverage file.
     //
-    for ( i=0 ; i<length ; i++ ) {
+    for (i=0; i<length; i++) {
       status = fread( &cover, sizeof(uint8_t), 1, coverageFile );
-      if ( status != 1 ) {
+      if (status != 1) {
         fprintf(
           stderr,
           "CoverageReaderRTEMS::ProcessFile - breaking after 0x%08x in %s\n",
@@ -100,8 +102,14 @@
         break;
       }
 
-      if ( cover ) {
-        executableInformation->markWasExecuted( baseAddress + i );
+      //
+      // Obtain the coverage map containing the address and
+      // mark the address as executed.
+      //
+      if (cover) {
+        aCoverageMap = executableInformation->getCoverageMap( baseAddress + i );
+        if (aCoverageMap)
+          aCoverageMap->setWasExecuted( baseAddress + i );
       }
     }
 

diff -u gcc-testing/rtems-coverage/CoverageReaderSkyeye.cc:1.8 gcc-testing/rtems-coverage/CoverageReaderSkyeye.cc:1.9
--- gcc-testing/rtems-coverage/CoverageReaderSkyeye.cc:1.8	Fri Mar  5 10:45:37 2010
+++ gcc-testing/rtems-coverage/CoverageReaderSkyeye.cc	Fri May  7 13:53:58 2010
@@ -14,6 +14,7 @@
 #include <sys/stat.h>
 
 #include "CoverageReaderSkyeye.h"
+#include "CoverageMap.h"
 #include "ExecutableInfo.h"
 #include "skyeye_header.h"
 
@@ -32,14 +33,15 @@
     ExecutableInfo* const executableInformation
   )
   {
-    uintptr_t     baseAddress;
-    uint8_t       cover;
-    FILE*         coverageFile;
-    prof_header_t header;
-    uintptr_t     i;
-    uintptr_t     length;
-    struct stat   statbuf;
-    int           status;
+    CoverageMapBase* aCoverageMap = NULL;
+    uintptr_t        baseAddress;
+    uint8_t          cover;
+    FILE*            coverageFile;
+    prof_header_t    header;
+    uintptr_t        i;
+    uintptr_t        length;
+    struct stat      statbuf;
+    int              status;
 
     //
     // Verify that the coverage file has a non-zero size.
@@ -100,17 +102,32 @@
         break;
       }
 
+      //
+      // Obtain the coverage map containing the address and
+      // mark the address as executed.
+      //
+      // NOTE: This method ONLY works for Skyeye in 32-bit mode.
+      //
       if (cover & 0x01) {
-        executableInformation->markWasExecuted( baseAddress + i );
-        executableInformation->markWasExecuted( baseAddress + i + 1 );
-        executableInformation->markWasExecuted( baseAddress + i + 2 );
-        executableInformation->markWasExecuted( baseAddress + i + 3 );
+        aCoverageMap = executableInformation->getCoverageMap( baseAddress + i );
+        if (aCoverageMap) {
+          aCoverageMap->setWasExecuted( baseAddress + i );
+          aCoverageMap->setWasExecuted( baseAddress + i + 1 );
+          aCoverageMap->setWasExecuted( baseAddress + i + 2 );
+          aCoverageMap->setWasExecuted( baseAddress + i + 3 );
+        }
       }
+
       if (cover & 0x10) {
-        executableInformation->markWasExecuted( baseAddress + i + 4 );
-        executableInformation->markWasExecuted( baseAddress + i + 5 );
-        executableInformation->markWasExecuted( baseAddress + i + 6 );
-        executableInformation->markWasExecuted( baseAddress + i + 7 );
+        aCoverageMap = executableInformation->getCoverageMap(
+          baseAddress + i + 4
+        );
+        if (aCoverageMap) {
+          aCoverageMap->setWasExecuted( baseAddress + i + 4 );
+          aCoverageMap->setWasExecuted( baseAddress + i + 5 );
+          aCoverageMap->setWasExecuted( baseAddress + i + 6 );
+          aCoverageMap->setWasExecuted( baseAddress + i + 7 );
+        }
       }
     }
 

diff -u gcc-testing/rtems-coverage/CoverageReaderTSIM.cc:1.6 gcc-testing/rtems-coverage/CoverageReaderTSIM.cc:1.7
--- gcc-testing/rtems-coverage/CoverageReaderTSIM.cc:1.6	Fri Mar  5 10:45:37 2010
+++ gcc-testing/rtems-coverage/CoverageReaderTSIM.cc	Fri May  7 13:53:58 2010
@@ -14,6 +14,7 @@
 #include <sys/stat.h>
 
 #include "CoverageReaderTSIM.h"
+#include "CoverageMap.h"
 #include "ExecutableInfo.h"
 
 namespace Coverage {
@@ -31,23 +32,24 @@
     ExecutableInfo* const executableInformation
   )
   {
-    int         baseAddress;
-    int         cover;
-    FILE*       coverageFile;
-    int         i;
-    struct stat statbuf;
-    int         status;
+    CoverageMapBase* aCoverageMap = NULL;
+    int              baseAddress;
+    int              cover;
+    FILE*            coverageFile;
+    int              i;
+    struct stat      statbuf;
+    int              status;
 
     //
     // Verify that the coverage file has a non-zero size.
     //
     status = stat( file, &statbuf );
-    if ( status == -1 ) {
+    if (status == -1) {
       fprintf( stderr, "Unable to stat %s\n", file );
       return false;
     }
 
-    if ( statbuf.st_size == 0 ) {
+    if (statbuf.st_size == 0) {
       fprintf( stderr, "%s is 0 bytes long\n", file );
       return false;
     }
@@ -56,7 +58,7 @@
     // Open the coverage file.
     //
     coverageFile = fopen( file, "r" );
-    if ( !coverageFile ) {
+    if (!coverageFile) {
       fprintf( stderr, "Unable to open %s\n", file );
       return false;
     }
@@ -66,13 +68,13 @@
     //
     while ( 1 ) {
       status = fscanf( coverageFile, "%x : ", &baseAddress );
-      if ( status == EOF || status == 0 ) {
+      if (status == EOF || status == 0) {
         break;
       }
-      // fprintf( stderr, "%08x : ", baseAddress );
-      for ( i=0 ; i < 0x80 ; i+=4 ) {
+
+      for (i=0; i < 0x80; i+=4) {
         status = fscanf( coverageFile, "%d", &cover );
-	if ( status == EOF || status == 0 ) {
+	if (status == EOF || status == 0) {
           fprintf(
             stderr,
             "CoverageReaderTSIM: WARNING! Short line in %s at address 0x%08x\n",
@@ -81,16 +83,23 @@
           );
           break;
 	}
-        // fprintf( stderr, "%d ", cover );
-        if ( cover & 1 ) {
-          executableInformation->markWasExecuted( baseAddress + i );
-          executableInformation->markWasExecuted( baseAddress + i + 1 );
-          executableInformation->markWasExecuted( baseAddress + i + 2 );
-          executableInformation->markWasExecuted( baseAddress + i + 3 );
+
+        //
+        // Obtain the coverage map containing the address and
+        // mark the address as executed.
+        //
+        if (cover & 1) {
+          aCoverageMap = executableInformation->getCoverageMap(
+            baseAddress + i
+          );
+          if (aCoverageMap) {
+            aCoverageMap->setWasExecuted( baseAddress + i );
+            aCoverageMap->setWasExecuted( baseAddress + i + 1 );
+            aCoverageMap->setWasExecuted( baseAddress + i + 2 );
+            aCoverageMap->setWasExecuted( baseAddress + i + 3 );
+          }
         }
       }
-      // fprintf( stderr, "\n" );
-  
     }
 
     fclose( coverageFile );

diff -u gcc-testing/rtems-coverage/DesiredSymbols.h:1.2 gcc-testing/rtems-coverage/DesiredSymbols.h:1.3
--- gcc-testing/rtems-coverage/DesiredSymbols.h:1.2	Thu Apr 29 14:12:31 2010
+++ gcc-testing/rtems-coverage/DesiredSymbols.h	Fri May  7 13:53:58 2010
@@ -210,10 +210,10 @@
     );
 
     /*!
-     *  This method preprocess each symbols coverage map to marking nop
+     *  This method preprocesses each symbol's coverage map to mark nop
      *  and branch information.
      */
-    void Preprocess( void );
+    void preprocess( void );
 
   private:
 

diff -u gcc-testing/rtems-coverage/DesiredSymbols.cc:1.5 gcc-testing/rtems-coverage/DesiredSymbols.cc:1.6
--- gcc-testing/rtems-coverage/DesiredSymbols.cc:1.5	Thu Apr 29 14:12:31 2010
+++ gcc-testing/rtems-coverage/DesiredSymbols.cc	Fri May  7 13:53:58 2010
@@ -106,12 +106,12 @@
     #undef MAX_LINE_LENGTH
   }
 
-  void DesiredSymbols::Preprocess( void )
+  void DesiredSymbols::preprocess( void )
   {
-    CoverageMapBase*                                             theCoverageMap;
-    std::list<ObjdumpProcessor::objdumpLine_t>::reverse_iterator itr;
-    std::list<ObjdumpProcessor::objdumpLine_t>::iterator         fitr;
-    DesiredSymbols::symbolSet_t::iterator                        sitr;
+    ObjdumpProcessor::objdumpLines_t::iterator         fitr;
+    ObjdumpProcessor::objdumpLines_t::reverse_iterator itr;
+    DesiredSymbols::symbolSet_t::iterator              sitr;
+    CoverageMapBase*                                   theCoverageMap;
 
     // Look at each symbol.
     for (sitr = SymbolsToAnalyze->set.begin();
@@ -145,26 +145,28 @@
           break;
       }
 
-      for (fitr = sitr->second.instructions.begin(), fitr++;
+      // Mark any branch instructions.
+      for (fitr = sitr->second.instructions.begin();
            fitr != sitr->second.instructions.end();
            fitr++) {
         if (fitr->isBranch) {
-           theCoverageMap->setIsBranch( fitr->address -  sitr->second.baseAddress );
+           theCoverageMap->setIsBranch(
+             fitr->address - sitr->second.baseAddress
+           );
         }
       }
-
     }
   }
 
   void DesiredSymbols::computeUncovered( void )
   {
-    uint32_t                                             a, la, ha;
-    uint32_t                                             endAddress;
-    std::list<ObjdumpProcessor::objdumpLine_t>::reverse_iterator itr;
-    DesiredSymbols::symbolSet_t::iterator                sitr;
-    CoverageRanges*                                      theBranches;
-    CoverageMapBase*                                     theCoverageMap;
-    CoverageRanges*                                      theRanges;
+    uint32_t                                           a, la, ha;
+    uint32_t                                           endAddress;
+    ObjdumpProcessor::objdumpLines_t::reverse_iterator itr;
+    DesiredSymbols::symbolSet_t::iterator              sitr;
+    CoverageRanges*                                    theBranches;
+    CoverageMapBase*                                   theCoverageMap;
+    CoverageRanges*                                    theRanges;
 
     // Look at each symbol.
     for (sitr = SymbolsToAnalyze->set.begin();

diff -u gcc-testing/rtems-coverage/ExecutableInfo.h:1.1 gcc-testing/rtems-coverage/ExecutableInfo.h:1.2
--- gcc-testing/rtems-coverage/ExecutableInfo.h:1.1	Fri Mar  5 10:45:38 2010
+++ gcc-testing/rtems-coverage/ExecutableInfo.h	Fri May  7 13:53:58 2010
@@ -77,45 +77,18 @@
     void initialize( void );
 
     /*!
-     *  This method marks the specified address of the executable
-     *  as a branch instruction and indicates that it was NOT taken.
+     *  This method creates a coverage map for the specified symbol.
      *
-     *  @param[in] address indicates the address of the branch instruction
-     *             that was NOT taken
-     */
-    void markBranchNotTaken(
-      uint32_t address
-    );
-
-    /*!
-     *  This method marks the specified address of the executable
-     *  as a branch instruction and indicates that it was taken.
-     *
-     *  @param[in] address indicates the address of the branch instruction
-     *             that was taken
-     */
-    void markBranchTaken(
-      uint32_t address
-    );
-
-    /*!
-     *  This method marks the specified address of the executable
-     *  as the starting address for an instruction.
-     *
-     *  @param[in] address indicates the address of the start of an instruction
-     */
-    void markStartOfInstruction(
-      uint32_t address
-    );
-
-    /*!
-     *  This method marks the specified address of the executable
-     *  as an address that was executed.
+     *  @param[in] symbolName specifies the name of the symbol
+     *  @param[in] lowAddress specifies the low address of the coverage map
+     *  @param[in] highAddress specifies the high address of the coverage map
      *
-     *  @param[in] address indicates the address that was executed
+     *  @return Returns a pointer to the coverage map
      */
-    void markWasExecuted(
-      uint32_t address
+    CoverageMapBase* createCoverageMap (
+      const std::string& symbolName,
+      uint32_t           lowAddress,
+      uint32_t           highAddress
     );
 
     /*!

diff -u gcc-testing/rtems-coverage/ExecutableInfo.cc:1.2 gcc-testing/rtems-coverage/ExecutableInfo.cc:1.3
--- gcc-testing/rtems-coverage/ExecutableInfo.cc:1.2	Thu Mar 11 09:58:10 2010
+++ gcc-testing/rtems-coverage/ExecutableInfo.cc	Fri May  7 13:53:58 2010
@@ -68,136 +68,30 @@
 
   void ExecutableInfo::initialize( void )
   {
-    CoverageMapBase                       *aCoverageMap;
-    uint32_t                               highAddress;
-    SymbolTable::symbolInfo*               info;
-    DesiredSymbols::symbolSet_t::iterator  itr;
-    uint32_t                               lowAddress;
-    std::string                            symbol;
-
-    // Create and initialize symbol table.
-    if ( Verbose )
-      fprintf( stderr, "Reading symbol table of %s\n", fileName.c_str() );
+    // Create the symbol table.
     theSymbolTable = new SymbolTable();
-    theSymbolTable->load( fileName );
-
-    // Create a coverage map for each symbol to analyze.
-    for (itr = SymbolsToAnalyze->set.begin();
-         itr != SymbolsToAnalyze->set.end();
-         itr++) {
-
-      symbol = (*itr).first;
-      info = NULL;
-      info = theSymbolTable->getInfo( symbol );
-      if (!info) {
-        /* A little too verbose :-D */
-        #if 0
-        if (Verbose)
-          fprintf(
-            stderr,
-            "Unable to find symbol information for %s\n",
-            symbol.c_str()
-          );
-        #endif
-        continue;
-      }
-
-      lowAddress = info->startingAddress;
-      highAddress = lowAddress + info->length - 1;
-
-      aCoverageMap = NULL;
-      aCoverageMap = new CoverageMap( lowAddress, highAddress );
-      if (!aCoverageMap) {
-        fprintf(
-          stderr, "Unable to create coverage map for %s\n", symbol.c_str()
-        );
-        continue;
-      }
-
-      coverageMaps[ symbol ] = aCoverageMap;
-    }
-  }
-
-  void ExecutableInfo::markBranchNotTaken(
-    uint32_t address
-  )
-  {
-    CoverageMapBase* aCoverageMap = NULL;
-    uint32_t         beginning;
-
-    // Obtain the coverage map containing the specified address.
-    aCoverageMap = getCoverageMap( address );
-
-    // Ensure that coverage map exists.
-    if (aCoverageMap) {
-
-      // Determine the beginning address of the instruction that
-      // contains the specified address.  We only want to mark the
-      // beginning address of the instruction.
-      if (aCoverageMap->getBeginningOfInstruction( address, &beginning )) {
-        aCoverageMap->setIsBranch( beginning );
-        aCoverageMap->setWasNotTaken( beginning );
-        if (Verbose)
-          fprintf(
-            stderr, "Marking branch not taken at 0x%x\n", beginning
-          );
-      }
-    }
   }
 
-  void ExecutableInfo::markBranchTaken(
-    uint32_t address
+  CoverageMapBase* ExecutableInfo::createCoverageMap (
+    const std::string& symbolName,
+    uint32_t           lowAddress,
+    uint32_t           highAddress
   )
   {
-    CoverageMapBase* aCoverageMap = NULL;
-    uint32_t         beginning;
-
-    // Obtain the coverage map containing the specified address.
-    aCoverageMap = getCoverageMap( address );
+    CoverageMapBase* theMap = NULL;
 
-    // Ensure that coverage map exists.
-    if (aCoverageMap) {
+    theMap = new CoverageMap( lowAddress, highAddress );
 
-      // Determine the beginning address of the instruction that
-      // contains the specified address.  We only want to mark the
-      // beginning address of the instruction.
-      if (aCoverageMap->getBeginningOfInstruction( address, &beginning )) {
-        aCoverageMap->setIsBranch( beginning );
-        aCoverageMap->setWasTaken( beginning );
-        if (Verbose)
-          fprintf(
-            stderr, "Marking branch taken at 0x%x\n", beginning
-          );
-      }
-    }
-  }
-
-  void ExecutableInfo::markStartOfInstruction(
-    uint32_t address 
-  )
-  {
-    CoverageMapBase* aCoverageMap = NULL;
-
-    // Obtain the coverage map containing the specified address.
-    aCoverageMap = getCoverageMap( address );
-
-    // Ensure that coverage map exists.
-    if (aCoverageMap)
-      aCoverageMap->setIsStartOfInstruction( address );
-  }
-
-  void ExecutableInfo::markWasExecuted(
-    uint32_t address
-  )
-  {
-    CoverageMapBase* aCoverageMap = NULL;
+    if (!theMap)
+      fprintf(
+        stderr, "Unable to create coverage map for %s\n",
+        symbolName.c_str()
+      );
 
-    // Obtain the coverage map containing the specified address.
-    aCoverageMap = getCoverageMap( address );
+    else
+      coverageMaps[ symbolName ] = theMap;
 
-    // Ensure that coverage map exists.
-    if (aCoverageMap)
-      aCoverageMap->setWasExecuted( address );
+    return theMap;
   }
 
   void ExecutableInfo::mergeCoverage( void ) {

diff -u gcc-testing/rtems-coverage/ObjdumpProcessor.h:1.8 gcc-testing/rtems-coverage/ObjdumpProcessor.h:1.9
--- gcc-testing/rtems-coverage/ObjdumpProcessor.h:1.8	Thu Apr 29 14:12:31 2010
+++ gcc-testing/rtems-coverage/ObjdumpProcessor.h	Fri May  7 13:53:58 2010
@@ -72,6 +72,8 @@
 
     } objdumpLine_t;
 
+    typedef std::list<objdumpLine_t> objdumpLines_t;
+
     typedef std::list<uint32_t> objdumpFile_t;
 
     /*!
@@ -132,8 +134,7 @@
   private:
 
     objdumpFile_t       objdumpList;
-    Target::TargetBase  *target_m;
-
+    Target::TargetBase* target_m;
 
     /*!
      *  This method determines whether the specified line is a

diff -u gcc-testing/rtems-coverage/ObjdumpProcessor.cc:1.28 gcc-testing/rtems-coverage/ObjdumpProcessor.cc:1.29
--- gcc-testing/rtems-coverage/ObjdumpProcessor.cc:1.28	Thu Apr 29 14:12:31 2010
+++ gcc-testing/rtems-coverage/ObjdumpProcessor.cc	Fri May  7 13:53:58 2010
@@ -19,11 +19,61 @@
 
 #include "ObjdumpProcessor.h"
 #include "app_common.h"
+#include "CoverageMap.h"
 #include "ExecutableInfo.h"
+#include "SymbolTable.h"
 #include "TargetFactory.h"
 
 namespace Coverage {
 
+  void finalizeSymbol(
+    ExecutableInfo* const            executableInfo,
+    std::string&                     symbolName,
+    uint32_t                         lowAddress,
+    uint32_t                         highAddress,
+    ObjdumpProcessor::objdumpLines_t instructions,
+    SymbolInformation*               symbolInfo
+  ) {
+
+    CoverageMapBase*                           aCoverageMap = NULL;
+    ObjdumpProcessor::objdumpLines_t::iterator itr;
+    SymbolTable*                               theSymbolTable;
+
+    // If there are NOT already saved instructions, save them.
+    if (symbolInfo->instructions.empty()) {
+      symbolInfo->sourceFile = executableInfo->getFileName();
+      symbolInfo->baseAddress = lowAddress;
+      symbolInfo->instructions = instructions;
+    }
+
+    // Add the symbol to this executable's symbol table.
+    theSymbolTable = executableInfo->getSymbolTable();
+    theSymbolTable->addSymbol(
+      symbolName, lowAddress, highAddress - lowAddress + 1
+    );
+
+    // Create a coverage map for the symbol.
+    aCoverageMap = executableInfo->createCoverageMap(
+      symbolName, lowAddress, highAddress
+    );
+
+    if (aCoverageMap) {
+
+      // Mark the start of each instruction in the coverage map.
+      for (itr = instructions.begin();
+           itr != instructions.end();
+           itr++ ) {
+
+        aCoverageMap->setIsStartOfInstruction( itr->address );
+      }
+
+      // Create a unified coverage map for the symbol.
+      SymbolsToAnalyze->createCoverageMap(
+        symbolName, highAddress - lowAddress + 1
+      );
+    }
+  }
+
   ObjdumpProcessor::ObjdumpProcessor()
   {
     target_m = Target::TargetFactory(Tools->getTarget());
@@ -90,7 +140,7 @@
     if ( FileIsNewer( exeFileName.c_str(), dumpFile )) {
       sprintf(
         buffer,
-        "%s -da --source %s | sed -e \'s/ *$//\' >%s",
+        "%s -da --section=.text --source %s | sed -e \'s/ *$//\' >%s",
         Tools->getObjdump(),
          exeFileName.c_str(),
         dumpFile
@@ -100,7 +150,7 @@
       if (status) {
         fprintf(
           stderr,
-          "ERROR: ObjdumpProcessor::load - command (%s) failed with %d\n",
+          "ERROR: ObjdumpProcessor::getFile - command (%s) failed with %d\n",
           buffer,
           status
         );
@@ -113,7 +163,7 @@
     if (!objdumpFile) {
       fprintf(
         stderr,
-        "ERROR: ObjdumpProcessor::load - unable to open %s\n",
+        "ERROR: ObjdumpProcessor::getFile - unable to open %s\n",
         dumpFile
       );
       exit(-1);
@@ -175,26 +225,26 @@
     }
   }
 
-
   void ObjdumpProcessor::load(
     ExecutableInfo* const executableInformation
   )
   {
-    uint32_t           baseAddress;
+    uint32_t           address;
+    uint32_t           baseAddress = 0;
     char               buffer[ 512 ];
     char*              cStatus;
-    uint32_t           endAddress = 0xffffffff;
+    std::string        currentSymbol = "";
     uint32_t           instructionAddress;
     int                items;
     objdumpLine_t      lineInfo;
     FILE*              objdumpFile;
     bool               processSymbol = false;
-    bool               saveInstructionDump = false;
     char               symbol[ 100 ];
-    SymbolInformation* symbolInfo = NULL;
+    SymbolInformation* symbolInformation = NULL;
     char               terminator;
+    objdumpLines_t     theInstructions;
 
-
+    // Obtain the objdump file.
     objdumpFile = getFile( executableInformation->getFileName() );
 
     // Process all lines from the objdump file.
@@ -203,8 +253,29 @@
       // Get the line.
       cStatus = fgets( buffer, 512, objdumpFile );
       if (cStatus == NULL) {
+
+        // If we are currently processing a symbol, finalize it.
+        if ((processSymbol) && (symbolInformation)) {
+          finalizeSymbol(
+            executableInformation,
+            currentSymbol,
+            baseAddress,
+            address,  // XXX fix to determine corrent end address
+            theInstructions,
+            symbolInformation
+          );
+          fprintf(
+            stderr,
+            "WARNING: ObjdumpProcessor::load - analysis of symbol %s \n"
+            "         may be incorrect.  It was the last symbol in %s\n"
+            "         and the length of its last instruction is assumed to be one.\n",
+            currentSymbol.c_str(),
+            executableInformation->getFileName().c_str()
+          );
+        }
         break;
       }
+
       buffer[ strlen(buffer) - 1] = '\0';
 
       lineInfo.line          = buffer;
@@ -215,40 +286,42 @@
       lineInfo.isBranch      = false;
 
       // Look for the start of a symbol's objdump and extract
-      // address and symbol.
+      // address and symbol (i.e. address <symbolname>:).
       items = sscanf(
         buffer,
         "%x <%[^>]>%c",
-        &baseAddress, symbol, &terminator
+        &address, symbol, &terminator
       );
 
-      // If all items found ...
+      // If all items found, we are at the beginning of a symbol's objdump.
       if ((items == 3) && (terminator == ':')) {
 
-        // we are at the beginning of a symbol's objdump and
-        // must end any processing of the previous symbol.
-        processSymbol = false;
-        saveInstructionDump = false;
+        // If we are currently processing a symbol, finalize it.
+        if ((processSymbol) && (symbolInformation)) {
+          finalizeSymbol(
+            executableInformation,
+            currentSymbol,
+            baseAddress,
+            address - 1,
+            theInstructions,
+            symbolInformation
+          );
+        }
 
-        // See if the symbol is one that we care about.
-        symbolInfo = SymbolsToAnalyze->find( symbol );
+        // Start processing of a new symbol.
+        baseAddress = 0;
+        currentSymbol = "";
+        processSymbol = false;
+        theInstructions.clear();
 
-        // If it is, ...
-        if (symbolInfo) {
+        // See if the new symbol is one that we care about.
+        symbolInformation = SymbolsToAnalyze->find( symbol );
 
-          // indicate that we are processing a symbols objdump and
-          // compute the ending address for termination.
+        if (symbolInformation) {
+          baseAddress = address;
+          currentSymbol = symbol;
           processSymbol = true;
-          endAddress = baseAddress +
-           executableInformation->getSymbolTable()->getLength( symbol ) - 1;
-
-          // If there are NOT already instructions available, indicate that they
-          // are to be saved.
-          if (symbolInfo->instructions.empty()) {
-            saveInstructionDump = true;
-            symbolInfo->sourceFile = executableInformation->getFileName();
-            symbolInfo->baseAddress = baseAddress;
-          }
+          theInstructions.push_back( lineInfo );
         }
       }
 
@@ -264,36 +337,16 @@
         // If it looks like an instruction ...
         if ((items == 2) && (terminator == ':')) {
 
-          // and we are NOT beyond the end of the symbol's objdump,
-          if (instructionAddress <= endAddress) {
-
-            // update the line's information and ...
-            lineInfo.address       = instructionAddress;
-            lineInfo.isInstruction = true;
-            lineInfo.isNop         = isNop( buffer, lineInfo.nopSize );
-            lineInfo.isBranch      = isBranchLine( buffer );
-
-            // mark the address as the beginning of an instruction.
-            executableInformation->markStartOfInstruction( instructionAddress );
-          }
-
-          // If we are beyond the end of the symbol's objdump,
-          // it's time to end processing of this symbol.
-          else {
-            processSymbol = false;
-            saveInstructionDump = false;
-          }
+          // update the line's information, save it and ...
+          lineInfo.address       = instructionAddress;
+          lineInfo.isInstruction = true;
+          lineInfo.isNop         = isNop( buffer, lineInfo.nopSize );
+          lineInfo.isBranch      = isBranchLine( buffer );
         }
-      }
-
-      // If we are processing a symbol, ...
-      if (processSymbol && saveInstructionDump) {
-
-        // add line to the current symbol's information and ...
-        symbolInfo->instructions.push_back( lineInfo );
 
+        // Always save the line.
+        theInstructions.push_back( lineInfo );
       }
     }
   }
-
 }

diff -u gcc-testing/rtems-coverage/SymbolTable.h:1.2 gcc-testing/rtems-coverage/SymbolTable.h:1.3
--- gcc-testing/rtems-coverage/SymbolTable.h:1.2	Tue Apr 13 14:23:22 2010
+++ gcc-testing/rtems-coverage/SymbolTable.h	Fri May  7 13:53:58 2010
@@ -46,6 +46,21 @@
     virtual ~SymbolTable();
 
     /*!
+     *  This method adds the specified symbol information to the
+     *  symbol table.
+     *
+     *  @param[in] symbol specifies the symbol to add
+     *  @param[in] start specifies the symbol's start address
+     *  @param[in] length specifies the symbol's length
+     *
+     */
+    void addSymbol(
+      const std::string& symbol,
+      const uint32_t     start,
+      const uint32_t     length
+    );
+
+    /*!
      *  This method returns the symbol information for the specified symbol.
      *
      *  @param[in] symbol specifies the symbol for which to obtain information
@@ -78,33 +93,20 @@
       uint32_t address
     );
 
-    /*!
-     *  This method loads the symbol table from the specified executable.
-     *
-     *  @param[in] executableName specifies the file name of the executable
-     *
-     *  @return Returns TRUE if the symbol table was loaded and
-     *          FALSE otherwise.
-     */
-    bool load(
-      const std::string& executableName
-    );
-
   private:
 
     /*!
-     *  This map associates each address from an executable
-     *  with the symbol that contains the address.
+     *  This map associates the end address of a symbol's address
+     *  range with the symbol's address range definition.
      */
     typedef struct {
-       uint32_t min;
-       uint32_t max;
+       uint32_t    low;
+       uint32_t    high;
        std::string symbol;
     } symbol_entry_t;
     typedef std::map< uint32_t, symbol_entry_t > contents_t;
     contents_t contents;
 
-
     /*!
      *  This map associates each symbol from an executable with
      *  the symbol's information.

diff -u gcc-testing/rtems-coverage/SymbolTable.cc:1.5 gcc-testing/rtems-coverage/SymbolTable.cc:1.6
--- gcc-testing/rtems-coverage/SymbolTable.cc:1.5	Sat Apr 24 10:34:00 2010
+++ gcc-testing/rtems-coverage/SymbolTable.cc	Fri May  7 13:53:58 2010
@@ -27,6 +27,29 @@
   {
   }
 
+  void SymbolTable::addSymbol(
+    const std::string& symbol,
+    const uint32_t     start,
+    const uint32_t     length
+  )
+  {
+    uint32_t       end = 0;
+    symbol_entry_t entry;
+    symbolInfo     symbolData;
+
+    // Add an entry to the address map.
+    end = start + length - 1;
+    entry.low = start;
+    entry.high = end;
+    entry.symbol = symbol;
+    contents[ end ] = entry;
+
+    // Add an entry to the symbol information map.
+    symbolData.startingAddress = start;
+    symbolData.length = length;
+    info[ symbol ] = symbolData;
+  }
+
   SymbolTable::symbolInfo* SymbolTable::getInfo(
     const std::string& symbol
   )
@@ -55,116 +78,22 @@
     uint32_t address
   )
   {
-    contents_t::iterator it = contents.end();
+    contents_t::iterator it;
 
+    // Ensure that the symbol table is not empty.
     if ( contents.size() == 0 )
       return "";
 
-    it--;
-    if (address > ((*it).first)) {
-      return "";
-    }
-
+    // Find the first entry whose end address is greater
+    // than the specified address.
     it = contents.lower_bound( address );
-    if (((*it).second).min <= address ) {
-      return ((*it).second).symbol;
-    } else {
-      return "";
-    }
-  }
 
-  bool SymbolTable::load(
-    const std::string& executableName
-  )
-  {
-    char        buffer[512];
-    char       *cStatus;
-    uint32_t    end = 0;
-    int         items;
-    uint32_t    length = 0;
-    FILE       *nmFile = NULL;
-    uint32_t    start = 0;
-    char        symbol[ 100 ];
-    symbolInfo  symbolData;
-    char        nmName[128];
-
-
-    sprintf(
-      nmName,
-      "%s.nm",
-      executableName.c_str()
-    );
-
-    // Generate the nm output
-    if (FileIsNewer(executableName.c_str(), nmName )){
-
-      sprintf( buffer, "%s -n -f sysv %s | sed -e \'s/ *$//\' >%s",
-        Tools->getNm(), executableName.c_str(), nmName );
-
-      if ( system( buffer ) ) {
-        fprintf(
-          stderr,
-          "ERROR: SymbolTable::load - command (%s) failed\n",
-          buffer
-        );
-        exit( -1 );
-      }
-    }
-
-    // Read the file and process each desired symbol
-    nmFile = fopen( nmName, "r" );
-    if ( !nmFile ) {
-      fprintf(
-        stderr,
-        "ERROR: SymbolTable::load - unable to open %s\n",
-        nmName
-      );
-      exit(-1);
-    }
-
-    // Process all lines from the nm file.
-    while ( 1 ) {
-
-      // Get the line.
-      cStatus = fgets( buffer, 512, nmFile );
-      if ( cStatus == NULL ) {
-        break;
-      }
-      buffer[ strlen(buffer) - 1] = '\0';
-
-      // Extract the symbol, start address and length.
-      items = sscanf(
-        buffer,
-        "%[^| ] |%x|%*[^|]| FUNC|%x",
-        symbol, &start, &length
-      );
-
-      // If all items found ...
-      if (items == 3) {
-
-        // and it is a desired symbol, ...
-        if (SymbolsToAnalyze->isDesired( symbol )) {
-
-          // add the symbol information to the symbol table.
-          end = start + length - 1;
-          symbol_entry_t entry = { start, end, symbol };
-          contents[end] = entry;
-
-          symbolData.startingAddress = start;
-          symbolData.length = length;
-          info[ symbol ] = symbolData;
-
-          // Also create a coverage map for the results of the analysis.
-          SymbolsToAnalyze->createCoverageMap( symbol, length );
-        }
-      }
-    }
-
-    fclose( nmFile );
-
-    // Remove temporary file
-    // (void) system( "rm -f nm.tmp" );
-    return true;
+    // If an entry was found and its low address is less than or
+    // equal to the specified address, then return the symbol.
+    if ((it != contents.end()) && ((it->second).low <= address ))
+      return (it->second).symbol;
+
+    return "";
   }
 
 }

diff -u gcc-testing/rtems-coverage/covoar.cc:1.13 gcc-testing/rtems-coverage/covoar.cc:1.14
--- gcc-testing/rtems-coverage/covoar.cc:1.13	Thu May  6 12:54:13 2010
+++ gcc-testing/rtems-coverage/covoar.cc	Fri May  7 13:53:58 2010
@@ -342,10 +342,10 @@
       eitr++;
   }
 
-  // Do necessary preprocessing uncovered ranges and branches
+  // Do necessary preprocessing of uncovered ranges and branches
   if (Verbose)
-     fprintf( stderr, "Preprocess uncovered ranges and branches\n" );
-  SymbolsToAnalyze->Preprocess();
+    fprintf( stderr, "Preprocess uncovered ranges and branches\n" );
+  SymbolsToAnalyze->preprocess();
 
   // Determine the uncovered ranges and branches.
   if (Verbose)


 *joel*:
2010-05-07	Joel Sherrill <joel.sherrill at oarcorp.com>

	* ReportsBase.cc: Fix name of coverage report.

M  1.204  rtems-coverage/ChangeLog
M    1.3  rtems-coverage/ReportsBase.cc

diff -u gcc-testing/rtems-coverage/ChangeLog:1.203 gcc-testing/rtems-coverage/ChangeLog:1.204
--- gcc-testing/rtems-coverage/ChangeLog:1.203	Fri May  7 13:01:50 2010
+++ gcc-testing/rtems-coverage/ChangeLog	Fri May  7 13:28:31 2010
@@ -1,3 +1,7 @@
+2010-05-07	Joel Sherrill <joel.sherrill at oarcorp.com>
+
+	* ReportsBase.cc: Fix name of coverage report.
+
 2010-05-07	Jennifer Averett <Jennifer.Averett>
 
 	* Makefile, ReportsBase.cc, ReportsBase.h, ReportsText.cc,

diff -u gcc-testing/rtems-coverage/ReportsBase.cc:1.2 gcc-testing/rtems-coverage/ReportsBase.cc:1.3
--- gcc-testing/rtems-coverage/ReportsBase.cc:1.2	Fri May  7 13:01:51 2010
+++ gcc-testing/rtems-coverage/ReportsBase.cc	Fri May  7 13:28:31 2010
@@ -344,7 +344,7 @@
     reportName = "branch" + reports->ReportExtension();
     reports->WriteBranchReport(reportName.c_str() );
 
-    reportName = "coverage" + reports->ReportExtension();
+    reportName = "uncovered" + reports->ReportExtension();
     reports->WriteCoverageReport(reportName.c_str() );
 
     reportName = "sizes" + reports->ReportExtension();


 *joel*:
2010-05-07	Joel Sherrill <joel.sherrill at oarcorp.com>

	* do_coverage: Pick up style sheet for reports.

M  1.205  rtems-coverage/ChangeLog
M   1.51  rtems-coverage/do_coverage

diff -u gcc-testing/rtems-coverage/ChangeLog:1.204 gcc-testing/rtems-coverage/ChangeLog:1.205
--- gcc-testing/rtems-coverage/ChangeLog:1.204	Fri May  7 13:28:31 2010
+++ gcc-testing/rtems-coverage/ChangeLog	Fri May  7 13:29:44 2010
@@ -1,5 +1,9 @@
 2010-05-07	Joel Sherrill <joel.sherrill at oarcorp.com>
 
+	* do_coverage: Pick up style sheet for reports.
+
+2010-05-07	Joel Sherrill <joel.sherrill at oarcorp.com>
+
 	* ReportsBase.cc: Fix name of coverage report.
 
 2010-05-07	Jennifer Averett <Jennifer.Averett>

diff -u gcc-testing/rtems-coverage/do_coverage:1.50 gcc-testing/rtems-coverage/do_coverage:1.51
--- gcc-testing/rtems-coverage/do_coverage:1.50	Fri Apr 23 15:38:20 2010
+++ gcc-testing/rtems-coverage/do_coverage	Fri May  7 13:29:44 2010
@@ -355,7 +355,7 @@
   mkdir ${results_dir}
   cp annotated.txt branch.txt configuration.txt sizes.txt summary.txt \
      uncovered.txt row.html ${results_dir}
-  cp ${COVBASE}/Explanations.txt.NotFound ${results_dir}
+  cp ${COVBASE}/Explanations.txt.NotFound ${COVBASE}/covoar.css ${results_dir}
   echo "Results saved in ${results_dir}.tar.bz2"
   tar cjf ${results_dir}.tar.bz2 ${results_dir}
   rm -rf ${results_dir}



--

Generated by Deluxe Loginfo [http://www.codewiz.org/projects/index.html#loginfo] 2.122 by Bernardo Innocenti <bernie at develer.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/vc/attachments/20100507/7bbc6fee/attachment-0001.html>


More information about the vc mailing list