Skip to content

Commit 4a79908

Browse files
committed
Fix StdNonZeroNumberSummaryProvider.
1 parent ecee730 commit 4a79908

File tree

5 files changed

+38
-33
lines changed

5 files changed

+38
-33
lines changed

src/etc/lldb_commands

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ type summary add -F lldb_lookup.summary_lookup -e -x -h "^(core::([a-z_]+::)+)C
1515
type summary add -F lldb_lookup.summary_lookup -e -x -h "^(core::([a-z_]+::)+)Ref<.+>$" --category Rust
1616
type summary add -F lldb_lookup.summary_lookup -e -x -h "^(core::([a-z_]+::)+)RefMut<.+>$" --category Rust
1717
type summary add -F lldb_lookup.summary_lookup -e -x -h "^(core::([a-z_]+::)+)RefCell<.+>$" --category Rust
18-
type summary add -F lldb_lookup.summary_lookup -e -x -h "^core::num::([a-z_]+::)*NonZero<.+>$" --category Rust
18+
type summary add -F lldb_lookup.summary_lookup -e -x -h "^(core::([a-z_]+::)+)NonZero<.+>$" --category Rust
1919
type category enable Rust

src/etc/lldb_providers.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,10 @@ def has_children(self):
743743

744744
def StdNonZeroNumberSummaryProvider(valobj, _dict):
745745
# type: (SBValue, dict) -> str
746-
objtype = valobj.GetType()
747-
field = objtype.GetFieldAtIndex(0)
748-
element = valobj.GetChildMemberWithName(field.name)
749-
return element.GetValue()
746+
inner = valobj.GetChildAtIndex(0)
747+
inner_inner = inner.GetChildAtIndex(0)
748+
749+
if inner_inner.GetTypeName() in ['char', 'unsigned char']:
750+
return str(inner_inner.GetValueAsSigned())
751+
else:
752+
return inner_inner.GetValue()

src/etc/rust_types.py

+15-15
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,23 @@ class RustType(object):
3434
STD_NONZERO_NUMBER = "StdNonZeroNumber"
3535

3636

37-
STD_STRING_REGEX = re.compile(r"^(alloc::(\w+::)+)String$")
37+
STD_STRING_REGEX = re.compile(r"^(alloc::([a-z_]+::)+)String$")
3838
STD_STR_REGEX = re.compile(r"^&(mut )?str$")
3939
STD_SLICE_REGEX = re.compile(r"^&(mut )?\[.+\]$")
40-
STD_OS_STRING_REGEX = re.compile(r"^(std::ffi::(\w+::)+)OsString$")
41-
STD_VEC_REGEX = re.compile(r"^(alloc::(\w+::)+)Vec<.+>$")
42-
STD_VEC_DEQUE_REGEX = re.compile(r"^(alloc::(\w+::)+)VecDeque<.+>$")
43-
STD_BTREE_SET_REGEX = re.compile(r"^(alloc::(\w+::)+)BTreeSet<.+>$")
44-
STD_BTREE_MAP_REGEX = re.compile(r"^(alloc::(\w+::)+)BTreeMap<.+>$")
45-
STD_HASH_MAP_REGEX = re.compile(r"^(std::collections::(\w+::)+)HashMap<.+>$")
46-
STD_HASH_SET_REGEX = re.compile(r"^(std::collections::(\w+::)+)HashSet<.+>$")
47-
STD_RC_REGEX = re.compile(r"^(alloc::(\w+::)+)Rc<.+>$")
48-
STD_ARC_REGEX = re.compile(r"^(alloc::(\w+::)+)Arc<.+>$")
49-
STD_CELL_REGEX = re.compile(r"^(core::(\w+::)+)Cell<.+>$")
50-
STD_REF_REGEX = re.compile(r"^(core::(\w+::)+)Ref<.+>$")
51-
STD_REF_MUT_REGEX = re.compile(r"^(core::(\w+::)+)RefMut<.+>$")
52-
STD_REF_CELL_REGEX = re.compile(r"^(core::(\w+::)+)RefCell<.+>$")
53-
STD_NONZERO_NUMBER_REGEX = re.compile(r"^core::num::([a-z_]+::)*NonZero<.+>$")
40+
STD_OS_STRING_REGEX = re.compile(r"^(std::ffi::([a-z_]+::)+)OsString$")
41+
STD_VEC_REGEX = re.compile(r"^(alloc::([a-z_]+::)+)Vec<.+>$")
42+
STD_VEC_DEQUE_REGEX = re.compile(r"^(alloc::([a-z_]+::)+)VecDeque<.+>$")
43+
STD_BTREE_SET_REGEX = re.compile(r"^(alloc::([a-z_]+::)+)BTreeSet<.+>$")
44+
STD_BTREE_MAP_REGEX = re.compile(r"^(alloc::([a-z_]+::)+)BTreeMap<.+>$")
45+
STD_HASH_MAP_REGEX = re.compile(r"^(std::collections::([a-z_]+::)+)HashMap<.+>$")
46+
STD_HASH_SET_REGEX = re.compile(r"^(std::collections::([a-z_]+::)+)HashSet<.+>$")
47+
STD_RC_REGEX = re.compile(r"^(alloc::([a-z_]+::)+)Rc<.+>$")
48+
STD_ARC_REGEX = re.compile(r"^(alloc::([a-z_]+::)+)Arc<.+>$")
49+
STD_CELL_REGEX = re.compile(r"^(core::([a-z_]+::)+)Cell<.+>$")
50+
STD_REF_REGEX = re.compile(r"^(core::([a-z_]+::)+)Ref<.+>$")
51+
STD_REF_MUT_REGEX = re.compile(r"^(core::([a-z_]+::)+)RefMut<.+>$")
52+
STD_REF_CELL_REGEX = re.compile(r"^(core::([a-z_]+::)+)RefCell<.+>$")
53+
STD_NONZERO_NUMBER_REGEX = re.compile(r"^(core::([a-z_]+::)+)NonZero<.+>$")
5454

5555
TUPLE_ITEM_REGEX = re.compile(r"__\d+$")
5656

src/tools/compiletest/src/runtest.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1495,7 +1495,7 @@ impl<'test> TestCx<'test> {
14951495
"^(core::([a-z_]+::)+)Ref<.+>$",
14961496
"^(core::([a-z_]+::)+)RefMut<.+>$",
14971497
"^(core::([a-z_]+::)+)RefCell<.+>$",
1498-
"^core::num::([a-z_]+::)*NonZero<.+>$",
1498+
"^(core::([a-z_]+::)+)NonZero<.+>$",
14991499
];
15001500

15011501
// In newer versions of lldb, persistent results (the `$N =` part at the start of

tests/debuginfo/numeric-types.rs

+14-12
Original file line numberDiff line numberDiff line change
@@ -203,40 +203,42 @@
203203
// lldb-command:run
204204

205205
// lldb-command:print/d nz_i8
206-
// lldb-check:[...]$0 = None { __0 = { 0 = 11 } }
206+
// lldb-check:[...]$0 = 11 { __0 = { 0 = 11 } }
207207

208208
// lldb-command:print nz_i16
209-
// lldb-check:[...]$1 = None { __0 = { 0 = 22 } }
209+
// lldb-check:[...]$1 = 22 { __0 = { 0 = 22 } }
210210

211211
// lldb-command:print nz_i32
212-
// lldb-check:[...]$2 = None { __0 = { 0 = 33 } }
212+
// lldb-check:[...]$2 = 33 { __0 = { 0 = 33 } }
213213

214214
// lldb-command:print nz_i64
215-
// lldb-check:[...]$3 = None { __0 = { 0 = 44 } }
215+
// lldb-check:[...]$3 = 44 { __0 = { 0 = 44 } }
216216

217217
// lldb-command:print nz_i128
218-
// lldb-check:[...]$4 = None { __0 = { 0 = 55 } }
218+
// lldb-check:[...]$4 = 55 { __0 = { 0 = 55 } }
219219

220220
// lldb-command:print nz_isize
221-
// lldb-check:[...]$5 = None { __0 = { 0 = 66 } }
221+
// FIXME: `lldb_lookup.summary_lookup` is never called for `NonZero<isize>` for some reason.
222+
// // lldb-check:[...]$5 = 66 { __0 = { 0 = 66 } }
222223

223224
// lldb-command:print/d nz_u8
224-
// lldb-check:[...]$6 = None { __0 = { 0 = 77 } }
225+
// lldb-check:[...]$6 = 77 { __0 = { 0 = 77 } }
225226

226227
// lldb-command:print nz_u16
227-
// lldb-check:[...]$7 = None { __0 = { 0 = 88 } }
228+
// lldb-check:[...]$7 = 88 { __0 = { 0 = 88 } }
228229

229230
// lldb-command:print nz_u32
230-
// lldb-check:[...]$8 = None { __0 = { 0 = 99 } }
231+
// lldb-check:[...]$8 = 99 { __0 = { 0 = 99 } }
231232

232233
// lldb-command:print nz_u64
233-
// lldb-check:[...]$9 = None { __0 = { 0 = 100 } }
234+
// lldb-check:[...]$9 = 100 { __0 = { 0 = 100 } }
234235

235236
// lldb-command:print nz_u128
236-
// lldb-check:[...]$10 = None { __0 = { 0 = 111 } }
237+
// lldb-check:[...]$10 = 111 { __0 = { 0 = 111 } }
237238

238239
// lldb-command:print nz_usize
239-
// lldb-check:[...]$11 = None { __0 = { 0 = 122 } }
240+
// FIXME: `lldb_lookup.summary_lookup` is never called for `NonZero<usize>` for some reason.
241+
// // lldb-check:[...]$11 = 122 { __0 = { 0 = 122 } }
240242
#![feature(generic_nonzero)]
241243

242244
use std::num::*;

0 commit comments

Comments
 (0)