Page MenuHomePhabricator

[DebugInfo][unittest] Use YAML to generate the .debug_loclists section.
ClosedPublic

Authored by Higuoxing on Aug 3 2020, 8:37 PM.

Details

Summary

DWARFYAML supports generating the .debug_loclists section. We can use it
to simplify tests.

Diff Detail

Event Timeline

Higuoxing created this revision.Aug 3 2020, 8:37 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 3 2020, 8:37 PM
Higuoxing requested review of this revision.Aug 3 2020, 8:37 PM

Generally looks good for my eyes.

nit: I think the comment about intentionally missing end_of_list is better to be preserved.

llvm/unittests/DebugInfo/DWARF/DWARFDieTest.cpp
78

// end_of_list intentionally missing

I think this comment was useful.

Higuoxing updated this revision to Diff 282815.Aug 4 2020, 12:46 AM
Higuoxing marked an inline comment as done.

Address comments.

llvm/unittests/DebugInfo/DWARF/DWARFDieTest.cpp
78

Done. Thanks for reviewing!

grimar accepted this revision.Aug 4 2020, 1:11 AM

LGTM, but please wait for someone's else approvement too.

llvm/unittests/DebugInfo/DWARF/DWARFDieTest.cpp
64

nit: no full stop after "missing".

This revision is now accepted and ready to land.Aug 4 2020, 1:11 AM
jhenderson accepted this revision.Aug 4 2020, 1:28 AM

LGTM, with @grimar's nit fixed.

Higuoxing updated this revision to Diff 282826.Aug 4 2020, 1:33 AM

Address comments.

This revision was landed with ongoing or failed builds.Aug 4 2020, 1:38 AM
This revision was automatically updated to reflect the committed changes.
RKSimon added a subscriber: RKSimon.Aug 4 2020, 8:57 AM

@Higuoxing There's undef sanitizer warnings after this patch: http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/44524/

I haven't been able to repro but by inspection it looks like DI.Is64BitAddrSize has an undefined value:

Error DWARFYAML::emitDebugLoclists(raw_ostream &OS, const Data &DI) {
  assert(DI.DebugLoclists && "unexpected emitDebugRnglists() call");
  return writeDWARFLists<DWARFYAML::LoclistEntry>(
      OS, *DI.DebugLoclists, DI.IsLittleEndian, DI.Is64BitAddrSize);
}
/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/ObjectYAML/DWARFEmitter.cpp:900:52: runtime error: load of value 200, which is not a valid value for type 'bool'
    #0 0x1951b19 in llvm::DWARFYAML::emitDebugLoclists(llvm::raw_ostream&, llvm::DWARFYAML::Data const&) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/ObjectYAML/DWARFEmitter.cpp:900:52
    #1 0x1956ff3 in std::_Function_handler<llvm::Error (llvm::raw_ostream&, llvm::DWARFYAML::Data const&), llvm::Error (*)(llvm::raw_ostream&, llvm::DWARFYAML::Data const&)>::_M_invoke(std::_Any_data const&, llvm::raw_ostream&, llvm::DWARFYAML::Data const&) /usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/bits/std_function.h:282:9
    #2 0x1954f91 in std::function<llvm::Error (llvm::raw_ostream&, llvm::DWARFYAML::Data const&)>::operator()(llvm::raw_ostream&, llvm::DWARFYAML::Data const&) const /usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/bits/std_function.h:687:14
    #3 0x1953465 in emitDebugSectionImpl /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/ObjectYAML/DWARFEmitter.cpp:938:19
    #4 0x1953465 in llvm::DWARFYAML::emitDebugSections(llvm::StringRef, bool) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/ObjectYAML/DWARFEmitter.cpp:969:22
    #5 0x541abd in (anonymous namespace)::DWARFDie_getLocations_Test::TestBody() /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/unittests/DebugInfo/DWARF/DWARFDieTest.cpp:67:7
    #6 0x1af4529 in testing::Test::Run() /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/unittest/googletest/src/gtest.cc:2474:5
    #7 0x1af5481 in testing::TestInfo::Run() /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/unittest/googletest/src/gtest.cc:2656:11
    #8 0x1af5dd2 in testing::TestCase::Run() /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/unittest/googletest/src/gtest.cc:2774:28
    #9 0x1afc443 in testing::internal::UnitTestImpl::RunAllTests() /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/unittest/googletest/src/gtest.cc:4649:43
    #10 0x1afbed5 in testing::UnitTest::Run() /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/unittest/googletest/src/gtest.cc:4257:10
    #11 0x1aedfc3 in RUN_ALL_TESTS /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/unittest/googletest/include/gtest/gtest.h:2233:46
    #12 0x1aedfc3 in main /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/unittest/UnitTestMain/TestMain.cpp:50:10
    #13 0x7f47dc44a09a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
    #14 0x455839 in _start (/b/sanitizer-x86_64-linux-fast/build/llvm_build_ubsan/unittests/DebugInfo/DWARF/DebugInfoDWARFTests+0x455839)

SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/ObjectYAML/DWARFEmitter.cpp:900:52 in

Hi @RKSimon, thanks for pointing this out! I will fix it later.

@Higuoxing There's undef sanitizer warnings after this patch: http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/44524/

I haven't been able to repro but by inspection it looks like DI.Is64BitAddrSize has an undefined value:

Error DWARFYAML::emitDebugLoclists(raw_ostream &OS, const Data &DI) {
  assert(DI.DebugLoclists && "unexpected emitDebugRnglists() call");
  return writeDWARFLists<DWARFYAML::LoclistEntry>(
      OS, *DI.DebugLoclists, DI.IsLittleEndian, DI.Is64BitAddrSize);
}
/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/ObjectYAML/DWARFEmitter.cpp:900:52: runtime error: load of value 200, which is not a valid value for type 'bool'
    #0 0x1951b19 in llvm::DWARFYAML::emitDebugLoclists(llvm::raw_ostream&, llvm::DWARFYAML::Data const&) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/ObjectYAML/DWARFEmitter.cpp:900:52
    #1 0x1956ff3 in std::_Function_handler<llvm::Error (llvm::raw_ostream&, llvm::DWARFYAML::Data const&), llvm::Error (*)(llvm::raw_ostream&, llvm::DWARFYAML::Data const&)>::_M_invoke(std::_Any_data const&, llvm::raw_ostream&, llvm::DWARFYAML::Data const&) /usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/bits/std_function.h:282:9
    #2 0x1954f91 in std::function<llvm::Error (llvm::raw_ostream&, llvm::DWARFYAML::Data const&)>::operator()(llvm::raw_ostream&, llvm::DWARFYAML::Data const&) const /usr/lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/bits/std_function.h:687:14
    #3 0x1953465 in emitDebugSectionImpl /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/ObjectYAML/DWARFEmitter.cpp:938:19
    #4 0x1953465 in llvm::DWARFYAML::emitDebugSections(llvm::StringRef, bool) /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/ObjectYAML/DWARFEmitter.cpp:969:22
    #5 0x541abd in (anonymous namespace)::DWARFDie_getLocations_Test::TestBody() /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/unittests/DebugInfo/DWARF/DWARFDieTest.cpp:67:7
    #6 0x1af4529 in testing::Test::Run() /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/unittest/googletest/src/gtest.cc:2474:5
    #7 0x1af5481 in testing::TestInfo::Run() /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/unittest/googletest/src/gtest.cc:2656:11
    #8 0x1af5dd2 in testing::TestCase::Run() /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/unittest/googletest/src/gtest.cc:2774:28
    #9 0x1afc443 in testing::internal::UnitTestImpl::RunAllTests() /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/unittest/googletest/src/gtest.cc:4649:43
    #10 0x1afbed5 in testing::UnitTest::Run() /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/unittest/googletest/src/gtest.cc:4257:10
    #11 0x1aedfc3 in RUN_ALL_TESTS /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/unittest/googletest/include/gtest/gtest.h:2233:46
    #12 0x1aedfc3 in main /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/unittest/UnitTestMain/TestMain.cpp:50:10
    #13 0x7f47dc44a09a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
    #14 0x455839 in _start (/b/sanitizer-x86_64-linux-fast/build/llvm_build_ubsan/unittests/DebugInfo/DWARF/DebugInfoDWARFTests+0x455839)

SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/ObjectYAML/DWARFEmitter.cpp:900:52 in