source: rtems-tools/tester/covoar/ExecutableInfo.cc @ 3e187ba

Last change on this file since 3e187ba was 3e187ba, checked in by Cillian O'Donnell <cpodonnell8@…>, on Apr 25, 2018 at 8:33:58 PM

covoar: Add symbol set reader and ELF data parser to covoar.

Add ability to organize symbol sets of libraries in INI file
and then read them with covoar and load the symbols directly from the
libraries.

rtems-tools/../testing: Add configuration files for coverage analysis.

A number of covoar options are not required and are defaulted.

Co-author: Krzysztof Miesowicz <krzysztof.miesowicz@…>
Co-author: Vijay Kumar Banerjee <vijaykumar9597@…>
Co-author: Chris Johns <chrisj@…>

  • Property mode set to 100644
File size: 3.2 KB
Line 
1/*! @file ExecutableInfo.cc
2 *  @brief ExecutableInfo Implementation
3 *
4 *  This file contains the implementation of the functionality
5 *  of the ExecutableInfo class.
6 */
7
8#include <stdio.h>
9
10#include "ExecutableInfo.h"
11#include "app_common.h"
12#include "CoverageMap.h"
13#include "DesiredSymbols.h"
14#include "SymbolTable.h"
15
16namespace Coverage {
17
18  ExecutableInfo::ExecutableInfo(
19    const char* const theExecutableName,
20    const char* const theLibraryName
21  )
22  {
23    executableName = theExecutableName;
24    loadAddress = 0;
25    libraryName = "";
26    if (theLibraryName)
27      libraryName = theLibraryName;
28    theSymbolTable = new SymbolTable();
29  }
30
31  ExecutableInfo::~ExecutableInfo()
32  {
33    if (theSymbolTable)
34      delete theSymbolTable;
35  }
36
37  void ExecutableInfo::dumpCoverageMaps( void ) {
38    ExecutableInfo::coverageMaps_t::iterator  itr;
39
40    for (itr = coverageMaps.begin(); itr != coverageMaps.end(); itr++) {
41      fprintf( stderr, "Coverage Map for %s\n", ((*itr).first).c_str() );;
42      ((*itr).second)->dump();
43    }
44  }
45
46  void ExecutableInfo::dumpExecutableInfo( void ){
47    fprintf( stdout, "\n== Executable info ==\n");
48    fprintf( stdout, "executableName = %s\n", executableName.c_str());
49    fprintf( stdout, "libraryName = %s\n", libraryName.c_str());
50    fprintf( stdout, "loadAddress = %u\n", loadAddress);
51    theSymbolTable->dumpSymbolTable();
52  }
53
54  CoverageMapBase* ExecutableInfo::getCoverageMap ( uint32_t address )
55  {
56    CoverageMapBase*         aCoverageMap = NULL;
57    coverageMaps_t::iterator it;
58    std::string              itsSymbol;
59
60    // Obtain the coverage map containing the specified address.
61    itsSymbol = theSymbolTable->getSymbol( address );
62    if (itsSymbol != "") {
63      it = coverageMaps.find( itsSymbol );
64      aCoverageMap = (*it).second;
65    }
66
67    return aCoverageMap;
68  }
69
70  const std::string& ExecutableInfo::getFileName ( void ) const
71  {
72    return executableName;
73  }
74
75  const std::string& ExecutableInfo::getLibraryName( void ) const
76  {
77    return libraryName;
78  }
79
80  uint32_t ExecutableInfo::getLoadAddress( void ) const
81  {
82    return loadAddress;
83  }
84
85
86  SymbolTable* ExecutableInfo::getSymbolTable ( void ) const
87  {
88    return theSymbolTable;
89  }
90
91  CoverageMapBase* ExecutableInfo::createCoverageMap (
92    const std::string& fileName,
93    const std::string& symbolName,
94    uint32_t           lowAddress,
95    uint32_t           highAddress
96  )
97  {
98    CoverageMapBase                          *theMap;
99    ExecutableInfo::coverageMaps_t::iterator  itr;
100
101    itr = coverageMaps.find( symbolName );
102    if ( itr == coverageMaps.end() ) {
103      theMap = new CoverageMap( fileName, lowAddress, highAddress );
104      coverageMaps[ symbolName ] = theMap;
105    } else {
106      theMap = itr->second;
107      theMap->Add( lowAddress, highAddress );
108    }
109    return theMap;
110  }
111
112  bool ExecutableInfo::hasDynamicLibrary( void )
113  {
114     return (libraryName != "");
115  }
116
117  void ExecutableInfo::mergeCoverage( void ) {
118    ExecutableInfo::coverageMaps_t::iterator  itr;
119
120    for (itr = coverageMaps.begin(); itr != coverageMaps.end(); itr++) {
121      SymbolsToAnalyze->mergeCoverageMap( (*itr).first, (*itr).second );
122    }
123  }
124
125  void ExecutableInfo::setLoadAddress( uint32_t address )
126  {
127    loadAddress = address;
128  }
129
130}
Note: See TracBrowser for help on using the repository browser.