diff options
author | Greg Clayton <gclayton@apple.com> | 2017-11-27 22:12:44 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2017-11-27 22:12:44 +0000 |
commit | d6b67eb15c3640c38d2e12f83373def07ca6fae9 (patch) | |
tree | 262876b3b8b3e88452483f5201330a6caf8bc02d /llvm/unittests | |
parent | 4aa519507d3234cf7843f1c6079dc783ed088dc2 (diff) | |
download | bcm5719-llvm-d6b67eb15c3640c38d2e12f83373def07ca6fae9.tar.gz bcm5719-llvm-d6b67eb15c3640c38d2e12f83373def07ca6fae9.zip |
Fixed the ability to recursively get an attribute value from a DWARFDie.
The previous implementation would only look 1 DW_AT_specification or DW_AT_abstract_origin deep. This means DWARFDie::getName() would fail in certain cases. I ran into such a case while creating a tool that used the LLVM DWARF parser to generate a symbolication format so I have seen this in the wild.
Differential Revision: https://reviews.llvm.org/D40156
llvm-svn: 319104
Diffstat (limited to 'llvm/unittests')
-rw-r--r-- | llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp b/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp index 4786cc25420..cdccd9f797d 100644 --- a/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp +++ b/llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp @@ -1287,12 +1287,16 @@ TEST(DWARFDebugInfo, TestFindRecurse) { auto CUDie = CU.getUnitDIE(); auto FuncSpecDie = CUDie.addChild(DW_TAG_subprogram); auto FuncAbsDie = CUDie.addChild(DW_TAG_subprogram); + // Put the linkage name in a second abstract origin DIE to ensure we + // recurse through more than just one DIE when looking for attributes. + auto FuncAbsDie2 = CUDie.addChild(DW_TAG_subprogram); auto FuncDie = CUDie.addChild(DW_TAG_subprogram); auto VarAbsDie = CUDie.addChild(DW_TAG_variable); auto VarDie = CUDie.addChild(DW_TAG_variable); FuncSpecDie.addAttribute(DW_AT_name, DW_FORM_strp, SpecDieName); - FuncAbsDie.addAttribute(DW_AT_linkage_name, DW_FORM_strp, SpecLinkageName); + FuncAbsDie2.addAttribute(DW_AT_linkage_name, DW_FORM_strp, SpecLinkageName); FuncAbsDie.addAttribute(DW_AT_specification, DW_FORM_ref4, FuncSpecDie); + FuncAbsDie.addAttribute(DW_AT_abstract_origin, DW_FORM_ref4, FuncAbsDie2); FuncDie.addAttribute(DW_AT_abstract_origin, DW_FORM_ref4, FuncAbsDie); VarAbsDie.addAttribute(DW_AT_name, DW_FORM_strp, AbsDieName); VarDie.addAttribute(DW_AT_abstract_origin, DW_FORM_ref4, VarAbsDie); @@ -1314,7 +1318,8 @@ TEST(DWARFDebugInfo, TestFindRecurse) { auto FuncSpecDie = CUDie.getFirstChild(); auto FuncAbsDie = FuncSpecDie.getSibling(); - auto FuncDie = FuncAbsDie.getSibling(); + auto FuncAbsDie2 = FuncAbsDie.getSibling(); + auto FuncDie = FuncAbsDie2.getSibling(); auto VarAbsDie = FuncDie.getSibling(); auto VarDie = VarAbsDie.getSibling(); |