rust/tests/debuginfo/basic-stepping.rs
Martin Nordholts 5ad2f434dc rustc_codegen_llvm: Require opt-level >= 1 for index-based loop
To make debugger stepping intuitive with `-Copt-level=0`. See the
adjusted `basic-stepping.rs` test.

This is kind of a revert of bd0aae92dc, except we don't revert it,
we just make it conditional on `opt-level`. That commit regressed
`basic-stepping.rs`, but it was not noticed since that test did not
exist back then. I have retroactively bisected to find that out.

It seems messy to sprinkle if-cases inside of the
`write_operand_repeatedly()` so make the whole function conditional.

The test that bd0aae92dc added in
`tests/codegen/issues/issue-111603.rs` already use `-Copt-level=3`, so
we don't need to adjust the compiler flags for it to keep passing.
2025-11-13 06:29:55 +01:00

50 lines
1.5 KiB
Rust

//! Test that stepping through a simple program with a debugger one line at a
//! time works intuitively, e.g. that `next` takes you to the next source line.
//! Regression test for <https://github.com/rust-lang/rust/issues/33013>.
//@ ignore-aarch64: Doesn't work yet.
//@ ignore-loongarch64: Doesn't work yet.
//@ ignore-riscv64: Doesn't work yet.
//@ compile-flags: -g
//@ ignore-backends: gcc
// gdb-command: run
// FIXME(#97083): Should we be able to break on initialization of zero-sized types?
// FIXME(#97083): Right now the first breakable line is:
// gdb-check: let mut c = 27;
// gdb-command: next
// gdb-check: let d = c = 99;
// gdb-command: next
// FIXME(#33013): gdb-check: let e = "hi bob";
// FIXME(#33013): gdb-command: next
// FIXME(#33013): gdb-check: let f = b"hi bob";
// FIXME(#33013): gdb-command: next
// FIXME(#33013): gdb-check: let g = b'9';
// FIXME(#33013): gdb-command: next
// gdb-check: let h = ["whatever"; 8];
// gdb-command: next
// gdb-check: let i = [1,2,3,4];
// gdb-command: next
// gdb-check: let j = (23, "hi");
// gdb-command: next
// gdb-check: let k = 2..3;
// gdb-command: next
// gdb-check: let l = &i[k];
// gdb-command: next
// gdb-check: let m: *const() = &a;
fn main () {
let a = (); // #break
let b : [i32; 0] = [];
let mut c = 27;
let d = c = 99;
let e = "hi bob";
let f = b"hi bob";
let g = b'9';
let h = ["whatever"; 8];
let i = [1,2,3,4];
let j = (23, "hi");
let k = 2..3;
let l = &i[k];
let m: *const() = &a;
}