summaryrefslogtreecommitdiff
path: root/lib/DebugInfo/DWARFCompileUnit.cpp
diff options
context:
space:
mode:
authorAlexey Samsonov <samsonov@google.com>2012-07-02 05:54:45 +0000
committerAlexey Samsonov <samsonov@google.com>2012-07-02 05:54:45 +0000
commit3e25c4a1e3e58bc1d00d894854a29dd2e4e7e88a (patch)
tree742a54896b5de0397c3d8cbf4809e0e225ea016e /lib/DebugInfo/DWARFCompileUnit.cpp
parent9c3d5a70f40f9e7bb90f3cb8ec1d87cff6e3f0ae (diff)
downloadllvm-3e25c4a1e3e58bc1d00d894854a29dd2e4e7e88a.tar.gz
llvm-3e25c4a1e3e58bc1d00d894854a29dd2e4e7e88a.tar.bz2
llvm-3e25c4a1e3e58bc1d00d894854a29dd2e4e7e88a.tar.xz
This patch extends the libLLVMDebugInfo which contains a minimalistic DWARF parser:
1) DIContext is now able to return function name for a given instruction address (besides file/line info). 2) llvm-dwarfdump accepts flag --functions that prints the function name (if address is specified by --address flag). 3) test case that checks the basic functionality of llvm-dwarfdump added git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159512 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/DebugInfo/DWARFCompileUnit.cpp')
-rw-r--r--lib/DebugInfo/DWARFCompileUnit.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/DebugInfo/DWARFCompileUnit.cpp b/lib/DebugInfo/DWARFCompileUnit.cpp
index 24bf97ff60..2683990e58 100644
--- a/lib/DebugInfo/DWARFCompileUnit.cpp
+++ b/lib/DebugInfo/DWARFCompileUnit.cpp
@@ -82,7 +82,7 @@ void DWARFCompileUnit::clear() {
Abbrevs = 0;
AddrSize = 0;
BaseAddr = 0;
- DieArray.clear();
+ clearDIEs(false);
}
void DWARFCompileUnit::dump(raw_ostream &OS) {
@@ -201,7 +201,7 @@ size_t DWARFCompileUnit::extractDIEsIfNeeded(bool cu_die_only) {
}
void DWARFCompileUnit::clearDIEs(bool keep_compile_unit_die) {
- if (DieArray.size() > 1) {
+ if (DieArray.size() > (unsigned)keep_compile_unit_die) {
// std::vectors never get any smaller when resized to a smaller size,
// or when clear() or erase() are called, the size will report that it
// is smaller, but the memory allocated remains intact (call capacity()
@@ -227,8 +227,8 @@ DWARFCompileUnit::buildAddressRangeTable(DWARFDebugAranges *debug_aranges,
// all compile units to stay loaded when they weren't needed. So we can end
// up parsing the DWARF and then throwing them all away to keep memory usage
// down.
- const bool clear_dies = extractDIEsIfNeeded(false) > 1;
-
+ const bool clear_dies = extractDIEsIfNeeded(false) > 1 &&
+ clear_dies_if_already_not_parsed;
DieArray[0].buildAddressRangeTable(this, debug_aranges);
// Keep memory down by clearing DIEs if this generate function
@@ -236,3 +236,13 @@ DWARFCompileUnit::buildAddressRangeTable(DWARFDebugAranges *debug_aranges,
if (clear_dies)
clearDIEs(true);
}
+
+const DWARFDebugInfoEntryMinimal*
+DWARFCompileUnit::getFunctionDIEForAddress(int64_t address) {
+ size_t n = extractDIEsIfNeeded(false);
+ for (size_t i = 0; i != n; i++) {
+ if (DieArray[i].addressRangeContainsAddress(this, address))
+ return &DieArray[i];
+ }
+ return 0;
+}