This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Use CompileUnit::ResolveSymbolContext in SymbolFileDWARF
ClosedPublic

Authored by kimanh on Mar 14 2021, 11:19 PM.

Details

Summary

SymbolFileDWARF::ResolveSymbolContext is currently unaware that in DWARF5 the primary file is specified at file index 0. As a result it misses to correctly resolve the symbol context for the primary file when DWARF5 debug data is used and the primary file is only specified at index 0.

This change makes use of CompileUnit::ResolveSymbolContext to resolve the symbol context. The ResolveSymbolContext in CompileUnit has been previously already updated to reflect changes in DWARF5
and contains a more readable version. It can resolve more, but will also do a bit more work than
SymbolFileDWARF::ResolveSymbolContext (getting the Module, and going through SymbolFileDWARF::ResolveSymbolContextForAddress), however, it's mostly directed by $resolve_scope
what will be resolved, and ensures that code is easier to maintain if there's only one path.

Diff Detail

Event Timeline

kimanh created this revision.Mar 14 2021, 11:19 PM
kimanh requested review of this revision.Mar 14 2021, 11:19 PM
labath accepted this revision.Mar 17 2021, 7:41 AM

I remember seeing this that this (duplicated) code was not dwarf5 ready, but I did not want to change it without understanding when it actually gets used. It looks like you've found that. Thanks for doing that, and for removing the duplication.

lldb/test/Shell/SymbolFile/DWARF/dwarf5-debug_line-file-index.s
99

I was puzzled by this line as the string 3 is nowhere to be found. I take it this was manually reduced? If so, I think you should be able to delete the entire subprogram and base_type tags (and the relevant abbreviations), as that is not necessary for the line tables to work.

This revision is now accepted and ready to land.Mar 17 2021, 7:41 AM
kimanh updated this revision to Diff 331547.Mar 18 2021, 6:37 AM

Removing subprogram and base_type tags (as they are not needed for the test)

kimanh marked an inline comment as done.Mar 18 2021, 6:46 AM

Thanks a lot for the review Pavel! I've updated the test. If it looks fine like this, could you help me to commit this change?

lldb/test/Shell/SymbolFile/DWARF/dwarf5-debug_line-file-index.s
99

Thanks for the guidance here! Yes, that's correct, I've manually reduced it but wasn't sure what else I could safely remove. I've now removed the subprogram parts, and the base_type tags. Hope that looks better now!

This revision was landed with ongoing or failed builds.Mar 22 2021, 12:45 AM
This revision was automatically updated to reflect the committed changes.

Thanks a lot for the review Pavel! I've updated the test. If it looks fine like this, could you help me to commit this change?

Done. Thanks for the patch.

lldb/test/Shell/SymbolFile/DWARF/dwarf5-debug_line-file-index.s
99

This looks better. Thanks. FTR, I don't think it's necessary to produce absolutely minimal inputs (though the easy-to-do reductions are definitely nice to have). I just don't want to have invalid inputs (like these missing cross-references) in the test file (unless of course, that is what you're testing, but that's not the case here).

kimanh marked an inline comment as done.Mar 22 2021, 1:30 AM

Unfortunately the test seems to run and fail on the ARM. I thoughty adding REQUIRES: x85 would skip no x86 ones, but maybe I did something wrong.

lldb/test/Shell/SymbolFile/DWARF/dwarf5-debug_line-file-index.s
3

I can see that my CL is failing on the ARM. From looking at the other tests I thought this line would prevent it from running on the ARM, but apparently it doesn't. How can I fix this?

https://lab.llvm.org/buildbot/#/builders/17/builds/5500

REQUIRES: x86 disables the test in those builds, which don't have the X86 target enabled (in the build config). That is exactly what we want here -- the test is not actually running this code, so it should succeed regardless of the host architecture. It's working fine on aarch64, for instance (http://lab.llvm.org:8011/#/builders/96/builds/5891). I'm not sure what's the deal with the arm bot (cc @omjavaid). It could be some 32-bit thing. I'm going to try to get a better error message first, and then we'll see what to do next...

Thanks for having a look, and for the explanation! Please let me know if I can do anything to help debugging this!

REQUIRES: x86 disables the test in those builds, which don't have the X86 target enabled (in the build config). That is exactly what we want here -- the test is not actually running this code, so it should succeed regardless of the host architecture. It's working fine on aarch64, for instance (http://lab.llvm.org:8011/#/builders/96/builds/5891). I'm not sure what's the deal with the arm bot (cc @omjavaid). It could be some 32-bit thing. I'm going to try to get a better error message first, and then we'll see what to do next...

This is crashing LLDB on arm linux I have reported a bug and marked it xfail. I ll look for a fix later.

REQUIRES: x86 disables the test in those builds, which don't have the X86 target enabled (in the build config). That is exactly what we want here -- the test is not actually running this code, so it should succeed regardless of the host architecture. It's working fine on aarch64, for instance (http://lab.llvm.org:8011/#/builders/96/builds/5891). I'm not sure what's the deal with the arm bot (cc @omjavaid). It could be some 32-bit thing. I'm going to try to get a better error message first, and then we'll see what to do next...

This is crashing LLDB on arm linux I have reported a bug and marked it xfail. I ll look for a fix later.

Interesting. Crashing actually explains the test output. Thanks for disabling that test. The issue seems to be arm specific as I couldn't reproduce this on i386 lldb (and that makes it pretty weird).

Do you have a backtrace handy by any chance?

It seems as if it's the same for windows (I don't have windows unfortunately to check):

https://lab.llvm.org/buildbot/#/builders/83/builds/4884

REQUIRES: x86 disables the test in those builds, which don't have the X86 target enabled (in the build config). That is exactly what we want here -- the test is not actually running this code, so it should succeed regardless of the host architecture. It's working fine on aarch64, for instance (http://lab.llvm.org:8011/#/builders/96/builds/5891). I'm not sure what's the deal with the arm bot (cc @omjavaid). It could be some 32-bit thing. I'm going to try to get a better error message first, and then we'll see what to do next...

This is crashing LLDB on arm linux I have reported a bug and marked it xfail. I ll look for a fix later.

Interesting. Crashing actually explains the test output. Thanks for disabling that test. The issue seems to be arm specific as I couldn't reproduce this on i386 lldb (and that makes it pretty weird).

Do you have a backtrace handy by any chance?

I have created http://llvm.org/pr49678. Stack trace attached to pr.

The backtrace was very helpful. Thanks.

I think I've found the problem and I believe it should be fixed by 10d54e2f8d (though I couldn't actually check right now).

The problem was (sort of) in the incorrect reduction in the test input, which that patch should fix. That said, the incorrect input still should not have caused a crash...

I'm very sorry for the incorrect reduction, and thanks for fixing this!