Skip to content

Conversation

Copy link

Copilot AI commented Nov 29, 2025

This PR adds support for revision-specific debugger commands in debuginfo tests, making them work like ./tests/ui tests.

Changes Made

  • Modified DebuggerCommands::parse_from: Added an optional test_revision parameter to filter directives based on the current revision
  • Updated parsing logic: Handle [revision] prefix in directive lines (supports both //@[revision] directive and //@ [revision] directive formats)
  • Updated call sites: All three debugger test runners (cdb, gdb, lldb) in debuginfo.rs now pass self.revision
  • Added unit tests: Tests for the parsing helper functions
  • Improved error messages: Failure messages now include revision info (e.g., check directive(s) from '/path/test.rs#revision')
  • Fixed typo: Corrected "debuuger" to "debugger" in doc comment

Example Usage

Tests can now use revision-specific debugger commands:

//@ revisions: lto no-lto
//@ [lto] compile-flags: -C lto
//@ [lto] gdb-command:print optimized_value
//@ [lto] gdb-check:$1 = 42
//@ [no-lto] gdb-command:print unoptimized_value  
//@ [no-lto] gdb-check:$1 = 100

Note: The directive format must use a space after ], not a colon. For example, //@[revision] gdb-check:... is valid, but //@[revision]: gdb-check:... is not valid compiletest syntax.

Original prompt

Make ./tests/debuginfo also support revisions, just like ./tests/ui.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits November 29, 2025 10:18
Co-authored-by: Enselic <115040+Enselic@users.noreply.github.com>
Co-authored-by: Enselic <115040+Enselic@users.noreply.github.com>
Copilot AI changed the title [WIP] Add revision support to debuginfo tests Add revision support to debuginfo test debugger commands Nov 29, 2025
Copilot AI requested a review from Enselic November 29, 2025 10:24
Copilot finished work on behalf of Enselic November 29, 2025 10:24
@Enselic
Copy link
Owner

Enselic commented Nov 29, 2025

@copilot A test of mine looks like this on line 22:

//@[no-SingleUseConsts-mir-pass]: gdb-check:   let e = "hi bob";

but I get this failure:

thread '<unnamed>' (2581365) panicked at src/tools/compiletest/src/lib.rs:877:9:
directives check failed:
ERROR: unknown compiletest directive `: gdb-check:   let e = "hi bob";` at /home/martin/src/rust-add-revision-support-debuginfo/tests/debuginfo/basic-stepping.rs:22
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Build completed unsuccessfully in 0:03:01

Copy link
Author

Copilot AI commented Nov 29, 2025

@copilot A test of mine looks like this on line 22:

The error you're seeing is caused by the directive format, not by my changes. The format //@[revision]: directive (with a colon immediately after the ]) is not valid compiletest syntax.

The correct format should be:

//@[no-SingleUseConsts-mir-pass] gdb-check:   let e = "hi bob";

Note the space after ] instead of :. The main compiletest directive parser in line.rs extracts the directive name by splitting on : or space, so when you have : gdb-check:..., it parses the name as an empty string (everything before the first :), which is not a known directive.

This error would have occurred before my changes as well - the directive check happens during test collection, before the debugger command parsing runs.

Copilot finished work on behalf of Enselic November 29, 2025 14:41
@Enselic
Copy link
Owner

Enselic commented Nov 29, 2025

@copilot Upon failures there is no info about what revision that runs:

$ ./x test tests/debuginfo/basic-stepping.rs
Building bootstrap
    Finished `dev` profile [unoptimized] target(s) in 0.04s
WARNING: you have not made a `bootstrap.toml`
HELP: consider running `./x.py setup` or copying `bootstrap.example.toml` by running `cp bootstrap.example.toml bootstrap.toml`
/home/martin/src/rust-add-revision-support-debuginfo/build/x86_64-unknown-linux-gnu/ci-llvm/bin/llvm-strip does not exist; skipping copy
Building stage1 compiler artifacts (stage0 -> stage1, x86_64-unknown-linux-gnu)
    Finished `release` profile [optimized] target(s) in 0.15s
Creating a sysroot for stage1 compiler (use `rustup toolchain link 'name' build/host/stage1`)
Building stage1 lld-wrapper (stage0 -> stage1, x86_64-unknown-linux-gnu)
    Finished `release` profile [optimized] target(s) in 0.08s
Building stage1 library artifacts (stage1 -> stage1, x86_64-unknown-linux-gnu)
    Finished `release` profile [optimized] target(s) in 0.02s
Building stage1 compiletest (stage0 -> stage1, x86_64-unknown-linux-gnu)
    Finished `release` profile [optimized] target(s) in 0.09s
Testing stage1 with compiletest suite=debuginfo mode=debuginfo (x86_64-unknown-linux-gnu)

running 1 tests

[debuginfo-gdb] tests/debuginfo/basic-stepping.rs ... F


failures:

---- [debuginfo-gdb] tests/debuginfo/basic-stepping.rs stdout ----
NOTE: compiletest thinks it is using GDB version 15000050

error: check directive(s) from `/home/martin/src/rust-add-revision-support-debuginfo/tests/debuginfo/basic-stepping.rs` not found in debugger output. errors:
    (basic-stepping.rs:22) `   let e = "hi bob";`
    (basic-stepping.rs:24) `   let f = b"hi bob";`
    (basic-stepping.rs:26) `   let g = b'9';`
the following subset of check directive(s) was found successfully:
    (basic-stepping.rs:18) `43      let mut c = 27;`
    (basic-stepping.rs:20) `44      let d = c = 99;`
    (basic-stepping.rs:28) `48      let h = ["whatever"; 8];`
    (basic-stepping.rs:30) `49      let i = [1,2,3,4];`
    (basic-stepping.rs:32) `50      let j = (23, "hi");`
    (basic-stepping.rs:34) `51      let k = 2..3;`
    (basic-stepping.rs:36) `52      let l = &i[k];`
    (basic-stepping.rs:38) `53      let m: *const() = &a;`
status: exit status: 0
command: PYTHONPATH="/home/martin/src/rust-add-revision-support-debuginfo/src/etc" "/usr/bin/gdb" "-quiet" "-batch" "-nx" "-command=/home/martin/src/rust-add-revision-support-debuginfo/build/x86_64-unknown-linux-gnu/test/debuginfo/basic-stepping.gdb/basic-stepping.debugger.script"
--- stdout -------------------------------
GNU gdb (Ubuntu 15.0.50.20240403-0ubuntu1) 15.0.50.20240403-git
Copyright (C) 2024 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word".
Breakpoint 1 at 0x1bd9: file tests/debuginfo/basic-stepping.rs, line 43.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Breakpoint 1, basic_stepping::main () at tests/debuginfo/basic-stepping.rs:43
43          let mut c = 27;
44          let d = c = 99;
48          let h = ["whatever"; 8];
49          let i = [1,2,3,4];
50          let j = (23, "hi");
51          let k = 2..3;
52          let l = &i[k];
53          let m: *const() = &a;
54      }
std::sys::backtrace::__rust_begin_short_backtrace<fn(), ()> (f=0x555555555ba0 <basic_stepping::main>) at /rustc/FAKE_PREFIX/library/std/src/sys/backtrace.rs:166
std::rt::lang_start::{closure#0}<()> () at /rustc/FAKE_PREFIX/library/std/src/rt.rs:206
A debugging session is active.

        Inferior 1 [process 2606177] will be killed.

Quit anyway? (y or n) [answered Y; input not from terminal]
------------------------------------------
--- stderr -------------------------------
warning: 166    /rustc/FAKE_PREFIX/library/std/src/sys/backtrace.rs: No such file or directory
warning: 206    /rustc/FAKE_PREFIX/library/std/src/rt.rs: No such file or directory
------------------------------------------

---- [debuginfo-gdb] tests/debuginfo/basic-stepping.rs stdout end ----

failures:
    [debuginfo-gdb] tests/debuginfo/basic-stepping.rs

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 168 filtered out; finished in 227.82ms

Some tests failed in compiletest suite=debuginfo mode=debuginfo host=x86_64-unknown-linux-gnu target=x86_64-unknown-linux-gnu
Build completed unsuccessfully in 0:00:03

Co-authored-by: Enselic <115040+Enselic@users.noreply.github.com>
Copy link
Author

Copilot AI commented Nov 29, 2025

@copilot Upon failures there is no info about what revision that runs:

Added revision info to the error message in commit 12acdc4. Now when a test with revisions fails, the error will show:

error: check directive(s) from `/path/to/test.rs#revision-name` not found in debugger output.

The #revision-name suffix will only appear when testing a revision.

@Enselic
Copy link
Owner

Enselic commented Dec 1, 2025

@copilot try again

Copy link
Author

Copilot AI commented Dec 1, 2025

@copilot try again

Could you clarify what specific issue you're encountering? The current implementation:

  1. Supports both //@[revision] directive and //@ [revision] directive formats
  2. Includes revision info in error messages (e.g., check directive(s) from '/path/test.rs#revision')
  3. Filters debugger commands based on the current revision

If you're still seeing an issue, please share:

  • The test file content with revisions
  • The exact error message
  • What behavior you expected vs. what you observed

Copilot finished work on behalf of Enselic December 1, 2025 06:35
@Enselic
Copy link
Owner

Enselic commented Dec 1, 2025

@copilot Upon failures there is no info about what revision that runs:

$ ./x test tests/debuginfo/basic-stepping.rs
Building bootstrap
    Finished `dev` profile [unoptimized] target(s) in 0.04s
WARNING: you have not made a `bootstrap.toml`
HELP: consider running `./x.py setup` or copying `bootstrap.example.toml` by running `cp bootstrap.example.toml bootstrap.toml`
/home/martin/src/rust-add-revision-support-debuginfo/build/x86_64-unknown-linux-gnu/ci-llvm/bin/llvm-strip does not exist; skipping copy
Building stage1 compiler artifacts (stage0 -> stage1, x86_64-unknown-linux-gnu)
    Finished `release` profile [optimized] target(s) in 0.15s
Creating a sysroot for stage1 compiler (use `rustup toolchain link 'name' build/host/stage1`)
Building stage1 lld-wrapper (stage0 -> stage1, x86_64-unknown-linux-gnu)
    Finished `release` profile [optimized] target(s) in 0.08s
Building stage1 library artifacts (stage1 -> stage1, x86_64-unknown-linux-gnu)
    Finished `release` profile [optimized] target(s) in 0.02s
Building stage1 compiletest (stage0 -> stage1, x86_64-unknown-linux-gnu)
    Finished `release` profile [optimized] target(s) in 0.09s
Testing stage1 with compiletest suite=debuginfo mode=debuginfo (x86_64-unknown-linux-gnu)

running 1 tests

[debuginfo-gdb] tests/debuginfo/basic-stepping.rs ... F


failures:

---- [debuginfo-gdb] tests/debuginfo/basic-stepping.rs stdout ----
NOTE: compiletest thinks it is using GDB version 15000050

error: check directive(s) from `/home/martin/src/rust-add-revision-support-debuginfo/tests/debuginfo/basic-stepping.rs` not found in debugger output. errors:
    (basic-stepping.rs:22) `   let e = "hi bob";`
    (basic-stepping.rs:24) `   let f = b"hi bob";`
    (basic-stepping.rs:26) `   let g = b'9';`
the following subset of check directive(s) was found successfully:
    (basic-stepping.rs:18) `43      let mut c = 27;`
    (basic-stepping.rs:20) `44      let d = c = 99;`
    (basic-stepping.rs:28) `48      let h = ["whatever"; 8];`
    (basic-stepping.rs:30) `49      let i = [1,2,3,4];`
    (basic-stepping.rs:32) `50      let j = (23, "hi");`
    (basic-stepping.rs:34) `51      let k = 2..3;`
    (basic-stepping.rs:36) `52      let l = &i[k];`
    (basic-stepping.rs:38) `53      let m: *const() = &a;`
status: exit status: 0
command: PYTHONPATH="/home/martin/src/rust-add-revision-support-debuginfo/src/etc" "/usr/bin/gdb" "-quiet" "-batch" "-nx" "-command=/home/martin/src/rust-add-revision-support-debuginfo/build/x86_64-unknown-linux-gnu/test/debuginfo/basic-stepping.gdb/basic-stepping.debugger.script"
--- stdout -------------------------------
GNU gdb (Ubuntu 15.0.50.20240403-0ubuntu1) 15.0.50.20240403-git
Copyright (C) 2024 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word".
Breakpoint 1 at 0x1bd9: file tests/debuginfo/basic-stepping.rs, line 43.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Breakpoint 1, basic_stepping::main () at tests/debuginfo/basic-stepping.rs:43
43          let mut c = 27;
44          let d = c = 99;
48          let h = ["whatever"; 8];
49          let i = [1,2,3,4];
50          let j = (23, "hi");
51          let k = 2..3;
52          let l = &i[k];
53          let m: *const() = &a;
54      }
std::sys::backtrace::__rust_begin_short_backtrace<fn(), ()> (f=0x555555555ba0 <basic_stepping::main>) at /rustc/FAKE_PREFIX/library/std/src/sys/backtrace.rs:166
std::rt::lang_start::{closure#0}<()> () at /rustc/FAKE_PREFIX/library/std/src/rt.rs:206
A debugging session is active.

        Inferior 1 [process 2606177] will be killed.

Quit anyway? (y or n) [answered Y; input not from terminal]
------------------------------------------
--- stderr -------------------------------
warning: 166    /rustc/FAKE_PREFIX/library/std/src/sys/backtrace.rs: No such file or directory
warning: 206    /rustc/FAKE_PREFIX/library/std/src/rt.rs: No such file or directory
------------------------------------------

---- [debuginfo-gdb] tests/debuginfo/basic-stepping.rs stdout end ----

failures:
    [debuginfo-gdb] tests/debuginfo/basic-stepping.rs

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 168 filtered out; finished in 227.82ms

Some tests failed in compiletest suite=debuginfo mode=debuginfo host=x86_64-unknown-linux-gnu target=x86_64-unknown-linux-gnu
Build completed unsuccessfully in 0:00:03

Copy link
Author

Copilot AI commented Dec 1, 2025

@copilot Upon failures there is no info about what revision that runs:

...

Looking at your output, the test header shows [debuginfo-gdb] tests/debuginfo/basic-stepping.rs without a #revision suffix, which means the test is running without revisions enabled.

For revision support to work, your test file needs:

  1. A //@ revisions: rev1 rev2 directive at the top
  2. Revision-specific directives in format //@ [rev1] gdb-check:... (space after @, no colon after ])

When revisions are properly configured, both the test header and error message will show the revision:

  • Test header: [debuginfo-gdb] tests/debuginfo/basic-stepping.rs#rev1
  • Error message: check directive(s) from '.../basic-stepping.rs#rev1'

Could you share your test file's first ~10 lines to verify the revision directive is present?

Copilot finished work on behalf of Enselic December 1, 2025 12:04
@Enselic
Copy link
Owner

Enselic commented Dec 2, 2025

@copilot Can I push a commit with the whole test instead?

Copy link
Author

Copilot AI commented Dec 2, 2025

@copilot Can I push a commit with the whole test instead?

Yes, that would be helpful! You can push a commit with your test file to your branch. That way I can see the full test setup including the //@ revisions: directive and all the revision-specific directives to help debug why the revision isn't showing in the output.

Copilot finished work on behalf of Enselic December 2, 2025 05:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants