Fix `StdNonZeroNumberSummaryProvider`.

This commit is contained in:
Markus Reiter 2024-03-10 06:45:39 +01:00
parent ecee730c45
commit 4a799082fe
No known key found for this signature in database
GPG Key ID: 245293B51702655B
5 changed files with 38 additions and 33 deletions

View File

@ -15,5 +15,5 @@ type summary add -F lldb_lookup.summary_lookup -e -x -h "^(core::([a-z_]+::)+)C
type summary add -F lldb_lookup.summary_lookup -e -x -h "^(core::([a-z_]+::)+)Ref<.+>$" --category Rust
type summary add -F lldb_lookup.summary_lookup -e -x -h "^(core::([a-z_]+::)+)RefMut<.+>$" --category Rust
type summary add -F lldb_lookup.summary_lookup -e -x -h "^(core::([a-z_]+::)+)RefCell<.+>$" --category Rust
type summary add -F lldb_lookup.summary_lookup -e -x -h "^core::num::([a-z_]+::)*NonZero<.+>$" --category Rust
type summary add -F lldb_lookup.summary_lookup -e -x -h "^(core::([a-z_]+::)+)NonZero<.+>$" --category Rust
type category enable Rust

View File

@ -743,7 +743,10 @@ class StdRefSyntheticProvider:
def StdNonZeroNumberSummaryProvider(valobj, _dict):
# type: (SBValue, dict) -> str
objtype = valobj.GetType()
field = objtype.GetFieldAtIndex(0)
element = valobj.GetChildMemberWithName(field.name)
return element.GetValue()
inner = valobj.GetChildAtIndex(0)
inner_inner = inner.GetChildAtIndex(0)
if inner_inner.GetTypeName() in ['char', 'unsigned char']:
return str(inner_inner.GetValueAsSigned())
else:
return inner_inner.GetValue()

View File

@ -34,23 +34,23 @@ class RustType(object):
STD_NONZERO_NUMBER = "StdNonZeroNumber"
STD_STRING_REGEX = re.compile(r"^(alloc::(\w+::)+)String$")
STD_STRING_REGEX = re.compile(r"^(alloc::([a-z_]+::)+)String$")
STD_STR_REGEX = re.compile(r"^&(mut )?str$")
STD_SLICE_REGEX = re.compile(r"^&(mut )?\[.+\]$")
STD_OS_STRING_REGEX = re.compile(r"^(std::ffi::(\w+::)+)OsString$")
STD_VEC_REGEX = re.compile(r"^(alloc::(\w+::)+)Vec<.+>$")
STD_VEC_DEQUE_REGEX = re.compile(r"^(alloc::(\w+::)+)VecDeque<.+>$")
STD_BTREE_SET_REGEX = re.compile(r"^(alloc::(\w+::)+)BTreeSet<.+>$")
STD_BTREE_MAP_REGEX = re.compile(r"^(alloc::(\w+::)+)BTreeMap<.+>$")
STD_HASH_MAP_REGEX = re.compile(r"^(std::collections::(\w+::)+)HashMap<.+>$")
STD_HASH_SET_REGEX = re.compile(r"^(std::collections::(\w+::)+)HashSet<.+>$")
STD_RC_REGEX = re.compile(r"^(alloc::(\w+::)+)Rc<.+>$")
STD_ARC_REGEX = re.compile(r"^(alloc::(\w+::)+)Arc<.+>$")
STD_CELL_REGEX = re.compile(r"^(core::(\w+::)+)Cell<.+>$")
STD_REF_REGEX = re.compile(r"^(core::(\w+::)+)Ref<.+>$")
STD_REF_MUT_REGEX = re.compile(r"^(core::(\w+::)+)RefMut<.+>$")
STD_REF_CELL_REGEX = re.compile(r"^(core::(\w+::)+)RefCell<.+>$")
STD_NONZERO_NUMBER_REGEX = re.compile(r"^core::num::([a-z_]+::)*NonZero<.+>$")
STD_OS_STRING_REGEX = re.compile(r"^(std::ffi::([a-z_]+::)+)OsString$")
STD_VEC_REGEX = re.compile(r"^(alloc::([a-z_]+::)+)Vec<.+>$")
STD_VEC_DEQUE_REGEX = re.compile(r"^(alloc::([a-z_]+::)+)VecDeque<.+>$")
STD_BTREE_SET_REGEX = re.compile(r"^(alloc::([a-z_]+::)+)BTreeSet<.+>$")
STD_BTREE_MAP_REGEX = re.compile(r"^(alloc::([a-z_]+::)+)BTreeMap<.+>$")
STD_HASH_MAP_REGEX = re.compile(r"^(std::collections::([a-z_]+::)+)HashMap<.+>$")
STD_HASH_SET_REGEX = re.compile(r"^(std::collections::([a-z_]+::)+)HashSet<.+>$")
STD_RC_REGEX = re.compile(r"^(alloc::([a-z_]+::)+)Rc<.+>$")
STD_ARC_REGEX = re.compile(r"^(alloc::([a-z_]+::)+)Arc<.+>$")
STD_CELL_REGEX = re.compile(r"^(core::([a-z_]+::)+)Cell<.+>$")
STD_REF_REGEX = re.compile(r"^(core::([a-z_]+::)+)Ref<.+>$")
STD_REF_MUT_REGEX = re.compile(r"^(core::([a-z_]+::)+)RefMut<.+>$")
STD_REF_CELL_REGEX = re.compile(r"^(core::([a-z_]+::)+)RefCell<.+>$")
STD_NONZERO_NUMBER_REGEX = re.compile(r"^(core::([a-z_]+::)+)NonZero<.+>$")
TUPLE_ITEM_REGEX = re.compile(r"__\d+$")

View File

@ -1495,7 +1495,7 @@ impl<'test> TestCx<'test> {
"^(core::([a-z_]+::)+)Ref<.+>$",
"^(core::([a-z_]+::)+)RefMut<.+>$",
"^(core::([a-z_]+::)+)RefCell<.+>$",
"^core::num::([a-z_]+::)*NonZero<.+>$",
"^(core::([a-z_]+::)+)NonZero<.+>$",
];
// In newer versions of lldb, persistent results (the `$N =` part at the start of

View File

@ -203,40 +203,42 @@
// lldb-command:run
// lldb-command:print/d nz_i8
// lldb-check:[...]$0 = None { __0 = { 0 = 11 } }
// lldb-check:[...]$0 = 11 { __0 = { 0 = 11 } }
// lldb-command:print nz_i16
// lldb-check:[...]$1 = None { __0 = { 0 = 22 } }
// lldb-check:[...]$1 = 22 { __0 = { 0 = 22 } }
// lldb-command:print nz_i32
// lldb-check:[...]$2 = None { __0 = { 0 = 33 } }
// lldb-check:[...]$2 = 33 { __0 = { 0 = 33 } }
// lldb-command:print nz_i64
// lldb-check:[...]$3 = None { __0 = { 0 = 44 } }
// lldb-check:[...]$3 = 44 { __0 = { 0 = 44 } }
// lldb-command:print nz_i128
// lldb-check:[...]$4 = None { __0 = { 0 = 55 } }
// lldb-check:[...]$4 = 55 { __0 = { 0 = 55 } }
// lldb-command:print nz_isize
// lldb-check:[...]$5 = None { __0 = { 0 = 66 } }
// FIXME: `lldb_lookup.summary_lookup` is never called for `NonZero<isize>` for some reason.
// // lldb-check:[...]$5 = 66 { __0 = { 0 = 66 } }
// lldb-command:print/d nz_u8
// lldb-check:[...]$6 = None { __0 = { 0 = 77 } }
// lldb-check:[...]$6 = 77 { __0 = { 0 = 77 } }
// lldb-command:print nz_u16
// lldb-check:[...]$7 = None { __0 = { 0 = 88 } }
// lldb-check:[...]$7 = 88 { __0 = { 0 = 88 } }
// lldb-command:print nz_u32
// lldb-check:[...]$8 = None { __0 = { 0 = 99 } }
// lldb-check:[...]$8 = 99 { __0 = { 0 = 99 } }
// lldb-command:print nz_u64
// lldb-check:[...]$9 = None { __0 = { 0 = 100 } }
// lldb-check:[...]$9 = 100 { __0 = { 0 = 100 } }
// lldb-command:print nz_u128
// lldb-check:[...]$10 = None { __0 = { 0 = 111 } }
// lldb-check:[...]$10 = 111 { __0 = { 0 = 111 } }
// lldb-command:print nz_usize
// lldb-check:[...]$11 = None { __0 = { 0 = 122 } }
// FIXME: `lldb_lookup.summary_lookup` is never called for `NonZero<usize>` for some reason.
// // lldb-check:[...]$11 = 122 { __0 = { 0 = 122 } }
#![feature(generic_nonzero)]
use std::num::*;