Skip to content
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
d978cb5
[lldb] Add count for errors of DWO files in statistics
zw3917 Aug 22, 2025
ed0530f
Merge branch 'main' of https://github.com/llvm/llvm-project
zw3917 Aug 22, 2025
04a0e16
Merge branch 'main' of https://github.com/llvm/llvm-project
zw3917 Aug 22, 2025
4416c22
Merge branch 'main' of https://github.com/llvm/llvm-project
zw3917 Aug 22, 2025
38cf0ea
Merge branch 'main' of https://github.com/llvm/llvm-project
zw3917 Aug 22, 2025
5370425
Merge remote-tracking branch 'zw3917/main'
zw3917 Aug 22, 2025
c9184c7
Merge branch 'main' into main
zw3917 Aug 22, 2025
6649b3d
Merge branch 'main' into main
zw3917 Aug 22, 2025
d526eac
Merge branch 'main' of https://github.com/llvm/llvm-project
zw3917 Aug 22, 2025
698bc9e
Combine DWO counting statistics into a single DWOStats struct
zw3917 Aug 24, 2025
f65f68d
Merge branch 'main' of https://github.com/llvm/llvm-project
zw3917 Aug 24, 2025
aa223d3
Merge branch 'llvm:main' into main
zw3917 Aug 24, 2025
460fcae
Merge branch 'main' of https://github.com/zw3917/llvm-project
zw3917 Aug 24, 2025
1e50bec
Merge branch 'llvm:main' into main
zw3917 Aug 28, 2025
ba2c528
Merge branch 'llvm:main' into main
zw3917 Aug 28, 2025
3881633
Reuse DWOStats in Statistics
zw3917 Aug 28, 2025
ec5dabd
[lldb]Reuse DWOStats in statistics
zw3917 Aug 28, 2025
76850ec
[lldb]Reuse DWOStats in statistics
zw3917 Aug 28, 2025
3f866ad
[format]Revert for auto-formatter
zw3917 Sep 2, 2025
1a703e7
Merge branch 'main' into main
zw3917 Sep 3, 2025
90d01ec
Merge branch 'main' into main
zw3917 Sep 3, 2025
033551d
[lldb]Update TestStas to include correct dwo stats
zw3917 Sep 3, 2025
3c6f745
Merge branch 'main' of https://github.com/zw3917/llvm-project
zw3917 Sep 3, 2025
805129f
Merge branch 'main' into main
zw3917 Sep 3, 2025
c4e4694
Merge branch 'main' into main
zw3917 Sep 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 29 additions & 26 deletions lldb/include/lldb/Symbol/SymbolFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -488,22 +488,26 @@ class SymbolFile : public PluginInterface {
return false;
};

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

virtual lldb::TypeSP
MakeType(lldb::user_id_t uid, ConstString name,
std::optional<uint64_t> byte_size, SymbolContextScope *context,
lldb::user_id_t encoding_uid,
Type::EncodingDataType encoding_uid_type, const Declaration &decl,
const CompilerType &compiler_qual_type,
Type::ResolveState compiler_type_resolve_state,
uint32_t opaque_payload = 0) = 0;
/// A DWOStats struct with loaded, total, and error counts for DWO files.
virtual DWOStats GetDwoStats() { return {}; }

virtual lldb::TypeSP MakeType(lldb::user_id_t uid, ConstString name,
std::optional<uint64_t> byte_size,
SymbolContextScope *context,
lldb::user_id_t encoding_uid,
Type::EncodingDataType encoding_uid_type,
const Declaration &decl,
const CompilerType &compiler_qual_type,
Type::ResolveState compiler_type_resolve_state,
uint32_t opaque_payload = 0) = 0;

virtual lldb::TypeSP CopyType(const lldb::TypeSP &other_type) = 0;

Expand Down Expand Up @@ -597,7 +601,7 @@ class SymbolFileCommon : public SymbolFile {
return m_debug_info_had_variable_errors;
}
void SetDebugInfoHadFrameVariableErrors() override {
m_debug_info_had_variable_errors = true;
m_debug_info_had_variable_errors = true;
}

/// This function is used to create types that belong to a SymbolFile. The
Expand All @@ -612,21 +616,20 @@ class SymbolFileCommon : public SymbolFile {
const CompilerType &compiler_qual_type,
Type::ResolveState compiler_type_resolve_state,
uint32_t opaque_payload = 0) override {
lldb::TypeSP type_sp (new Type(
uid, this, name, byte_size, context, encoding_uid,
encoding_uid_type, decl, compiler_qual_type,
compiler_type_resolve_state, opaque_payload));
m_type_list.Insert(type_sp);
return type_sp;
lldb::TypeSP type_sp(new Type(
uid, this, name, byte_size, context, encoding_uid, encoding_uid_type,
decl, compiler_qual_type, compiler_type_resolve_state, opaque_payload));
m_type_list.Insert(type_sp);
return type_sp;
}

lldb::TypeSP CopyType(const lldb::TypeSP &other_type) override {
// Make sure the real symbol file matches when copying types.
if (GetBackingSymbolFile() != other_type->GetSymbolFile())
// Make sure the real symbol file matches when copying types.
if (GetBackingSymbolFile() != other_type->GetSymbolFile())
return lldb::TypeSP();
lldb::TypeSP type_sp(new Type(*other_type));
m_type_list.Insert(type_sp);
return type_sp;
lldb::TypeSP type_sp(new Type(*other_type));
m_type_list.Insert(type_sp);
return type_sp;
}

protected:
Expand Down
16 changes: 14 additions & 2 deletions lldb/include/lldb/Target/Statistics.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,19 @@ struct StatsSuccessFail {
uint32_t failures = 0;
};

/// Holds statistics about DWO (Debug With Object) files.
struct DWOStats {
uint32_t loaded_dwo_file_count = 0;
uint32_t dwo_file_count = 0;
uint32_t dwo_error_count = 0;

DWOStats operator+(const DWOStats &rhs) const {
return DWOStats{loaded_dwo_file_count + rhs.loaded_dwo_file_count,
dwo_file_count + rhs.dwo_file_count,
dwo_error_count + rhs.dwo_error_count};
}
};

/// A class that represents statistics for a since lldb_private::Module.
struct ModuleStats {
llvm::json::Value ToJSON() const;
Expand Down Expand Up @@ -153,8 +166,7 @@ struct ModuleStats {
bool symtab_stripped = false;
bool debug_info_had_variable_errors = false;
bool debug_info_had_incomplete_types = false;
uint32_t dwo_file_count = 0;
uint32_t loaded_dwo_file_count = 0;
DWOStats dwo_stats;
};

struct ConstStringStats {
Expand Down
23 changes: 14 additions & 9 deletions lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
#include <cctype>
#include <cstring>

//#define ENABLE_DEBUG_PRINTF // COMMENT OUT THIS LINE PRIOR TO CHECKIN
// #define ENABLE_DEBUG_PRINTF // COMMENT OUT THIS LINE PRIOR TO CHECKIN

#ifdef ENABLE_DEBUG_PRINTF
#include <cstdio>
Expand Down Expand Up @@ -1716,7 +1716,7 @@ SymbolFileDWARF *SymbolFileDWARF::GetDIERefSymbolFile(const DIERef &die_ref) {
return this;

if (file_index) {
// We have a SymbolFileDWARFDebugMap, so let it find the right file
// We have a SymbolFileDWARFDebugMap, so let it find the right file
if (SymbolFileDWARFDebugMap *debug_map = GetDebugMapSymfile())
return debug_map->GetSymbolFileByOSOIndex(*file_index);

Expand All @@ -1725,7 +1725,8 @@ SymbolFileDWARF *SymbolFileDWARF::GetDIERefSymbolFile(const DIERef &die_ref) {
return GetDwpSymbolFile().get(); // DWP case

// Handle the .dwo file case correctly
return DebugInfo().GetUnitAtIndex(*die_ref.file_index())
return DebugInfo()
.GetUnitAtIndex(*die_ref.file_index())
->GetDwoSymbolFile(); // DWO case
}
return this;
Expand Down Expand Up @@ -4502,9 +4503,8 @@ void SymbolFileDWARF::GetCompileOptions(
}
}

std::pair<uint32_t, uint32_t> SymbolFileDWARF::GetDwoFileCounts() {
uint32_t total_dwo_count = 0;
uint32_t loaded_dwo_count = 0;
DWOStats SymbolFileDWARF::GetDwoStats() {
DWOStats stats;

DWARFDebugInfo &info = DebugInfo();
const size_t num_cus = info.GetNumUnits();
Expand All @@ -4517,16 +4517,21 @@ std::pair<uint32_t, uint32_t> SymbolFileDWARF::GetDwoFileCounts() {
if (!dwarf_cu->GetDWOId().has_value())
continue;

total_dwo_count++;
stats.dwo_file_count++;

// If we have a DWO symbol file, that means we were able to successfully
// load it.
SymbolFile *dwo_symfile =
dwarf_cu->GetDwoSymbolFile(/*load_all_debug_info=*/false);
if (dwo_symfile) {
loaded_dwo_count++;
stats.loaded_dwo_file_count++;
}

// Check if this unit has a DWO load error, false by default.
const Status &dwo_error = dwarf_cu->GetDwoError();
if (dwo_error.Fail())
stats.dwo_error_count++;
}

return {loaded_dwo_count, total_dwo_count};
return stats;
}
9 changes: 5 additions & 4 deletions lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
Original file line number Diff line number Diff line change
Expand Up @@ -283,10 +283,11 @@ class SymbolFileDWARF : public SymbolFileCommon {
bool GetSeparateDebugInfo(StructuredData::Dictionary &d, bool errors_only,
bool load_all_debug_info = false) override;

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

DWARFContext &GetDWARFContext() { return m_context; }

Expand Down
20 changes: 10 additions & 10 deletions lldb/source/Target/Statistics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ json::Value ModuleStats::ToJSON() const {
debug_info_had_incomplete_types);
module.try_emplace("symbolTableStripped", symtab_stripped);
module.try_emplace("symbolTableSymbolCount", symtab_symbol_count);
module.try_emplace("dwoFileCount", dwo_file_count);
module.try_emplace("loadedDwoFileCount", loaded_dwo_file_count);
module.try_emplace("dwoFileCount", dwo_stats.dwo_file_count);
module.try_emplace("loadedDwoFileCount", dwo_stats.loaded_dwo_file_count);
module.try_emplace("dwoErrorCount", dwo_stats.dwo_error_count);

if (!symbol_locator_time.map.empty()) {
json::Object obj;
Expand Down Expand Up @@ -324,8 +325,7 @@ 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;
DWOStats total_dwo_stats;
for (size_t image_idx = 0; image_idx < num_modules; ++image_idx) {
Module *module = target != nullptr
? target->GetImages().GetModuleAtIndex(image_idx).get()
Expand Down Expand Up @@ -357,10 +357,9 @@ llvm::json::Value DebuggerStats::ReportStatistics(
for (const auto &symbol_module : symbol_modules.Modules())
module_stat.symfile_modules.push_back((intptr_t)symbol_module.get());
}
std::tie(module_stat.loaded_dwo_file_count, module_stat.dwo_file_count) =
sym_file->GetDwoFileCounts();
total_dwo_file_count += module_stat.dwo_file_count;
total_loaded_dwo_file_count += module_stat.loaded_dwo_file_count;
DWOStats current_dwo_stats = sym_file->GetDwoStats();
module_stat.dwo_stats = module_stat.dwo_stats + current_dwo_stats;
total_dwo_stats = total_dwo_stats + current_dwo_stats;
module_stat.debug_info_index_loaded_from_cache =
sym_file->GetDebugInfoIndexWasLoadedFromCache();
if (module_stat.debug_info_index_loaded_from_cache)
Expand Down Expand Up @@ -435,8 +434,9 @@ 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},
{"totalLoadedDwoFileCount", total_dwo_stats.loaded_dwo_file_count},
{"totalDwoFileCount", total_dwo_stats.dwo_file_count},
{"totalDwoErrorCount", total_dwo_stats.dwo_error_count},
};

if (include_targets) {
Expand Down
Loading