Skip to content

Commit 8cfd1ee

Browse files
committed
Only report total currently loaded debug info
1 parent 61c83e9 commit 8cfd1ee

14 files changed

+40
-19
lines changed

lldb/include/lldb/Symbol/SymbolFile.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,8 @@ class SymbolFile : public PluginInterface {
381381

382382
/// Metrics gathering functions
383383

384-
/// Return the size in bytes of all debug information in the symbol file.
384+
/// Return the size in bytes of all loaded debug information or total possible
385+
/// debug info in the symbol file.
385386
///
386387
/// If the debug information is contained in sections of an ObjectFile, then
387388
/// this call should add the size of all sections that contain debug
@@ -391,7 +392,14 @@ class SymbolFile : public PluginInterface {
391392
/// entire file should be returned. The default implementation of this
392393
/// function will iterate over all sections in a module and add up their
393394
/// debug info only section byte sizes.
394-
virtual uint64_t GetDebugInfoSize() = 0;
395+
///
396+
/// \param load_if_needed
397+
/// If true, force loading any symbol files if they are not yet loaded and
398+
/// add to the total size
399+
///
400+
/// \returns
401+
/// Total currently loaded debug info size in bytes
402+
virtual uint64_t GetDebugInfoSize(bool load_if_needed = false) = 0;
395403

396404
/// Return the time taken to parse the debug information.
397405
///
@@ -534,7 +542,7 @@ class SymbolFileCommon : public SymbolFile {
534542

535543
void Dump(Stream &s) override;
536544

537-
uint64_t GetDebugInfoSize() override;
545+
uint64_t GetDebugInfoSize(bool load_if_needed = false) override;
538546

539547
bool GetDebugInfoIndexWasLoadedFromCache() const override {
540548
return m_index_was_loaded_from_cache;

lldb/include/lldb/Symbol/SymbolFileOnDemand.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ class SymbolFileOnDemand : public lldb_private::SymbolFile {
178178

179179
void PreloadSymbols() override;
180180

181-
uint64_t GetDebugInfoSize() override;
181+
uint64_t GetDebugInfoSize(bool load_if_needed = false) override;
182182
lldb_private::StatsDuration::Duration GetDebugInfoParseTime() override;
183183
lldb_private::StatsDuration::Duration GetDebugInfoIndexTime() override;
184184

lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,7 @@ void SymbolFileBreakpad::ParseUnwindData() {
918918
m_unwind_data->win.Sort();
919919
}
920920

921-
uint64_t SymbolFileBreakpad::GetDebugInfoSize() {
921+
uint64_t SymbolFileBreakpad::GetDebugInfoSize(bool load_if_needed) {
922922
// Breakpad files are all debug info.
923923
return m_objfile_sp->GetByteSize();
924924
}

lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ class SymbolFileBreakpad : public SymbolFileCommon {
141141

142142
llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
143143

144-
uint64_t GetDebugInfoSize() override;
144+
uint64_t GetDebugInfoSize(bool load_if_needed = false) override;
145145

146146
private:
147147
// A class representing a position in the breakpad file. Useful for

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -896,8 +896,9 @@ void DWARFUnit::ComputeAbsolutePath() {
896896
m_file_spec->MakeAbsolute(GetCompilationDirectory());
897897
}
898898

899-
SymbolFileDWARFDwo *DWARFUnit::GetDwoSymbolFile() {
900-
ExtractUnitDIEIfNeeded();
899+
SymbolFileDWARFDwo *DWARFUnit::GetDwoSymbolFile(bool load_if_needed) {
900+
if (load_if_needed)
901+
ExtractUnitDIEIfNeeded();
901902
if (m_dwo)
902903
return &llvm::cast<SymbolFileDWARFDwo>(m_dwo->GetSymbolFileDWARF());
903904
return nullptr;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ class DWARFUnit : public UserID {
241241
FileSpec GetFile(size_t file_idx);
242242
FileSpec::Style GetPathStyle();
243243

244-
SymbolFileDWARFDwo *GetDwoSymbolFile();
244+
SymbolFileDWARFDwo *GetDwoSymbolFile(bool load_if_needed = false);
245245

246246
die_iterator_range dies() {
247247
ExtractDIEsIfNeeded();

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2672,7 +2672,7 @@ static bool UpdateCompilerContextForSimpleTemplateNames(TypeQuery &match) {
26722672
return any_context_updated;
26732673
}
26742674

2675-
uint64_t SymbolFileDWARF::GetDebugInfoSize() {
2675+
uint64_t SymbolFileDWARF::GetDebugInfoSize(bool load_if_needed) {
26762676
DWARFDebugInfo &info = DebugInfo();
26772677
uint32_t num_comp_units = info.GetNumUnits();
26782678

@@ -2687,7 +2687,7 @@ uint64_t SymbolFileDWARF::GetDebugInfoSize() {
26872687
if (cu == nullptr)
26882688
continue;
26892689

2690-
SymbolFileDWARFDwo *dwo = cu->GetDwoSymbolFile();
2690+
SymbolFileDWARFDwo *dwo = cu->GetDwoSymbolFile(load_if_needed);
26912691
if (dwo)
26922692
debug_info_size += dwo->GetDebugInfoSize();
26932693
}

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,19 @@ class SymbolFileDWARF : public SymbolFileCommon {
186186
GetMangledNamesForFunction(const std::string &scope_qualified_name,
187187
std::vector<ConstString> &mangled_names) override;
188188

189-
uint64_t GetDebugInfoSize() override;
189+
/// Get total currently loaded debug info size or total possible debug info
190+
/// size.
191+
///
192+
/// For cases like .dwo files, the debug info = skeleton debug info +
193+
/// all dwo debug info where .dwo files might not be loaded yet. Calling this
194+
/// function by default will NOT force the loading of any .dwo files.
195+
///
196+
/// \param load_if_needed
197+
/// If true, force loading any .dwo files associated and add to the size
198+
///
199+
/// \return
200+
/// Returns total currently loaded debug info size
201+
uint64_t GetDebugInfoSize(bool load_if_needed = false) override;
190202

191203
void FindTypes(const lldb_private::TypeQuery &match,
192204
lldb_private::TypeResults &results) override;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ lldb::offset_t SymbolFileDWARFDwo::GetVendorDWARFOpcodeSize(
8585
return GetBaseSymbolFile().GetVendorDWARFOpcodeSize(data, data_offset, op);
8686
}
8787

88-
uint64_t SymbolFileDWARFDwo::GetDebugInfoSize() {
88+
uint64_t SymbolFileDWARFDwo::GetDebugInfoSize(bool load_if_needed) {
8989
// Directly get debug info from current dwo object file's section list
9090
// instead of asking SymbolFileCommon::GetDebugInfo() which parses from
9191
// owning module which is wrong.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class SymbolFileDWARFDwo : public SymbolFileDWARF {
4747
const lldb::offset_t data_offset,
4848
const uint8_t op) const override;
4949

50-
uint64_t GetDebugInfoSize() override;
50+
uint64_t GetDebugInfoSize(bool load_if_needed = false) override;
5151

5252
bool ParseVendorDWARFOpcode(uint8_t op, const DataExtractor &opcodes,
5353
lldb::offset_t &offset,

lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2156,7 +2156,7 @@ SymbolFileNativePDB::GetTypeSystemForLanguage(lldb::LanguageType language) {
21562156
return type_system_or_err;
21572157
}
21582158

2159-
uint64_t SymbolFileNativePDB::GetDebugInfoSize() {
2159+
uint64_t SymbolFileNativePDB::GetDebugInfoSize(bool load_if_needed) {
21602160
// PDB files are a separate file that contains all debug info.
21612161
return m_index->pdb().getFileSize();
21622162
}

lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class SymbolFileNativePDB : public SymbolFileCommon {
7777

7878
void InitializeObject() override;
7979

80-
uint64_t GetDebugInfoSize() override;
80+
uint64_t GetDebugInfoSize(bool load_if_needed = false) override;
8181

8282
// Compile Unit function calls
8383

lldb/source/Symbol/SymbolFile.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ SymbolFileCommon::GetTypeSystemForLanguage(lldb::LanguageType language) {
227227
return type_system_or_err;
228228
}
229229

230-
uint64_t SymbolFileCommon::GetDebugInfoSize() {
230+
uint64_t SymbolFileCommon::GetDebugInfoSize(bool load_if_needed) {
231231
if (!m_objfile_sp)
232232
return 0;
233233
ModuleSP module_sp(m_objfile_sp->GetModule());

lldb/source/Symbol/SymbolFileOnDemand.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -535,11 +535,11 @@ void SymbolFileOnDemand::PreloadSymbols() {
535535
return m_sym_file_impl->PreloadSymbols();
536536
}
537537

538-
uint64_t SymbolFileOnDemand::GetDebugInfoSize() {
538+
uint64_t SymbolFileOnDemand::GetDebugInfoSize(bool load_if_needed) {
539539
// Always return the real debug info size.
540540
LLDB_LOG(GetLog(), "[{0}] {1} is not skipped", GetSymbolFileName(),
541541
__FUNCTION__);
542-
return m_sym_file_impl->GetDebugInfoSize();
542+
return m_sym_file_impl->GetDebugInfoSize(load_if_needed);
543543
}
544544

545545
StatsDuration::Duration SymbolFileOnDemand::GetDebugInfoParseTime() {

0 commit comments

Comments
 (0)