This is an archive of the discontinued LLVM Phabricator instance.

Cache the manual DWARF index out to the LLDB cache directory when the LLDB index cache is enabled.
ClosedPublic

Authored by clayborg on Dec 17 2021, 10:18 AM.

Details

Summary

This patch add the ability to cache the manual DWARF indexing results to disk for faster subsequent debug sessions. Manual DWARF indexing is time consuming and causes all DWARF to be fully parsed and indexed each time you debug a binary that doesn't have an acceptable accelerator table. Acceptable accelerator tables include .debug_names in DWARF5 or Apple accelerator tables.

This patch breaks up testing by testing all of the encoding and decoding of required C++ objects in a gtest unit test, and then has a test to verify the debug info cache is generated correctly.

This patch also adds the ability to track when a symbol table or DWARF index is loaded or saved to the cache in the "statistics dump" command. This is essential to know in statistics as it can help explain why a debug session was slower or faster than expected.

Diff Detail

Event Timeline

clayborg created this revision.Dec 17 2021, 10:18 AM
clayborg requested review of this revision.Dec 17 2021, 10:18 AM
Herald added a project: Restricted Project. · View Herald Transcript
wallace added inline comments.Dec 17 2021, 1:17 PM
lldb/include/lldb/Symbol/Symtab.h
279–280

teach me C++. What is this? Is everything stored as part of a single 8 byte section in memory?

lldb/test/API/functionalities/module_cache/debug_index/TestDebugIndexCache.py
41–42

i'm curious, why do you do that?

clayborg added inline comments.Dec 19 2021, 6:15 PM
lldb/include/lldb/Symbol/Symtab.h
279–280

This allows one byte to contain 8 bools. If you have a integer based type (bool, char, int, long, long long, etc) then they can be split up into bits for more efficient storage. Since we were already using bitfields here, I continued to use then. If you specify more than 8 in a row, it will take up another byte.

lldb/test/API/functionalities/module_cache/debug_index/TestDebugIndexCache.py
41–42

It was for debugging. If you don't specify a "log_path" then nothing happens here. But handy as we add more things to the statistics to dump the stats when debugging tests. I can remove if needed.

labath added inline comments.Dec 20 2021, 6:14 AM
lldb/source/Plugins/SymbolFile/DWARF/DIERef.h
59

if m_dwo_num_valid then we shouldn't be checking/comparing m_dwo_num. Right now, it is kinda ok, as I don't think there's a way to obtain a non-zero m_dwo_num with m_dwo_num_valid = false, but it'd be better to not rely on that. You can just compare dwo_num() with rhs.dwo_num().

lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
31

The m_dwarf pointer also served as a flag indicating whether indexing has been done. If you want to keep it around, you'll need to introduce another field to track the indexing state.

lldb/unittests/SymbolFile/DWARF/DWARFIndexCachingTest.cpp
33–35

EXPECT_EQ(object, DIERef::Decode(data, &data_offset))

clayborg updated this revision to Diff 395440.Dec 20 2021, 7:19 AM

Address review comments.

clayborg marked 3 inline comments as done.Dec 20 2021, 7:20 AM
clayborg updated this revision to Diff 395441.Dec 20 2021, 7:21 AM

Remove commented out code.

This revision is now accepted and ready to land.Dec 21 2021, 11:38 AM
labath accepted this revision.Dec 22 2021, 4:06 AM

The problem was that (without accelerator tables) we would always have more than one cache file for a given module. I have now adjusted the test (daed479) to check for the presence of one _symtab_ index, but other solutions are possible as well. Feel free to change it to something else if you think they're better.

Thanks Pavel, that fix is good.