Skip to content

Commit c8d034a

Browse files
authored
Revert "[lldb] Add count for errors of DWO files in statistics and combine DWO file count functions" (llvm#156777)
Reverts llvm#155023 The PR tests passed, but it failed in the CI. Reverting to give time to investigate.
1 parent 1959e12 commit c8d034a

File tree

8 files changed

+27
-177
lines changed

8 files changed

+27
-177
lines changed

lldb/include/lldb/Symbol/SymbolFile.h

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -488,16 +488,13 @@ class SymbolFile : public PluginInterface {
488488
return false;
489489
};
490490

491-
/// Retrieves statistics about DWO files associated with this symbol file.
492-
/// This function returns a DWOStats struct containing:
493-
/// - The number of successfully loaded/parsed DWO files.
494-
/// - The total number of DWO files encountered.
495-
/// - The number of DWO CUs that failed to load due to errors.
496-
/// If this symbol file does not support DWO files, all counts will be zero.
491+
/// Get number of loaded/parsed DWO files. This is emitted in "statistics
492+
/// dump"
497493
///
498494
/// \returns
499-
/// A DWOStats struct with loaded, total, and error counts for DWO files.
500-
virtual DWOStats GetDwoStats() { return {}; }
495+
/// A pair containing (loaded_dwo_count, total_dwo_count). If this
496+
/// symbol file doesn't support DWO files, both counts will be 0.
497+
virtual std::pair<uint32_t, uint32_t> GetDwoFileCounts() { return {0, 0}; }
501498

502499
virtual lldb::TypeSP
503500
MakeType(lldb::user_id_t uid, ConstString name,

lldb/include/lldb/Target/Statistics.h

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -123,19 +123,6 @@ struct StatsSuccessFail {
123123
uint32_t failures = 0;
124124
};
125125

126-
/// Holds statistics about DWO (Debug With Object) files.
127-
struct DWOStats {
128-
uint32_t loaded_dwo_file_count = 0;
129-
uint32_t dwo_file_count = 0;
130-
uint32_t dwo_error_count = 0;
131-
132-
DWOStats operator+(const DWOStats &rhs) const {
133-
return DWOStats{loaded_dwo_file_count + rhs.loaded_dwo_file_count,
134-
dwo_file_count + rhs.dwo_file_count,
135-
dwo_error_count + rhs.dwo_error_count};
136-
}
137-
};
138-
139126
/// A class that represents statistics for a since lldb_private::Module.
140127
struct ModuleStats {
141128
llvm::json::Value ToJSON() const;
@@ -166,7 +153,8 @@ struct ModuleStats {
166153
bool symtab_stripped = false;
167154
bool debug_info_had_variable_errors = false;
168155
bool debug_info_had_incomplete_types = false;
169-
DWOStats dwo_stats;
156+
uint32_t dwo_file_count = 0;
157+
uint32_t loaded_dwo_file_count = 0;
170158
};
171159

172160
struct ConstStringStats {

lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4502,8 +4502,9 @@ void SymbolFileDWARF::GetCompileOptions(
45024502
}
45034503
}
45044504

4505-
DWOStats SymbolFileDWARF::GetDwoStats() {
4506-
DWOStats stats;
4505+
std::pair<uint32_t, uint32_t> SymbolFileDWARF::GetDwoFileCounts() {
4506+
uint32_t total_dwo_count = 0;
4507+
uint32_t loaded_dwo_count = 0;
45074508

45084509
DWARFDebugInfo &info = DebugInfo();
45094510
const size_t num_cus = info.GetNumUnits();
@@ -4516,21 +4517,16 @@ DWOStats SymbolFileDWARF::GetDwoStats() {
45164517
if (!dwarf_cu->GetDWOId().has_value())
45174518
continue;
45184519

4519-
stats.dwo_file_count++;
4520+
total_dwo_count++;
45204521

45214522
// If we have a DWO symbol file, that means we were able to successfully
45224523
// load it.
45234524
SymbolFile *dwo_symfile =
45244525
dwarf_cu->GetDwoSymbolFile(/*load_all_debug_info=*/false);
45254526
if (dwo_symfile) {
4526-
stats.loaded_dwo_file_count++;
4527+
loaded_dwo_count++;
45274528
}
4528-
4529-
// Check if this unit has a DWO load error, false by default.
4530-
const Status &dwo_error = dwarf_cu->GetDwoError();
4531-
if (dwo_error.Fail())
4532-
stats.dwo_error_count++;
45334529
}
45344530

4535-
return stats;
4531+
return {loaded_dwo_count, total_dwo_count};
45364532
}

lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -283,11 +283,10 @@ class SymbolFileDWARF : public SymbolFileCommon {
283283
bool GetSeparateDebugInfo(StructuredData::Dictionary &d, bool errors_only,
284284
bool load_all_debug_info = false) override;
285285

286-
/// Gets statistics about dwo files associated with this symbol file.
287-
/// For split-dwarf files, this reports the counts for successfully loaded DWO
288-
/// CUs, total DWO CUs, and the number of DWO CUs with loading errors.
289-
/// For non-split-dwarf files, this reports 0 for all.
290-
DWOStats GetDwoStats() override;
286+
// Gets a pair of loaded and total dwo file counts.
287+
// For split-dwarf files, this reports the counts for successfully loaded DWO
288+
// CUs and total DWO CUs. For non-split-dwarf files, this reports 0 for both.
289+
std::pair<uint32_t, uint32_t> GetDwoFileCounts() override;
291290

292291
DWARFContext &GetDWARFContext() { return m_context; }
293292

lldb/source/Target/Statistics.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,8 @@ json::Value ModuleStats::ToJSON() const {
7373
debug_info_had_incomplete_types);
7474
module.try_emplace("symbolTableStripped", symtab_stripped);
7575
module.try_emplace("symbolTableSymbolCount", symtab_symbol_count);
76-
module.try_emplace("dwoFileCount", dwo_stats.dwo_file_count);
77-
module.try_emplace("loadedDwoFileCount", dwo_stats.loaded_dwo_file_count);
78-
module.try_emplace("dwoErrorCount", dwo_stats.dwo_error_count);
76+
module.try_emplace("dwoFileCount", dwo_file_count);
77+
module.try_emplace("loadedDwoFileCount", loaded_dwo_file_count);
7978

8079
if (!symbol_locator_time.map.empty()) {
8180
json::Object obj;
@@ -325,7 +324,8 @@ llvm::json::Value DebuggerStats::ReportStatistics(
325324
uint32_t num_modules_with_incomplete_types = 0;
326325
uint32_t num_stripped_modules = 0;
327326
uint32_t symtab_symbol_count = 0;
328-
DWOStats total_dwo_stats;
327+
uint32_t total_loaded_dwo_file_count = 0;
328+
uint32_t total_dwo_file_count = 0;
329329
for (size_t image_idx = 0; image_idx < num_modules; ++image_idx) {
330330
Module *module = target != nullptr
331331
? target->GetImages().GetModuleAtIndex(image_idx).get()
@@ -357,9 +357,10 @@ llvm::json::Value DebuggerStats::ReportStatistics(
357357
for (const auto &symbol_module : symbol_modules.Modules())
358358
module_stat.symfile_modules.push_back((intptr_t)symbol_module.get());
359359
}
360-
DWOStats current_dwo_stats = sym_file->GetDwoStats();
361-
module_stat.dwo_stats = module_stat.dwo_stats + current_dwo_stats;
362-
total_dwo_stats = total_dwo_stats + current_dwo_stats;
360+
std::tie(module_stat.loaded_dwo_file_count, module_stat.dwo_file_count) =
361+
sym_file->GetDwoFileCounts();
362+
total_dwo_file_count += module_stat.dwo_file_count;
363+
total_loaded_dwo_file_count += module_stat.loaded_dwo_file_count;
363364
module_stat.debug_info_index_loaded_from_cache =
364365
sym_file->GetDebugInfoIndexWasLoadedFromCache();
365366
if (module_stat.debug_info_index_loaded_from_cache)
@@ -434,9 +435,8 @@ llvm::json::Value DebuggerStats::ReportStatistics(
434435
{"totalDebugInfoEnabled", num_debug_info_enabled_modules},
435436
{"totalSymbolTableStripped", num_stripped_modules},
436437
{"totalSymbolTableSymbolCount", symtab_symbol_count},
437-
{"totalLoadedDwoFileCount", total_dwo_stats.loaded_dwo_file_count},
438-
{"totalDwoFileCount", total_dwo_stats.dwo_file_count},
439-
{"totalDwoErrorCount", total_dwo_stats.dwo_error_count},
438+
{"totalLoadedDwoFileCount", total_loaded_dwo_file_count},
439+
{"totalDwoFileCount", total_dwo_file_count},
440440
};
441441

442442
if (include_targets) {

lldb/test/API/commands/statistics/basic/TestStats.py

Lines changed: 0 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
import glob
21
import json
32
import os
43
import re
5-
import shutil
64

75
import lldb
86
from lldbsuite.test.decorators import *
@@ -181,7 +179,6 @@ def test_default_no_run(self):
181179
"totalDebugInfoParseTime",
182180
"totalDwoFileCount",
183181
"totalLoadedDwoFileCount",
184-
"totalDwoErrorCount",
185182
]
186183
self.verify_keys(debug_stats, '"debug_stats"', debug_stat_keys, None)
187184
if self.getPlatform() != "windows":
@@ -294,7 +291,6 @@ def test_default_with_run(self):
294291
"totalDebugInfoParseTime",
295292
"totalDwoFileCount",
296293
"totalLoadedDwoFileCount",
297-
"totalDwoErrorCount",
298294
]
299295
self.verify_keys(debug_stats, '"debug_stats"', debug_stat_keys, None)
300296
stats = debug_stats["targets"][0]
@@ -335,7 +331,6 @@ def test_memory(self):
335331
"totalDebugInfoByteSize",
336332
"totalDwoFileCount",
337333
"totalLoadedDwoFileCount",
338-
"totalDwoErrorCount",
339334
]
340335
self.verify_keys(debug_stats, '"debug_stats"', debug_stat_keys, None)
341336

@@ -390,7 +385,6 @@ def test_modules(self):
390385
"totalDebugInfoByteSize",
391386
"totalDwoFileCount",
392387
"totalLoadedDwoFileCount",
393-
"totalDwoErrorCount",
394388
]
395389
self.verify_keys(debug_stats, '"debug_stats"', debug_stat_keys, None)
396390
stats = debug_stats["targets"][0]
@@ -413,7 +407,6 @@ def test_modules(self):
413407
"symbolTableSavedToCache",
414408
"dwoFileCount",
415409
"loadedDwoFileCount",
416-
"dwoErrorCount",
417410
"triple",
418411
"uuid",
419412
]
@@ -504,7 +497,6 @@ def test_breakpoints(self):
504497
"totalDebugInfoByteSize",
505498
"totalDwoFileCount",
506499
"totalLoadedDwoFileCount",
507-
"totalDwoErrorCount",
508500
]
509501
self.verify_keys(debug_stats, '"debug_stats"', debug_stat_keys, None)
510502
target_stats = debug_stats["targets"][0]
@@ -663,113 +655,6 @@ def test_dwp_dwo_file_count(self):
663655
self.assertEqual(debug_stats["totalDwoFileCount"], 2)
664656
self.assertEqual(debug_stats["totalLoadedDwoFileCount"], 2)
665657

666-
@add_test_categories(["dwo"])
667-
def test_dwo_missing_error_stats(self):
668-
"""
669-
Test that DWO missing errors are reported correctly in statistics.
670-
This test:
671-
1) Builds a program with split DWARF (.dwo files)
672-
2) Delete all two .dwo files
673-
3) Verify that 2 DWO errors are reported in statistics
674-
"""
675-
da = {
676-
"CXX_SOURCES": "dwo_error_main.cpp dwo_error_foo.cpp",
677-
"EXE": self.getBuildArtifact("a.out"),
678-
}
679-
# -gsplit-dwarf creates separate .dwo files,
680-
# Expected output: dwo_error_main.dwo (contains main) and dwo_error_foo.dwo (contains foo struct/function)
681-
self.build(dictionary=da, debug_info="dwo")
682-
self.addTearDownCleanup(dictionary=da)
683-
exe = self.getBuildArtifact("a.out")
684-
685-
# Remove the two .dwo files to trigger a DWO load error
686-
dwo_files = glob.glob(self.getBuildArtifact("*.dwo"))
687-
for dwo_file in dwo_files:
688-
os.rename(dwo_file, dwo_file + ".bak")
689-
690-
target = self.createTestTarget(file_path=exe)
691-
debug_stats = self.get_stats()
692-
693-
# Check DWO load error statistics are reported
694-
self.assertIn("totalDwoErrorCount", debug_stats)
695-
self.assertEqual(debug_stats["totalDwoErrorCount"], 2)
696-
697-
# Since there's only one module, module stats should have the same count as total count
698-
self.assertIn("dwoErrorCount", debug_stats["modules"][0])
699-
self.assertEqual(debug_stats["modules"][0]["dwoErrorCount"], 2)
700-
701-
# Restore the original .dwo file
702-
for dwo_file in dwo_files:
703-
os.rename(dwo_file + ".bak", dwo_file)
704-
705-
@add_test_categories(["dwo"])
706-
def test_dwo_id_mismatch_error_stats(self):
707-
"""
708-
Test that DWO ID mismatch errors are reported correctly in statistics.
709-
This test:
710-
1) Builds a program with split DWARF (.dwo files)
711-
2) Change one of the source file content and rebuild
712-
3) Replace the new .dwo file with the original one to create a DWO ID mismatch
713-
4) Verifies that a DWO error is reported in statistics
714-
5) Restores the original source file
715-
"""
716-
da = {
717-
"CXX_SOURCES": "dwo_error_main.cpp dwo_error_foo.cpp",
718-
"EXE": self.getBuildArtifact("a.out"),
719-
}
720-
# -gsplit-dwarf creates separate .dwo files,
721-
# Expected output: dwo_error_main.dwo (contains main) and dwo_error_foo.dwo (contains foo struct/function)
722-
self.build(dictionary=da, debug_info="dwo")
723-
self.addTearDownCleanup(dictionary=da)
724-
exe = self.getBuildArtifact("a.out")
725-
726-
# Find and make a backup of the original .dwo file
727-
dwo_files = glob.glob(self.getBuildArtifact("*.dwo"))
728-
729-
original_dwo_file = dwo_files[1]
730-
original_dwo_backup = original_dwo_file + ".bak"
731-
shutil.copy2(original_dwo_file, original_dwo_backup)
732-
733-
target = self.createTestTarget(file_path=exe)
734-
initial_stats = self.get_stats()
735-
self.assertIn("totalDwoErrorCount", initial_stats)
736-
self.assertEqual(initial_stats["totalDwoErrorCount"], 0)
737-
self.dbg.DeleteTarget(target)
738-
739-
# Get the original file size before modification
740-
source_file_path = self.getSourcePath("dwo_error_foo.cpp")
741-
original_size = os.path.getsize(source_file_path)
742-
743-
try:
744-
# Modify the source code and rebuild
745-
with open(source_file_path, "a") as f:
746-
f.write("\n void additional_foo(){}\n")
747-
748-
# Rebuild and replace the new .dwo file with the original one
749-
self.build(dictionary=da, debug_info="dwo")
750-
shutil.copy2(original_dwo_backup, original_dwo_file)
751-
752-
# Create a new target and run to a breakpoint to force DWO file loading
753-
target = self.createTestTarget(file_path=exe)
754-
debug_stats = self.get_stats()
755-
756-
# Check that DWO load error statistics are reported
757-
self.assertIn("totalDwoErrorCount", debug_stats)
758-
self.assertEqual(debug_stats["totalDwoErrorCount"], 1)
759-
760-
# Since there's only one module, module stats should have the same count as total count
761-
self.assertIn("dwoErrorCount", debug_stats["modules"][0])
762-
self.assertEqual(debug_stats["modules"][0]["dwoErrorCount"], 1)
763-
764-
finally:
765-
# Remove the appended content
766-
with open(source_file_path, "a") as f:
767-
f.truncate(original_size)
768-
769-
# Restore the original .dwo file
770-
if os.path.exists(original_dwo_backup):
771-
os.unlink(original_dwo_backup)
772-
773658
@skipUnlessDarwin
774659
@no_debug_info_test
775660
def test_dsym_binary_has_symfile_in_stats(self):

lldb/test/API/commands/statistics/basic/dwo_error_foo.cpp

Lines changed: 0 additions & 10 deletions
This file was deleted.

lldb/test/API/commands/statistics/basic/dwo_error_main.cpp

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)