File: skip_second_statement_collapse.rs

package info (click to toggle)
rustc 1.85.0%2Bdfsg3-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental, sid, trixie
  • size: 893,396 kB
  • sloc: xml: 158,127; python: 35,830; javascript: 19,497; cpp: 19,002; sh: 17,245; ansic: 13,127; asm: 4,376; makefile: 1,051; perl: 29; lisp: 29; ruby: 19; sql: 11
file content (168 lines) | stat: -rw-r--r-- 4,522 bytes parent folder | download | duplicates (3)
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
//@ ignore-lldb

// Test that statement, skipped/added/reordered by macros, is correctly processed in debuginfo
// Performed step-over and step-into debug stepping through call statements.

//@ compile-flags:-g

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

// gdb-command:run
// gdb-command:next
// gdb-command:frame
// gdb-check:[...]#loc_rem1_call1[...]
// gdb-command:next
// gdb-command:frame
// gdb-check:[...]#loc_rem1_call3[...]
// gdb-command:next
// gdb-command:frame
// gdb-check:[...]#loc_rem2_call1[...]
// gdb-command:step
// gdb-command:frame
// gdb-check:[...]#loc_call1[...]
// gdb-command:next 2
// gdb-check:[...]#loc_rem2_call3[...]
// gdb-command:step 2
// gdb-command:frame
// gdb-check:[...]#loc_call3_println[...]
// gdb-command:next 3
// gdb-command:frame
// gdb-check:[...]#loc_after_rem[...]
// gdb-command:next
// gdb-command:frame
// gdb-check:[...]#loc_add1_call1[...]
// gdb-command:next
// gdb-command:frame
// gdb-check:[...]#loc_add_macro[...]
// gdb-command:next
// gdb-command:frame
// gdb-check:[...]#loc_add1_call3[...]
// gdb-command:next
// gdb-command:frame
// gdb-check:[...]#loc_add2_call1[...]
// gdb-command:step
// gdb-command:frame
// gdb-check:[...]#loc_call1[...]
// gdb-command:next 2
// gdb-check:[...]#loc_add_macro[...]
// gdb-command:step
// gdb-command:frame
// gdb-check:[...]#loc_call2[...]
// gdb-command:next 2
// gdb-command:frame
// gdb-check:[...]#loc_add2_call3[...]
// gdb-command:step 2
// gdb-command:frame
// gdb-check:[...]#loc_call3_println[...]
// gdb-command:next 3
// gdb-command:frame
// gdb-check:[...]#loc_reorder1_call2[...]
// gdb-command:next
// gdb-command:frame
// gdb-check:[...]#loc_reorder1_call3[...]
// gdb-command:next
// gdb-command:frame
// gdb-check:[...]#loc_reorder1_call1[...]
// gdb-command:next
// gdb-command:frame
// gdb-check:[...]#loc_reorder2_call2[...]
// gdb-command:step
// gdb-command:frame
// gdb-check:[...]#loc_call2[...]
// gdb-command:next 2
// gdb-command:frame
// gdb-check:[...]#loc_reorder2_call3[...]
// gdb-command:step
// gdb-command:frame
// gdb-check:[...]#loc_call3[...]
// gdb-command:step
// gdb-command:frame
// gdb-check:[...]#loc_call3_println[...]
// gdb-command:next 3
// gdb-command:frame
// gdb-check:[...]#loc_reorder2_call1[...]
// gdb-command:step
// gdb-command:frame
// gdb-check:[...]#loc_call1[...]
// gdb-command:next 2
// gdb-command:continue

#[inline(never)]
fn myprintln_impl(text: &str) {
    println!("{}", text)
}

#[collapse_debuginfo(yes)]
macro_rules! myprintln {
    ($($arg:tt)*) => {{
        myprintln_impl($($arg)*);
    }};
}

// Macro accepts 3 statements and removes the 2nd statement
macro_rules! remove_second_statement {
    ($s1:stmt; $s2:stmt; $s3:stmt;) => { $s1 $s3 }
}

macro_rules! add_second_statement {
    ($s1:stmt; $s3:stmt;) => {
        $s1
        call2(); // #loc_add_macro
        $s3
    }
}

macro_rules! reorder_statements {
    ($s1:stmt; $s2:stmt; $s3:stmt;) => { $s2 $s3 $s1 }
}

fn call1() {
    myprintln!("one"); // #loc_call1
}

fn call2() {
    myprintln!("two"); // #loc_call2
}

fn call3() {
    (||{
        myprintln!("three") // #loc_call3_println
    })(); // #loc_call3
}

fn main() {
    let ret = 0; // #break, step should go to call1
    remove_second_statement! { // #loc_rem1_hdr
        call1(); // #loc_rem1_call1, breakpoint should set to call1, step should go call3
        call2(); // #loc_rem1_call2, breakpoint should set to call3
        call3(); // #loc_rem1_call3
    }
    remove_second_statement! { // #loc_rem2_hdr
        call1(); // #loc_rem2_call1, breakpoint should set to call1, step should go call3
        call2(); // #loc_rem2_call2, breakpoint should set to call3
        call3(); // #loc_rem2_call3, breakpoint should set to call3
    }
    myprintln!("After remove_second_statement test"); // #loc_after_rem

    add_second_statement! { // #loc_add1_hdr
        call1(); // #loc_add1_call1
        call3(); // #loc_add1_call3
    }
    add_second_statement! { // #loc_add2_hdr
        call1(); // #loc_add2_call1
        call3(); // #loc_add2_call3
    }

    reorder_statements! { // #loc_reorder1_hdr
        call1(); // #loc_reorder1_call1
        call2(); // #loc_reorder1_call2
        call3(); // #loc_reorder1_call3
    }
    reorder_statements! { // #loc_reorder2_hdr
        call1(); // #loc_reorder2_call1
        call2(); // #loc_reorder2_call2
        call3(); // #loc_reorder2_call3
    }

    std::process::exit(ret); // #loc_exit
}