[Lldb-commits] [lldb] b8d8405 - [LLDB] Expose checking if the symbol file exists/is loaded via SBModule (#134163)
via lldb-commits
lldb-commits at lists.llvm.org
Wed Apr 2 21:27:47 PDT 2025
Author: Jacob Lalonde
Date: 2025-04-02T21:27:44-07:00
New Revision: b8d8405238387ddd92450d6a3ad84350254e76a3
URL: https://github.com/llvm/llvm-project/commit/b8d8405238387ddd92450d6a3ad84350254e76a3
DIFF: https://github.com/llvm/llvm-project/commit/b8d8405238387ddd92450d6a3ad84350254e76a3.diff
LOG: [LLDB] Expose checking if the symbol file exists/is loaded via SBModule (#134163)
The motivation for this patch is that in Statistics.cpp we [check to see
if the module symfile is
loaded](https://github.com/llvm/llvm-project/blob/990a086d9da0bc2fd53a6a4c95ecbbe23a297a83/lldb/source/Target/Statistics.cpp#L353C60-L353C75)
to calculate how much debug info has been loaded. I have an external
utility that only wants to look at the loaded debug info, which isn't
exposed by the SBAPI.
Added:
Modified:
lldb/include/lldb/API/SBModule.h
lldb/source/API/SBModule.cpp
Removed:
################################################################################
diff --git a/lldb/include/lldb/API/SBModule.h b/lldb/include/lldb/API/SBModule.h
index 85332066ee687..651455bdb78d2 100644
--- a/lldb/include/lldb/API/SBModule.h
+++ b/lldb/include/lldb/API/SBModule.h
@@ -290,6 +290,9 @@ class LLDB_API SBModule {
lldb::SBAddress GetObjectFileHeaderAddress() const;
lldb::SBAddress GetObjectFileEntryPointAddress() const;
+ /// Get if the symbol file for this module is loaded.
+ bool IsDebugInfoLoaded() const;
+
/// Get the number of global modules.
static uint32_t GetNumberAllocatedModules();
diff --git a/lldb/source/API/SBModule.cpp b/lldb/source/API/SBModule.cpp
index 985107ec68efd..4978a553f57c7 100644
--- a/lldb/source/API/SBModule.cpp
+++ b/lldb/source/API/SBModule.cpp
@@ -659,6 +659,18 @@ lldb::SBAddress SBModule::GetObjectFileEntryPointAddress() const {
return sb_addr;
}
+bool SBModule::IsDebugInfoLoaded() const {
+ LLDB_INSTRUMENT_VA(this);
+
+ ModuleSP module_sp(GetSP());
+ if (module_sp) {
+ SymbolFile *sym_file = module_sp->GetSymbolFile(/*create=*/false);
+ return sym_file && sym_file->GetLoadDebugInfoEnabled();
+ }
+
+ return false;
+}
+
uint32_t SBModule::GetNumberAllocatedModules() {
LLDB_INSTRUMENT();
More information about the lldb-commits
mailing list