Skip to content

Document debuginfo repr directive - #2947

Open
Walnut356 wants to merge 1 commit into
rust-lang:mainfrom
Walnut356:di_test
Open

Document debuginfo repr directive#2947
Walnut356 wants to merge 1 commit into
rust-lang:mainfrom
Walnut356:di_test

Conversation

@Walnut356

Copy link
Copy Markdown
Contributor

Documents the directive added in rust-lang/rust#158298 as part of rust-lang/rust#148483 (I also a fixed a few things that have changed in the lead-up to adding the directive).

I'm planning on coming back and filling the testing section a bit more once the GDB implementation is finalized. I also want to fill out the section on writing GDB visualizers, but that's not as urgent.

@Kobzol @jieyouxu

@rustbot

rustbot commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the PR. If you have write access, feel free to merge this PR if it does not need reviews. You can request a review using r? rustc-dev-guide or r? <username>.

@rustbot rustbot added the S-waiting-on-review Status: this PR is waiting for a reviewer to verify its content label Jul 28, 2026
@Walnut356

Copy link
Copy Markdown
Contributor Author

hmm, i think that's an bug with linkcheck? Those aren't link specifiers, they're github-style alerts. mdbook added support for them a few months ago.

@Kobzol Kobzol 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.

Thanks a lot for documenting all of this! Left a few comments.

View changes since this review

Comment thread src/debuginfo/testing.md
a nightmare and lead to a [litany of issues](https://github.com/rust-lang/rust/issues/134682).
To help remedy this:

1. [`tests/debuginfo` is now opt-in](https://github.com/rust-lang/rust/pull/159455)

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.

Except for CDB, that is still implicit, AFAIK.

Comment thread src/debuginfo/testing.md

When the commands are passed to the debugger, our test framework intercepts `repr` pseudo-commands
and runs special logic on them, testing against data stored in
`tests/debuginfo/<test_name></test_name>/input/<debugger>_input/<target_group>.json`.

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.

Suggested change
`tests/debuginfo/<test_name></test_name>/input/<debugger>_input/<target_group>.json`.
`tests/debuginfo/<test_name>/input/<debugger>_input/<target_group>.json`.

Comment thread src/debuginfo/testing.md
target file (or creates a new file if necessary).

The schema of the input data is defined by the classes in
[`common.py`](https://github.com/rust-lang/rust/blob/main/src/etc/lldb_batchmode/common.py).

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.

Could you use a permalink here, please? Thanks!

Comment thread src/debuginfo/testing.md

Once imported, `common` automatically deserializes any existing input data and [stores it in the
global variable `INPUT_DATA`](https://github.com/rust-lang/rust/blob/bf9944f0b8006b152ef4d5f408ae75a0dde3d044/src/etc/lldb_batchmode/common.py#L523). This
data is what is tested against.

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.

Suggested change
data is what is tested against.
data is what we test against.

Comment thread src/debuginfo/testing.md

### Entry point and `--bless`

Upon encountering a `repr` pseudo-command, `lldb_batchmode.main` calls `dispatch_repr`, which calls

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.

I don't think that we have to document these low-level details (e.g. calling a specific function), because they should be immediately visible in the code, and more importantly they can easily change and then the docs will be stale.

Comment thread src/debuginfo/testing.md
to it, and print the exception ourselves. We can also inspect the synthetic provider class to make
sure it implements all the mandatory functions.

Errors *do not* fail fast. This is especially important now that a `--bless` option has been added.

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.

I know what you meant here, but this sounds a bit misleading - if there is an error/mismatch found, then surely the test will fail, right? Maybe add something like "do not fail the test immediately"?

Comment thread src/tests/compiletest.md
> At time of writing (July 2026) this command is limited to LLDB, with an implementation coming soon
> for GDB. There are not firm plans to port the logic to CDB.

This command effectivly de-sugars into:

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.

Suggested change
This command effectivly de-sugars into:
This command effectively desugars into:

Comment thread src/tests/compiletest.md
The `repr $VAR_NAME` command is intercepted by special logic that uses the debuggers' API to inspect
data that isn't reflected in the variable's printed output. The variable in memory is compared
against input data stored in
`tests/debuginfo/<test_name></test_name>/input/<debugger>_input/<target_group>.json` and

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.

Suggested change
`tests/debuginfo/<test_name></test_name>/input/<debugger>_input/<target_group>.json` and
`tests/debuginfo/<test_name>/input/<debugger>_input/<target_group>.json` and

Maybe we can just link to the debuginfo section here, to avoid this duplication.

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

Labels

S-waiting-on-review Status: this PR is waiting for a reviewer to verify its content

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants