<div dir="ltr">Hello,<div><br></div><div>I'm getting this build failure after applying this patch</div><div><br></div><div>---</div><div><div>Build failed</div><div> -> task in 'ccovoar' failed with exit status 1: </div><div><span style="white-space:pre">        </span>{task 140086064254560: cxx app_common.cc -> app_common.cc.1.o}</div><div>['/usr/bin/g++', '-std=c++11', '-O2', '-g', '-Itester/covoar', '-I../tester/covoar', '-Irtemstoolkit', '-I../rtemstoolkit', '-Irtemstoolkit/elftoolchain/libelf', '-I../rtemstoolkit/elftoolchain/libelf', '-Irtemstoolkit/elftoolchain/common', '-I../rtemstoolkit/elftoolchain/common', '-Irtemstoolkit/libiberty', '-I../rtemstoolkit/libiberty', '../tester/covoar/app_common.cc', '-c', '-o/home/lunatic/development/rtems/test/rtems-tools/build/tester/covoar/app_common.cc.1.o']</div></div><div><br></div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr">-- vijay</div></div></div></div></div>
<br><div class="gmail_quote">On 5 May 2018 at 14:10, Chris Johns <span dir="ltr"><<a href="mailto:chrisj@rtems.org" target="_blank">chrisj@rtems.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">---<br>
 tester/covoar/DesiredSymbols.<wbr>cc | 122 ++----------------------------<wbr>----------<br>
 tester/covoar/ExecutableInfo.<wbr>cc |  80 +++++++++++++++++---------<br>
 tester/covoar/ExecutableInfo.h  |  41 +++++++++++---<br>
 tester/covoar/covoar.cc         |   2 +-<br>
 tester/covoar/wscript           |   2 +-<br>
 5 files changed, 94 insertions(+), 153 deletions(-)<br>
<br>
diff --git a/tester/covoar/<wbr>DesiredSymbols.cc b/tester/covoar/<wbr>DesiredSymbols.cc<br>
index 9957b28..79ee78d 100644<br>
--- a/tester/covoar/<wbr>DesiredSymbols.cc<br>
+++ b/tester/covoar/<wbr>DesiredSymbols.cc<br>
@@ -449,123 +449,13 @@ namespace Coverage {<br>
<br>
   )<br>
   {<br>
-    char*                              base;<br>
-    char*                              cStatus;<br>
-    char                               command[512];<br>
-    std::string                        fileName;<br>
-    CoverageRanges::ranges_t::<wbr>iterator ritr;<br>
-    char                               rpath[PATH_MAX];<br>
-    FILE*                              tmpfile;<br>
-<br>
-    // Open a temporary file for the uncovered ranges.<br>
-    tmpfile = fopen( "ranges1.tmp", "w" );<br>
-    if ( !tmpfile ) {<br>
-      fprintf(<br>
-        stderr,<br>
-        "ERROR: DesiredSymbols::<wbr>determineSourceLines - "<br>
-        "unable to open %s\n",<br>
-        "ranges1.tmp"<br>
-      );<br>
-      exit(-1);<br>
-    }<br>
-<br>
-    // Write the range addresses to the temporary file.<br>
-    for (ritr =  theRanges->set.begin();<br>
-         ritr != theRanges->set.end();<br>
-         ritr++ ) {<br>
-      fprintf(<br>
-        tmpfile,<br>
-        "0x%08x\n0x%08x\n",<br>
-        ritr->lowAddress - theExecutable->getLoadAddress(<wbr>),<br>
-        ritr->highAddress - theExecutable->getLoadAddress(<wbr>)<br>
-      );<br>
-    }<br>
-<br>
-    fclose( tmpfile );<br>
-<br>
-    // Invoke addr2line to generate the source lines for each address.<br>
-    if (theExecutable-><wbr>hasDynamicLibrary())<br>
-      fileName = theExecutable->getLibraryName(<wbr>);<br>
-    else<br>
-      fileName = theExecutable->getFileName();<br>
-<br>
-    sprintf(<br>
-      command,<br>
-      "%s -Ce %s <%s | dos2unix >%s",<br>
-      TargetInfo->getAddr2line(),<br>
-      fileName.c_str(),<br>
-      "ranges1.tmp",<br>
-      "ranges2.tmp"<br>
-    );<br>
-<br>
-    if (system( command )) {<br>
-      fprintf(<br>
-        stderr,<br>
-        "ERROR: DesiredSymbols::<wbr>determineSourceLines - "<br>
-        "command (%s) failed\n",<br>
-        command<br>
-      );<br>
-      exit( -1 );<br>
-    }<br>
-<br>
-    // Open the addr2line output file.<br>
-    tmpfile = fopen( "ranges2.tmp", "r" );<br>
-    if ( !tmpfile ) {<br>
-      fprintf(<br>
-        stderr,<br>
-        "ERROR: DesiredSymbols::<wbr>determineSourceLines - "<br>
-        "unable to open %s\n",<br>
-        "ranges2.tmp"<br>
-      );<br>
-      exit(-1);<br>
+    for (auto& r : theRanges->set) {<br>
+      std::string location;<br>
+      theExecutable-><wbr>getSourceAndLine(r.lowAddress, location);<br>
+      r.lowSourceLine = rld::path::basename (location);<br>
+      theExecutable-><wbr>getSourceAndLine(r.<wbr>highAddress, location);<br>
+      r.highSourceLine = rld::path::basename (location);<br>
     }<br>
-<br>
-    // Process the addr2line output.<br>
-    for (ritr =  theRanges->set.begin();<br>
-         ritr != theRanges->set.end();<br>
-         ritr++ ) {<br>
-<br>
-      cStatus = fgets( inputBuffer, MAX_LINE_LENGTH, tmpfile );<br>
-      if ( cStatus == NULL ) {<br>
-        fprintf(<br>
-          stderr,<br>
-          "ERROR: DesiredSymbols::<wbr>determineSourceLines - "<br>
-          "Out of sync in addr2line output\n"<br>
-        );<br>
-        exit( -1 );<br>
-      }<br>
-      inputBuffer[ strlen(inputBuffer) - 1] = '\0';<br>
-<br>
-      // Use only the base filename without directory path.<br>
-#ifdef _WIN32<br>
-      #define realpath(N,R) _fullpath((R),(N),_MAX_PATH)<br>
-#endif<br>
-      realpath( inputBuffer, rpath );<br>
-      base = basename( rpath );<br>
-<br>
-      ritr->lowSourceLine = std::string( base );<br>
-<br>
-      cStatus = fgets( inputBuffer, MAX_LINE_LENGTH, tmpfile );<br>
-      if ( cStatus == NULL ) {<br>
-        fprintf(<br>
-          stderr,<br>
-          "ERROR: DesiredSymbols::<wbr>determineSourceLines - "<br>
-          "Out of sync in addr2line output\n"<br>
-        );<br>
-        exit( -1 );<br>
-      }<br>
-      inputBuffer[ strlen(inputBuffer) - 1] = '\0';<br>
-<br>
-      // Use only the base filename without directory path.<br>
-      realpath( inputBuffer, rpath );<br>
-      base = basename( rpath );<br>
-<br>
-      ritr->highSourceLine = std::string( base );<br>
-    }<br>
-<br>
-    fclose( tmpfile );<br>
-    unlink( "ranges1.tmp" );<br>
-    unlink( "ranges2.tmp" );<br>
   }<br>
<br>
   SymbolInformation* DesiredSymbols::find(<br>
diff --git a/tester/covoar/<wbr>ExecutableInfo.cc b/tester/covoar/<wbr>ExecutableInfo.cc<br>
index c41d931..1755e93 100644<br>
--- a/tester/covoar/<wbr>ExecutableInfo.cc<br>
+++ b/tester/covoar/<wbr>ExecutableInfo.cc<br>
@@ -7,6 +7,8 @@<br>
<br>
 #include <stdio.h><br>
<br>
+#include <rld.h><br>
+<br>
 #include "ExecutableInfo.h"<br>
 #include "app_common.h"<br>
 #include "CoverageMap.h"<br>
@@ -18,24 +20,36 @@ namespace Coverage {<br>
   ExecutableInfo::<wbr>ExecutableInfo(<br>
     const char* const theExecutableName,<br>
     const char* const theLibraryName<br>
-  )<br>
+    ) : executable(theExecutableName),<br>
+        loadAddress(0)<br>
   {<br>
-    executableName = theExecutableName;<br>
-    loadAddress = 0;<br>
-    libraryName = "";<br>
     if (theLibraryName)<br>
       libraryName = theLibraryName;<br>
-    theSymbolTable = new SymbolTable();<br>
+    try {<br>
+      executable.open();<br>
+      executable.begin();<br>
+      executable.load_symbols(<wbr>symbols);<br>
+      debug.begin(executable.elf());<br>
+      debug.load_debug();<br>
+    } catch (rld::error re) {<br>
+      std::cerr << "error: "<br>
+                << re.where << ": " << re.what<br>
+                << std::endl;<br>
+      exit(2);<br>
+    } catch (...) {<br>
+      exit(2);<br>
+    }<br>
   }<br>
<br>
   ExecutableInfo::~<wbr>ExecutableInfo()<br>
   {<br>
-    if (theSymbolTable)<br>
-      delete theSymbolTable;<br>
+    debug.end();<br>
+    executable.end();<br>
+    executable.close();<br>
   }<br>
<br>
   void ExecutableInfo::<wbr>dumpCoverageMaps( void ) {<br>
-    ExecutableInfo::coverageMaps_<wbr>t::iterator  itr;<br>
+    ExecutableInfo::CoverageMaps::<wbr>iterator  itr;<br>
<br>
     for (itr = coverageMaps.begin(); itr != coverageMaps.end(); itr++) {<br>
       fprintf( stderr, "Coverage Map for %s\n", ((*itr).first).c_str() );;<br>
@@ -44,21 +58,22 @@ namespace Coverage {<br>
   }<br>
<br>
   void ExecutableInfo::<wbr>dumpExecutableInfo( void ){<br>
-    fprintf( stdout, "\n== Executable info ==\n");<br>
-    fprintf( stdout, "executableName = %s\n", executableName.c_str());<br>
-    fprintf( stdout, "libraryName = %s\n", libraryName.c_str());<br>
-    fprintf( stdout, "loadAddress = %u\n", loadAddress);<br>
-    theSymbolTable-><wbr>dumpSymbolTable();<br>
+    std::cout << std::endl<br>
+              << "== Executable info ==" << std::endl<br>
+              << "executable = " << getFileName () << std::endl<br>
+              << "library = " << libraryName << std::endl<br>
+              << "loadAddress = " << loadAddress << std::endl;<br>
+    theSymbolTable.<wbr>dumpSymbolTable();<br>
   }<br>
<br>
   CoverageMapBase* ExecutableInfo::getCoverageMap ( uint32_t address )<br>
   {<br>
-    CoverageMapBase*         aCoverageMap = NULL;<br>
-    coverageMaps_t::iterator it;<br>
-    std::string              itsSymbol;<br>
+    CoverageMapBase*       aCoverageMap = NULL;<br>
+    CoverageMaps::iterator it;<br>
+    std::string            itsSymbol;<br>
<br>
     // Obtain the coverage map containing the specified address.<br>
-    itsSymbol = theSymbolTable->getSymbol( address );<br>
+    itsSymbol = theSymbolTable.getSymbol( address );<br>
     if (itsSymbol != "") {<br>
       it = coverageMaps.find( itsSymbol );<br>
       aCoverageMap = (*it).second;<br>
@@ -67,12 +82,12 @@ namespace Coverage {<br>
     return aCoverageMap;<br>
   }<br>
<br>
-  const std::string& ExecutableInfo::getFileName ( void ) const<br>
+  const std::string ExecutableInfo::getFileName ( void ) const<br>
   {<br>
-    return executableName;<br>
+    return <a href="http://executable.name" rel="noreferrer" target="_blank">executable.name</a>().full();<br>
   }<br>
<br>
-  const std::string& ExecutableInfo::<wbr>getLibraryName( void ) const<br>
+  const std::string ExecutableInfo::<wbr>getLibraryName( void ) const<br>
   {<br>
     return libraryName;<br>
   }<br>
@@ -83,9 +98,9 @@ namespace Coverage {<br>
   }<br>
<br>
<br>
-  SymbolTable* ExecutableInfo::getSymbolTable ( void ) const<br>
+  SymbolTable* ExecutableInfo::getSymbolTable ( void )<br>
   {<br>
-    return theSymbolTable;<br>
+    return &theSymbolTable;<br>
   }<br>
<br>
   CoverageMapBase* ExecutableInfo::<wbr>createCoverageMap (<br>
@@ -95,8 +110,8 @@ namespace Coverage {<br>
     uint32_t           highAddress<br>
   )<br>
   {<br>
-    CoverageMapBase                          *theMap;<br>
-    ExecutableInfo::coverageMaps_<wbr>t::iterator  itr;<br>
+    CoverageMapBase                        *theMap;<br>
+    ExecutableInfo::CoverageMaps::<wbr>iterator  itr;<br>
<br>
     itr = coverageMaps.find( symbolName );<br>
     if ( itr == coverageMaps.end() ) {<br>
@@ -109,13 +124,26 @@ namespace Coverage {<br>
     return theMap;<br>
   }<br>
<br>
+  void ExecutableInfo::<wbr>getSourceAndLine(<br>
+    const unsigned int address,<br>
+    std::string&       line<br>
+  )<br>
+  {<br>
+    std::string file;<br>
+    int         lno;<br>
+    debug.get_source (address, file, lno);<br>
+    std::ostringstream ss;<br>
+    ss << file << ':' << lno;<br>
+    line = ss.str ();<br>
+  }<br>
+<br>
   bool ExecutableInfo::<wbr>hasDynamicLibrary( void )<br>
   {<br>
-     return (libraryName != "");<br>
+    return !libraryName.empty();<br>
   }<br>
<br>
   void ExecutableInfo::mergeCoverage( void ) {<br>
-    ExecutableInfo::coverageMaps_<wbr>t::iterator  itr;<br>
+    ExecutableInfo::CoverageMaps::<wbr>iterator  itr;<br>
<br>
     for (itr = coverageMaps.begin(); itr != coverageMaps.end(); itr++) {<br>
       SymbolsToAnalyze-><wbr>mergeCoverageMap( (*itr).first, (*itr).second );<br>
diff --git a/tester/covoar/<wbr>ExecutableInfo.h b/tester/covoar/<wbr>ExecutableInfo.h<br>
index 20ea9bf..9106db3 100644<br>
--- a/tester/covoar/<wbr>ExecutableInfo.h<br>
+++ b/tester/covoar/<wbr>ExecutableInfo.h<br>
@@ -11,6 +11,10 @@<br>
 #include <stdint.h><br>
 #include <string><br>
<br>
+#include <rld-dwarf.h><br>
+#include <rld-files.h><br>
+#include <rld-symbols.h><br>
+<br>
 #include "CoverageMapBase.h"<br>
 #include "SymbolTable.h"<br>
<br>
@@ -67,14 +71,14 @@ namespace Coverage {<br>
      *<br>
      *  @return Returns the executable's file name<br>
      */<br>
-    const std::string& getFileName( void ) const;<br>
+    const std::string getFileName( void ) const;<br>
<br>
     /*!<br>
      *  This method returns the library name associated with the executable.<br>
      *<br>
      *  @return Returns the executable's library name<br>
      */<br>
-    const std::string& getLibraryName( void ) const;<br>
+    const std::string getLibraryName( void ) const;<br>
<br>
     /*!<br>
      *  This method returns the load address of the dynamic library<br>
@@ -88,7 +92,7 @@ namespace Coverage {<br>
      *<br>
      *  @return Returns a pointer to the symbol table.<br>
      */<br>
-    SymbolTable* getSymbolTable( void ) const;<br>
+    SymbolTable* getSymbolTable( void );<br>
<br>
     /*!<br>
      *  This method creates a coverage map for the specified symbol.<br>
@@ -107,6 +111,15 @@ namespace Coverage {<br>
       uint32_t           highAddress<br>
     );<br>
<br>
+    /*!<br>
+     *  This method gets the source location, the file and line number given an<br>
+     *  address.<br>
+     */<br>
+    void getSourceAndLine(<br>
+      const unsigned int address,<br>
+      std::string&       location<br>
+    );<br>
+<br>
     /*!<br>
      *  This method indicates whether a dynamic library has been<br>
      *  associated with the executable.<br>
@@ -132,15 +145,25 @@ namespace Coverage {<br>
   private:<br>
<br>
     /*!<br>
-     *  This map associates a symbol with its coverage map.<br>
+     *  The ELF executable.<br>
      */<br>
-    typedef std::map<std::string, CoverageMapBase *> coverageMaps_t;<br>
-    coverageMaps_t coverageMaps;<br>
+    rld::files::object executable;<br>
<br>
     /*!<br>
-     *  This member variable contains the name of the executable.<br>
+     *  The DWARF data to the ELF executable.<br>
+     */<br>
+    rld::dwarf::file debug;<br>
+<br>
+    /*!<br>
+     *  The executable's symbol table.<br>
+     */<br>
+    rld::symbols::table symbols;<br>
+<br>
+    /*!<br>
+     *  This map associates a symbol with its coverage map.<br>
      */<br>
-    std::string executableName;<br>
+    typedef std::map<std::string, CoverageMapBase *> CoverageMaps;<br>
+    CoverageMaps coverageMaps;<br>
<br>
     /*!<br>
      *  This member variable contains the name of a dynamic library<br>
@@ -158,7 +181,7 @@ namespace Coverage {<br>
      *  This member variable contains a pointer to the symbol table<br>
      *  of the executable or library.<br>
      */<br>
-    SymbolTable* theSymbolTable;<br>
+    SymbolTable theSymbolTable;<br>
<br>
   };<br>
 }<br>
diff --git a/tester/covoar/covoar.cc b/tester/covoar/covoar.cc<br>
index 5c87402..09c86c2 100644<br>
--- a/tester/covoar/covoar.cc<br>
+++ b/tester/covoar/covoar.cc<br>
@@ -186,7 +186,7 @@ int main(<br>
   Coverage::ExecutableInfo*     executableInfo = NULL;<br>
   std::string                   executableExtension = "exe";<br>
   std::string                   coverageExtension = "cov";<br>
-  Coverage::CoverageFormats_t   coverageFormat;<br>
+  Coverage::CoverageFormats_t   coverageFormat = Coverage::COVERAGE_FORMAT_<wbr>QEMU;<br>
   Coverage::CoverageReaderBase* coverageReader = NULL;<br>
   char*                         executable = NULL;<br>
   const char*                   explanations = NULL;<br>
diff --git a/tester/covoar/wscript b/tester/covoar/wscript<br>
index c0270d8..55d5ec9 100644<br>
--- a/tester/covoar/wscript<br>
+++ b/tester/covoar/wscript<br>
@@ -70,7 +70,7 @@ def build(bld):<br>
     #<br>
     # The list of modules.<br>
     #<br>
-    modules = ['rld', 'elf', 'iberty']<br>
+    modules = ['rld', 'dwarf', 'elf', 'iberty']<br>
<br>
     bld.stlib(target = 'ccovoar',<br>
               source = ['app_common.cc',<br>
<span class="HOEnZb"><font color="#888888">-- <br>
2.15.1<br>
<br>
______________________________<wbr>_________________<br>
devel mailing list<br>
<a href="mailto:devel@rtems.org">devel@rtems.org</a><br>
<a href="http://lists.rtems.org/mailman/listinfo/devel" rel="noreferrer" target="_blank">http://lists.rtems.org/<wbr>mailman/listinfo/devel</a><br>
</font></span></blockquote></div><br></div>