diff --git a/src/etc/gdb_lookup.py b/src/etc/gdb_lookup.py index d368f7ed1ec5c..c70944790d2b5 100644 --- a/src/etc/gdb_lookup.py +++ b/src/etc/gdb_lookup.py @@ -3,7 +3,7 @@ import re from gdb_providers import * -from rust_types import * +from rust_types import RustType, classify_struct, classify_union _gdb_version_matched = re.search("([0-9]+)\\.([0-9]+)", gdb.VERSION) @@ -28,7 +28,7 @@ def classify_rust_type(type): if type_class == gdb.TYPE_CODE_UNION: return classify_union(type.fields()) - return RustType.OTHER + return RustType.Other def check_enum_discriminant(valobj): @@ -85,7 +85,7 @@ def __init__(self, name): def add(self, rust_type, provider): # Just use the rust_type as the name. - printer = PrintByRustType(rust_type, provider) + printer = PrintByRustType(rust_type.name, provider) self.type_map[rust_type] = printer self.subprinters.append(printer) @@ -99,23 +99,23 @@ def __call__(self, valobj): printer = RustPrettyPrinter("rust") # use enum provider only for GDB <7.12 if gdb_version[0] < 7 or (gdb_version[0] == 7 and gdb_version[1] < 12): - printer.add(RustType.ENUM, enum_provider) -printer.add(RustType.STD_STRING, StdStringProvider) -printer.add(RustType.STD_OS_STRING, StdOsStringProvider) -printer.add(RustType.STD_STR, StdStrProvider) -printer.add(RustType.STD_SLICE, StdSliceProvider) -printer.add(RustType.STD_VEC, StdVecProvider) -printer.add(RustType.STD_VEC_DEQUE, StdVecDequeProvider) -printer.add(RustType.STD_BTREE_SET, StdBTreeSetProvider) -printer.add(RustType.STD_BTREE_MAP, StdBTreeMapProvider) -printer.add(RustType.STD_HASH_MAP, hashmap_provider) -printer.add(RustType.STD_HASH_SET, hashset_provider) -printer.add(RustType.STD_RC, StdRcProvider) -printer.add(RustType.STD_ARC, lambda valobj: StdRcProvider(valobj, is_atomic=True)) - -printer.add(RustType.STD_CELL, StdCellProvider) -printer.add(RustType.STD_REF, StdRefProvider) -printer.add(RustType.STD_REF_MUT, StdRefProvider) -printer.add(RustType.STD_REF_CELL, StdRefCellProvider) - -printer.add(RustType.STD_NONZERO_NUMBER, StdNonZeroNumberProvider) + printer.add(RustType.Enum, enum_provider) +printer.add(RustType.StdString, StdStringProvider) +printer.add(RustType.StdOsString, StdOsStringProvider) +printer.add(RustType.StdStr, StdStrProvider) +printer.add(RustType.StdSlice, StdSliceProvider) +printer.add(RustType.StdVec, StdVecProvider) +printer.add(RustType.StdVecDeque, StdVecDequeProvider) +printer.add(RustType.StdBTreeSet, StdBTreeSetProvider) +printer.add(RustType.StdBTreeMap, StdBTreeMapProvider) +printer.add(RustType.StdHashMap, hashmap_provider) +printer.add(RustType.StdHashSet, hashset_provider) +printer.add(RustType.StdRc, StdRcProvider) +printer.add(RustType.StdArc, lambda valobj: StdRcProvider(valobj, is_atomic=True)) + +printer.add(RustType.StdCell, StdCellProvider) +printer.add(RustType.StdRef, StdRefProvider) +printer.add(RustType.StdRefMut, StdRefProvider) +printer.add(RustType.StdRefCell, StdRefCellProvider) + +printer.add(RustType.StdNonZeroNumber, StdNonZeroNumberProvider) diff --git a/src/etc/lldb_commands b/src/etc/lldb_commands index eff065d545657..6db81ce9be4df 100644 --- a/src/etc/lldb_commands +++ b/src/etc/lldb_commands @@ -1,81 +1,86 @@ +# LLDB iterates through these in reverse order to discover summaries/synthetics that means the top +# of the list can be "overwritten" by items lower on the list. Be careful when reordering items. + # Forces test-compliant formatting to all other types type synthetic add -l lldb_lookup.synthetic_lookup -x ".*" --category Rust # Std String type synthetic add -l lldb_lookup.StdStringSyntheticProvider -x "^(alloc::([a-z_]+::)+)String$" --category Rust -type summary add -F lldb_lookup.StdStringSummaryProvider -e -x -h "^(alloc::([a-z_]+::)+)String$" --category Rust +type summary add -F lldb_lookup.StdStringSummaryProvider -e -x -h "^(alloc::([a-z_]+::)+)String$" --category Rust + # Std str -type synthetic add -l lldb_lookup.synthetic_lookup -x "^&(mut )?str$" --category Rust -type summary add -F lldb_lookup.summary_lookup -e -x -h "^&(mut )?str$" --category Rust +type synthetic add -l lldb_lookup.StdSliceSyntheticProvider -x "^&(mut )?str$" --category Rust +type summary add -F lldb_lookup.StdStrSummaryProvider -e -x -h "^&(mut )?str$" --category Rust + ## MSVC type synthetic add -l lldb_lookup.MSVCStrSyntheticProvider -x "^ref(_mut)?\$$" --category Rust type summary add -F lldb_lookup.StdStrSummaryProvider -e -h -x "^ref(_mut)?\$$" --category Rust -# Array -type synthetic add -l lldb_lookup.synthetic_lookup -x "^&(mut )?\\[.+\\]$" --category Rust -type summary add -F lldb_lookup.summary_lookup -e -x -h "^&(mut )?\\[.+\\]$" --category Rust -# Slice + +# Array/Slice +type synthetic add -l lldb_lookup.StdSliceSyntheticProvider -x "^&(mut )?\\[.+\\]$" --category Rust +type summary add -F lldb_lookup.SizeSummaryProvider -e -x -h "^&(mut )?\\[.+\\]$" --category Rust + ## MSVC type synthetic add -l lldb_lookup.MSVCStdSliceSyntheticProvider -x "^ref(_mut)?\$ >" --category Rust type summary add -F lldb_lookup.StdSliceSummaryProvider -e -x -h "^ref(_mut)?\$ >" --category Rust + # OsString -type synthetic add -l lldb_lookup.synthetic_lookup -x "^(std::ffi::([a-z_]+::)+)OsString$" --category Rust -type summary add -F lldb_lookup.summary_lookup -e -x -h "^(std::ffi::([a-z_]+::)+)OsString$" --category Rust +type summary add -F lldb_lookup.StdOsStringSummaryProvider -e -x -h "^(std::ffi::([a-z_]+::)+)OsString$" --category Rust + # Vec -type synthetic add -l lldb_lookup.synthetic_lookup -x "^(alloc::([a-z_]+::)+)Vec<.+>$" --category Rust -type summary add -F lldb_lookup.summary_lookup -e -x -h "^(alloc::([a-z_]+::)+)Vec<.+>$" --category Rust +type synthetic add -l lldb_lookup.StdVecSyntheticProvider -x "^(alloc::([a-z_]+::)+)Vec<.+>$" --category Rust +type summary add -F lldb_lookup.SizeSummaryProvider -e -x -h "^(alloc::([a-z_]+::)+)Vec<.+>$" --category Rust + # VecDeque -type synthetic add -l lldb_lookup.synthetic_lookup -x "^(alloc::([a-z_]+::)+)VecDeque<.+>$" --category Rust -type summary add -F lldb_lookup.summary_lookup -e -x -h "^(alloc::([a-z_]+::)+)VecDeque<.+>$" --category Rust -# BTreeSet -type synthetic add -l lldb_lookup.synthetic_lookup -x "^(alloc::([a-z_]+::)+)BTreeSet<.+>$" --category Rust -type summary add -F lldb_lookup.summary_lookup -e -x -h "^(alloc::([a-z_]+::)+)BTreeSet<.+>$" --category Rust -# BTreeMap -type synthetic add -l lldb_lookup.synthetic_lookup -x "^(alloc::([a-z_]+::)+)BTreeMap<.+>$" --category Rust -type summary add -F lldb_lookup.summary_lookup -e -x -h "^(alloc::([a-z_]+::)+)BTreeMap<.+>$" --category Rust +type synthetic add -l lldb_lookup.StdVecDequeSyntheticProvider -x "^(alloc::([a-z_]+::)+)VecDeque<.+>$" --category Rust +type summary add -F lldb_lookup.SizeSummaryProvider -e -x -h "^(alloc::([a-z_]+::)+)VecDeque<.+>$" --category Rust + # HashMap -type synthetic add -l lldb_lookup.synthetic_lookup -x "^(std::collections::([a-z_]+::)+)HashMap<.+>$" --category Rust -type summary add -F lldb_lookup.summary_lookup -e -x -h "^(std::collections::([a-z_]+::)+)HashMap<.+>$" --category Rust +type synthetic add -l lldb_lookup.classify_hashmap -x "^(std::collections::([a-z_]+::)+)HashMap<.+>$" --category Rust +type summary add -F lldb_lookup.SizeSummaryProvider -e -x -h "^(std::collections::([a-z_]+::)+)HashMap<.+>$" --category Rust + # HashSet -type synthetic add -l lldb_lookup.synthetic_lookup -x "^(std::collections::([a-z_]+::)+)HashSet<.+>$" --category Rust -type summary add -F lldb_lookup.summary_lookup -e -x -h "^(std::collections::([a-z_]+::)+)HashSet<.+>$" --category Rust +type synthetic add -l lldb_lookup.classify_hashset -x "^(std::collections::([a-z_]+::)+)HashSet<.+>$" --category Rust +type summary add -F lldb_lookup.SizeSummaryProvider -e -x -h "^(std::collections::([a-z_]+::)+)HashSet<.+>$" --category Rust + # Rc -type synthetic add -l lldb_lookup.synthetic_lookup -x "^(alloc::([a-z_]+::)+)Rc<.+>$" --category Rust -type summary add -F lldb_lookup.summary_lookup -e -x -h "^(alloc::([a-z_]+::)+)Rc<.+>$" --category Rust +type synthetic add -l lldb_lookup.StdRcSyntheticProvider -x "^(alloc::([a-z_]+::)+)Rc<.+>$" --category Rust +type summary add -F lldb_lookup.StdRcSummaryProvider -e -x -h "^(alloc::([a-z_]+::)+)Rc<.+>$" --category Rust + # Arc -type synthetic add -l lldb_lookup.synthetic_lookup -x "^(alloc::([a-z_]+::)+)Arc<.+>$" --category Rust -type summary add -F lldb_lookup.summary_lookup -e -x -h "^(alloc::([a-z_]+::)+)Arc<.+>$" --category Rust +type synthetic add -l lldb_lookup.arc_synthetic -x "^(alloc::([a-z_]+::)+)Arc<.+>$" --category Rust +type summary add -F lldb_lookup.StdRcSummaryProvider -e -x -h "^(alloc::([a-z_]+::)+)Arc<.+>$" --category Rust + # Cell -type synthetic add -l lldb_lookup.synthetic_lookup -x "^(core::([a-z_]+::)+)Cell<.+>$" --category Rust -type summary add -F lldb_lookup.summary_lookup -e -x -h "^(core::([a-z_]+::)+)Cell<.+>$" --category Rust +type synthetic add -l lldb_lookup.StdCellSyntheticProvider -x "^(core::([a-z_]+::)+)Cell<.+>$" --category Rust + # RefCell -type synthetic add -l lldb_lookup.synthetic_lookup -x "^(core::([a-z_]+::)+)Ref<.+>$" --category Rust -type synthetic add -l lldb_lookup.synthetic_lookup -x "^(core::([a-z_]+::)+)RefMut<.+>$" --category Rust -type synthetic add -l lldb_lookup.synthetic_lookup -x "^(core::([a-z_]+::)+)RefCell<.+>$" --category Rust -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 synthetic add -l lldb_lookup.StdRefSyntheticProvider -x "^(core::([a-z_]+::)+)Ref(Cell|Mut)?<.+>$" --category Rust +type summary add -F lldb_lookup.StdRefSummaryProvider -e -x -h "^(core::([a-z_]+::)+)Ref(Cell|Mut)?<.+>$" --category Rust + # NonZero -type synthetic add -l lldb_lookup.synthetic_lookup -x "^(core::([a-z_]+::)+)NonZero<.+>$" --category Rust -type synthetic add -l lldb_lookup.synthetic_lookup -x "^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 summary add -F lldb_lookup.summary_lookup -e -x -h "^core::num::([a-z_]+::)*NonZero.+$" --category Rust +type summary add -F lldb_lookup.StdNonZeroNumberSummaryProvider -e -x -h "^(core::([a-z_]+::)+)NonZero(<.+>|I\d{0,3}|U\d{0,3})$" --category Rust + # PathBuf -type synthetic add -l lldb_lookup.synthetic_lookup -x "^(std::([a-z_]+::)+)PathBuf$" --category Rust -type summary add -F lldb_lookup.summary_lookup -e -x -h "^(std::([a-z_]+::)+)PathBuf$" --category Rust +type summary add -F lldb_lookup.StdPathBufSummaryProvider -e -x -h "^(std::([a-z_]+::)+)PathBuf$" --category Rust + # Path -type synthetic add -l lldb_lookup.synthetic_lookup -x "^&(mut )?(std::([a-z_]+::)+)Path$" --category Rust -type summary add -F lldb_lookup.summary_lookup -e -x -h "^&(mut )?(std::([a-z_]+::)+)Path$" --category Rust +type summary add -F lldb_lookup.StdPathSummaryProvider -e -x -h "^&(mut )?(std::([a-z_]+::)+)Path$" --category Rust + # Enum # type summary add -F lldb_lookup.ClangEncodedEnumSummaryProvider -e -h "lldb_lookup.is_sum_type_enum" --recognizer-function --category Rust ## MSVC type synthetic add -l lldb_lookup.MSVCEnumSyntheticProvider -x "^enum2\$<.+>$" --category Rust type summary add -F lldb_lookup.MSVCEnumSummaryProvider -e -x -h "^enum2\$<.+>$" --category Rust + ## MSVC Variants type synthetic add -l lldb_lookup.synthetic_lookup -x "^enum2\$<.+>::.*$" --category Rust -type summary add -F lldb_lookup.summary_lookup -e -x -h "^enum2\$<.+>::.*$" --category Rust + # Tuple -type synthetic add -l lldb_lookup.synthetic_lookup -x "^\(.*\)$" --category Rust -type summary add -F lldb_lookup.TupleSummaryProvider -e -x -h "^\(.*\)$" --category Rust +type synthetic add -l lldb_lookup.TupleSyntheticProvider -x "^\(.*\)$" --category Rust +type summary add -F lldb_lookup.TupleSummaryProvider -x "^\(.*\)$" --category Rust + ## MSVC type synthetic add -l lldb_lookup.MSVCTupleSyntheticProvider -x "^tuple\$<.+>$" --category Rust type summary add -F lldb_lookup.TupleSummaryProvider -e -x -h "^tuple\$<.+>$" --category Rust + type category enable Rust diff --git a/src/etc/lldb_lookup.py b/src/etc/lldb_lookup.py index 2b90d4022f7fb..67194a09ec4ce 100644 --- a/src/etc/lldb_lookup.py +++ b/src/etc/lldb_lookup.py @@ -1,7 +1,35 @@ +from __future__ import annotations +from typing import List + + import lldb from lldb_providers import * -from rust_types import RustType, classify_struct, classify_union +from rust_types import ( + ENUM_DISR_FIELD_NAME, + ENUM_LLDB_ENCODED_VARIANTS, + RustType, + classify_union, + is_tuple_fields, +) + +#################################################################################################### +# This file contains lookup functions that associate rust types with their synthetic/summary +# providers. +# +# LLDB caches the results of the the commands in `lldb_commands`, but that caching is "shallow". It +# purely associates the type with the function given, whether it is a regular function or a class +# constructor. If the function makes decisions about what type of SyntheticProvider to return, that +# processing is done **each time a value of that type is encountered**. +# +# To reiterate, inspecting a `vec![T; 100_000]` will call `T`'s lookup function/constructor 100,000 +# times. This can lead to significant delays in value visualization if the lookup logic is complex. +# +# As such, lookup functions should be kept as minimal as possible. LLDB technically expects a +# SyntheticProvider class constructor. If you can provide just a class constructor, that should be +# preferred. If extra processing must be done, try to keep it as minimal and as targeted as possible +# (see: `classify_hashmap()` vs `classify_hashset()`). +#################################################################################################### # BACKCOMPAT: rust 1.35 @@ -9,82 +37,90 @@ def is_hashbrown_hashmap(hash_map: lldb.SBValue) -> bool: return len(hash_map.type.fields) == 1 -def classify_rust_type(type: lldb.SBType) -> str: - type_class = type.GetTypeClass() - if type_class == lldb.eTypeClassStruct: - return classify_struct(type.name, type.fields) - if type_class == lldb.eTypeClassUnion: - return classify_union(type.fields) +def classify_hashmap(valobj: lldb.SBValue, _dict: LLDBOpaque) -> object: + if is_hashbrown_hashmap(valobj): + return StdHashMapSyntheticProvider(valobj, _dict) + else: + return StdOldHashMapSyntheticProvider(valobj, _dict) - return RustType.OTHER +def classify_hashset(valobj: lldb.SBValue, _dict: LLDBOpaque) -> object: + hash_map = valobj.GetChildAtIndex(0) + if is_hashbrown_hashmap(hash_map): + return StdHashMapSyntheticProvider(valobj, _dict, show_values=False) + else: + return StdOldHashMapSyntheticProvider(hash_map, _dict, show_values=False) -def summary_lookup(valobj: lldb.SBValue, _dict: LLDBOpaque) -> str: - """Returns the summary provider for the given value""" - rust_type = classify_rust_type(valobj.GetType()) - if rust_type == RustType.STD_STRING: - return StdStringSummaryProvider(valobj, _dict) - if rust_type == RustType.STD_OS_STRING: - return StdOsStringSummaryProvider(valobj, _dict) - if rust_type == RustType.STD_STR: - return StdStrSummaryProvider(valobj, _dict) +def arc_synthetic(valobj: lldb.SBValue, _dict: LLDBOpaque) -> object: + return StdRcSyntheticProvider(valobj, _dict, is_atomic=True) - if rust_type == RustType.STD_VEC: - return SizeSummaryProvider(valobj, _dict) - if rust_type == RustType.STD_VEC_DEQUE: - return SizeSummaryProvider(valobj, _dict) - if rust_type == RustType.STD_SLICE: - return SizeSummaryProvider(valobj, _dict) - if rust_type == RustType.STD_HASH_MAP: - return SizeSummaryProvider(valobj, _dict) - if rust_type == RustType.STD_HASH_SET: - return SizeSummaryProvider(valobj, _dict) +def classify_rust_type(type: lldb.SBType, is_msvc: bool) -> RustType: + if type.IsPointerType(): + return RustType.Indirection - if rust_type == RustType.STD_RC: - return StdRcSummaryProvider(valobj, _dict) - if rust_type == RustType.STD_ARC: - return StdRcSummaryProvider(valobj, _dict) + # there is a bit of code duplication here because we don't want to check all of the standard + # library regexes since LLDB handles that for us + type_class = type.GetTypeClass() + if type_class == lldb.eTypeClassStruct: + fields: List[lldb.SBTypeMember] = type.fields + if len(fields) == 0: + return RustType.Empty - if rust_type == RustType.STD_REF: - return StdRefSummaryProvider(valobj, _dict) - if rust_type == RustType.STD_REF_MUT: - return StdRefSummaryProvider(valobj, _dict) - if rust_type == RustType.STD_REF_CELL: - return StdRefSummaryProvider(valobj, _dict) + # <> is emitted by GDB while LLDB(18.1+) emits "$variants$" + if ( + fields[0].name == ENUM_DISR_FIELD_NAME + or fields[0].name == ENUM_LLDB_ENCODED_VARIANTS + ): + return RustType.Enum - if rust_type == RustType.STD_NONZERO_NUMBER: - return StdNonZeroNumberSummaryProvider(valobj, _dict) + if is_tuple_fields(fields): + return RustType.Tuple - if rust_type == RustType.STD_PATHBUF: - return StdPathBufSummaryProvider(valobj, _dict) - if rust_type == RustType.STD_PATH: - return StdPathSummaryProvider(valobj, _dict) + return RustType.Struct + if type_class == lldb.eTypeClassUnion: + # If we're debugging msvc, sum-type enums should have been caught by the regex in lldb + # commands since they all start with "enum2$<" + if is_msvc: + return RustType.Union + return classify_union(type.fields) - return "" + return RustType.Other def synthetic_lookup(valobj: lldb.SBValue, _dict: LLDBOpaque) -> object: """Returns the synthetic provider for the given value""" - rust_type = classify_rust_type(valobj.GetType()) - if rust_type == RustType.STRUCT: + # small hack to check for the DWARF debug info section, since SBTarget.triple and + # SBProcess.triple report lldb's target rather than the executable's. SBProcessInfo.triple + # returns a triple without the ABI. It is also possible for any of those functions to return a + # None object. + # Instead, we look for the GNU `.debug_info` section, as MSVC does not have one with the same + # name + # FIXME: I don't know if this works when the DWARF lives in a separate file + # (see: https://gcc.gnu.org/wiki/DebugFissionDWP). Splitting the DWARF is very uncommon afaik so + # it should be okay for the time being. + is_msvc = not valobj.GetFrame().GetModule().FindSection(".debug_info").IsValid() + + rust_type = classify_rust_type(valobj.GetType(), is_msvc) + + if rust_type == RustType.Struct or rust_type == RustType.Union: return StructSyntheticProvider(valobj, _dict) - if rust_type == RustType.STRUCT_VARIANT: + if rust_type == RustType.StructVariant: return StructSyntheticProvider(valobj, _dict, is_variant=True) - if rust_type == RustType.TUPLE: + if rust_type == RustType.Tuple: return TupleSyntheticProvider(valobj, _dict) - if rust_type == RustType.TUPLE_VARIANT: + if rust_type == RustType.TupleVariant: return TupleSyntheticProvider(valobj, _dict, is_variant=True) - if rust_type == RustType.EMPTY: + if rust_type == RustType.Empty: return EmptySyntheticProvider(valobj, _dict) - if rust_type == RustType.REGULAR_ENUM: + if rust_type == RustType.RegularEnum: discriminant = valobj.GetChildAtIndex(0).GetChildAtIndex(0).GetValueAsUnsigned() return synthetic_lookup(valobj.GetChildAtIndex(discriminant), _dict) - if rust_type == RustType.SINGLETON_ENUM: + if rust_type == RustType.SingletonEnum: return synthetic_lookup(valobj.GetChildAtIndex(0), _dict) - if rust_type == RustType.ENUM: + if rust_type == RustType.Enum: # this little trick lets us treat `synthetic_lookup` as a "recognizer function" for the enum # summary providers, reducing the number of lookups we have to do. This is a huge time save # because there's no way (via type name) to recognize sum-type enums on `*-gnu` targets. The @@ -106,37 +142,7 @@ def synthetic_lookup(valobj: lldb.SBValue, _dict: LLDBOpaque) -> object: ) return ClangEncodedEnumProvider(valobj, _dict) - if rust_type == RustType.STD_VEC: - return StdVecSyntheticProvider(valobj, _dict) - if rust_type == RustType.STD_VEC_DEQUE: - return StdVecDequeSyntheticProvider(valobj, _dict) - if rust_type == RustType.STD_SLICE or rust_type == RustType.STD_STR: - return StdSliceSyntheticProvider(valobj, _dict) - - if rust_type == RustType.STD_HASH_MAP: - if is_hashbrown_hashmap(valobj): - return StdHashMapSyntheticProvider(valobj, _dict) - else: - return StdOldHashMapSyntheticProvider(valobj, _dict) - if rust_type == RustType.STD_HASH_SET: - hash_map = valobj.GetChildAtIndex(0) - if is_hashbrown_hashmap(hash_map): - return StdHashMapSyntheticProvider(valobj, _dict, show_values=False) - else: - return StdOldHashMapSyntheticProvider(hash_map, _dict, show_values=False) - - if rust_type == RustType.STD_RC: - return StdRcSyntheticProvider(valobj, _dict) - if rust_type == RustType.STD_ARC: - return StdRcSyntheticProvider(valobj, _dict, is_atomic=True) - - if rust_type == RustType.STD_CELL: - return StdCellSyntheticProvider(valobj, _dict) - if rust_type == RustType.STD_REF: - return StdRefSyntheticProvider(valobj, _dict) - if rust_type == RustType.STD_REF_MUT: - return StdRefSyntheticProvider(valobj, _dict) - if rust_type == RustType.STD_REF_CELL: - return StdRefSyntheticProvider(valobj, _dict, is_cell=True) + if rust_type == RustType.Indirection: + return IndirectionSyntheticProvider(valobj, _dict) return DefaultSyntheticProvider(valobj, _dict) diff --git a/src/etc/lldb_providers.py b/src/etc/lldb_providers.py index 88d210691d00e..407e87cdf785b 100644 --- a/src/etc/lldb_providers.py +++ b/src/etc/lldb_providers.py @@ -102,11 +102,14 @@ def __init__(self, valobj: SBValue, _dict: LLDBOpaque): # logger = Logger.Logger() # logger >> "Default synthetic provider for " + str(valobj.GetName()) self.valobj = valobj + self.is_ptr = valobj.GetType().IsPointerType() def num_children(self) -> int: return self.valobj.GetNumChildren() def get_child_index(self, name: str) -> int: + if self.is_ptr and name == "$$dereference$$": + return self.valobj.Dereference().GetSyntheticValue() return self.valobj.GetIndexOfChildWithName(name) def get_child_at_index(self, index: int) -> SBValue: @@ -118,6 +121,36 @@ def update(self): def has_children(self) -> bool: return self.valobj.MightHaveChildren() + def get_value(self): + return self.valobj.value + + +class IndirectionSyntheticProvider: + def __init__(self, valobj: SBValue, _dict: LLDBOpaque): + self.valobj = valobj + + def num_children(self) -> int: + return 1 + + def get_child_index(self, name: str) -> int: + if self.is_ptr and name == "$$dereference$$": + return 0 + return -1 + + def get_child_at_index(self, index: int) -> SBValue: + if index == 0: + return self.valobj.Dereference().GetSyntheticValue() + return None + + def update(self): + pass + + def has_children(self) -> bool: + return True + + def get_value(self): + return self.valobj.value + class EmptySyntheticProvider: def __init__(self, valobj: SBValue, _dict: LLDBOpaque): @@ -256,7 +289,7 @@ def vec_to_string(vec: SBValue) -> str: ) -def StdStringSummaryProvider(valobj, dict): +def StdStringSummaryProvider(valobj: SBValue, dict: LLDBOpaque): inner_vec = ( valobj.GetNonSyntheticValue() .GetChildMemberWithName("vec") diff --git a/src/etc/rust_types.py b/src/etc/rust_types.py index af03e8ede9c3f..1ed68458ae3a5 100644 --- a/src/etc/rust_types.py +++ b/src/etc/rust_types.py @@ -1,40 +1,42 @@ +from enum import Enum from typing import List import re -class RustType(object): - OTHER = "Other" - STRUCT = "Struct" - TUPLE = "Tuple" - CSTYLE_VARIANT = "CStyleVariant" - TUPLE_VARIANT = "TupleVariant" - STRUCT_VARIANT = "StructVariant" - ENUM = "Enum" - EMPTY = "Empty" - SINGLETON_ENUM = "SingletonEnum" - REGULAR_ENUM = "RegularEnum" - COMPRESSED_ENUM = "CompressedEnum" - REGULAR_UNION = "RegularUnion" - - STD_STRING = "StdString" - STD_OS_STRING = "StdOsString" - STD_STR = "StdStr" - STD_SLICE = "StdSlice" - STD_VEC = "StdVec" - STD_VEC_DEQUE = "StdVecDeque" - STD_BTREE_SET = "StdBTreeSet" - STD_BTREE_MAP = "StdBTreeMap" - STD_HASH_MAP = "StdHashMap" - STD_HASH_SET = "StdHashSet" - STD_RC = "StdRc" - STD_ARC = "StdArc" - STD_CELL = "StdCell" - STD_REF = "StdRef" - STD_REF_MUT = "StdRefMut" - STD_REF_CELL = "StdRefCell" - STD_NONZERO_NUMBER = "StdNonZeroNumber" - STD_PATH = "StdPath" - STD_PATHBUF = "StdPathBuf" +class RustType(Enum): + Other = 0 + Struct = 1 + Tuple = 2 + CStyleVariant = 3 + TupleVariant = 4 + StructVariant = 5 + Enum = 6 + Empty = 7 + SingletonEnum = 8 + RegularEnum = 9 + CompressedEnum = 10 + Union = 11 + Indirection = 12 + + StdString = 13 + StdOsString = 14 + StdStr = 15 + StdSlice = 16 + StdVec = 17 + StdVecDeque = 18 + StdBTreeSet = 19 + StdBTreeMap = 20 + StdHashMap = 21 + StdHashSet = 22 + StdRc = 23 + StdArc = 24 + StdCell = 25 + StdRef = 26 + StdRefMut = 27 + StdRefCell = 28 + StdNonZeroNumber = 29 + StdPath = 30 + StdPathBuf = 31 STD_STRING_REGEX = re.compile(r"^(alloc::([a-z_]+::)+)String$") @@ -57,42 +59,45 @@ class RustType(object): STD_PATHBUF_REGEX = re.compile(r"^(std::([a-z_]+::)+)PathBuf$") STD_PATH_REGEX = re.compile(r"^&(mut )?(std::([a-z_]+::)+)Path$") -TUPLE_ITEM_REGEX = re.compile(r"__\d+$") - ENCODED_ENUM_PREFIX = "RUST$ENCODED$ENUM$" ENUM_DISR_FIELD_NAME = "<>" ENUM_LLDB_ENCODED_VARIANTS = "$variants$" STD_TYPE_TO_REGEX = { - RustType.STD_STRING: STD_STRING_REGEX, - RustType.STD_OS_STRING: STD_OS_STRING_REGEX, - RustType.STD_STR: STD_STR_REGEX, - RustType.STD_SLICE: STD_SLICE_REGEX, - RustType.STD_VEC: STD_VEC_REGEX, - RustType.STD_VEC_DEQUE: STD_VEC_DEQUE_REGEX, - RustType.STD_HASH_MAP: STD_HASH_MAP_REGEX, - RustType.STD_HASH_SET: STD_HASH_SET_REGEX, - RustType.STD_BTREE_SET: STD_BTREE_SET_REGEX, - RustType.STD_BTREE_MAP: STD_BTREE_MAP_REGEX, - RustType.STD_RC: STD_RC_REGEX, - RustType.STD_ARC: STD_ARC_REGEX, - RustType.STD_REF: STD_REF_REGEX, - RustType.STD_REF_MUT: STD_REF_MUT_REGEX, - RustType.STD_REF_CELL: STD_REF_CELL_REGEX, - RustType.STD_CELL: STD_CELL_REGEX, - RustType.STD_NONZERO_NUMBER: STD_NONZERO_NUMBER_REGEX, - RustType.STD_PATHBUF: STD_PATHBUF_REGEX, - RustType.STD_PATH: STD_PATH_REGEX, + RustType.StdString: STD_STRING_REGEX, + RustType.StdOsString: STD_OS_STRING_REGEX, + RustType.StdStr: STD_STR_REGEX, + RustType.StdSlice: STD_SLICE_REGEX, + RustType.StdVec: STD_VEC_REGEX, + RustType.StdVecDeque: STD_VEC_DEQUE_REGEX, + RustType.StdHashMap: STD_HASH_MAP_REGEX, + RustType.StdHashSet: STD_HASH_SET_REGEX, + RustType.StdBTreeSet: STD_BTREE_SET_REGEX, + RustType.StdBTreeMap: STD_BTREE_MAP_REGEX, + RustType.StdRc: STD_RC_REGEX, + RustType.StdArc: STD_ARC_REGEX, + RustType.StdRef: STD_REF_REGEX, + RustType.StdRefMut: STD_REF_MUT_REGEX, + RustType.StdRefCell: STD_REF_CELL_REGEX, + RustType.StdCell: STD_CELL_REGEX, + RustType.StdNonZeroNumber: STD_NONZERO_NUMBER_REGEX, + RustType.StdPath: STD_PATH_REGEX, + RustType.StdPathBuf: STD_PATHBUF_REGEX, } def is_tuple_fields(fields: List) -> bool: - return all(TUPLE_ITEM_REGEX.match(str(field.name)) for field in fields) + for f in fields: + name = str(f.name) + if not name.startswith("__") or not name[2:].isdigit(): + return False + + return True -def classify_struct(name: str, fields: List) -> str: +def classify_struct(name: str, fields: List) -> RustType: if len(fields) == 0: - return RustType.EMPTY + return RustType.Empty for ty, regex in STD_TYPE_TO_REGEX.items(): if regex.match(name): @@ -103,26 +108,26 @@ def classify_struct(name: str, fields: List) -> str: fields[0].name == ENUM_DISR_FIELD_NAME or fields[0].name == ENUM_LLDB_ENCODED_VARIANTS ): - return RustType.ENUM + return RustType.Enum if is_tuple_fields(fields): - return RustType.TUPLE + return RustType.Tuple - return RustType.STRUCT + return RustType.Struct -def classify_union(fields: List) -> str: +def classify_union(fields: List) -> RustType: if len(fields) == 0: - return RustType.EMPTY + return RustType.Empty first_variant_name = fields[0].name if first_variant_name is None: if len(fields) == 1: - return RustType.SINGLETON_ENUM + return RustType.SingletonEnum else: - return RustType.REGULAR_ENUM + return RustType.RegularEnum elif first_variant_name.startswith(ENCODED_ENUM_PREFIX): assert len(fields) == 1 - return RustType.COMPRESSED_ENUM + return RustType.CompressedEnum else: - return RustType.REGULAR_UNION + return RustType.RegularEnum diff --git a/tests/debuginfo/associated-types.rs b/tests/debuginfo/associated-types.rs index ac994b9d5ebcd..5944cc14a1e81 100644 --- a/tests/debuginfo/associated-types.rs +++ b/tests/debuginfo/associated-types.rs @@ -53,7 +53,7 @@ //@ lldb-command:continue //@ lldb-command:v arg -//@ lldb-check:[...] { 0 = 4 1 = 5 } +//@ lldb-check:[...] (4, 5) //@ lldb-command:continue //@ lldb-command:v a diff --git a/tests/debuginfo/borrowed-tuple.rs b/tests/debuginfo/borrowed-tuple.rs index 901d7f6ed08b0..411e1b0a15828 100644 --- a/tests/debuginfo/borrowed-tuple.rs +++ b/tests/debuginfo/borrowed-tuple.rs @@ -21,13 +21,13 @@ //@ lldb-command:run //@ lldb-command:v *stack_val_ref -//@ lldb-check:[...] { 0 = -14 1 = -19 } +//@ lldb-check:[...] (-14, -19) //@ lldb-command:v *ref_to_unnamed -//@ lldb-check:[...] { 0 = -15 1 = -20 } +//@ lldb-check:[...] (-15, -20) //@ lldb-command:v *unique_val_ref -//@ lldb-check:[...] { 0 = -17 1 = -22 } +//@ lldb-check:[...] (-17, -22) #![allow(unused_variables)] diff --git a/tests/debuginfo/box.rs b/tests/debuginfo/box.rs index 3d9d568e8e63d..2431ccc000a02 100644 --- a/tests/debuginfo/box.rs +++ b/tests/debuginfo/box.rs @@ -18,7 +18,7 @@ //@ lldb-command:v *a //@ lldb-check:[...] 1 //@ lldb-command:v *b -//@ lldb-check:[...] { 0 = 2 1 = 3.5 } +//@ lldb-check:[...] (2, 3.5) #![allow(unused_variables)] diff --git a/tests/debuginfo/by-value-self-argument-in-trait-impl.rs b/tests/debuginfo/by-value-self-argument-in-trait-impl.rs index 9f36e3d89ee98..42874f9afe10c 100644 --- a/tests/debuginfo/by-value-self-argument-in-trait-impl.rs +++ b/tests/debuginfo/by-value-self-argument-in-trait-impl.rs @@ -32,7 +32,7 @@ //@ lldb-command:continue //@ lldb-command:v self -//@ lldb-check:[...] { 0 = 4444.5 1 = 5555 2 = 6666 3 = 7777.5 } +//@ lldb-check:[...] (4444.5, 5555, 6666, 7777.5) //@ lldb-command:continue trait Trait { diff --git a/tests/debuginfo/c-style-enum-in-composite.rs b/tests/debuginfo/c-style-enum-in-composite.rs index d28ad6cc73708..2362eee008bbf 100644 --- a/tests/debuginfo/c-style-enum-in-composite.rs +++ b/tests/debuginfo/c-style-enum-in-composite.rs @@ -32,13 +32,13 @@ //@ lldb-command:run //@ lldb-command:v tuple_interior_padding -//@ lldb-check:[...] { 0 = 0 1 = OneHundred } +//@ lldb-check:[...] (0, OneHundred) //@ lldb-command:v tuple_padding_at_end -//@ lldb-check:[...] ((1, OneThousand), 2) { 0 = (1, OneThousand) { 0 = 1 1 = OneThousand } 1 = 2 } +//@ lldb-check:[...] ((1, OneThousand), 2) //@ lldb-command:v tuple_different_enums -//@ lldb-check:[...] { 0 = OneThousand 1 = MountainView 2 = OneMillion 3 = Vienna } +//@ lldb-check:[...] (OneThousand, MountainView, OneMillion, Vienna) //@ lldb-command:v padded_struct //@ lldb-check:[...] { a = 3 b = OneMillion c = 4 d = Toronto e = 5 } @@ -50,7 +50,7 @@ //@ lldb-check:[...] { a = OneMillion b = MountainView c = OneThousand d = Toronto } //@ lldb-command:v struct_with_drop -//@ lldb-check:[...] { 0 = { a = OneHundred b = Vienna } 1 = 9 } +//@ lldb-check:[...] ({a:OneHundred, b:Vienna}, 9) #![allow(unused_variables)] diff --git a/tests/debuginfo/cross-crate-spans.rs b/tests/debuginfo/cross-crate-spans.rs index 97fcda13fe4b9..e752baf9d2634 100644 --- a/tests/debuginfo/cross-crate-spans.rs +++ b/tests/debuginfo/cross-crate-spans.rs @@ -35,7 +35,7 @@ extern crate cross_crate_spans; //@ lldb-command:run //@ lldb-command:v result -//@ lldb-check:[...] { 0 = 17 1 = 17 } +//@ lldb-check:[...] (17, 17) //@ lldb-command:v a_variable //@ lldb-check:[...] 123456789 //@ lldb-command:v another_variable @@ -43,7 +43,7 @@ extern crate cross_crate_spans; //@ lldb-command:continue //@ lldb-command:v result -//@ lldb-check:[...] { 0 = 1212 1 = 1212 } +//@ lldb-check:[...] (1212, 1212) //@ lldb-command:v a_variable //@ lldb-check:[...] 123456789 //@ lldb-command:v another_variable diff --git a/tests/debuginfo/destructured-fn-argument.rs b/tests/debuginfo/destructured-fn-argument.rs index af9e620e61512..def1d159c598e 100644 --- a/tests/debuginfo/destructured-fn-argument.rs +++ b/tests/debuginfo/destructured-fn-argument.rs @@ -172,7 +172,7 @@ //@ lldb-command:v a //@ lldb-check:[...] 5 //@ lldb-command:v b -//@ lldb-check:[...] { 0 = 6 1 = 7 } +//@ lldb-check:[...] (6, 7) //@ lldb-command:continue //@ lldb-command:v h @@ -234,11 +234,11 @@ //@ lldb-command:continue //@ lldb-command:v aa -//@ lldb-check:[...] { 0 = 34 1 = 35 } +//@ lldb-check:[...] (34, 35) //@ lldb-command:continue //@ lldb-command:v bb -//@ lldb-check:[...] { 0 = 36 1 = 37 } +//@ lldb-check:[...] (36, 37) //@ lldb-command:continue //@ lldb-command:v cc @@ -246,17 +246,17 @@ //@ lldb-command:continue //@ lldb-command:v dd -//@ lldb-check:[...] { 0 = 40 1 = 41 2 = 42 } +//@ lldb-check:[...] (40, 41, 42) //@ lldb-command:continue //@ lldb-command:v *ee -//@ lldb-check:[...] { 0 = 43 1 = 44 2 = 45 } +//@ lldb-check:[...] (43, 44, 45) //@ lldb-command:continue //@ lldb-command:v *ff //@ lldb-check:[...] 46 //@ lldb-command:v gg -//@ lldb-check:[...] { 0 = 47 1 = 48 } +//@ lldb-check:[...] (47, 48) //@ lldb-command:continue //@ lldb-command:v *hh diff --git a/tests/debuginfo/destructured-for-loop-variable.rs b/tests/debuginfo/destructured-for-loop-variable.rs index 8ea6f70aa0497..5febb9e77e71c 100644 --- a/tests/debuginfo/destructured-for-loop-variable.rs +++ b/tests/debuginfo/destructured-for-loop-variable.rs @@ -138,7 +138,7 @@ //@ lldb-command:continue //@ lldb-command:v simple_tuple_ident -//@ lldb-check:[...] { 0 = 34903493 1 = 232323 } +//@ lldb-check:[...] (34903493, 232323) //@ lldb-command:continue #![allow(unused_variables)] diff --git a/tests/debuginfo/destructured-local.rs b/tests/debuginfo/destructured-local.rs index 13399480ca445..0f7667a135209 100644 --- a/tests/debuginfo/destructured-local.rs +++ b/tests/debuginfo/destructured-local.rs @@ -136,7 +136,7 @@ //@ lldb-command:v f //@ lldb-check:[...] 5 //@ lldb-command:v g -//@ lldb-check:[...] { 0 = 6 1 = 7 } +//@ lldb-check:[...] (6, 7) //@ lldb-command:v h //@ lldb-check:[...] 8 @@ -190,25 +190,25 @@ //@ lldb-check:[...] 33 //@ lldb-command:v aa -//@ lldb-check:[...] { 0 = 34 1 = 35 } +//@ lldb-check:[...] (34, 35) //@ lldb-command:v bb -//@ lldb-check:[...] { 0 = 36 1 = 37 } +//@ lldb-check:[...] (36, 37) //@ lldb-command:v cc //@ lldb-check:[...] 38 //@ lldb-command:v dd -//@ lldb-check:[...] { 0 = 40 1 = 41 2 = 42 } +//@ lldb-check:[...] (40, 41, 42) //@ lldb-command:v *ee -//@ lldb-check:[...] { 0 = 43 1 = 44 2 = 45 } +//@ lldb-check:[...] (43, 44, 45) //@ lldb-command:v *ff //@ lldb-check:[...] 46 //@ lldb-command:v gg -//@ lldb-check:[...] { 0 = 47 1 = 48 } +//@ lldb-check:[...] (47, 48) //@ lldb-command:v *hh //@ lldb-check:[...] 50 diff --git a/tests/debuginfo/generic-method-on-generic-struct.rs b/tests/debuginfo/generic-method-on-generic-struct.rs index 54e0798c90dc5..6ec2151e2cdb9 100644 --- a/tests/debuginfo/generic-method-on-generic-struct.rs +++ b/tests/debuginfo/generic-method-on-generic-struct.rs @@ -58,7 +58,7 @@ // STACK BY REF //@ lldb-command:v *self -//@ lldb-check:[...] { x = (8888, -8888) { 0 = 8888 1 = -8888 } } +//@ lldb-check:[...] { x = (8888, -8888) } //@ lldb-command:v arg1 //@ lldb-check:[...] -1 //@ lldb-command:v arg2 @@ -67,7 +67,7 @@ // STACK BY VAL //@ lldb-command:v self -//@ lldb-check:[...] { x = (8888, -8888) { 0 = 8888 1 = -8888 } } +//@ lldb-check:[...] { x = (8888, -8888) } //@ lldb-command:v arg1 //@ lldb-check:[...] -3 //@ lldb-command:v arg2 diff --git a/tests/debuginfo/method-on-generic-struct.rs b/tests/debuginfo/method-on-generic-struct.rs index e050d3074f443..6194cd58bbb0d 100644 --- a/tests/debuginfo/method-on-generic-struct.rs +++ b/tests/debuginfo/method-on-generic-struct.rs @@ -58,7 +58,7 @@ // STACK BY REF //@ lldb-command:v *self -//@ lldb-check:[...]Struct<(u32, i32)>) *self = { x = (8888, -8888) { 0 = 8888 1 = -8888 } } +//@ lldb-check:[...]Struct<(u32, i32)>) *self = { x = (8888, -8888) } //@ lldb-command:v arg1 //@ lldb-check:[...] -1 //@ lldb-command:v arg2 @@ -67,7 +67,7 @@ // STACK BY VAL //@ lldb-command:v self -//@ lldb-check:[...]Struct<(u32, i32)>) self = { x = (8888, -8888) { 0 = 8888 1 = -8888 } } +//@ lldb-check:[...]Struct<(u32, i32)>) self = { x = (8888, -8888) } //@ lldb-command:v arg1 //@ lldb-check:[...] -3 //@ lldb-command:v arg2 diff --git a/tests/debuginfo/numeric-types.rs b/tests/debuginfo/numeric-types.rs index dbbc4ee6e8614..a27102da96923 100644 --- a/tests/debuginfo/numeric-types.rs +++ b/tests/debuginfo/numeric-types.rs @@ -199,40 +199,40 @@ //@ lldb-command:run //@ lldb-command:v/d nz_i8 -//@ lldb-check:[...] 11 { __0 = { 0 = 11 } } +//@ lldb-check:[...] 11 { 0 = { 0 = 11 } } //@ lldb-command:v nz_i16 -//@ lldb-check:[...] 22 { __0 = { 0 = 22 } } +//@ lldb-check:[...] 22 { 0 = { 0 = 22 } } //@ lldb-command:v nz_i32 -//@ lldb-check:[...] 33 { __0 = { 0 = 33 } } +//@ lldb-check:[...] 33 { 0 = { 0 = 33 } } //@ lldb-command:v nz_i64 -//@ lldb-check:[...] 44 { __0 = { 0 = 44 } } +//@ lldb-check:[...] 44 { 0 = { 0 = 44 } } //@ lldb-command:v nz_i128 -//@ lldb-check:[...] 55 { __0 = { 0 = 55 } } +//@ lldb-check:[...] 55 { 0 = { 0 = 55 } } //@ lldb-command:v nz_isize -//@ lldb-check:[...] 66 { __0 = { 0 = 66 } } +//@ lldb-check:[...] 66 { 0 = { 0 = 66 } } //@ lldb-command:v/d nz_u8 -//@ lldb-check:[...] 77 { __0 = { 0 = 77 } } +//@ lldb-check:[...] 77 { 0 = { 0 = 77 } } //@ lldb-command:v nz_u16 -//@ lldb-check:[...] 88 { __0 = { 0 = 88 } } +//@ lldb-check:[...] 88 { 0 = { 0 = 88 } } //@ lldb-command:v nz_u32 -//@ lldb-check:[...] 99 { __0 = { 0 = 99 } } +//@ lldb-check:[...] 99 { 0 = { 0 = 99 } } //@ lldb-command:v nz_u64 -//@ lldb-check:[...] 100 { __0 = { 0 = 100 } } +//@ lldb-check:[...] 100 { 0 = { 0 = 100 } } //@ lldb-command:v nz_u128 -//@ lldb-check:[...] 111 { __0 = { 0 = 111 } } +//@ lldb-check:[...] 111 { 0 = { 0 = 111 } } //@ lldb-command:v nz_usize -//@ lldb-check:[...] 122 { __0 = { 0 = 122 } } +//@ lldb-check:[...] 122 { 0 = { 0 = 122 } } use std::num::*; use std::sync::atomic::*; diff --git a/tests/debuginfo/pretty-std-collections.rs b/tests/debuginfo/pretty-std-collections.rs index 85292cdad67af..4f0b51e8589dd 100644 --- a/tests/debuginfo/pretty-std-collections.rs +++ b/tests/debuginfo/pretty-std-collections.rs @@ -59,7 +59,7 @@ //@ lldb-check:[...] size=7 { [0] = 2 [1] = 3 [2] = 4 [3] = 5 [4] = 6 [5] = 7 [6] = 8 } //@ lldb-command:v hash_map -//@ lldb-check:[...] size=4 { [0] = (1, 10) { 0 = 1 1 = 10 } [1] = (2, 20) { 0 = 2 1 = 20 } [2] = (3, 30) { 0 = 3 1 = 30 } [3] = (4, 40) { 0 = 4 1 = 40 } } +//@ lldb-check:[...] size=4 { [0] = (1, 10) [1] = (2, 20) [2] = (3, 30) [3] = (4, 40) } //@ lldb-command:v hash_set //@ lldb-check:[...] size=4 { [0] = 1 [1] = 2 [2] = 3 [3] = 4 } diff --git a/tests/debuginfo/simple-tuple.rs b/tests/debuginfo/simple-tuple.rs index a82070900aafc..65eac8bca557d 100644 --- a/tests/debuginfo/simple-tuple.rs +++ b/tests/debuginfo/simple-tuple.rs @@ -61,23 +61,24 @@ // === LLDB TESTS ================================================================================== //@ lldb-command:run - +//@ lldb-command: type format add -f u u8 "unsigned char" +//@ lldb-command: type format add -f d i8 char "signed char" //@ lldb-command:v/d noPadding8 -//@ lldb-check:[...] { 0 = -100 1 = 100 } +//@ lldb-check:[...] (-100, 100) //@ lldb-command:v noPadding16 -//@ lldb-check:[...] { 0 = 0 1 = 1 2 = 2 } +//@ lldb-check:[...] (0, 1, 2) //@ lldb-command:v noPadding32 -//@ lldb-check:[...] { 0 = 3 1 = 4.5 2 = 5 } +//@ lldb-check:[...] (3, 4.5, 5) //@ lldb-command:v noPadding64 -//@ lldb-check:[...] { 0 = 6 1 = 7.5 2 = 8 } +//@ lldb-check:[...] (6, 7.5, 8) //@ lldb-command:v internalPadding1 -//@ lldb-check:[...] { 0 = 9 1 = 10 } +//@ lldb-check:[...] (9, 10) //@ lldb-command:v internalPadding2 -//@ lldb-check:[...] { 0 = 11 1 = 12 2 = 13 3 = 14 } +//@ lldb-check:[...] (11, 12, 13, 14) //@ lldb-command:v paddingAtEnd -//@ lldb-check:[...] { 0 = 15 1 = 16 } +//@ lldb-check:[...] (15, 16) // === CDB TESTS ================================================================================== diff --git a/tests/debuginfo/tuple-in-tuple.rs b/tests/debuginfo/tuple-in-tuple.rs index 98e2daf623ef1..fe49aeb6da8ed 100644 --- a/tests/debuginfo/tuple-in-tuple.rs +++ b/tests/debuginfo/tuple-in-tuple.rs @@ -29,21 +29,21 @@ //@ lldb-command:run //@ lldb-command:v no_padding1 -//@ lldb-check:[...] ((0, 1), 2, 3) { 0 = (0, 1) { 0 = 0 1 = 1 } 1 = 2 2 = 3 } +//@ lldb-check:[...] ((0, 1), 2, 3) //@ lldb-command:v no_padding2 -//@ lldb-check:[...] (4, (5, 6), 7) { 0 = 4 1 = (5, 6) { 0 = 5 1 = 6 } 2 = 7 } +//@ lldb-check:[...] (4, (5, 6), 7) //@ lldb-command:v no_padding3 -//@ lldb-check:[...] (8, 9, (10, 11)) { 0 = 8 1 = 9 2 = (10, 11) { 0 = 10 1 = 11 } } +//@ lldb-check:[...] (8, 9, (10, 11)) //@ lldb-command:v internal_padding1 -//@ lldb-check:[...] (12, (13, 14)) { 0 = 12 1 = (13, 14) { 0 = 13 1 = 14 } } +//@ lldb-check:[...] (12, (13, 14)) //@ lldb-command:v internal_padding2 -//@ lldb-check:[...] (15, (16, 17)) { 0 = 15 1 = (16, 17) { 0 = 16 1 = 17 } } +//@ lldb-check:[...] (15, (16, 17)) //@ lldb-command:v padding_at_end1 -//@ lldb-check:[...] (18, (19, 20)) { 0 = 18 1 = (19, 20) { 0 = 19 1 = 20 } } +//@ lldb-check:[...] (18, (19, 20)) //@ lldb-command:v padding_at_end2 -//@ lldb-check:[...] ((21, 22), 23) { 0 = (21, 22) { 0 = 21 1 = 22 } 1 = 23 } +//@ lldb-check:[...] ((21, 22), 23) // === CDB TESTS ================================================================================== diff --git a/tests/debuginfo/union-smoke.rs b/tests/debuginfo/union-smoke.rs index 884a1f3e6992e..9934a32914417 100644 --- a/tests/debuginfo/union-smoke.rs +++ b/tests/debuginfo/union-smoke.rs @@ -14,10 +14,10 @@ //@ lldb-command:run //@ lldb-command:v u -//@ lldb-check:[...] { a = ('\x02', '\x02') { 0 = '\x02' 1 = '\x02' } b = 514 } +//@ lldb-check:[...] { a = ('\x02', '\x02') b = 514 } //@ lldb-command:print union_smoke::SU -//@ lldb-check:[...] { a = ('\x01', '\x01') { 0 = '\x01' 1 = '\x01' } b = 257 } +//@ lldb-check:[...] { a = ('\x01', '\x01') b = 257 } #![allow(unused)] diff --git a/tests/debuginfo/unique-enum.rs b/tests/debuginfo/unique-enum.rs index 3bc6ce259655d..6ba20c5bec00b 100644 --- a/tests/debuginfo/unique-enum.rs +++ b/tests/debuginfo/unique-enum.rs @@ -27,10 +27,10 @@ //@ lldb-check:(unique_enum::ABC) *the_a = TheA{x:0, y:8970181431921507452} { x = 0 y = 8970181431921507452 } //@ lldb-command:v *the_b -//@ lldb-check:(unique_enum::ABC) *the_b = TheB(0, 286331153, 286331153) { 0 = 0 1 = 286331153 2 = 286331153 } +//@ lldb-check:(unique_enum::ABC) *the_b = TheB(0, 286331153, 286331153) //@ lldb-command:v *univariant -//@ lldb-check:(unique_enum::Univariant) *univariant = TheOnlyCase(123234) { 0 = 123234 } +//@ lldb-check:(unique_enum::Univariant) *univariant = TheOnlyCase(123234) #![allow(unused_variables)] diff --git a/tests/debuginfo/vec-slices.rs b/tests/debuginfo/vec-slices.rs index e7f6fd03e5410..ad31ca8fff2f5 100644 --- a/tests/debuginfo/vec-slices.rs +++ b/tests/debuginfo/vec-slices.rs @@ -67,7 +67,7 @@ //@ lldb-check:[...] size=2 { [0] = 3 [1] = 4 } //@ lldb-command:v padded_tuple -//@ lldb-check:[...] size=2 { [0] = (6, 7) { 0 = 6 1 = 7 } [1] = (8, 9) { 0 = 8 1 = 9 } } +//@ lldb-check:[...] size=2 { [0] = (6, 7) [1] = (8, 9) } //@ lldb-command:v padded_struct //@ lldb-check:[...] size=2 { [0] = { x = 10 y = 11 z = 12 } [1] = { x = 13 y = 14 z = 15 } }