summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2017-09-29 00:33:22 +0000
committerAdrian Prantl <aprantl@apple.com>2017-09-29 00:33:22 +0000
commit714ee4d536366449e6c89b63d423371f81d4f070 (patch)
tree5490b051275dbf791e3ff92f99125020506e3446
parentb5f39a05a329534979572781b10326c60b0bdc9e (diff)
downloadbcm5719-llvm-714ee4d536366449e6c89b63d423371f81d4f070.tar.gz
bcm5719-llvm-714ee4d536366449e6c89b63d423371f81d4f070.zip
llvm-dwarfdump: add support for .apple_types in --find
llvm-svn: 314479
-rw-r--r--llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h4
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFContext.cpp8
-rw-r--r--llvm/test/tools/llvm-dwarfdump/X86/find.test9
-rw-r--r--llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp19
4 files changed, 33 insertions, 7 deletions
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h
index 471fb4c971f..9a1da73c20c 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h
@@ -70,6 +70,7 @@ class DWARFContext : public DIContext {
std::unique_ptr<DWARFDebugFrame> EHFrame;
std::unique_ptr<DWARFDebugMacro> Macro;
std::unique_ptr<DWARFAcceleratorTable> AppleNames;
+ std::unique_ptr<DWARFAcceleratorTable> AppleTypes;
DWARFUnitSection<DWARFCompileUnit> DWOCUs;
std::deque<DWARFUnitSection<DWARFTypeUnit>> DWOTUs;
@@ -242,6 +243,9 @@ public:
/// Get a reference to the parsed accelerator table object.
const DWARFAcceleratorTable &getAppleNames();
+ /// Get a reference to the parsed accelerator table object.
+ const DWARFAcceleratorTable &getAppleTypes();
+
/// Get a pointer to a parsed line table corresponding to a compile unit.
const DWARFDebugLine::LineTable *getLineTableForUnit(DWARFUnit *cu);
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
index 4a5253a0404..a48f5c41b67 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
@@ -457,8 +457,7 @@ void DWARFContext::dump(
if (shouldDump(Explicit, ".apple_types", DIDT_ID_AppleTypes,
DObj->getAppleTypesSection().Data))
- dumpAccelSection(OS, *DObj, DObj->getAppleTypesSection(),
- DObj->getStringSection(), isLittleEndian());
+ getAppleTypes().dump(OS);
if (shouldDump(Explicit, ".apple_namespaces", DIDT_ID_AppleNamespaces,
DObj->getAppleNamespacesSection().Data))
@@ -655,6 +654,11 @@ const DWARFAcceleratorTable &DWARFContext::getAppleNames() {
DObj->getStringSection(), isLittleEndian());
}
+const DWARFAcceleratorTable &DWARFContext::getAppleTypes() {
+ return getAccelTable(AppleTypes, *DObj, DObj->getAppleTypesSection(),
+ DObj->getStringSection(), isLittleEndian());
+}
+
const DWARFLineTable *
DWARFContext::getLineTableForUnit(DWARFUnit *U) {
if (!Line)
diff --git a/llvm/test/tools/llvm-dwarfdump/X86/find.test b/llvm/test/tools/llvm-dwarfdump/X86/find.test
index b6e91b9a14c..e6a40b07736 100644
--- a/llvm/test/tools/llvm-dwarfdump/X86/find.test
+++ b/llvm/test/tools/llvm-dwarfdump/X86/find.test
@@ -26,3 +26,12 @@ MULTI: : DW_TAG_variable
MULTI-NOT: {{: DW}}
MULTI: DW_AT_name ("x86_64h_var")
MULTI-NOT: {{: DW}}
+
+RUN: llvm-mc %S/brief.s -filetype obj -triple x86_64-apple-darwin -o - \
+RUN: | llvm-dwarfdump -find=int - | FileCheck %s --check-prefix=TYPES
+TYPES: .debug_info contents:
+TYPES-NOT: {{:}}
+TYPES: : DW_TAG_base_type
+TYPES-NOT: {{:}}
+TYPES: DW_AT_name ("int")
+TYPES-NOT: {{:}}
diff --git a/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp b/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
index 9c4a7c88bb3..a36926d1097 100644
--- a/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
+++ b/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
@@ -247,11 +247,20 @@ static bool dumpObjectFile(ObjectFile &Obj, DWARFContext &DICtx, Twine Filename,
// Handle the --find option and lower it to --debug-info=<offset>.
if (!Find.empty()) {
DumpOffsets[DIDT_ID_DebugInfo] = [&]() -> llvm::Optional<uint64_t> {
- for (auto Name : Find)
- for (auto Entry : DICtx.getAppleNames().equal_range(Name))
- for (auto Atom : Entry)
- if (auto Offset = Atom.getAsSectionOffset())
- return DumpOffsets[DIDT_ID_DebugInfo] = *Offset;
+ for (auto Name : Find) {
+ auto find = [&](const DWARFAcceleratorTable &Accel)
+ -> llvm::Optional<uint64_t> {
+ for (auto Entry : Accel.equal_range(Name))
+ for (auto Atom : Entry)
+ if (auto Offset = Atom.getAsSectionOffset())
+ return Offset;
+ return None;
+ };
+ if (auto Offset = find(DICtx.getAppleNames()))
+ return DumpOffsets[DIDT_ID_DebugInfo] = *Offset;
+ if (auto Offset = find(DICtx.getAppleTypes()))
+ return DumpOffsets[DIDT_ID_DebugInfo] = *Offset;
+ }
return None;
}();
// Early exit if --find was specified but the current file doesn't have it.
OpenPOWER on IntegriCloud