summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2016-11-11 16:21:37 +0000
committerGreg Clayton <gclayton@apple.com>2016-11-11 16:21:37 +0000
commitf5acbc29d8c965f2ead0dda5f255e24c1f524ed9 (patch)
treec00e34168274025e7a23725e67f501f4394f8cef /tools
parent3726719543bf6b91abe7c94d27432c69c6a60616 (diff)
Clean up DWARFFormValue by reducing duplicated code and removing DWARFFormValue::getFixedFormSizes()
In preparation for a follow on patch that improves DWARF parsing speed, clean up DWARFFormValue so that we have can get the fixed byte size of a form value given a DWARFUnit or given the version, address byte size and dwarf32/64. This patch cleans up code so that everyone is using one of the new DWARFFormValue functions: static Optional<uint8_t> DWARFFormValue::getFixedByteSize(dwarf::Form Form, const DWARFUnit *U = nullptr); static Optional<uint8_t> DWARFFormValue::getFixedByteSize(dwarf::Form Form, uint16_t Version, uint8_t AddrSize, bool Dwarf32); This patch changes DWARFFormValue::skipValue() to rely on the output of DWARFFormValue::getFixedByteSize(...) instead of duplicating the code in each function. This will reduce the number of changes we need to make to DWARF to fewer places in DWARFFormValue when we add support for new form. This patch also starts to support DWARF64 so that we can get correct byte sizes for forms that vary according the DWARF 32/64. To reduce the code duplication a new FormSizeHelper pure virtual class was created that can be created as a FormSizeHelperDWARFUnit when you have a DWARFUnit, or FormSizeHelperManual where you manually specify the DWARF version, address byte size and DWARF32/DWARF64. There is now a single implementation of a function that gets the fixed byte size (instead of two where one took a DWARFUnit and one took the DWARF version, address byte size and DWARFFormat enum) and one function to skip the form values. https://reviews.llvm.org/D26526 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@286597 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r--tools/llvm-dwp/llvm-dwp.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/tools/llvm-dwp/llvm-dwp.cpp b/tools/llvm-dwp/llvm-dwp.cpp
index 5ee620a77b0..7418c77bdec 100644
--- a/tools/llvm-dwp/llvm-dwp.cpp
+++ b/tools/llvm-dwp/llvm-dwp.cpp
@@ -133,7 +133,14 @@ static Expected<CompileUnitIdentifiers> getCUIdentifiers(StringRef Abbrev,
StringRef Str) {
uint32_t Offset = 0;
DataExtractor InfoData(Info, true, 0);
- InfoData.getU32(&Offset); // Length
+ dwarf::DwarfFormat Format = dwarf::DwarfFormat::DWARF32;
+ uint64_t Length = InfoData.getU32(&Offset);
+ // If the length is 0xffffffff, then this indictes that this is a DWARF 64
+ // stream and the length is actually encoded into a 64 bit value that follows.
+ if (Length == 0xffffffffU) {
+ Format = dwarf::DwarfFormat::DWARF64;
+ Length = InfoData.getU64(&Offset);
+ }
uint16_t Version = InfoData.getU16(&Offset);
InfoData.getU32(&Offset); // Abbrev offset (should be zero)
uint8_t AddrSize = InfoData.getU8(&Offset);
@@ -174,7 +181,8 @@ static Expected<CompileUnitIdentifiers> getCUIdentifiers(StringRef Abbrev,
ID.Signature = InfoData.getU64(&Offset);
break;
default:
- DWARFFormValue::skipValue(Form, InfoData, &Offset, Version, AddrSize);
+ DWARFFormValue::skipValue(Form, InfoData, &Offset, Version, AddrSize,
+ Format);
}
}
return ID;