Skip to content

Conversation

@Jlalond
Copy link
Contributor

@Jlalond Jlalond commented Apr 2, 2025

The motivation for this patch is that in Statistics.cpp we check to see if the module symfile is loaded 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.

@Jlalond Jlalond requested a review from JDevlieghere as a code owner April 2, 2025 22:29
@llvmbot llvmbot added the lldb label Apr 2, 2025
@llvmbot
Copy link
Member

llvmbot commented Apr 2, 2025

@llvm/pr-subscribers-lldb

Author: Jacob Lalonde (Jlalond)

Changes

The motivation for this patch is that in Statistics.cpp we check to see if the module symfile is loaded 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.


Full diff: https://github.com/llvm/llvm-project/pull/134163.diff

2 Files Affected:

  • (modified) lldb/include/lldb/API/SBModule.h (+3)
  • (modified) lldb/source/API/SBModule.cpp (+12)
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();
 

@Jlalond Jlalond requested a review from dmpots April 2, 2025 22:34
@Jlalond Jlalond merged commit b8d8405 into llvm:main Apr 3, 2025
12 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Apr 3, 2025

LLVM Buildbot has detected a new failure on builder lldb-aarch64-ubuntu running on linaro-lldb-aarch64-ubuntu while building lldb at step 6 "test".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/59/builds/15374

Here is the relevant piece of the build log for the reference
Step 6 (test) failure: build (failure)
...
PASS: lldb-api :: tools/lldb-server/registers-target-xml-reading/TestGdbRemoteTargetXmlPacket.py (1223 of 2116)
PASS: lldb-api :: tools/lldb-server/libraries-svr4/TestGdbRemoteLibrariesSvr4Support.py (1224 of 2116)
PASS: lldb-api :: tools/lldb-server/attach-wait/TestGdbRemoteAttachWait.py (1225 of 2116)
PASS: lldb-api :: tools/lldb-server/thread-name/TestGdbRemoteThreadName.py (1226 of 2116)
PASS: lldb-api :: tools/lldb-server/signal-filtering/TestGdbRemote_QPassSignals.py (1227 of 2116)
UNSUPPORTED: lldb-api :: tools/lldb-server/vCont-threads/TestSignal.py (1228 of 2116)
PASS: lldb-api :: types/TestDoubleTypes.py (1229 of 2116)
PASS: lldb-api :: types/TestCharType.py (1230 of 2116)
PASS: lldb-api :: types/TestCharTypeExpr.py (1231 of 2116)
PASS: lldb-api :: tools/lldb-server/qSupported/TestGdbRemote_qSupported.py (1232 of 2116)
FAIL: lldb-api :: types/TestDoubleTypesExpr.py (1233 of 2116)
******************** TEST 'lldb-api :: types/TestDoubleTypesExpr.py' FAILED ********************
Script:
--
/usr/bin/python3.10 /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/dotest.py -u CXXFLAGS -u CFLAGS --env LLVM_LIBS_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./lib --env LLVM_INCLUDE_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/include --env LLVM_TOOLS_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin --arch aarch64 --build-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex --lldb-module-cache-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex/module-cache-lldb/lldb-api --clang-module-cache-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex/module-cache-clang/lldb-api --executable /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/lldb --compiler /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/clang --dsymutil /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/dsymutil --make /usr/bin/gmake --llvm-tools-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin --lldb-obj-root /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb --lldb-libs-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./lib /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/types -p TestDoubleTypesExpr.py
--
Exit Code: -11

Command Output (stdout):
--
lldb version 21.0.0git (https://github.com/llvm/llvm-project.git revision b8d8405238387ddd92450d6a3ad84350254e76a3)
  clang revision b8d8405238387ddd92450d6a3ad84350254e76a3
  llvm revision b8d8405238387ddd92450d6a3ad84350254e76a3
Skipping the following test categories: ['libc++', 'dsym', 'gmodules', 'debugserver', 'objc']

--
Command Output (stderr):
--
UNSUPPORTED: LLDB (/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: test_double_type_dsym (TestDoubleTypesExpr.DoubleTypesExprTestCase) (test case does not fall in any category of interest for this run) 
PASS: LLDB (/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: test_double_type_dwarf (TestDoubleTypesExpr.DoubleTypesExprTestCase)
PASS: LLDB (/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: test_double_type_dwo (TestDoubleTypesExpr.DoubleTypesExprTestCase)
UNSUPPORTED: LLDB (/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: test_double_type_from_block_dsym (TestDoubleTypesExpr.DoubleTypesExprTestCase) (test case does not fall in any category of interest for this run) 
UNSUPPORTED: LLDB (/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: test_double_type_from_block_dwarf (TestDoubleTypesExpr.DoubleTypesExprTestCase) (requires one of macosx, darwin, ios, tvos, watchos, bridgeos, iphonesimulator, watchsimulator, appletvsimulator) 
UNSUPPORTED: LLDB (/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: test_double_type_from_block_dwo (TestDoubleTypesExpr.DoubleTypesExprTestCase) (requires one of macosx, darwin, ios, tvos, watchos, bridgeos, iphonesimulator, watchsimulator, appletvsimulator) 
----------------------------------------------------------------------
Ran 6 tests in 1.011s

OK (skipped=4)

--

********************
PASS: lldb-api :: types/TestFloatTypes.py (1234 of 2116)
PASS: lldb-api :: tools/lldb-server/TestGdbRemote_vCont.py (1235 of 2116)
PASS: lldb-api :: tools/lldb-server/vCont-threads/TestPartialResume.py (1236 of 2116)
PASS: lldb-api :: types/TestFloatTypesExpr.py (1237 of 2116)
PASS: lldb-api :: types/TestIntegerType.py (1238 of 2116)
PASS: lldb-api :: types/TestRecursiveTypes.py (1239 of 2116)
PASS: lldb-api :: types/TestIntegerTypeExpr.py (1240 of 2116)

@Jlalond
Copy link
Contributor Author

Jlalond commented Apr 3, 2025

Seems unrelated, but I will check in the morning.

@clayborg
Copy link
Collaborator

clayborg commented Apr 3, 2025

Just a quick comment here for this:

  /// Get if the symbol file for this module is loaded.
  bool IsDebugInfoLoaded() const;

This isn't clear what it is returning. What it seems like it should be returning from the name is "are there debug symbols in this module. But what is actually exposed should be more like:

  /// Return true if the debug symbols are fully enabled. 
  ///
  /// Symbols on demand might end up disabling debug info until
  /// a query is made that requires debug information from this module
  /// and this function will return false if debug information has been
  /// disabled in this way.
  bool IsDebugInfoEnabled() const;

The new API added as is seems like we are saying "is there some debug info in the symbol file". But this will always return true unless symbols on demand is restricting debug info access.

If we have a "a.out" binary that has no debug info, it will have a "SymbolFileSymtab" and with no debug info and it will return true because it has a symbol file and it isn't restricted by symbols on demand.

Can we revert this and switch to my above suggestion if everyone agrees?

Jlalond added a commit that referenced this pull request Apr 4, 2025
…a SBModule" (#134341)

Reverts #134163

Reverting while @clayborg and I come up with a better API
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request Apr 4, 2025
…s loaded via SBModule" (#134341)

Reverts llvm/llvm-project#134163

Reverting while @clayborg and I come up with a better API
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants