[Lldb-commits] [lldb] [lldb] Add count for number of DWO files loaded in statistics (PR #144424)

via lldb-commits lldb-commits at lists.llvm.org
Wed Jun 18 10:00:49 PDT 2025


================
@@ -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)
----------------
jeffreytan81 wrote:

I am not sure this is correct for dwp. In dwp scenario, there is one dwp file for the entire module (instead of one dwo for each compile unit), so if you check the code here https://github.com/llvm/llvm-project/blob/main/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp#L4185-L4194, it will mark that dwo as "loaded if `SymbolFileDWARFDwo` exists, which will happen for all dwo files during dwp scenarios which can be wrong -- if you have .debug_names, lldb won't need to parse all debug info during startup but parse/load lazily so only partial of dwp are parsed while the current implementation reports all parsed/loaded. This is probably a bug in original `SymbolFileDWARF::GetSeparateDebugInfo` implementation though, cc @zhyty

https://github.com/llvm/llvm-project/pull/144424


More information about the lldb-commits mailing list