Changeset ac56fce in rtems-tools


Ignore:
Timestamp:
Apr 30, 2021, 7:34:18 PM (3 months ago)
Author:
Alex White <alex.white@…>
Branches:
master
Children:
2650d70
Parents:
a88be93
git-author:
Alex White <alex.white@…> (04/30/21 19:34:18)
git-committer:
Joel Sherrill <joel@…> (06/17/21 21:00:08)
Message:

covoar: Store address-to-line info outside of DWARF

This adds the AddressToLineMapper? class and supporting classes to
assume responsibility of tracking address-to-line information.

This allows the DWARF library to properly cleanup all of its resources
and leads to significant memory savings.

Closes #4383

Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • rtemstoolkit/rld-dwarf.cpp

    ra88be93 rac56fce  
    18941894    }
    18951895
     1896    const addresses& compilation_unit::get_addresses () const
     1897    {
     1898      return addr_lines_;
     1899    }
     1900
    18961901    functions&
    18971902    compilation_unit::get_functions ()
  • rtemstoolkit/rld-dwarf.h

    ra88be93 rac56fce  
    709709
    710710      /**
     711       * The addresses associated with this compilation unit.
     712       */
     713      const addresses& get_addresses () const;
     714
     715      /**
    711716       * Get the source and line for an address. If the address does not match
    712717       * false is returned the file is set to 'unknown' and the line is set to
  • tester/covoar/ExecutableInfo.cc

    ra88be93 rac56fce  
    4141    executable.load_symbols(symbols);
    4242
     43    rld::dwarf::file debug;
     44
    4345    debug.begin(executable.elf());
    4446    debug.load_debug();
    4547    debug.load_functions();
    4648
    47     try {
    48       for (auto& cu : debug.get_cus()) {
    49         for (auto& func : cu.get_functions()) {
    50           if (!func.has_machine_code()) {
     49    for (auto& cu : debug.get_cus()) {
     50      AddressLineRange& range = mapper.makeRange(cu.pc_low(), cu.pc_high());
     51      // Does not filter on desired symbols under the assumption that the test
     52      // code and any support code is small relative to what is being tested.
     53      for (const auto &address : cu.get_addresses()) {
     54        range.addSourceLine(address);
     55      }
     56
     57      for (auto& func : cu.get_functions()) {
     58        if (!func.has_machine_code()) {
     59          continue;
     60        }
     61
     62        if (!SymbolsToAnalyze->isDesired(func.name())) {
     63          continue;
     64        }
     65
     66        if (func.is_inlined()) {
     67          if (func.is_external()) {
     68            // Flag it
     69            std::cerr << "Function is both external and inlined: "
     70                      << func.name() << std::endl;
     71          }
     72
     73          if (func.has_entry_pc()) {
    5174            continue;
    5275          }
    5376
    54           if (!SymbolsToAnalyze->isDesired(func.name())) {
     77          // If the low PC address is zero, the symbol does not appear in
     78          // this executable.
     79          if (func.pc_low() == 0) {
    5580            continue;
    5681          }
    57 
    58           if (func.is_inlined()) {
    59             if (func.is_external()) {
    60               // Flag it
    61               std::cerr << "Function is both external and inlined: "
    62                         << func.name() << std::endl;
    63             }
    64 
    65             if (func.has_entry_pc()) {
    66               continue;
    67             }
    68 
    69             // If the low PC address is zero, the symbol does not appear in
    70             // this executable.
    71             if (func.pc_low() == 0) {
    72               continue;
    73             }
    74           }
    75 
    76           // We can't process a zero size function.
    77           if (func.pc_high() == 0) {
    78             continue;
    79           }
    80 
    81           createCoverageMap (cu.name(), func.name(),
    82                               func.pc_low(), func.pc_high() - 1);
    83         }
     82        }
     83
     84        // We can't process a zero size function.
     85        if (func.pc_high() == 0) {
     86          continue;
     87        }
     88
     89        createCoverageMap (cu.name(), func.name(),
     90                            func.pc_low(), func.pc_high() - 1);
    8491      }
    85     } catch (...) {
    86       debug.end();
    87       throw;
    88     }
    89 
    90     // Can't cleanup handles until the destructor because the information is
    91     // referenced elsewhere. NOTE: This could cause problems from too many open
    92     // file descriptors.
     92    }
    9393  }
    9494
    9595  ExecutableInfo::~ExecutableInfo()
    9696  {
    97     debug.end();
    9897  }
    9998
     
    198197    std::string file;
    199198    int         lno;
    200     debug.get_source (address, file, lno);
     199    mapper.getSource (address, file, lno);
    201200    std::ostringstream ss;
    202201    ss << file << ':' << lno;
  • tester/covoar/ExecutableInfo.h

    ra88be93 rac56fce  
    1616#include <rld-symbols.h>
    1717
     18#include "AddressToLineMapper.h"
    1819#include "CoverageMapBase.h"
    1920#include "SymbolTable.h"
     
    159160
    160161    /*!
    161      *  The DWARF data to the ELF executable.
    162      */
    163     rld::dwarf::file debug;
    164 
    165     /*!
    166162     *  The executable's file name.
    167163     */
     
    172168     */
    173169    rld::symbols::table symbols;
     170
     171    /*!
     172     *  The address-to-line mapper for this executable.
     173     */
     174    AddressToLineMapper mapper;
    174175
    175176    /*!
  • tester/covoar/wscript

    ra88be93 rac56fce  
    8484    bld.stlib(target = 'ccovoar',
    8585              source = ['app_common.cc',
     86                        'AddressToLineMapper.cc',
    8687                        'CoverageFactory.cc',
    8788                        'CoverageMap.cc',
Note: See TracChangeset for help on using the changeset viewer.