From a03cbcc6a6030e29437543871fb78520e31cfd02 Mon Sep 17 00:00:00 2001 From: Chris Bieneman Date: Tue, 7 Mar 2017 21:34:35 +0000 Subject: [ObjectYAML] Fix issue with DWARF2 AddrSize 8 In my refactoring I introduced a bug where we were using the reference size instead of the offset size for DW_FORM_strp and similar forms. This patch resolves the error and adds a test case testing all the DWARF forms for DWARF2 AddrSize 8. There is similar coverage already in the DWARFDebugInfoTest sources that covers the parser. Once I migrate the DWARFGenerator APIs to be built on the YAML tools they will be fully covered under the same tests. llvm-svn: 297230 --- llvm/lib/ObjectYAML/DWARFVisitor.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'llvm/lib/ObjectYAML/DWARFVisitor.cpp') diff --git a/llvm/lib/ObjectYAML/DWARFVisitor.cpp b/llvm/lib/ObjectYAML/DWARFVisitor.cpp index cb9ad7a4cb8..36a9f7638bd 100644 --- a/llvm/lib/ObjectYAML/DWARFVisitor.cpp +++ b/llvm/lib/ObjectYAML/DWARFVisitor.cpp @@ -34,10 +34,14 @@ void DWARFYAML::VisitorImpl::onVariableSizeValue(uint64_t U, unsigned Size) { } } +unsigned getOffsetSize(const DWARFYAML::Unit &Unit) { + return Unit.Length.isDWARF64() ? 8 : 4; +} + unsigned getRefSize(const DWARFYAML::Unit &Unit) { if (Unit.Version == 2) return Unit.AddrSize; - return Unit.Length.isDWARF64() ? 8 : 4; + return getOffsetSize(Unit); } template void DWARFYAML::VisitorImpl::traverseDebugInfo() { @@ -149,7 +153,7 @@ template void DWARFYAML::VisitorImpl::traverseDebugInfo() { case dwarf::DW_FORM_GNU_strp_alt: case dwarf::DW_FORM_line_strp: case dwarf::DW_FORM_strp_sup: - onVariableSizeValue(FormVal->Value, getRefSize(Unit)); + onVariableSizeValue(FormVal->Value, getOffsetSize(Unit)); break; case dwarf::DW_FORM_ref_sig8: onValue((uint64_t)FormVal->Value); -- cgit v1.2.3