Skip to content

[Debug Info] replace lldb_commands with __lldb_init_module#155336

Merged
rust-bors[bot] merged 3 commits into
rust-lang:mainfrom
Walnut356:lldb_init_module
Jun 1, 2026
Merged

[Debug Info] replace lldb_commands with __lldb_init_module#155336
rust-bors[bot] merged 3 commits into
rust-lang:mainfrom
Walnut356:lldb_init_module

Conversation

@Walnut356

@Walnut356 Walnut356 commented Apr 15, 2026

Copy link
Copy Markdown
Contributor

View all comments

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

rustbot commented Apr 15, 2026

Copy link
Copy Markdown
Collaborator

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

rustbot commented Apr 15, 2026

Copy link
Copy Markdown
Collaborator

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

rust-bors Bot commented Apr 15, 2026

Copy link
Copy Markdown
Contributor

✌️ @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

rust-bors Bot commented Apr 15, 2026

Copy link
Copy Markdown
Contributor

💔 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.

@jieyouxu

jieyouxu commented May 19, 2026

Copy link
Copy Markdown
Member

(Will try to get to this next Monday or so)

@rust-bors

This comment has been minimized.

@rustbot

rustbot commented May 25, 2026

Copy link
Copy Markdown
Collaborator

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.

@jieyouxu jieyouxu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This largely looks good to me, and I also tried this locally. I do like the __lldb_init_module approach much better than the plain-text lldb_commands which was a pain to read let alone write.

Only one thing with ‎tests/debuginfo/captured-fields-1.rs‎, where I think the apple lldb used in aarch64-apple is borked on this test case.

@rustbot author

View changes since this review

@jieyouxu jieyouxu May 26, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Review notes:

  • I tested the changes locally on a aarch64-apple-darwin host w/:
    • Apple lldb 2100
    • LLVM lldb 22.1.6

Comment thread src/etc/lldb_commands Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Comment thread src/etc/lldb_providers.py Outdated
Comment thread tests/debuginfo/captured-fields-1.rs Outdated
//@ lldb-command:continue
//@ lldb-command:v test
//@ lldb-check:(captured_fields_1::main::{closure_env#2}) test = { _ref__my_ref = 0x[...] }
//@ lldb-check:[...] = {_ref__my_ref:{*_ref__my_ref:{my_field1:11, my_field2:22}}}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Problem: on llvm lldb 22 locally (aarch64-apple-darwin host), this check is failing for me.

LLVM lldb 22

lldb version 22.1.6
v test
(captured_fields_1::main::{closure_env#0}) test = {_ref__my_ref__my_field1:0x000000016fdfe520}
continue
v test
(captured_fields_1::main::{closure_env#1}) test = {_ref__my_ref__my_field2:0x000000016fdfe524}
continue
v test
(captured_fields_1::main::{closure_env#2}) test = {_ref__my_ref:0x000000016fdfe528}
continue
v test
(captured_fields_1::main::{closure_env#3}) test = {my_ref:{my_field1:11, my_field2:22}}
continue
v test
(captured_fields_1::main::{closure_env#4}) test = {my_var__my_field2:22}
continue
v test
(captured_fields_1::main::{closure_env#5}) test = {my_var:{my_field1:11, my_field2:22}}
continue
quit

Apple lldb 2100

lldb-2100.0.17.108
Apple Swift version 6.3.2 (swiftlang-6.3.2.1.108 clang-2100.1.1.101)
v test
(captured_fields_1::main::{closure_env#0}) test = {_ref__my_ref__my_field1:0x000000016fdfe450}
continue
v test
(captured_fields_1::main::{closure_env#1}) test = {_ref__my_ref__my_field2:0x000000016fdfe454}
continue
v test
(captured_fields_1::main::{closure_env#2}) test = {_ref__my_ref:0x000000016fdfe458}
continue
v test
(captured_fields_1::main::{closure_env#3}) test = {my_ref:{my_field1:11, my_field2:22}}
continue
v test
(captured_fields_1::main::{closure_env#4}) test = {my_var__my_field2:22}
continue
v test
(captured_fields_1::main::{closure_env#5}) test = {my_var:{my_field1:11, my_field2:22}}
continue
quit

@jieyouxu jieyouxu Jun 1, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

IOW something seems broken with this with the lldb that aarch64-apple CI has (LLDB version 1703) 🤔 I think that is a bug with an older Apple lldb version.
I would suggest gating this with minimum lldb version 21 (or 2100 apple lldb...), or we can look into bumping the lldb that aarch64-apple is using, I suppose 🤔

@jieyouxu jieyouxu Jun 1, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It looks like the macos-15 runner in our aarch64-apple CI currently has Apple LLVM 17 as the baseline... It can become Apple LLVM 21 baseline if we can figure out how to bump to macos-26 without having that exceed the 6h timeout... 🤦:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

huh, fair enough. I'm almost tempted to figure out what actually changed in the printing logic, but that whole submodule of LLDB is really obtuse and i don't think I have it in me to debug LLDB atm.

At the very least, the old and new outputs both happen to be acceptable ways of visualizing the struct from an end-user perspective

@jieyouxu jieyouxu Jun 1, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes. And I'm not so worried about this particular case because Apple lldb 2100+ seems to not, you know, give up on this case (and actually seems to converge back with whatever formatting LLVM lldb 22 gives). It's the Apple lldb 17xx series that seem to have this problem.

@rustbot

rustbot commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@jieyouxu

jieyouxu commented Jun 1, 2026

Copy link
Copy Markdown
Member

Thanks. You can r=me once PR CI is green. I retested ur change on Apple lldb 2100 / LLVM lldb 22.1.6.
@bors rollup=never
@bors delegate+

@rust-bors

rust-bors Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

✌️ @Walnut356, you can now approve this pull request!

If @jieyouxu told you to "r=me" after making some further change, then please make that change and post @bors r=jieyouxu.

View changes since this delegation.

@Walnut356

Copy link
Copy Markdown
Contributor Author

@bors r=jieyouxu

@rust-bors

rust-bors Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 7f84e5c has been approved by jieyouxu

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 1, 2026
@rust-bors

This comment has been minimized.

@rust-bors rust-bors Bot added merged-by-bors This PR was explicitly merged by bors. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jun 1, 2026
@rust-bors

rust-bors Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

☀️ Test successful - CI
Approved by: jieyouxu
Duration: 3h 31m 25s
Pushing 4804ad7 to main...

@rust-bors rust-bors Bot merged commit 4804ad7 into rust-lang:main Jun 1, 2026
13 checks passed
@rustbot rustbot added this to the 1.98.0 milestone Jun 1, 2026
@github-actions

github-actions Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor
What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing 4530eac (parent) -> 4804ad7 (this PR)

Test differences

Show 5 test diffs

Stage 2

  • [debuginfo-lldb] tests/debuginfo/captured-fields-1.rs: pass -> ignore (ignored when the LLDB version is 2100) (J0)

Additionally, 4 doctest diffs were found. These are ignored, as they are noisy.

Job group index

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard 4804ad7e93e1b31f4605b7083871d0d3d85a2afe --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. x86_64-gnu-gcc-core-tests: 14m 41s -> 7m 54s (-46.1%)
  2. dist-aarch64-linux: 1h 50m -> 2h 31m (+36.4%)
  3. x86_64-gnu-llvm-21-3: 1h 59m -> 1h 28m (-26.0%)
  4. i686-msvc-2: 2h 15m -> 1h 40m (-25.5%)
  5. arm-android: 1h 45m -> 1h 20m (-23.3%)
  6. dist-x86_64-msvc-alt: 2h 37m -> 3h 12m (+22.5%)
  7. pr-check-1: 33m 32s -> 26m 17s (-21.6%)
  8. dist-loongarch64-linux: 1h 53m -> 1h 30m (-20.5%)
  9. dist-powerpc64-linux-gnu: 1h 18m -> 1h 33m (+19.5%)
  10. x86_64-msvc-ext3: 1h 46m -> 1h 25m (-19.1%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (4804ad7): comparison URL.

Overall result: ❌✅ regressions and improvements - no action needed

@rustbot label: -perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.1% [0.1%, 0.1%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.3% [-0.3%, -0.3%] 1
All ❌✅ (primary) - - 0

Max RSS (memory usage)

This perf run didn't have relevant results for this metric.

Cycles

Results (primary 0.1%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
3.0% [3.0%, 3.0%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-2.8% [-2.8%, -2.8%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.1% [-2.8%, 3.0%] 2

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 510.437s -> 509.892s (-0.11%)
Artifact size: 400.71 MiB -> 400.78 MiB (0.02%)

JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jun 8, 2026
Use alternate means of detecting enums in `is_udt`

This fixes a small regression from rust-lang#155336

Flat enums are excluded from `is_udt` since LLDB natively handles them correctly. The previous logic (`SBType.IsScopedEnumerationType()`) behaved correctly for non-msvc targets, but for some reason on msvc enums don't count as scoped enumerations?

The new logic checks the type returned by `SBType.GetEnumerationIntegerType()`. If the queried type isn't an enum, the returned type is invalid. This behaves correctly on both msvc and non-msvc targets, and its behavior doesn't conflict with sum-type enums.

As always, testing on msvc isn't really possible atm. That should change soon though =)

---

try-job: aarch64-apple
rust-timer added a commit that referenced this pull request Jun 8, 2026
Rollup merge of #157298 - Walnut356:msvc_enum, r=jieyouxu

Use alternate means of detecting enums in `is_udt`

This fixes a small regression from #155336

Flat enums are excluded from `is_udt` since LLDB natively handles them correctly. The previous logic (`SBType.IsScopedEnumerationType()`) behaved correctly for non-msvc targets, but for some reason on msvc enums don't count as scoped enumerations?

The new logic checks the type returned by `SBType.GetEnumerationIntegerType()`. If the queried type isn't an enum, the returned type is invalid. This behaves correctly on both msvc and non-msvc targets, and its behavior doesn't conflict with sum-type enums.

As always, testing on msvc isn't really possible atm. That should change soon though =)

---

try-job: aarch64-apple
pull Bot pushed a commit to Kokoro2336/rust-analyzer that referenced this pull request Jun 11, 2026
Use alternate means of detecting enums in `is_udt`

This fixes a small regression from rust-lang/rust#155336

Flat enums are excluded from `is_udt` since LLDB natively handles them correctly. The previous logic (`SBType.IsScopedEnumerationType()`) behaved correctly for non-msvc targets, but for some reason on msvc enums don't count as scoped enumerations?

The new logic checks the type returned by `SBType.GetEnumerationIntegerType()`. If the queried type isn't an enum, the returned type is invalid. This behaves correctly on both msvc and non-msvc targets, and its behavior doesn't conflict with sum-type enums.

As always, testing on msvc isn't really possible atm. That should change soon though =)

---

try-job: aarch64-apple
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 merged-by-bors This PR was explicitly merged by bors. 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.

6 participants