[Lldb-commits] [lldb] [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. (PR #90663)

Zequan Wu via lldb-commits lldb-commits at lists.llvm.org
Wed May 15 13:55:16 PDT 2024


ZequanWu wrote:

I had a fix to this:  Let `SymbolFileDWARF::GetForwardDeclCompilerTypeToDIE` do the same as `SymbolFileDWARF::GetUniqueDWARFASTTypeMap`: inquery SymbolFileDWARFDebugMap first to get the shared underlying SymbolFile so the map is shared among multiple SymbolFileDWARF. It's here: https://github.com/ZequanWu/llvm-project/commit/2172c660821e273205e7ad3a64eb7f3623b21606

It fixes those failed tests shown on the macos bot. However, I noticed that lldb crashes on three tests related to clang module (they also crashes when the fix is not given, but not crash after reverting this PR):
```
Unresolved Tests (3):
  lldb-api :: commands/expression/import-std-module/deque-dbg-info-content/TestDbgInfoContentDequeFromStdModule.py
  lldb-api :: commands/expression/import-std-module/list-dbg-info-content/TestDbgInfoContentListFromStdModule.py
  lldb-api :: commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py
```

I found it's the following commands causing crash.
```
$ out/cmake/bin/lldb out/cmake/lldb-test-build.noindex/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.test_dwarf/a.out -o "settings set symbols.clang-modules-cache-path /Users/zequanwu/work/llvm/out/cmake/lldb-test-build.noindex/module-cache-lldb/lldb-api" -o "settings set target.import-std-module true" -o "b 9" -o "r"  -o "expr a"
(lldb) target create "../cmake/lldb-test-build.noindex/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.test_dwarf/a.out"
Current executable set to '/Users/zequanwu/work/llvm/out/cmake/lldb-test-build.noindex/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.test_dwarf/a.out' (arm64).
(lldb) settings set symbols.clang-modules-cache-path /Users/zequanwu/work/llvm/out/cmake/lldb-test-build.noindex/module-cache-lldb/lldb-api
(lldb) settings set target.import-std-module true
(lldb) b 9
Breakpoint 1: where = a.out`main + 104 at main.cpp:9:3, address = 0x0000000100002508
(lldb) r
Process 12273 launched: '/Users/zequanwu/work/llvm/out/cmake/lldb-test-build.noindex/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.test_dwarf/a.out' (arm64)
Process 12273 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
    frame #0: 0x0000000100002508 a.out`main(argc=1, argv=0x000000016fdff428) at main.cpp:9:3
   6
   7    int main(int argc, char **argv) {
   8      std::vector<Foo> a = {{3}, {1}, {2}};
-> 9      return 0; // Set break point at this line.
   10   }
(lldb) expr a
Assertion failed: (0 && "Invalid SLocOffset or bad function choice"), function getFileIDLoaded, file SourceManager.cpp, line 865.
LLDB diagnostics will be written to /var/folders/jf/zylbx28s05n0d_xwqdf5jnrc00lnhs/T/diagnostics-512963
Please include the directory content when filing a bug report
[1]    12267 abort      bin/lldb  -o  -o "settings set target.import-std-module true" -o "b 9" -o "r"
```

The clang module in `out/cmake/lldb-test-build.noindex/module-cache-lldb/lldb-api` was created when running `check-lldb`. If I delete the clang modules in that directory and run the above command again, it no longer crashes and able to give correct result (after the first run, a new clang module is created in the directory. Following runs of the above commands no longer crashes). So, it looks like related to stale clang module. If I use debug built lldb, it no longer crashes. Do you have any idea how to debug this crash? I'm not familiar with how clang module interact with type completion etc.

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


More information about the lldb-commits mailing list