[PATCH] D149058: [BPF][DebugInfo] Use .BPF.ext for line info when DWARF is not available

Eduard Zingerman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 12 15:49:06 PDT 2023


eddyz87 added a comment.

In D149058#4495293 <https://reviews.llvm.org/D149058#4495293>, @MaskRay wrote:

> The test has good test coverage for the regular code path, but the error code paths need the unittest.

Actually, I think there are test cases for each error message parser can currently produce...

I want to push the patch below to the main branch.
I tested it locally and -Wunaligned-access does catch the issue with `Obj` and `Storage`.
What do you think?

  diff --git a/llvm/unittests/DebugInfo/BTF/BTFParserTest.cpp b/llvm/unittests/DebugInfo/BTF/BTFParserTest.cpp
  index 097d6205adec..041933deb4ec 100644
  --- a/llvm/unittests/DebugInfo/BTF/BTFParserTest.cpp
  +++ b/llvm/unittests/DebugInfo/BTF/BTFParserTest.cpp
  @@ -44,11 +44,11 @@ namespace {
   // modified before a call to `makeObj()` to test parser with invalid
   // input, etc.
   
  +struct MockData1 {
   // Use "pragma pack" to model .BTF & .BTF.ext sections content using
   // 'struct' objects. This pragma is supported by CLANG, GCC & MSVC,
   // which matters for LLVM CI.
   #pragma pack(push, 1)
  -struct MockData1 {
     struct B {
       BTF::Header Header = {};
       // no types
  @@ -99,6 +99,7 @@ struct MockData1 {
         Header.LineInfoLen = sizeof(Lines);
       }
     } Ext;
  +#pragma pack(pop)
   
     int BTFSectionLen = sizeof(BTF);
     int ExtSectionLen = sizeof(Ext);
  @@ -143,7 +144,6 @@ Sections:
       return *Obj.get();
     }
   };
  -#pragma pack(pop)
   
   TEST(BTFParserTest, simpleCorrectInput) {
     BTFParser BTF;
  diff --git a/llvm/unittests/DebugInfo/BTF/CMakeLists.txt b/llvm/unittests/DebugInfo/BTF/CMakeLists.txt
  index b425e46b9f0c..8cd4b793a741 100644
  --- a/llvm/unittests/DebugInfo/BTF/CMakeLists.txt
  +++ b/llvm/unittests/DebugInfo/BTF/CMakeLists.txt
  @@ -10,4 +10,11 @@ add_llvm_unittest(DebugInfoBTFTests
   
   target_link_libraries(DebugInfoBTFTests PRIVATE LLVMTestingSupport)
   
  +# Packed structures are used in the test. Asan/UBsan can catch
  +# unaligned access errors, but such builds take significant time.
  +# Use clang's -Wunaligned-access to get a heads-up.
  +if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  +  set_source_files_properties(BTFParserTest.cpp PROPERTIES COMPILE_FLAGS -Wunaligned-access)
  +endif()
  +
   set_property(TARGET DebugInfoBTFTests PROPERTY FOLDER "Tests/UnitTests/DebugInfoTests")


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D149058/new/

https://reviews.llvm.org/D149058



More information about the llvm-commits mailing list