diff options
author | Alex White <alex.white@oarcorp.com> | 2021-04-30 14:34:18 -0500 |
---|---|---|
committer | Joel Sherrill <joel@rtems.org> | 2021-06-17 16:00:08 -0500 |
commit | ac56fce7c17e40c6ecd7980fa828a76550bbacb3 (patch) | |
tree | e59a7e98baa63d8ac08a9265f5b8c9dd6d58efde /tester/covoar/ExecutableInfo.cc | |
parent | covoar: Store only the file name in ExecutableInfo (diff) | |
download | rtems-tools-ac56fce7c17e40c6ecd7980fa828a76550bbacb3.tar.bz2 |
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
Diffstat (limited to 'tester/covoar/ExecutableInfo.cc')
-rw-r--r-- | tester/covoar/ExecutableInfo.cc | 73 |
1 files changed, 36 insertions, 37 deletions
diff --git a/tester/covoar/ExecutableInfo.cc b/tester/covoar/ExecutableInfo.cc index 861e60d..a6184e7 100644 --- a/tester/covoar/ExecutableInfo.cc +++ b/tester/covoar/ExecutableInfo.cc @@ -40,61 +40,60 @@ namespace Coverage { executable.begin(); executable.load_symbols(symbols); + rld::dwarf::file debug; + debug.begin(executable.elf()); debug.load_debug(); debug.load_functions(); - try { - for (auto& cu : debug.get_cus()) { - for (auto& func : cu.get_functions()) { - if (!func.has_machine_code()) { - continue; - } + for (auto& cu : debug.get_cus()) { + AddressLineRange& range = mapper.makeRange(cu.pc_low(), cu.pc_high()); + // Does not filter on desired symbols under the assumption that the test + // code and any support code is small relative to what is being tested. + for (const auto &address : cu.get_addresses()) { + range.addSourceLine(address); + } - if (!SymbolsToAnalyze->isDesired(func.name())) { - continue; + for (auto& func : cu.get_functions()) { + if (!func.has_machine_code()) { + continue; + } + + if (!SymbolsToAnalyze->isDesired(func.name())) { + continue; + } + + if (func.is_inlined()) { + if (func.is_external()) { + // Flag it + std::cerr << "Function is both external and inlined: " + << func.name() << std::endl; } - if (func.is_inlined()) { - if (func.is_external()) { - // Flag it - std::cerr << "Function is both external and inlined: " - << func.name() << std::endl; - } - - if (func.has_entry_pc()) { - continue; - } - - // If the low PC address is zero, the symbol does not appear in - // this executable. - if (func.pc_low() == 0) { - continue; - } + if (func.has_entry_pc()) { + continue; } - // We can't process a zero size function. - if (func.pc_high() == 0) { + // If the low PC address is zero, the symbol does not appear in + // this executable. + if (func.pc_low() == 0) { continue; } + } - createCoverageMap (cu.name(), func.name(), - func.pc_low(), func.pc_high() - 1); + // We can't process a zero size function. + if (func.pc_high() == 0) { + continue; } + + createCoverageMap (cu.name(), func.name(), + func.pc_low(), func.pc_high() - 1); } - } catch (...) { - debug.end(); - throw; } - - // Can't cleanup handles until the destructor because the information is - // referenced elsewhere. NOTE: This could cause problems from too many open - // file descriptors. } ExecutableInfo::~ExecutableInfo() { - debug.end(); } void ExecutableInfo::dumpCoverageMaps( void ) { @@ -197,7 +196,7 @@ namespace Coverage { { std::string file; int lno; - debug.get_source (address, file, lno); + mapper.getSource (address, file, lno); std::ostringstream ss; ss << file << ':' << lno; line = ss.str (); |