This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Allow SymbolFileDWARFDebugMap to register multiple compile units
ClosedPublic

Authored by augusto2112 on Oct 17 2022, 2:42 PM.

Details

Summary

Currently, SymbolFileDWARFDebugMap works on the assumption that there is
only one compile unit per object file. This patch documents this
limitation (when using the general SymbolFile API), and allows users of
the concrete SymbolFileDWARFDebugMap class to find out about these extra
compile units.

Diff Detail

Event Timeline

augusto2112 created this revision.Oct 17 2022, 2:42 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 17 2022, 2:42 PM
augusto2112 requested review of this revision.Oct 17 2022, 2:42 PM
Herald added a project: Restricted Project. · View Herald Transcript

Remote extra semi-colon

labath added a subscriber: labath.Oct 17 2022, 10:40 PM
labath added inline comments.
lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
55

This isn't a valid requirement for general code. It essentially means that this code will only run for the first compile unit in an elf file (or, if type units are in use, it may not run at all).

Could we add a test for this that either uses full-LTO in an API test or some assembler code and and lldb-test test?

lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
55

Maybe it's better to filter out skeleton units specifically instead? (If that's what the condition is for)

lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
651

is std::find() shorter here?

1274–1281

is std::find() shorter / more readable?

lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
179

nit: convert these to ///

180

Why not only store a llvm::SmallVector<lldb::CompUnitSP, 1> and use the first element to store compile_unit_sp?

jdoerfert resigned from this revision.Oct 18 2022, 3:34 PM

Added test, changed DWARFCompileUnit::BuildAddressRangeTable to not stop looking at oso ranges at offset 0.

augusto2112 marked 6 inline comments as done.Oct 18 2022, 4:03 PM
augusto2112 added inline comments.
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
651

I think it'd be worse, because we're comparing pointers so we'd need to pass in a lambda, which would make things more confusing imo (ditto for the next comment).

aprantl added inline comments.Oct 18 2022, 4:30 PM
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
1277

This is technically a O(n^2) algorithm. What do you think about adding a SmallDenseMap<cu_id, cu_idx> into compile_unit_infos?

lldb/test/API/lang/c/full_lto_stepping/TestFullLtoStepping.py
2

I think this docstring looks copied&pasted?
test that debugging from object files with multiple compile units works.

14

You might want to mark the test as @skipUnlessDarwin since it's about debug maps.

27

If you use lldbutil.run_to_name_breakpoint I think you can delete most of the setup code?

augusto2112 marked an inline comment as done.

Add a map from compile unit id to index in vector.

aprantl accepted this revision.Oct 19 2022, 12:21 PM

LGTM, with two tiny new suggestions.

lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
179

IIUC, the common case is 1 unit (clang), 2 units (swift), n units (lto). Should we reserve 2 instead of one to cover the majority of use-cases?

181

nit: I think we should use the same size as above llvm::SmallDenseMap<uint64_t, uint64_t, 1>, just to keep them in sync?

This revision is now accepted and ready to land.Oct 19 2022, 12:21 PM

Updated default stack size of the cu containers