This repository was archived by the owner on May 28, 2025. It is now read-only.
Commit 74c1289
authored
Rollup merge of rust-lang#124500 - VladimirMakaev:lldb-str-formatters, r=Mark-Simulacrum
lldb-formatters: Use StdSliceSyntheticProvider for &str
&str has associated summary provider which correctly displays string values in debugger, but while working on rust-lang#124458 I've noticed that a &str inside an enum displays a blob of memory until a 0 is reached (as a c-string) which makes a very bizarre experience when debugging
However there is already StdSliceSyntheticProvider which we use for other slices. This PR enables the same synthetic provider to be used for &str, however the summary provider is still fixed to return the string value
I've added a test `debuginfo/strings-and-strs.rs` which prior to this PR would output the following in LLDB:
```
* thread #1, name = 'a', stop reason = breakpoint 1.1
frame #0: 0x0000555555556383 a`strings_and_strs::main::h1d2b5f9227b8767d at strings-and-strs.rs:47:5
44 let plain_str = "Hello";
45 let str_in_struct = Foo { inner: "Hello" };
46 let str_in_tuple = ("Hello", "World");
-> 47 zzz(); // #break
48 }
49
50 fn zzz() {
(lldb) frame var
(alloc::string::String) plain_string = "Hello" {
vec = size=5 {
[0] = 'H'
[1] = 'e'
[2] = 'l'
[3] = 'l'
[4] = 'o'
}
}
(&str) plain_str = "Hello" {
data_ptr = 0x0000555555557263 "HelloWorld\U00000001gdb_load_rust_pretty_printers.py"
length = 5
}
(strings_and_strs::Foo) str_in_struct = {
inner = "Hello" {
data_ptr = 0x0000555555557263 "HelloWorld\U00000001gdb_load_rust_pretty_printers.py"
length = 5
}
}
((&str, &str)) str_in_tuple = {
0 = "Hello" {
data_ptr = 0x0000555555557263 "HelloWorld\U00000001gdb_load_rust_pretty_printers.py"
length = 5
}
1 = "World" {
data_ptr = 0x0000555555557268 "World\U00000001gdb_load_rust_pretty_printers.py"
length = 5
}
}
```
After this PR it would look the following way:
```
* thread #1, name = 'a', stop reason = breakpoint 1.1
frame #0: 0x0000555555556383 a`strings_and_strs::main::h1d2b5f9227b8767d at strings-and-strs.rs:47:5
44 let plain_str = "Hello";
45 let str_in_struct = Foo { inner: "Hello" };
46 let str_in_tuple = ("Hello", "World");
-> 47 zzz(); // #break
48 }
49
50 fn zzz() {
(lldb) frame var
(alloc::string::String) plain_string = "Hello" {
vec = size=5 {
[0] = 'H'
[1] = 'e'
[2] = 'l'
[3] = 'l'
[4] = 'o'
}
}
(&str) plain_str = "Hello" {
[0] = 'H'
[1] = 'e'
[2] = 'l'
[3] = 'l'
[4] = 'o'
}
(strings_and_strs::Foo) str_in_struct = {
inner = "Hello" {
[0] = 'H'
[1] = 'e'
[2] = 'l'
[3] = 'l'
[4] = 'o'
}
}
((&str, &str)) str_in_tuple = {
0 = "Hello" {
[0] = 'H'
[1] = 'e'
[2] = 'l'
[3] = 'l'
[4] = 'o'
}
1 = "World" {
[0] = 'W'
[1] = 'o'
[2] = 'r'
[3] = 'l'
[4] = 'd'
}
}
```File tree
4 files changed
+68
-3
lines changed- src/etc
- tests/debuginfo
4 files changed
+68
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | | - | |
| 94 | + | |
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
159 | 159 | | |
160 | 160 | | |
161 | 161 | | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
162 | 165 | | |
163 | 166 | | |
164 | 167 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 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 | + | |
0 commit comments