Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 55 additions & 2 deletions tests/debuginfo/basic-stepping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
//@ revisions: default-mir-passes no-SingleUseConsts-mir-pass
//@ [no-SingleUseConsts-mir-pass] compile-flags: -Zmir-enable-passes=-SingleUseConsts

// === GDB TESTS ===================================================================================

//@ 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;
Expand All @@ -39,9 +39,62 @@
//@ gdb-command: next
//@ gdb-check: let m: *const() = &a;

// === LLDB TESTS ==================================================================================

// Unlike gdb, lldb will display 7 lines of context by default. It seems
// impossible to get it down to 1. The best we can do is to show the current
// line and one above. That is not ideal, but it will do for now.
//@ lldb-command: settings set stop-line-count-before 1
//@ lldb-command: settings set stop-line-count-after 0

//@ lldb-command: run
// In `breakpoint_callback()` in `./src/etc/lldb_batchmode.py` we do
// `SetSelectedFrame()`, which causes LLDB to show the current line and one line
// before (since we changed `stop-line-count-before`). Note that
// `normalize_whitespace()` in `lldb_batchmode.py` removes the newlines of the
// output. So the current line and the line before actually ends up on the same
// output line. That's fine.
//@ lldb-check: [...]let mut c = 27;[...]
//@ lldb-command: next
// From now on we must manually `frame select` to see the current line (and one
// line before).
//@ lldb-command: frame select
//@ lldb-check: [...]let d = c = 99;[...]
//@ lldb-command: next
//@ lldb-command: frame select
//@ [no-SingleUseConsts-mir-pass] lldb-check: [...]let e = "hi bob";[...]
//@ [no-SingleUseConsts-mir-pass] lldb-command: next
//@ [no-SingleUseConsts-mir-pass] lldb-command: frame select
//@ [no-SingleUseConsts-mir-pass] lldb-check: [...]let f = b"hi bob";[...]
//@ [no-SingleUseConsts-mir-pass] lldb-command: next
//@ [no-SingleUseConsts-mir-pass] lldb-command: frame select
//@ [no-SingleUseConsts-mir-pass] lldb-check: [...]let g = b'9';[...]
//@ [no-SingleUseConsts-mir-pass] lldb-command: next
//@ [no-SingleUseConsts-mir-pass] lldb-command: frame select
//@ lldb-check: [...]let h = ["whatever"; 8];[...]
//@ lldb-command: next
//@ lldb-command: frame select
//@ lldb-check: [...]let i = [1,2,3,4];[...]
//@ lldb-command: next
//@ lldb-command: frame select
//@ lldb-check: [...]let j = (23, "hi");[...]
//@ lldb-command: next
//@ lldb-command: frame select
//@ lldb-check: [...]let k = 2..3;[...]
//@ lldb-command: next
//@ lldb-command: frame select
//@ lldb-check: [...]let l = &i[k];[...]
//@ lldb-command: next
//@ lldb-command: frame select
//@ lldb-check: [...]let m: *const() = &a;[...]
Copy link
Member

Choose a reason for hiding this comment

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

Question (non-blocking): do we know if there's a min lldb version we need to gate this test on?

Copy link
Member Author

Choose a reason for hiding this comment

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

This test passes locally for me with lldb-15 to lldb-20. It fails with lldb-14:

$ for lldb in lldb-14 lldb-15 lldb-16 lldb-17 lldb-18 lldb-19 lldb-20 ; do sudo apt install $lldb -y >/dev/null 2>&1 ; echo -e "\nUsing $lldb:" ; ./x --set build.lldb=$lldb test tests/debuginfo/basic-stepping.rs --force-rerun  2>&1 | grep 'test result:' ; done

Using lldb-14:
test result: FAILED. 2 passed; 2 failed; 0 ignored; 0 measured; 342 filtered out; finished in 247.02ms

Using lldb-15:
test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 342 filtered out; finished in 1.02s

Using lldb-16:
test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 342 filtered out; finished in 1.01s

Using lldb-17:
test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 342 filtered out; finished in 983.62ms

Using lldb-18:
test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 342 filtered out; finished in 1.00s

Using lldb-19:
test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 342 filtered out; finished in 997.47ms

Using lldb-20:
test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 342 filtered out; finished in 944.02ms

To get lldb-15 to pass I actually need to set PYTHONPATH to bring python3-six into scope, which in turn requires a small compiletest patch I will shortly create a PR for:

$ for lldb in lldb-15  ; do sudo apt install $lldb -y >/dev/null 2>&1 ; echo -e "\nUsing $lldb:" ; PYTHONPATH=/usr/lib/python3/dist-packages ./x --set build.lldb=$lldb test tests/debuginfo/basic-stepping.rs --force-rerun  2>&1 | grep 'test result:' ; done

Using lldb-15:
test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 342 filtered out; finished in 1.00s

So even if the lldb situation in CI is a bit messy (see #152010 which I suspect you already know about), this seems fine to merge.

Copy link
Member Author

Choose a reason for hiding this comment

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

PR created: #153810


#![allow(unused_assignments, unused_variables)]

fn main () {
let a = (); // #break
let b : [i32; 0] = [];
// FIXME(#97083): Should we be able to break on initialization of zero-sized types?
// FIXME(#97083): Right now the first breakable line is:
let mut c = 27;
let d = c = 99;
let e = "hi bob";
Expand Down
Loading