@@ -131,7 +131,18 @@ def has_children(self) -> bool:
131
131
return False
132
132
133
133
134
- def get_template_args (type_name : str ) -> List [str ]:
134
+ def get_template_args (type_name : str ) -> list [str ]:
135
+ """
136
+ Takes a type name `T<A, tuple$<B, C>, D>` and returns a list of its generic args
137
+ `["A", "tuple$<B, C>", "D"]`.
138
+
139
+ String-based replacement for LLDB's `SBType.template_args`, as LLDB is currently unable to
140
+ populate this field for targets with PDB debug info. Also useful for manually altering the type
141
+ name of generics (e.g. `Vec<ref$<str$>` -> `Vec<&str>`).
142
+
143
+ Each element of the returned list can be looked up for its `SBType` value via
144
+ `SBTarget.FindFirstType()`
145
+ """
135
146
params = []
136
147
level = 0
137
148
start = 0
@@ -801,17 +812,7 @@ def update(self):
801
812
self .element_type = self .valobj .GetType ().GetTemplateArgumentType (0 )
802
813
803
814
if not self .element_type .IsValid ():
804
- # annoyingly, vec's constituent type isn't guaranteed to be contained anywhere useful.
805
- # Some functions have it, but those functions only exist in binary when they're used.
806
- # that means it's time for string-based garbage.
807
-
808
- # acquire the first generic parameter via its type name
809
- _ , _ , end = self .valobj .GetTypeName ().partition ("<" )
810
- element_name , _ , _ = end .partition ("," )
811
-
812
- # this works even for built-in rust types like `u32` because internally it's just a
813
- # `typedef` i really REALLY wish there was a better way to do this, but at the moment
814
- # LLDB flat out ignores template parameters due to piggybacking off of TypeSystemClang.
815
+ element_name = get_template_args (self .valobj .GetTypeName ())[0 ]
815
816
self .element_type = self .valobj .target .FindFirstType (element_name )
816
817
817
818
self .element_type_size = self .element_type .GetByteSize ()
0 commit comments