-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Expand file tree
/
Copy pathbasic-stepping.rs
More file actions
150 lines (136 loc) · 5.98 KB
/
basic-stepping.rs
File metadata and controls
150 lines (136 loc) · 5.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
//! 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>.
// Flaky. See https://github.com/rust-lang/rust/pull/153877#issuecomment-4064897776.
//@ ignore-aarch64-pc-windows-msvc
//@ ignore-loongarch64: Doesn't work yet.
//@ ignore-riscv64: Doesn't work yet.
//@ ignore-backends: gcc
// Debugger tests need debuginfo
//@ compile-flags: -g
// FIXME(#128945): SingleUseConsts shouldn't need to be disabled.
//@ revisions: default-mir-passes no-SingleUseConsts-mir-pass
//@ [no-SingleUseConsts-mir-pass] compile-flags: -Zmir-enable-passes=-SingleUseConsts
// === GDB TESTS ===================================================================================
//@ gdb-command: run
//@ gdb-check: let mut c = 27;
//@ gdb-command: next
//@ gdb-check: let d = c = 99;
//@ gdb-command: next
//@ [no-SingleUseConsts-mir-pass] gdb-check: let e = "hi bob";
//@ [no-SingleUseConsts-mir-pass] gdb-command: next
//@ [no-SingleUseConsts-mir-pass] gdb-check: let f = b"hi bob";
//@ [no-SingleUseConsts-mir-pass] gdb-command: next
//@ [no-SingleUseConsts-mir-pass] gdb-check: let g = b'9';
//@ [no-SingleUseConsts-mir-pass] 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;
// === 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;[...]
// === CDB TESTS ===================================================================================
// Enable source line support. See
// https://learn.microsoft.com/en-us/windows-hardware/drivers/debuggercmds/-lines--toggle-source-line-support-.
//@ cdb-command: .lines -e
// Display source lines and source line numbers at the command prompt. See
// https://learn.microsoft.com/en-us/windows-hardware/drivers/debuggercmds/l---l---set-source-options-.
//@ cdb-command: l+s
// Enter "source mode" so `p` steps source lines and not assembly instructions.
//@ cdb-command: l+t
// `g` means "go". See
// https://learn.microsoft.com/en-us/windows-hardware/drivers/debuggercmds/g--go-.
//@ cdb-command: g
// `p` means "step". See
// https://learn.microsoft.com/en-us/windows-hardware/drivers/debuggercmds/p--step-.
//@ cdb-command: p
//@ cdb-check: [...]: let mut c = 27;
//@ cdb-command: p
//@ cdb-check: [...]: let d = c = 99;
//@ [no-SingleUseConsts-mir-pass] cdb-command: p
//@ [no-SingleUseConsts-mir-pass] cdb-check: [...]: let e = "hi bob";
//@ [no-SingleUseConsts-mir-pass] cdb-command: p
//@ [no-SingleUseConsts-mir-pass] cdb-check: [...]: let f = b"hi bob";
//@ [no-SingleUseConsts-mir-pass] cdb-command: p
//@ [no-SingleUseConsts-mir-pass] cdb-check: [...]: let g = b'9';
//@ cdb-command: p
//@ cdb-check: [...]: let h = ["whatever"; 8];
//@ cdb-command: p
//@ cdb-check: [...]: let i = [1,2,3,4];
//@ cdb-command: p
//@ cdb-check: [...]: let j = (23, "hi");
//@ cdb-command: p
//@ cdb-check: [...]: let k = 2..3;
//@ cdb-command: p
//@ cdb-check: [...]: let l = &i[k];
//@ cdb-command: p
//@ cdb-check: [...]: let m: *const() = &a;
#![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";
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;
}