Skip to content

[lldb][SymbolFileDWARF] Don't search for DWP files on macOS #139554

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 29, 2025

Conversation

Michael137
Copy link
Member

A contrived performance measurement on my local machine:

  1. Attach LLDB to LLDB
  2. Measure how much time it takes to run b operator[]

Without this patch, we would spend a total of 400ms (which was ~4-5% of total execution) looking for DWP files (and failing to find them because they are not a concept on macOS).

We call into GetDwpSymbolFile via DebugNamesDWARFIndex::GetFunctions -> ManualDWARFIndex::GetFunctions -> ManualDWARFIndex::Index.

rdar://148212738

A contrived performance measurement on my local machine:
1. Attach LLDB to LLDB
2. Measure how much time it takes to run `b operator[]`

Without this patch, we would spend a total of 400ms (which was ~4-5% of
total execution) looking for DWP files (and failing to find them because
they are not a concept on macOS).

We call into `GetDwpSymbolFile` via `DebugNamesDWARFIndex::GetFunctions -> ManualDWARFIndex::GetFunctions -> ManualDWARFIndex::Index`.

rdar://148212738
@llvmbot
Copy link
Member

llvmbot commented May 12, 2025

@llvm/pr-subscribers-lldb

Author: Michael Buch (Michael137)

Changes

A contrived performance measurement on my local machine:

  1. Attach LLDB to LLDB
  2. Measure how much time it takes to run b operator[]

Without this patch, we would spend a total of 400ms (which was ~4-5% of total execution) looking for DWP files (and failing to find them because they are not a concept on macOS).

We call into GetDwpSymbolFile via DebugNamesDWARFIndex::GetFunctions -> ManualDWARFIndex::GetFunctions -> ManualDWARFIndex::Index.

rdar://148212738


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

1 Files Affected:

  • (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (+3)
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 907d63eb51afe..3f53e562ba65b 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -4211,6 +4211,9 @@ SymbolFileDWARFDebugMap *SymbolFileDWARF::GetDebugMapSymfile() {
 
 const std::shared_ptr<SymbolFileDWARFDwo> &SymbolFileDWARF::GetDwpSymbolFile() {
   llvm::call_once(m_dwp_symfile_once_flag, [this]() {
+    if (m_objfile_sp->GetArchitecture().GetTriple().isAppleMachO())
+      return;
+
     // Create a list of files to try and append .dwp to.
     FileSpecList symfiles;
     // Append the module's object file path.

@@ -4211,6 +4211,9 @@ SymbolFileDWARFDebugMap *SymbolFileDWARF::GetDebugMapSymfile() {

const std::shared_ptr<SymbolFileDWARFDwo> &SymbolFileDWARF::GetDwpSymbolFile() {
llvm::call_once(m_dwp_symfile_once_flag, [this]() {
if (m_objfile_sp->GetArchitecture().GetTriple().isAppleMachO())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be a check for the ObjectFile subclass instead?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JDevlieghere Maybe you have a better layering suggestion?

Copy link
Member Author

@Michael137 Michael137 May 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was my first inclination. But then I was reading the discussion at #139170 (comment) and was going to see where that goes before adding one of these kinds of APIs to ObjectFile

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this sounds like very much a dual problem to that, so it would be nice if they used the same approach. The thing that makes this fuzzier is that in this case you can't really say that SymbolFileDWARF requires ObjectFileMachO (or any other) because one can imagine a setup where someone knows they will only ever need to debug DWARF+ELF and so they want to strip out all of the other object file plugins. OTOH, I can also imagine us saying we don't want to support that. :P

Copy link
Member Author

@Michael137 Michael137 May 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what the resolution was re. the plugin dependencies discussion. Are we find with the current approach?

you can't really say that SymbolFileDWARF requires ObjectFileMachO (or any other) because one can imagine a setup where someone knows they will only ever need to debug DWARF+ELF and so they want to strip out all of the other object file plugins.

Good question. If we don't want to restrict a use-case such as the one you describe, I'm happy to add a SupportsDWP API to ObjectFile. Any thoughts @JDevlieghere ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a good solution until we've documented the dependency policy from #139170

@@ -4211,6 +4211,9 @@ SymbolFileDWARFDebugMap *SymbolFileDWARF::GetDebugMapSymfile() {

const std::shared_ptr<SymbolFileDWARFDwo> &SymbolFileDWARF::GetDwpSymbolFile() {
llvm::call_once(m_dwp_symfile_once_flag, [this]() {
if (m_objfile_sp->GetArchitecture().GetTriple().isAppleMachO())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a good solution until we've documented the dependency policy from #139170

@Michael137 Michael137 merged commit f5c6b7b into llvm:main May 29, 2025
12 checks passed
@Michael137 Michael137 deleted the lldb/no-dwp-on-darwin branch May 29, 2025 07:09
@llvm-ci
Copy link
Collaborator

llvm-ci commented May 29, 2025

LLVM Buildbot has detected a new failure on builder lldb-remote-linux-ubuntu running on as-builder-9 while building lldb at step 16 "test-check-lldb-api".

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

Here is the relevant piece of the build log for the reference
Step 16 (test-check-lldb-api) failure: Test just built components: check-lldb-api completed (failure)
...
PASS: lldb-api :: types/TestCharTypeExpr.py (1269 of 1278)
PASS: lldb-api :: types/TestIntegerType.py (1270 of 1278)
PASS: lldb-api :: types/TestRecursiveTypes.py (1271 of 1278)
UNSUPPORTED: lldb-api :: windows/launch/missing-dll/TestMissingDll.py (1272 of 1278)
PASS: lldb-api :: types/TestIntegerTypeExpr.py (1273 of 1278)
PASS: lldb-api :: types/TestShortType.py (1274 of 1278)
PASS: lldb-api :: types/TestShortTypeExpr.py (1275 of 1278)
PASS: lldb-api :: types/TestLongTypes.py (1276 of 1278)
PASS: lldb-api :: types/TestLongTypesExpr.py (1277 of 1278)
TIMEOUT: lldb-api :: python_api/process/cancel_attach/TestCancelAttach.py (1278 of 1278)
******************** TEST 'lldb-api :: python_api/process/cancel_attach/TestCancelAttach.py' FAILED ********************
Script:
--
/usr/bin/python3.12 /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/test/API/dotest.py -u CXXFLAGS -u CFLAGS --env LLVM_LIBS_DIR=/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/./lib --env LLVM_INCLUDE_DIR=/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/include --env LLVM_TOOLS_DIR=/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/./bin --libcxx-include-dir /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/include/c++/v1 --libcxx-include-target-dir /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/include/aarch64-unknown-linux-gnu/c++/v1 --libcxx-library-dir /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/./lib/aarch64-unknown-linux-gnu --arch aarch64 --build-dir /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/lldb-test-build.noindex --lldb-module-cache-dir /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/lldb-test-build.noindex/module-cache-lldb/lldb-api --clang-module-cache-dir /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/lldb-test-build.noindex/module-cache-clang/lldb-api --executable /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/./bin/lldb --compiler /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/bin/clang --dsymutil /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/./bin/dsymutil --make /usr/bin/gmake --llvm-tools-dir /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/./bin --lldb-obj-root /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/tools/lldb --lldb-libs-dir /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/./lib --cmake-build-type Release --platform-url connect://jetson-agx-2198.lab.llvm.org:1234 --platform-working-dir /home/ubuntu/lldb-tests --sysroot /mnt/fs/jetson-agx-ubuntu --env ARCH_CFLAGS=-mcpu=cortex-a78 --platform-name remote-linux --skip-category=lldb-server /home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/test/API/python_api/process/cancel_attach -p TestCancelAttach.py
--
Exit Code: -9
Timeout: Reached timeout of 600 seconds

Command Output (stdout):
--
lldb version 21.0.0git (https://github.com/llvm/llvm-project.git revision f5c6b7bde984691b60edc8585d1065107e60b5f3)
  clang revision f5c6b7bde984691b60edc8585d1065107e60b5f3
  llvm revision f5c6b7bde984691b60edc8585d1065107e60b5f3

--
Command Output (stderr):
--
WARNING:root:Custom libc++ is not supported for remote runs: ignoring --libcxx arguments
FAIL: LLDB (/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/build/bin/clang-aarch64) :: test_scripted_implementation (TestCancelAttach.AttachCancelTestCase.test_scripted_implementation)

--

********************
Slowest Tests:
--------------------------------------------------------------------------
600.04s: lldb-api :: python_api/process/cancel_attach/TestCancelAttach.py
180.95s: lldb-api :: commands/command/script_alias/TestCommandScriptAlias.py
70.80s: lldb-api :: commands/process/attach/TestProcessAttach.py
39.57s: lldb-api :: functionalities/data-formatter/data-formatter-stl/libcxx-simulators/string/TestDataFormatterLibcxxStringSimulator.py
34.88s: lldb-api :: functionalities/single-thread-step/TestSingleThreadStepTimeout.py
34.86s: lldb-api :: functionalities/completion/TestCompletion.py
23.54s: lldb-api :: python_api/watchpoint/watchlocation/TestTargetWatchAddress.py
21.92s: lldb-api :: commands/statistics/basic/TestStats.py
20.69s: lldb-api :: functionalities/gdb_remote_client/TestPlatformClient.py
18.98s: lldb-api :: functionalities/thread/state/TestThreadStates.py
18.14s: lldb-api :: commands/dwim-print/TestDWIMPrint.py
15.02s: lldb-api :: python_api/watchpoint/watchlocation/TestSetWatchlocation.py
15.00s: lldb-api :: functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py
14.73s: lldb-api :: commands/expression/expr-in-syscall/TestExpressionInSyscall.py

google-yfyang pushed a commit to google-yfyang/llvm-project that referenced this pull request May 29, 2025
Michael137 added a commit to swiftlang/llvm-project that referenced this pull request May 30, 2025
adrian-prantl pushed a commit to swiftlang/llvm-project that referenced this pull request May 30, 2025
sivan-shani pushed a commit to sivan-shani/llvm-project that referenced this pull request Jun 3, 2025
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