================ @@ -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) ---------------- qxy11 wrote:
This should work for DWP and correctly report the # of parsed CUs (see the unit test added `test_dwp_dwo_file_count` [here](https://github.com/llvm/llvm-project/blob/9b966482264b1c0188d474b013d1db7236da1448/lldb/test/API/commands/statistics/basic/TestStats.py#L618). My understanding is that each CU has its own `m_dwo` shared_ptr [object](https://github.com/llvm/llvm-project/blob/main/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp#L973) rather than there being a global DWP reference that's shared. It looks like the DWP file first gets loaded [here](https://github.com/llvm/llvm-project/blob/main/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp#L87), the specific DWO unit gets indexed [here](https://github.com/llvm/llvm-project/blob/main/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp#L92), and then only after the specific DWO data for the CU is parsed does `m_dwo` get [set](https://github.com/llvm/llvm-project/blob/main/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp#L146). So in the code for `GetSeparateDebugInfo` it should get the correct per-unit counts. https://github.com/llvm/llvm-project/pull/144424 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits