[llvm] Add support for verifying .debug_names in split DWARF for CUs and TUs. (PR #101775)

Michael Buch via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 20 01:21:37 PDT 2024


Michael137 wrote:

So looks like the offending DWARF is this:
```
.debug_info contents:
0x00000000: Compile Unit: length = 0x00000033, format = DWARF32, version = 0x0005, unit_type = DW_UT_compile, abbr_offset = 0x0000, addr_size = 0x08 (next unit at 0x00000037)

0x0000000c: DW_TAG_compile_unit
              DW_AT_producer    ("clang version 20.0.0git (https://github.com/Michael137/llvm-project.git fb326019769e448f9effe3c8b10e6df8e7e9ce71)")
              DW_AT_language    (DW_LANG_C_plus_plus_11)
              DW_AT_name        ("Foo")
              DW_AT_LLVM_sysroot        ("/path/to/sdk")
              DW_AT_APPLE_sdk   ("some.sdk")
              DW_AT_str_offsets_base    (0x00000008)
              DW_AT_stmt_list   (0x00000000)
              DW_AT_comp_dir    ("/Users/michaelbuch/Git/llvm-worktrees/playground/lldb-test-build.noindex/lang/cpp/modules-import/TestCXXModulesImport.test_expr_dsym")
              DW_AT_GNU_dwo_id  (0xb0d9e392fcae5b5c)
...

0x00000037: Compile Unit: length = 0x0000006c, format = DWARF32, version = 0x0005, unit_type = DW_UT_compile, abbr_offset = 0x0000, addr_size = 0x08 (next unit at 0x000000a7)

0x00000043: DW_TAG_compile_unit
              DW_AT_producer    ("clang version 20.0.0git (https://github.com/Michael137/llvm-project.git fb326019769e448f9effe3c8b10e6df8e7e9ce71)")
              DW_AT_language    (DW_LANG_C_plus_plus_11)
              DW_AT_name        ("/Users/michaelbuch/Git/llvm-worktrees/playground/lldb/test/API/lang/cpp/modules-import/main.cpp")
              DW_AT_LLVM_sysroot        ("/path/to/sdk")
              DW_AT_APPLE_sdk   ("some.sdk")
              DW_AT_str_offsets_base    (0x00000008)
              DW_AT_stmt_list   (0x0000003d)
              DW_AT_comp_dir    ("/Users/michaelbuch/Git/llvm-worktrees/playground/lldb-test-build.noindex/lang/cpp/modules-import/TestCXXModulesImport.test_expr_dsym")
              DW_AT_low_pc      (0x0000000100003f88)
              DW_AT_high_pc     (0x0000000100003fa8)
              DW_AT_addr_base   (0x00000008)
```

Note that the first CU has a `DW_AT_GNU_dwo_id` but there's no associated "DWO file" (which in the `gmodules` case is a CU with a matching `DW_AT_GNU_dwo_id` and a path to the `.pcm` in `DW_AT_dwo_name`).

AFAIU, this happens when we compile with `-gmodules`, followed by `dsymutil` (which, mostly (?), undoes `-gmodules`). But we're left with a `DW_AT_GNU_dwo_id` in the main CU. So with the new verifier check added in this PR:
```
if (DU->getDWOId() && DU->getUnitDIE() == NonSkeletonUnitDie) {
```
, we do have a `getDWOId`, but `DU->DWO` is empty, because there is none. And we claim to have failed to load the `.dwo` file.

Any idea on the best way forward here? @adrian-prantl @clayborg 

Maybe `dsymutil` shouldn't be cloning over the `DW_AT_GNU_dwo_id`? Locally that fixed things for me.

This new verifier check is causing a lot of our modules builds to fail.

https://github.com/llvm/llvm-project/pull/101775


More information about the llvm-commits mailing list