OSDN Git Service

Clean up DWARFFormValue by reducing duplicated code and removing DWARFFormValue:...
authorGreg Clayton <gclayton@apple.com>
Fri, 11 Nov 2016 16:21:37 +0000 (16:21 +0000)
committerGreg Clayton <gclayton@apple.com>
Fri, 11 Nov 2016 16:21:37 +0000 (16:21 +0000)
commitf5acbc29d8c965f2ead0dda5f255e24c1f524ed9
treec00e34168274025e7a23725e67f501f4394f8cef
parent3726719543bf6b91abe7c94d27432c69c6a60616
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
include/llvm/DebugInfo/DWARF/DWARFFormValue.h
include/llvm/DebugInfo/DWARF/DWARFUnit.h
include/llvm/Support/Dwarf.h
lib/DebugInfo/DWARF/DWARFDebugInfoEntry.cpp
lib/DebugInfo/DWARF/DWARFFormValue.cpp
tools/llvm-dwp/llvm-dwp.cpp
unittests/DebugInfo/DWARF/DWARFFormValueTest.cpp