1+ from __future__ import annotations
2+ from typing import Dict
3+
14import lldb
25
36from lldb_providers import *
@@ -9,57 +12,60 @@ def is_hashbrown_hashmap(hash_map: lldb.SBValue) -> bool:
912 return len (hash_map .type .fields ) == 1
1013
1114
12- def classify_rust_type (type : lldb .SBType ) -> str :
15+ def classify_rust_type (type : lldb .SBType ) -> RustType :
16+ if type .IsPointerType ():
17+ type = type .GetPointeeType ()
18+
1319 type_class = type .GetTypeClass ()
1420 if type_class == lldb .eTypeClassStruct :
1521 return classify_struct (type .name , type .fields )
1622 if type_class == lldb .eTypeClassUnion :
1723 return classify_union (type .fields )
1824
19- return RustType .OTHER
25+ return RustType .Other
2026
2127
2228def summary_lookup (valobj : lldb .SBValue , _dict : LLDBOpaque ) -> str :
2329 """Returns the summary provider for the given value"""
2430 rust_type = classify_rust_type (valobj .GetType ())
2531
26- if rust_type == RustType .STD_STRING :
32+ if rust_type == RustType .StdString :
2733 return StdStringSummaryProvider (valobj , _dict )
28- if rust_type == RustType .STD_OS_STRING :
34+ if rust_type == RustType .StdOsString :
2935 return StdOsStringSummaryProvider (valobj , _dict )
30- if rust_type == RustType .STD_STR :
36+ if rust_type == RustType .StdStr :
3137 return StdStrSummaryProvider (valobj , _dict )
3238
33- if rust_type == RustType .STD_VEC :
39+ if rust_type == RustType .StdVec :
3440 return SizeSummaryProvider (valobj , _dict )
35- if rust_type == RustType .STD_VEC_DEQUE :
41+ if rust_type == RustType .StdVecDeque :
3642 return SizeSummaryProvider (valobj , _dict )
37- if rust_type == RustType .STD_SLICE :
43+ if rust_type == RustType .StdSlice :
3844 return SizeSummaryProvider (valobj , _dict )
3945
40- if rust_type == RustType .STD_HASH_MAP :
46+ if rust_type == RustType .StdHashMap :
4147 return SizeSummaryProvider (valobj , _dict )
42- if rust_type == RustType .STD_HASH_SET :
48+ if rust_type == RustType .StdHashSet :
4349 return SizeSummaryProvider (valobj , _dict )
4450
45- if rust_type == RustType .STD_RC :
51+ if rust_type == RustType .StdRc :
4652 return StdRcSummaryProvider (valobj , _dict )
47- if rust_type == RustType .STD_ARC :
53+ if rust_type == RustType .StdArc :
4854 return StdRcSummaryProvider (valobj , _dict )
4955
50- if rust_type == RustType .STD_REF :
56+ if rust_type == RustType .StdRef :
5157 return StdRefSummaryProvider (valobj , _dict )
52- if rust_type == RustType .STD_REF_MUT :
58+ if rust_type == RustType .StdRefMut :
5359 return StdRefSummaryProvider (valobj , _dict )
54- if rust_type == RustType .STD_REF_CELL :
60+ if rust_type == RustType .StdRefCell :
5561 return StdRefSummaryProvider (valobj , _dict )
5662
57- if rust_type == RustType .STD_NONZERO_NUMBER :
63+ if rust_type == RustType .StdNonZeroNumber :
5864 return StdNonZeroNumberSummaryProvider (valobj , _dict )
5965
60- if rust_type == RustType .STD_PATHBUF :
66+ if rust_type == RustType .StdPathBuf :
6167 return StdPathBufSummaryProvider (valobj , _dict )
62- if rust_type == RustType .STD_PATH :
68+ if rust_type == RustType .StdPath :
6369 return StdPathSummaryProvider (valobj , _dict )
6470
6571 return ""
@@ -69,22 +75,22 @@ def synthetic_lookup(valobj: lldb.SBValue, _dict: LLDBOpaque) -> object:
6975 """Returns the synthetic provider for the given value"""
7076 rust_type = classify_rust_type (valobj .GetType ())
7177
72- if rust_type == RustType .STRUCT :
78+ if rust_type == RustType .Struct :
7379 return StructSyntheticProvider (valobj , _dict )
74- if rust_type == RustType .STRUCT_VARIANT :
80+ if rust_type == RustType .StructVariant :
7581 return StructSyntheticProvider (valobj , _dict , is_variant = True )
76- if rust_type == RustType .TUPLE :
82+ if rust_type == RustType .Tuple :
7783 return TupleSyntheticProvider (valobj , _dict )
78- if rust_type == RustType .TUPLE_VARIANT :
84+ if rust_type == RustType .TupleVariant :
7985 return TupleSyntheticProvider (valobj , _dict , is_variant = True )
80- if rust_type == RustType .EMPTY :
86+ if rust_type == RustType .Empty :
8187 return EmptySyntheticProvider (valobj , _dict )
82- if rust_type == RustType .REGULAR_ENUM :
88+ if rust_type == RustType .RegularEnum :
8389 discriminant = valobj .GetChildAtIndex (0 ).GetChildAtIndex (0 ).GetValueAsUnsigned ()
8490 return synthetic_lookup (valobj .GetChildAtIndex (discriminant ), _dict )
85- if rust_type == RustType .SINGLETON_ENUM :
91+ if rust_type == RustType .SingletonEnum :
8692 return synthetic_lookup (valobj .GetChildAtIndex (0 ), _dict )
87- if rust_type == RustType .ENUM :
93+ if rust_type == RustType .Enum :
8894 # this little trick lets us treat `synthetic_lookup` as a "recognizer function" for the enum
8995 # summary providers, reducing the number of lookups we have to do. This is a huge time save
9096 # because there's no way (via type name) to recognize sum-type enums on `*-gnu` targets. The
@@ -106,37 +112,37 @@ def synthetic_lookup(valobj: lldb.SBValue, _dict: LLDBOpaque) -> object:
106112 )
107113
108114 return ClangEncodedEnumProvider (valobj , _dict )
109- if rust_type == RustType .STD_VEC :
115+ if rust_type == RustType .StdVec :
110116 return StdVecSyntheticProvider (valobj , _dict )
111- if rust_type == RustType .STD_VEC_DEQUE :
117+ if rust_type == RustType .StdVecDeque :
112118 return StdVecDequeSyntheticProvider (valobj , _dict )
113- if rust_type == RustType .STD_SLICE or rust_type == RustType .STD_STR :
119+ if rust_type == RustType .StdSlice or rust_type == RustType .StdStr :
114120 return StdSliceSyntheticProvider (valobj , _dict )
115121
116- if rust_type == RustType .STD_HASH_MAP :
122+ if rust_type == RustType .StdHashMap :
117123 if is_hashbrown_hashmap (valobj ):
118124 return StdHashMapSyntheticProvider (valobj , _dict )
119125 else :
120126 return StdOldHashMapSyntheticProvider (valobj , _dict )
121- if rust_type == RustType .STD_HASH_SET :
127+ if rust_type == RustType .StdHashSet :
122128 hash_map = valobj .GetChildAtIndex (0 )
123129 if is_hashbrown_hashmap (hash_map ):
124130 return StdHashMapSyntheticProvider (valobj , _dict , show_values = False )
125131 else :
126132 return StdOldHashMapSyntheticProvider (hash_map , _dict , show_values = False )
127133
128- if rust_type == RustType .STD_RC :
134+ if rust_type == RustType .StdRc :
129135 return StdRcSyntheticProvider (valobj , _dict )
130- if rust_type == RustType .STD_ARC :
136+ if rust_type == RustType .StdArc :
131137 return StdRcSyntheticProvider (valobj , _dict , is_atomic = True )
132138
133- if rust_type == RustType .STD_CELL :
139+ if rust_type == RustType .StdCell :
134140 return StdCellSyntheticProvider (valobj , _dict )
135- if rust_type == RustType .STD_REF :
141+ if rust_type == RustType .StdRef :
136142 return StdRefSyntheticProvider (valobj , _dict )
137- if rust_type == RustType .STD_REF_MUT :
143+ if rust_type == RustType .StdRefMut :
138144 return StdRefSyntheticProvider (valobj , _dict )
139- if rust_type == RustType .STD_REF_CELL :
145+ if rust_type == RustType .StdRefCell :
140146 return StdRefSyntheticProvider (valobj , _dict , is_cell = True )
141147
142148 return DefaultSyntheticProvider (valobj , _dict )
0 commit comments