Skip to content
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

Implement lldb formatter for "clang encoded" enums (LLDB 18.1+) (V3) #124781

Merged
merged 1 commit into from
May 7, 2024

Conversation

VladimirMakaev
Copy link
Contributor

This is a redo of PR (#124458) which was approved previously but force-pushed out. Then a V2 (#124745) failed debuginfo\msvc-pretty-enums.rs test during merge.

I've fixed the test and checked it to pass on Windows with .\x.ps1 test .\tests\debuginfo\msvc-pretty-enums.rs

Below is the original summary:

Summary:

fixes #79530

I landed a fix last year to enable DW_TAG_variant_part encoding in LLDBs (https://reviews.llvm.org/D149213). This PR is a corresponding fix in synthetic formatters to decode that information.

This is in no way perfect implementation but at least it improves the status quo. But most types of enums will be visible and debuggable in some way.

I've also updated most of the existing tests that touch enums and re-enabled test cases based on LLDB for enums.

Test Plan:

ran tests ./x test tests/debuginfo/. Also tested manually in LLDB CLI and LLDB VSCode

Other Thoughs:

A better approach would probably be adopting formatters from codelldb. There is some neat hack that hooks up summary provider via synthetic provider which can ultimately fix more display issues for Rust types and enums too. But getting it to work well might take more time that I have right now.

@rustbot
Copy link
Collaborator

rustbot commented May 6, 2024

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

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 6, 2024
Summary:
I landed a fix last year to enable `DW_TAG_variant_part` encoding in LLDBs (https://reviews.llvm.org/D149213). This PR is a corresponding fix in synthetic formatters to decode that information.
This is in no way perfect implementation but at least it improves the status quo. But most types of enums will be visible and debuggable in some way.
I've also updated most of the existing tests that touch enums and re-enabled test cases based on LLDB for enums.

Test Plan:
ran tests `./x test tests/debuginfo/`. Also tested manually in LLDB CLI and LLDB VSCode

Other Thoughs
A better approach would probably be adopting [formatters from codelldb](https://github.com/vadimcn/codelldb/blob/master/formatters/rust.py). There is some neat hack that hooks up summary provider via synthetic provider which can ultimately fix more display issues for Rust types and enums too. But getting it to work well might take more time that I have right now.
@dtolnay dtolnay changed the title Implement lldb formattter for "clang encoded" enums (LLDB 18.1+) (V3) Implement lldb formatter for "clang encoded" enums (LLDB 18.1+) (V3) May 7, 2024
@dtolnay
Copy link
Member

dtolnay commented May 7, 2024

This is the diff from v1:

diff --git a/tests/debuginfo/coroutine-objects.rs b/tests/debuginfo/coroutine-objects.rs
@@ -27,7 +27,7 @@

 // lldb-command:run
 // lldb-command:v b
-// lldb-check:(coroutine_objects::main::{coroutine_env#0}) b = { value = { _ref__a = 0x[...] } $discr$ = ',' }
+// lldb-check:(coroutine_objects::main::{coroutine_env#0}) b = { value = { _ref__a = 0x[...] } $discr$ = [...] }

 // === CDB TESTS ===================================================================================
diff --git a/tests/debuginfo/msvc-pretty-enums.rs b/tests/debuginfo/msvc-pretty-enums.rs
@@ -3,8 +3,8 @@
 //@ compile-flags:-g

 // === LLDB TESTS ==================================================================================
-
 // lldb-command:run
+
 // lldb-command:v a
 // lldbg-check:(core::option::Option<msvc_pretty_enums::CStyleEnum>) a = { value = { 0 = Low } }

@@ -74,12 +74,7 @@
 // lldbg-check:(msvc_pretty_enums::ArbitraryDiscr) arbitrary_discr2 = { value = { 0 = 5678 } $discr$ = 5000000 }

 // === CDB TESTS ==================================================================================
-// cdb-command: g
-//
-// cdb-command: dx a
-// cdb-check:a                : Some [Type: enum2$<core::option::Option<msvc_pretty_enums::CStyleEnum> >]
-// cdb-check:    [+0x000] __0              : Low (0x2) [Type: msvc_pretty_enums::CStyleEnum]
-//
+
 // cdb-command: g
 //
 // cdb-command: dx a

Copy link
Member

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

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

Thank you!

@dtolnay
Copy link
Member

dtolnay commented May 7, 2024

@bors r+

@bors
Copy link
Contributor

bors commented May 7, 2024

📌 Commit fb2d9cd has been approved by dtolnay

It is now in the queue for this repository.

@bors bors 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-review Status: Awaiting review from the assignee but also interested parties. labels May 7, 2024
@dtolnay dtolnay assigned dtolnay and unassigned Mark-Simulacrum May 7, 2024
@bors
Copy link
Contributor

bors commented May 7, 2024

⌛ Testing commit fb2d9cd with merge 60a7c19...

@bors
Copy link
Contributor

bors commented May 7, 2024

☀️ Test successful - checks-actions
Approved by: dtolnay
Pushing 60a7c19 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label May 7, 2024
@bors bors merged commit 60a7c19 into rust-lang:master May 7, 2024
7 checks passed
@rustbot rustbot added this to the 1.80.0 milestone May 7, 2024
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (60a7c19): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-1.8% [-2.2%, -1.5%] 3
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -1.8% [-2.2%, -1.5%] 3

Cycles

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.9% [-3.5%, -2.2%] 2
All ❌✅ (primary) - - 0

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 675.387s -> 676.069s (0.10%)
Artifact size: 315.97 MiB -> 315.95 MiB (-0.01%)

bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 13, 2024
…=compiler-errors

Enable debuginfo tests that have been "temporarily disabled" for the past 6 years

The PR history is a bit of a mess because I had to test this a lot with try-jobs, so I'll try to summarize the non-obvious changes here.

A number of tests now have `min-lldb-version: 1800`. Those tests should have gotten an lldb version jump either in rust-lang#124781 or long ago. Note that all such tests with that lldb version requirement do not run in Apple CI.

`tests/debuginfo/drop-locations.rs` is staying disabled for now because gdb doesn't know to stop on the drop calls produced by a `}`: rust-lang#128971

`tests/debuginfo/function-arg-initialization.rs` now has `-Zmir-enable-passes=-SingleUseConsts`; without that we initialize the const before the function prelude: rust-lang#128945

`tests/debuginfo/by-value-non-immediate-argument.rs` fails because we don't generate a function prelude for unused non-immediate arguments, even with all optimizations disabled, and this seems to confuse debuggers on aarch64: rust-lang#128973

`tests/debuginfo/pretty-std.rs` is staying disabled on windows-gnu because our test harness doesn't know how to load our pretty-printers on that target: rust-lang#128981

`tests/debuginfo/method-on-enum.rs` and `tests/debuginfo/option-like-enum.rs` encounter some kind of gdb bug on i686-pc-windows-gnu. I don't know enough about that situation to write a good issue.

I plan on doing more work on this test suite. There's clearly a lot more basic cleanup work to do here.
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 13, 2024
…=<try>

Enable debuginfo tests that have been "temporarily disabled" for the past 6 years

The PR history is a bit of a mess because I had to test this a lot with try-jobs, so I'll try to summarize the non-obvious changes here.

A number of tests now have `min-lldb-version: 1800`. Those tests should have gotten an lldb version jump either in rust-lang#124781 or long ago. Note that all such tests with that lldb version requirement do not run in Apple CI.

`tests/debuginfo/drop-locations.rs` is staying disabled for now because gdb doesn't know to stop on the drop calls produced by a `}`: rust-lang#128971

`tests/debuginfo/function-arg-initialization.rs` now has `-Zmir-enable-passes=-SingleUseConsts`; without that we initialize the const before the function prelude: rust-lang#128945

`tests/debuginfo/by-value-non-immediate-argument.rs` fails because we don't generate a function prelude for unused non-immediate arguments, even with all optimizations disabled, and this seems to confuse debuggers on aarch64: rust-lang#128973

`tests/debuginfo/pretty-std.rs` is staying disabled on windows-gnu because our test harness doesn't know how to load our pretty-printers on that target: rust-lang#128981

`tests/debuginfo/method-on-enum.rs` and `tests/debuginfo/option-like-enum.rs` encounter some kind of gdb bug on i686-pc-windows-gnu. I don't know enough about that situation to write a good issue.

I plan on doing more work on this test suite. There's clearly a lot more basic cleanup work to do here.

try-job: i686-gnu
try-job: aarch64-gnu
try-job: x86_64-msvc
try-job: i686-mingw
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 15, 2024
…=compiler-errors

Enable debuginfo tests that have been "temporarily disabled" for the past 6 years

The PR history is a bit of a mess because I had to test this a lot with try-jobs, so I'll try to summarize the non-obvious changes here.

A number of tests now have `min-lldb-version: 1800`. Those tests should have gotten an lldb version jump either in rust-lang#124781 or long ago. Note that all such tests with that lldb version requirement do not run in Apple CI.

`tests/debuginfo/drop-locations.rs` is staying disabled for now because gdb doesn't know to stop on the drop calls produced by a `}`: rust-lang#128971

`tests/debuginfo/function-arg-initialization.rs` now has `-Zmir-enable-passes=-SingleUseConsts`; without that we initialize the const before the function prelude: rust-lang#128945

`tests/debuginfo/by-value-non-immediate-argument.rs` fails because we don't generate a function prelude for unused non-immediate arguments, even with all optimizations disabled, and this seems to confuse debuggers on aarch64: rust-lang#128973

`tests/debuginfo/pretty-std.rs` is staying disabled on windows-gnu because our test harness doesn't know how to load our pretty-printers on that target: rust-lang#128981

`tests/debuginfo/method-on-enum.rs` and `tests/debuginfo/option-like-enum.rs` encounter some kind of gdb bug on i686-pc-windows-gnu. I don't know enough about that situation to write a good issue.

I plan on doing more work on this test suite. There's clearly a lot more basic cleanup work to do here.
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 15, 2024
…=<try>

Enable debuginfo tests that have been "temporarily disabled" for the past 6 years

The PR history is a bit of a mess because I had to test this a lot with try-jobs, so I'll try to summarize the non-obvious changes here.

A number of tests now have `min-lldb-version: 1800`. Those tests should have gotten an lldb version jump either in rust-lang#124781 or long ago. Note that all such tests with that lldb version requirement do not run in Apple CI.

`tests/debuginfo/drop-locations.rs` is staying disabled for now because gdb doesn't know to stop on the drop calls produced by a `}`: rust-lang#128971

`tests/debuginfo/function-arg-initialization.rs` now has `-Zmir-enable-passes=-SingleUseConsts`; without that we initialize the const before the function prelude: rust-lang#128945

`tests/debuginfo/by-value-non-immediate-argument.rs` fails because we don't generate a function prelude for unused non-immediate arguments, even with all optimizations disabled, and this seems to confuse debuggers on aarch64: rust-lang#128973

`tests/debuginfo/pretty-std.rs` is staying disabled on windows-gnu because our test harness doesn't know how to load our pretty-printers on that target: rust-lang#128981

`tests/debuginfo/method-on-enum.rs` and `tests/debuginfo/option-like-enum.rs` encounter some kind of gdb bug on i686-pc-windows-gnu. I don't know enough about that situation to write a good issue.

I plan on doing more work on this test suite. There's clearly a lot more basic cleanup work to do here.

try-job: x86_64-gnu-llvm-17
try-job: x86_64-gnu-tools
try-job: aarch64-gnu
try-job: arm-android
try-job: armhf-gnu
try-job: i686-gnu
try-job: i686-gnu-nopt
try-job: mingw-check
try-job: test-various
try-job: x86_64-fuchsia
try-job: x86_64-rust-for-linux
try-job: x86_64-gnu
try-job: x86_64-gnu-stable
try-job: x86_64-gnu-aux
try-job: x86_64-gnu-debug
try-job: x86_64-gnu-llvm-18
try-job: x86_64-gnu-nopt
try-job: x86_64-apple-1
try-job: aarch64-apple
try-job: x86_64-msvc
try-job: i686-msvc
try-job: i686-mingw
try-job: x86_64-mingw
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 15, 2024
…=<try>

Enable debuginfo tests that have been "temporarily disabled" for the past 6 years

The PR history is a bit of a mess because I had to test this a lot with try-jobs, so I'll try to summarize the non-obvious changes here.

A number of tests now have `min-lldb-version: 1800`. Those tests should have gotten an lldb version jump either in rust-lang#124781 or long ago. Note that all such tests with that lldb version requirement do not run in Apple CI.

`tests/debuginfo/drop-locations.rs` is staying disabled for now because gdb doesn't know to stop on the drop calls produced by a `}`: rust-lang#128971

`tests/debuginfo/function-arg-initialization.rs` now has `-Zmir-enable-passes=-SingleUseConsts`; without that we initialize the const before the function prelude: rust-lang#128945

`tests/debuginfo/by-value-non-immediate-argument.rs` fails because we don't generate a function prelude for unused non-immediate arguments, even with all optimizations disabled, and this seems to confuse debuggers on aarch64: rust-lang#128973

`tests/debuginfo/pretty-std.rs` is staying disabled on windows-gnu because our test harness doesn't know how to load our pretty-printers on that target: rust-lang#128981

`tests/debuginfo/method-on-enum.rs` and `tests/debuginfo/option-like-enum.rs` encounter some kind of gdb bug on i686-pc-windows-gnu. I don't know enough about that situation to write a good issue.

I plan on doing more work on this test suite. There's clearly a lot more basic cleanup work to do here.

try-job: aarch64-gnu
try-job: arm-android
try-job: armhf-gnu
try-job: i686-gnu
try-job: i686-gnu-nopt
try-job: test-various
try-job: x86_64-fuchsia
try-job: x86_64-rust-for-linux
try-job: x86_64-gnu
try-job: x86_64-gnu-stable
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 15, 2024
…=<try>

Enable debuginfo tests that have been "temporarily disabled" for the past 6 years

The PR history is a bit of a mess because I had to test this a lot with try-jobs, so I'll try to summarize the non-obvious changes here.

A number of tests now have `min-lldb-version: 1800`. Those tests should have gotten an lldb version jump either in rust-lang#124781 or long ago. Note that all such tests with that lldb version requirement do not run in Apple CI.

`tests/debuginfo/drop-locations.rs` is staying disabled for now because gdb doesn't know to stop on the drop calls produced by a `}`: rust-lang#128971

`tests/debuginfo/function-arg-initialization.rs` now has `-Zmir-enable-passes=-SingleUseConsts`; without that we initialize the const before the function prelude: rust-lang#128945

`tests/debuginfo/by-value-non-immediate-argument.rs` fails because we don't generate a function prelude for unused non-immediate arguments, even with all optimizations disabled, and this seems to confuse debuggers on aarch64: rust-lang#128973

`tests/debuginfo/pretty-std.rs` is staying disabled on windows-gnu because our test harness doesn't know how to load our pretty-printers on that target: rust-lang#128981

`tests/debuginfo/method-on-enum.rs` and `tests/debuginfo/option-like-enum.rs` encounter some kind of gdb bug on i686-pc-windows-gnu. I don't know enough about that situation to write a good issue.

I plan on doing more work on this test suite. There's clearly a lot more basic cleanup work to do here.

try-job: aarch64-apple
try-job: aarch64-gnu
try-job: dist-i586-gnu-i586-i686-musl
try-job: i686-gnu
try-job: i686-gnu-nopt
try-job: i686-mingw
try-job: i686-msvc
try-job: test-various
try-job: x86_64-apple-1
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 16, 2024
…=<try>

Enable debuginfo tests that have been "temporarily disabled" for the past 6 years

The PR history is a bit of a mess because I had to test this a lot with try-jobs, so I'll try to summarize the non-obvious changes here.

A number of tests now have `min-lldb-version: 1800`. Those tests should have gotten an lldb version jump either in rust-lang#124781 or long ago. Note that all such tests with that lldb version requirement do not run in Apple CI.

`tests/debuginfo/drop-locations.rs` is staying disabled for now because gdb doesn't know to stop on the drop calls produced by a `}`: rust-lang#128971

`tests/debuginfo/function-arg-initialization.rs` now has `-Zmir-enable-passes=-SingleUseConsts`; without that we initialize the const before the function prelude: rust-lang#128945

`tests/debuginfo/by-value-non-immediate-argument.rs` fails because we don't generate a function prelude for unused non-immediate arguments, even with all optimizations disabled, and this seems to confuse debuggers on aarch64: rust-lang#128973

`tests/debuginfo/pretty-std.rs` is staying disabled on windows-gnu because our test harness doesn't know how to load our pretty-printers on that target: rust-lang#128981

`tests/debuginfo/method-on-enum.rs` and `tests/debuginfo/option-like-enum.rs` encounter some kind of gdb bug on i686-pc-windows-gnu. I don't know enough about that situation to write a good issue.

I plan on doing more work on this test suite. There's clearly a lot more basic cleanup work to do here.

try-job: x86_64-gnu
try-job: x86_64-gnu-distcheck
try-job: x86_64-gnu-llvm-17
try-job: x86_64-gnu-llvm-18
try-job: x86_64-gnu-nopt
try-job: x86_64-gnu-stable
try-job: x86_64-mingw
try-job: x86_64-msvc
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 16, 2024
…=compiler-errors

Enable debuginfo tests that have been "temporarily disabled" for the past 6 years

The PR history is a bit of a mess because I had to test this a lot with try-jobs, so I'll try to summarize the non-obvious changes here.

A number of tests now have `min-lldb-version: 1800`. Those tests should have gotten an lldb version jump either in rust-lang#124781 or long ago. Note that all such tests with that lldb version requirement do not run in Apple CI.

`tests/debuginfo/drop-locations.rs` is staying disabled for now because gdb doesn't know to stop on the drop calls produced by a `}`: rust-lang#128971

`tests/debuginfo/function-arg-initialization.rs` now has `-Zmir-enable-passes=-SingleUseConsts`; without that we initialize the const before the function prelude: rust-lang#128945

`tests/debuginfo/by-value-non-immediate-argument.rs` fails because we don't generate a function prelude for unused non-immediate arguments, even with all optimizations disabled, and this seems to confuse debuggers on aarch64: rust-lang#128973

`tests/debuginfo/pretty-std.rs` is staying disabled on windows-gnu because our test harness doesn't know how to load our pretty-printers on that target: rust-lang#128981

`tests/debuginfo/method-on-enum.rs` and `tests/debuginfo/option-like-enum.rs` encounter some kind of gdb bug on i686-pc-windows-gnu. I don't know enough about that situation to write a good issue.

I plan on doing more work on this test suite. There's clearly a lot more basic cleanup work to do here.
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Aug 17, 2024
…-errors

Enable debuginfo tests that have been "temporarily disabled" for the past 6 years

The PR history is a bit of a mess because I had to test this a lot with try-jobs, so I'll try to summarize the non-obvious changes here.

A number of tests now have `min-lldb-version: 1800`. Those tests should have gotten an lldb version jump either in rust-lang/rust#124781 or long ago. Note that all such tests with that lldb version requirement do not run in Apple CI.

`tests/debuginfo/drop-locations.rs` is staying disabled for now because gdb doesn't know to stop on the drop calls produced by a `}`: rust-lang/rust#128971

`tests/debuginfo/function-arg-initialization.rs` now has `-Zmir-enable-passes=-SingleUseConsts`; without that we initialize the const before the function prelude: rust-lang/rust#128945

`tests/debuginfo/by-value-non-immediate-argument.rs` fails because we don't generate a function prelude for unused non-immediate arguments, even with all optimizations disabled, and this seems to confuse debuggers on aarch64: rust-lang/rust#128973

`tests/debuginfo/pretty-std.rs` is staying disabled on windows-gnu because our test harness doesn't know how to load our pretty-printers on that target: rust-lang/rust#128981

`tests/debuginfo/method-on-enum.rs` and `tests/debuginfo/option-like-enum.rs` encounter some kind of gdb bug on i686-pc-windows-gnu. I don't know enough about that situation to write a good issue.

I plan on doing more work on this test suite. There's clearly a lot more basic cleanup work to do here.
lnicola pushed a commit to lnicola/rust-analyzer that referenced this pull request Aug 29, 2024
…-errors

Enable debuginfo tests that have been "temporarily disabled" for the past 6 years

The PR history is a bit of a mess because I had to test this a lot with try-jobs, so I'll try to summarize the non-obvious changes here.

A number of tests now have `min-lldb-version: 1800`. Those tests should have gotten an lldb version jump either in rust-lang/rust#124781 or long ago. Note that all such tests with that lldb version requirement do not run in Apple CI.

`tests/debuginfo/drop-locations.rs` is staying disabled for now because gdb doesn't know to stop on the drop calls produced by a `}`: rust-lang/rust#128971

`tests/debuginfo/function-arg-initialization.rs` now has `-Zmir-enable-passes=-SingleUseConsts`; without that we initialize the const before the function prelude: rust-lang/rust#128945

`tests/debuginfo/by-value-non-immediate-argument.rs` fails because we don't generate a function prelude for unused non-immediate arguments, even with all optimizations disabled, and this seems to confuse debuggers on aarch64: rust-lang/rust#128973

`tests/debuginfo/pretty-std.rs` is staying disabled on windows-gnu because our test harness doesn't know how to load our pretty-printers on that target: rust-lang/rust#128981

`tests/debuginfo/method-on-enum.rs` and `tests/debuginfo/option-like-enum.rs` encounter some kind of gdb bug on i686-pc-windows-gnu. I don't know enough about that situation to write a good issue.

I plan on doing more work on this test suite. There's clearly a lot more basic cleanup work to do here.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

lldb can not print Option<i32>
6 participants