Skip to content

[Debug Info] replace lldb_commands with __lldb_init_module#155336

Open
Walnut356 wants to merge 2 commits intorust-lang:mainfrom
Walnut356:lldb_init_module
Open

[Debug Info] replace lldb_commands with __lldb_init_module#155336
Walnut356 wants to merge 2 commits intorust-lang:mainfrom
Walnut356:lldb_init_module

Conversation

@Walnut356
Copy link
Copy Markdown
Contributor

@Walnut356 Walnut356 commented Apr 15, 2026

DO NOT MERGE. Please run through aarch64-apple. Ideally the tests fail. If they don't, the test runner is using too old of a version of LLDB and I need to fiddle with this some more.

TL;DR I hate lldb_commands, it's annoying to update and maintain since it's just a raw text file of CLI commands. All of the functionality can be replicated via the debugger's own API. __lldb_init_module is called immediately upon command script import lldb_lookup.py, so it should function identically (with one exception, see below). We can do things like let python tell us the names of the functions and classes, making them easier to keep in sync. Most importantly, we can conditionally use one set of visualizers or another depending on the version of the debugger. This is a precursor to using callback-based type matching, which was added in LLDB 19.

The one exception i mentioned above replaces our ".*" regex that dumps everything through lldb_lookup.synthetic_lookup. That wildcard also includes primitives which is less than ideal, especially for performance. It's bad enough that codelldb intercepts this command and replaces it with a type recognizer. If i remove lldb_commands, codelldb can no longer do this. To prevent a regression on their end, I added a conditional that replicates that behavior.

Here's the problem: for some godforsaken reason, if a struct contains a field with a SyntheticProvider (even one that is "empty", like for DefaultSyntheticProvider for primitives) it is formatted differently than a struct whose fields don't have providers. That breaks a bunch of the tests because instead of { x = 10 y = 30 } we get (x = 10, y = 30). Very cool.

So, we have divergent behavior depending on the version of LLDB. That's nothing new, since MSVC enums are broken prior to LLDB 18, so it's whatever (and the difference hardly matters to the end user). If the CI test runners have a new enough version of LLDB that it uses the type recognizer instead of the wildcard, the tests will fail. I'll update them and we'll be good to go. If they don't fail, I need to probably force a struct summary provider so that all versions look the same (which isn't ideal performance), or I can just wait until xcode happens to update to a newer version of LLDB.


try-job: aarch64-apple

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 15, 2026

Some changes occurred in src/tools/compiletest

cc @jieyouxu

@rustbot rustbot added A-compiletest Area: The compiletest test runner A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Apr 15, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 15, 2026

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @Mark-Simulacrum

@Walnut356
Copy link
Copy Markdown
Contributor Author

now that i think on it, apple's LLDB is a custom fork. I don't think the version extraction logic will work for it. Lemme fix that real quick.

@rust-log-analyzer

This comment has been minimized.

@jieyouxu
Copy link
Copy Markdown
Member

You should be able to run try jobs on this PR urself after this:
@bors delegate=try

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Apr 15, 2026

✌️ @Walnut356, you can now perform try builds on this pull request!

You can now post @bors try to start a try build.

@Walnut356
Copy link
Copy Markdown
Contributor Author

rad, thank you

@rust-log-analyzer

This comment has been minimized.

@jieyouxu jieyouxu self-assigned this Apr 15, 2026
@Walnut356
Copy link
Copy Markdown
Contributor Author

@bors try jobs=aarch64-apple

rust-bors Bot pushed a commit that referenced this pull request Apr 15, 2026
[Debug Info] replace `lldb_commands` with `__lldb_init_module`


try-job: aarch64-apple
@rust-bors

This comment has been minimized.

@rust-bors rust-bors Bot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 15, 2026
@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Apr 15, 2026

💔 Test for d52c8f9 failed: CI. Failed job:

@rust-log-analyzer

This comment has been minimized.

@Walnut356
Copy link
Copy Markdown
Contributor Author

Okay, bad news is this test didn't go exactly as planned because debugger.version was only added recently and is not present in apple's LLDB. The good news is:

  1. I can confirm it's not present via apple's repo (llvm's for comparison) so I should be able to check for similar things without running a try job.
  2. apple's LLDB does have the type recognizer enum value so those should work

i'm still iffy on whether I want to just update the tests, or if i want to force a StructSummaryProvider and save us from annoyances like this in the future (at the cost of some minor performance losses).

@Walnut356
Copy link
Copy Markdown
Contributor Author

I guess I should also note that, in additional bad news, apples versioning scheme seems to have 0 relation to llvm's, so using raw version numbers probably won't work. I should be able to just check for features via getattr to check what functions and values are present at runtime

@rust-bors

This comment has been minimized.

jhpratt added a commit to jhpratt/rust that referenced this pull request Apr 25, 2026
…youxu

Account for `GetSyntheticValue` failures

`GetSyntheticValue` returns an invalid `SBValue` if no synthetic is present. That wasn't a problem before when we  were attaching synthetics to every type, but it won't be the case once github.com/rust-lang/pull/155336 or similar lands. Additionally, codelldb subverts `lldb_commands` to apply similar behavior that doesn't attach synthetics to every type, so this fixes a regression there too.

Additionally, I removed 1 useless instance of `GetSyntheticValue`, since pointers should always be `IndirectionSyntheticProvider`, not `DefaultSyntheticProvider`.
@Walnut356
Copy link
Copy Markdown
Contributor Author

i'm still iffy on whether I want to just update the tests, or if i want to force a StructSummaryProvider

I think i'm just gonna update the tests for now since it's a bit safer. I can always go in and enforce StructSummaryProvider later.

@Walnut356
Copy link
Copy Markdown
Contributor Author

Nevermind, I'm really not fond of the formatting inconsistency in nested structs. StructSyntheticProvider it is.

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 28, 2026

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@rust-log-analyzer

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-compiletest Area: The compiletest test runner A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants