-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[lldb] Add count for number of DWO files loaded in statistics #144424
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
57483ee
3292b89
a90294d
9b96648
d3e89b7
ef1c131
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,6 +33,37 @@ static void EmplaceSafeString(llvm::json::Object &obj, llvm::StringRef key, | |
| obj.try_emplace(key, llvm::json::fixUTF8(str)); | ||
| } | ||
|
|
||
| static void UpdateDwoFileCounts(SymbolFile *sym_file, | ||
| uint32_t &total_dwo_file_count, | ||
| uint32_t &total_loaded_dwo_file_count) { | ||
| // Count DWO files from this symbol file using GetSeparateDebugInfo | ||
| // For DWP files, this increments counts for both total and successfully | ||
| // loaded DWO CUs. For non split-dwarf files, these counts should not change | ||
| StructuredData::Dictionary separate_debug_info; | ||
| if (sym_file->GetSeparateDebugInfo(separate_debug_info, | ||
| /*errors_only=*/false, | ||
| /*load_all_debug_info*/ false)) { | ||
|
||
| llvm::StringRef type; | ||
| if (separate_debug_info.GetValueForKeyAsString("type", type) && | ||
| type == "dwo") { | ||
| StructuredData::Array *files; | ||
| if (separate_debug_info.GetValueForKeyAsArray("separate-debug-info-files", | ||
| files)) { | ||
| files->ForEach([&](StructuredData::Object *obj) { | ||
| if (auto dict = obj->GetAsDictionary()) { | ||
| total_dwo_file_count++; | ||
|
|
||
| bool loaded = false; | ||
| if (dict->GetValueForKeyAsBoolean("loaded", loaded) && loaded) | ||
|
||
| total_loaded_dwo_file_count++; | ||
| } | ||
| return true; | ||
| }); | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| json::Value StatsSuccessFail::ToJSON() const { | ||
| return json::Object{{"successes", successes}, {"failures", failures}}; | ||
| } | ||
|
|
@@ -322,6 +353,8 @@ llvm::json::Value DebuggerStats::ReportStatistics( | |
| uint32_t num_modules_with_incomplete_types = 0; | ||
| uint32_t num_stripped_modules = 0; | ||
| uint32_t symtab_symbol_count = 0; | ||
| uint32_t total_loaded_dwo_file_count = 0; | ||
| uint32_t total_dwo_file_count = 0; | ||
| for (size_t image_idx = 0; image_idx < num_modules; ++image_idx) { | ||
| Module *module = target != nullptr | ||
| ? target->GetImages().GetModuleAtIndex(image_idx).get() | ||
|
|
@@ -353,6 +386,8 @@ llvm::json::Value DebuggerStats::ReportStatistics( | |
| for (const auto &symbol_module : symbol_modules.Modules()) | ||
| module_stat.symfile_modules.push_back((intptr_t)symbol_module.get()); | ||
| } | ||
| UpdateDwoFileCounts(sym_file, total_dwo_file_count, | ||
| total_loaded_dwo_file_count); | ||
|
||
| module_stat.debug_info_index_loaded_from_cache = | ||
| sym_file->GetDebugInfoIndexWasLoadedFromCache(); | ||
| if (module_stat.debug_info_index_loaded_from_cache) | ||
|
|
@@ -427,6 +462,8 @@ llvm::json::Value DebuggerStats::ReportStatistics( | |
| {"totalDebugInfoEnabled", num_debug_info_enabled_modules}, | ||
| {"totalSymbolTableStripped", num_stripped_modules}, | ||
| {"totalSymbolTableSymbolCount", symtab_symbol_count}, | ||
| {"totalLoadedDwoFileCount", total_loaded_dwo_file_count}, | ||
| {"totalDwoFileCount", total_dwo_file_count}, | ||
| }; | ||
|
|
||
| if (include_targets) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| // Helper that the lldb command `statistics dump` works in split-dwarf mode. | ||
|
|
||
| struct Baz { | ||
| int x; | ||
| bool y; | ||
| }; | ||
|
|
||
| void baz() { | ||
| Baz b; | ||
| b.x = 1; | ||
| b.y = true; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| // Test that the lldb command `statistics dump` works. | ||
|
|
||
| void baz(); | ||
| int main(void) { | ||
| baz(); | ||
| return 0; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would not recommend calling
GetSeparateDebugInfoAPI for this task.GetSeparateDebugInfoAPI constructsStructuredData::DictionaryJSON style objects internally which is not cheap (I have seen profile traces that indicate constructingStructuredData::Dictionaryas hot paths). This can get worse considering we are usingstatistics dumpin lldb session logging by default. (means we are paying the cost every time).If we want to reuse it, I would suggest refactoring and reuse the necessary underlying implementation without extra expensive burdens.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, I'll make a separate API for getting the counts here without constructing
StructuredData::Dictionary.