Skip to content

Commit f032edd

Browse files
committed
add LLDBOpaque type hint
1 parent a13d369 commit f032edd

File tree

2 files changed

+33
-24
lines changed

2 files changed

+33
-24
lines changed

src/etc/lldb_lookup.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def classify_rust_type(type: lldb.SBType) -> str:
1919
return RustType.OTHER
2020

2121

22-
def summary_lookup(valobj: lldb.SBValue, _dict) -> str:
22+
def summary_lookup(valobj: lldb.SBValue, _dict: LLDBOpaque) -> str:
2323
"""Returns the summary provider for the given value"""
2424
rust_type = classify_rust_type(valobj.GetType())
2525

@@ -65,7 +65,7 @@ def summary_lookup(valobj: lldb.SBValue, _dict) -> str:
6565
return ""
6666

6767

68-
def synthetic_lookup(valobj: lldb.SBValue, _dict) -> object:
68+
def synthetic_lookup(valobj: lldb.SBValue, _dict: LLDBOpaque) -> object:
6969
"""Returns the synthetic provider for the given value"""
7070
rust_type = classify_rust_type(valobj.GetType())
7171

src/etc/lldb_providers.py

+31-22
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,15 @@
4545
PY3 = sys.version_info[0] == 3
4646

4747

48+
class LLDBOpaque:
49+
"""
50+
A type used by LLDB internally. Values of this type should never be used except when passing as
51+
an argument to an LLDB function.
52+
"""
53+
54+
pass
55+
56+
4857
class ValueBuilder:
4958
def __init__(self, valobj: SBValue):
5059
self.valobj = valobj
@@ -77,7 +86,7 @@ def unwrap_unique_or_non_null(unique_or_nonnull: SBValue) -> SBValue:
7786

7887

7988
class DefaultSyntheticProvider:
80-
def __init__(self, valobj: SBValue, _dict):
89+
def __init__(self, valobj: SBValue, _dict: LLDBOpaque):
8190
# logger = Logger.Logger()
8291
# logger >> "Default synthetic provider for " + str(valobj.GetName())
8392
self.valobj = valobj
@@ -99,7 +108,7 @@ def has_children(self) -> bool:
99108

100109

101110
class EmptySyntheticProvider:
102-
def __init__(self, valobj: SBValue, _dict):
111+
def __init__(self, valobj: SBValue, _dict: LLDBOpaque):
103112
# logger = Logger.Logger()
104113
# logger >> "[EmptySyntheticProvider] for " + str(valobj.GetName())
105114
self.valobj = valobj
@@ -120,7 +129,7 @@ def has_children(self) -> bool:
120129
return False
121130

122131

123-
def SizeSummaryProvider(valobj: SBValue, _dict) -> str:
132+
def SizeSummaryProvider(valobj: SBValue, _dict: LLDBOpaque) -> str:
124133
return "size=" + str(valobj.GetNumChildren())
125134

126135

@@ -134,14 +143,14 @@ def vec_to_string(vec: SBValue) -> str:
134143
)
135144

136145

137-
def StdStringSummaryProvider(valobj: SBValue, _dict) -> str:
146+
def StdStringSummaryProvider(valobj: SBValue, _dict: LLDBOpaque) -> str:
138147
# logger = Logger.Logger()
139148
# logger >> "[StdStringSummaryProvider] for " + str(valobj.GetName())
140149
vec = valobj.GetChildAtIndex(0)
141150
return '"%s"' % vec_to_string(vec)
142151

143152

144-
def StdOsStringSummaryProvider(valobj: SBValue, _dict) -> str:
153+
def StdOsStringSummaryProvider(valobj: SBValue, _dict: LLDBOpaque) -> str:
145154
# logger = Logger.Logger()
146155
# logger >> "[StdOsStringSummaryProvider] for " + str(valobj.GetName())
147156
buf = valobj.GetChildAtIndex(0).GetChildAtIndex(0)
@@ -150,7 +159,7 @@ def StdOsStringSummaryProvider(valobj: SBValue, _dict) -> str:
150159
return '"%s"' % vec_to_string(vec)
151160

152161

153-
def StdStrSummaryProvider(valobj: SBValue, _dict) -> str:
162+
def StdStrSummaryProvider(valobj: SBValue, _dict: LLDBOpaque) -> str:
154163
# logger = Logger.Logger()
155164
# logger >> "[StdStrSummaryProvider] for " + str(valobj.GetName())
156165

@@ -171,13 +180,13 @@ def StdStrSummaryProvider(valobj: SBValue, _dict) -> str:
171180
return '"%s"' % data
172181

173182

174-
def StdPathBufSummaryProvider(valobj: SBValue, _dict) -> str:
183+
def StdPathBufSummaryProvider(valobj: SBValue, _dict: LLDBOpaque) -> str:
175184
# logger = Logger.Logger()
176185
# logger >> "[StdPathBufSummaryProvider] for " + str(valobj.GetName())
177186
return StdOsStringSummaryProvider(valobj.GetChildMemberWithName("inner"), _dict)
178187

179188

180-
def StdPathSummaryProvider(valobj: SBValue, _dict) -> str:
189+
def StdPathSummaryProvider(valobj: SBValue, _dict: LLDBOpaque) -> str:
181190
# logger = Logger.Logger()
182191
# logger >> "[StdPathSummaryProvider] for " + str(valobj.GetName())
183192
length = valobj.GetChildMemberWithName("length").GetValueAsUnsigned()
@@ -201,7 +210,7 @@ def StdPathSummaryProvider(valobj: SBValue, _dict) -> str:
201210
class StructSyntheticProvider:
202211
"""Pretty-printer for structs and struct enum variants"""
203212

204-
def __init__(self, valobj: SBValue, _dict, is_variant: bool = False):
213+
def __init__(self, valobj: SBValue, _dict: LLDBOpaque, is_variant: bool = False):
205214
# logger = Logger.Logger()
206215
self.valobj = valobj
207216
self.is_variant = is_variant
@@ -245,7 +254,7 @@ class ClangEncodedEnumProvider:
245254
DISCRIMINANT_MEMBER_NAME = "$discr$"
246255
VALUE_MEMBER_NAME = "value"
247256

248-
def __init__(self, valobj: SBValue, _dict):
257+
def __init__(self, valobj: SBValue, _dict: LLDBOpaque):
249258
self.valobj = valobj
250259
self.update()
251260

@@ -304,7 +313,7 @@ def _getCurrentVariantIndex(self, all_variants: SBValue) -> int:
304313
class TupleSyntheticProvider:
305314
"""Pretty-printer for tuples and tuple enum variants"""
306315

307-
def __init__(self, valobj: SBValue, _dict, is_variant: bool = False):
316+
def __init__(self, valobj: SBValue, _dict: LLDBOpaque, is_variant: bool = False):
308317
# logger = Logger.Logger()
309318
self.valobj = valobj
310319
self.is_variant = is_variant
@@ -354,7 +363,7 @@ class StdVecSyntheticProvider:
354363
struct NonNull<T> { pointer: *const T }
355364
"""
356365

357-
def __init__(self, valobj: SBValue, _dict):
366+
def __init__(self, valobj: SBValue, _dict: LLDBOpaque):
358367
# logger = Logger.Logger()
359368
# logger >> "[StdVecSyntheticProvider] for " + str(valobj.GetName())
360369
self.valobj = valobj
@@ -396,7 +405,7 @@ def has_children(self) -> bool:
396405

397406

398407
class StdSliceSyntheticProvider:
399-
def __init__(self, valobj: SBValue, _dict):
408+
def __init__(self, valobj: SBValue, _dict: LLDBOpaque):
400409
self.valobj = valobj
401410
self.update()
402411

@@ -435,7 +444,7 @@ class StdVecDequeSyntheticProvider:
435444
struct VecDeque<T> { head: usize, len: usize, buf: RawVec<T> }
436445
"""
437446

438-
def __init__(self, valobj: SBValue, _dict):
447+
def __init__(self, valobj: SBValue, _dict: LLDBOpaque):
439448
# logger = Logger.Logger()
440449
# logger >> "[StdVecDequeSyntheticProvider] for " + str(valobj.GetName())
441450
self.valobj = valobj
@@ -489,7 +498,7 @@ class StdOldHashMapSyntheticProvider:
489498
struct RawTable<K, V> { capacity_mask: usize, size: usize, hashes: TaggedHashUintPtr, ... }
490499
"""
491500

492-
def __init__(self, valobj: SBValue, _dict, show_values: bool = True):
501+
def __init__(self, valobj: SBValue, _dict: LLDBOpaque, show_values: bool = True):
493502
self.valobj = valobj
494503
self.show_values = show_values
495504
self.update()
@@ -578,7 +587,7 @@ def has_children(self) -> bool:
578587
class StdHashMapSyntheticProvider:
579588
"""Pretty-printer for hashbrown's HashMap"""
580589

581-
def __init__(self, valobj: SBValue, _dict, show_values: bool = True):
590+
def __init__(self, valobj: SBValue, _dict: LLDBOpaque, show_values: bool = True):
582591
self.valobj = valobj
583592
self.show_values = show_values
584593
self.update()
@@ -662,7 +671,7 @@ def has_children(self) -> bool:
662671
return True
663672

664673

665-
def StdRcSummaryProvider(valobj: SBValue, _dict) -> str:
674+
def StdRcSummaryProvider(valobj: SBValue, _dict: LLDBOpaque) -> str:
666675
strong = valobj.GetChildMemberWithName("strong").GetValueAsUnsigned()
667676
weak = valobj.GetChildMemberWithName("weak").GetValueAsUnsigned()
668677
return "strong={}, weak={}".format(strong, weak)
@@ -684,7 +693,7 @@ class StdRcSyntheticProvider:
684693
struct AtomicUsize { v: UnsafeCell<usize> }
685694
"""
686695

687-
def __init__(self, valobj: SBValue, _dict, is_atomic: bool = False):
696+
def __init__(self, valobj: SBValue, _dict: LLDBOpaque, is_atomic: bool = False):
688697
self.valobj = valobj
689698

690699
self.ptr = unwrap_unique_or_non_null(self.valobj.GetChildMemberWithName("ptr"))
@@ -740,7 +749,7 @@ def has_children(self) -> bool:
740749
class StdCellSyntheticProvider:
741750
"""Pretty-printer for std::cell::Cell"""
742751

743-
def __init__(self, valobj: SBValue, _dict):
752+
def __init__(self, valobj: SBValue, _dict: LLDBOpaque):
744753
self.valobj = valobj
745754
self.value = valobj.GetChildMemberWithName("value").GetChildAtIndex(0)
746755

@@ -764,7 +773,7 @@ def has_children(self) -> bool:
764773
return True
765774

766775

767-
def StdRefSummaryProvider(valobj: SBValue, _dict) -> str:
776+
def StdRefSummaryProvider(valobj: SBValue, _dict: LLDBOpaque) -> str:
768777
borrow = valobj.GetChildMemberWithName("borrow").GetValueAsSigned()
769778
return (
770779
"borrow={}".format(borrow) if borrow >= 0 else "borrow_mut={}".format(-borrow)
@@ -774,7 +783,7 @@ def StdRefSummaryProvider(valobj: SBValue, _dict) -> str:
774783
class StdRefSyntheticProvider:
775784
"""Pretty-printer for std::cell::Ref, std::cell::RefMut, and std::cell::RefCell"""
776785

777-
def __init__(self, valobj: SBValue, _dict, is_cell: bool = False):
786+
def __init__(self, valobj: SBValue, _dict: LLDBOpaque, is_cell: bool = False):
778787
self.valobj = valobj
779788

780789
borrow = valobj.GetChildMemberWithName("borrow")
@@ -821,7 +830,7 @@ def has_children(self) -> bool:
821830
return True
822831

823832

824-
def StdNonZeroNumberSummaryProvider(valobj: SBValue, _dict) -> str:
833+
def StdNonZeroNumberSummaryProvider(valobj: SBValue, _dict: LLDBOpaque) -> str:
825834
inner = valobj.GetChildAtIndex(0)
826835
inner_inner = inner.GetChildAtIndex(0)
827836

0 commit comments

Comments
 (0)