-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #85020 - lrh2000:named-upvars, r=tmandry
Name the captured upvars for closures/generators in debuginfo Previously, debuggers print closures as something like ``` y::main::closure-0 (0x7fffffffdd34) ``` The pointer actually references to an upvar. It is not very obvious, especially for beginners. It's because upvars don't have names before, as they are packed into a tuple. This PR names the upvars, so we can expect to see something like ``` y::main::closure-0 {_captured_ref__b: 0x[...]} ``` r? `@tmandry` Discussed at #84752 (comment) .
- Loading branch information
Showing
9 changed files
with
276 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
// compile-flags:-g | ||
|
||
// === GDB TESTS =================================================================================== | ||
|
||
// gdb-command:run | ||
// gdb-command:print test | ||
// gdbr-check:$1 = captured_fields_1::main::{closure#0} {_ref__my_ref__my_field1: 0x[...]} | ||
// gdb-command:continue | ||
// gdb-command:print test | ||
// gdbr-check:$2 = captured_fields_1::main::{closure#1} {_ref__my_ref__my_field2: 0x[...]} | ||
// gdb-command:continue | ||
// gdb-command:print test | ||
// gdbr-check:$3 = captured_fields_1::main::{closure#2} {_ref__my_ref: 0x[...]} | ||
// gdb-command:continue | ||
// gdb-command:print test | ||
// gdbr-check:$4 = captured_fields_1::main::{closure#3} {my_ref: 0x[...]} | ||
// gdb-command:continue | ||
// gdb-command:print test | ||
// gdbr-check:$5 = captured_fields_1::main::{closure#4} {my_var__my_field2: 22} | ||
// gdb-command:continue | ||
// gdb-command:print test | ||
// gdbr-check:$6 = captured_fields_1::main::{closure#5} {my_var: captured_fields_1::MyStruct {my_field1: 11, my_field2: 22}} | ||
// gdb-command:continue | ||
|
||
// === LLDB TESTS ================================================================================== | ||
|
||
// lldb-command:run | ||
// lldb-command:print test | ||
// lldbg-check:(captured_fields_1::main::{closure#0}) $0 = { _ref__my_ref__my_field1 = 0x[...] } | ||
// lldb-command:continue | ||
// lldb-command:print test | ||
// lldbg-check:(captured_fields_1::main::{closure#1}) $1 = { _ref__my_ref__my_field2 = 0x[...] } | ||
// lldb-command:continue | ||
// lldb-command:print test | ||
// lldbg-check:(captured_fields_1::main::{closure#2}) $2 = { _ref__my_ref = 0x[...] } | ||
// lldb-command:continue | ||
// lldb-command:print test | ||
// lldbg-check:(captured_fields_1::main::{closure#3}) $3 = { my_ref = 0x[...] } | ||
// lldb-command:continue | ||
// lldb-command:print test | ||
// lldbg-check:(captured_fields_1::main::{closure#4}) $4 = { my_var__my_field2 = 22 } | ||
// lldb-command:continue | ||
// lldb-command:print test | ||
// lldbg-check:(captured_fields_1::main::{closure#5}) $5 = { my_var = { my_field1 = 11 my_field2 = 22 } } | ||
// lldb-command:continue | ||
|
||
#![feature(capture_disjoint_fields)] | ||
#![allow(unused)] | ||
|
||
struct MyStruct { | ||
my_field1: u32, | ||
my_field2: u32, | ||
} | ||
|
||
fn main() { | ||
let mut my_var = MyStruct { | ||
my_field1: 11, | ||
my_field2: 22, | ||
}; | ||
let my_ref = &mut my_var; | ||
|
||
let test = || { | ||
let a = &mut my_ref.my_field1; | ||
}; | ||
|
||
_zzz(); // #break | ||
|
||
let test = || { | ||
let a = &my_ref.my_field2; | ||
}; | ||
|
||
_zzz(); // #break | ||
|
||
let test = || { | ||
let a = &my_ref; | ||
}; | ||
|
||
_zzz(); // #break | ||
|
||
let test = || { | ||
let a = my_ref; | ||
}; | ||
|
||
_zzz(); // #break | ||
|
||
let test = move || { | ||
let a = my_var.my_field2; | ||
}; | ||
|
||
_zzz(); // #break | ||
|
||
let test = || { | ||
let a = my_var; | ||
}; | ||
|
||
_zzz(); // #break | ||
} | ||
|
||
fn _zzz() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// compile-flags:-g | ||
|
||
// === GDB TESTS =================================================================================== | ||
|
||
// gdb-command:run | ||
// gdb-command:print my_ref__my_field1 | ||
// gdbr-check:$1 = 11 | ||
// gdb-command:continue | ||
// gdb-command:print my_var__my_field2 | ||
// gdbr-check:$2 = 22 | ||
// gdb-command:continue | ||
|
||
// === LLDB TESTS ================================================================================== | ||
|
||
// lldb-command:run | ||
// lldb-command:print my_ref__my_field1 | ||
// lldbg-check:(unsigned int) $0 = 11 | ||
// lldb-command:continue | ||
// lldb-command:print my_var__my_field2 | ||
// lldbg-check:(unsigned int) $1 = 22 | ||
// lldb-command:continue | ||
|
||
#![feature(capture_disjoint_fields)] | ||
#![allow(unused)] | ||
|
||
struct MyStruct { | ||
my_field1: u32, | ||
my_field2: u32, | ||
} | ||
|
||
fn main() { | ||
let mut my_var = MyStruct { | ||
my_field1: 11, | ||
my_field2: 22, | ||
}; | ||
let my_ref = &mut my_var; | ||
|
||
let test = || { | ||
let a = my_ref.my_field1; | ||
|
||
_zzz(); // #break | ||
}; | ||
|
||
test(); | ||
|
||
let test = move || { | ||
let a = my_var.my_field2; | ||
|
||
_zzz(); // #break | ||
}; | ||
|
||
test(); | ||
} | ||
|
||
fn _zzz() {} |
Oops, something went wrong.