From 4a799082fe5768fdc991a64f07debfb56b703622 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sun, 10 Mar 2024 06:45:39 +0100 Subject: [PATCH] Fix `StdNonZeroNumberSummaryProvider`. --- src/etc/lldb_commands | 2 +- src/etc/lldb_providers.py | 11 ++++++---- src/etc/rust_types.py | 30 ++++++++++++++-------------- src/tools/compiletest/src/runtest.rs | 2 +- tests/debuginfo/numeric-types.rs | 26 +++++++++++++----------- 5 files changed, 38 insertions(+), 33 deletions(-) diff --git a/src/etc/lldb_commands b/src/etc/lldb_commands index 5304f2ca34a..615d13ccd0f 100644 --- a/src/etc/lldb_commands +++ b/src/etc/lldb_commands @@ -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 diff --git a/src/etc/lldb_providers.py b/src/etc/lldb_providers.py index cfb3f0a4eae..319660f0ddc 100644 --- a/src/etc/lldb_providers.py +++ b/src/etc/lldb_providers.py @@ -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() diff --git a/src/etc/rust_types.py b/src/etc/rust_types.py index 3b2d2f9e983..2b06683ef93 100644 --- a/src/etc/rust_types.py +++ b/src/etc/rust_types.py @@ -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+$") diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 1e1c5fb20d4..386db1a64b8 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -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 diff --git a/tests/debuginfo/numeric-types.rs b/tests/debuginfo/numeric-types.rs index 9ea770652b1..f662fa7ed54 100644 --- a/tests/debuginfo/numeric-types.rs +++ b/tests/debuginfo/numeric-types.rs @@ -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` 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` for some reason. +// // lldb-check:[...]$11 = 122 { __0 = { 0 = 122 } } #![feature(generic_nonzero)] use std::num::*;