11from __future__ import annotations
22import sys
3- from typing import Generator , List , TYPE_CHECKING , Optional
3+ from typing import Generator , Dict , List , TYPE_CHECKING , Optional
44from enum import Flag , auto
55
66from lldb import (
99 eBasicTypeLong ,
1010 eBasicTypeUnsignedLong ,
1111 eBasicTypeUnsignedChar ,
12+ eBasicTypeUnsignedShort ,
13+ eBasicTypeUnsignedLongLong ,
14+ eBasicTypeSignedChar ,
15+ eBasicTypeShort ,
16+ eBasicTypeLongLong ,
17+ eBasicTypeFloat ,
18+ eBasicTypeDouble ,
19+ eBasicTypeFloat128 ,
20+ eBasicTypeHalf ,
21+ eBasicTypeChar32 ,
1222 eFormatChar ,
1323 eTypeIsInteger ,
1424)
@@ -198,6 +208,22 @@ def get_template_args(type_name: str) -> Generator[str, None, None]:
198208
199209MSVC_PTR_PREFIX : List [str ] = ["ref$<" , "ref_mut$<" , "ptr_const$<" , "ptr_mut$<" ]
200210
211+ PRIMITIVE_TYPES : Dict [str , int ] = {
212+ "u8" : eBasicTypeUnsignedChar ,
213+ "u16" : eBasicTypeUnsignedShort ,
214+ "u32" : eBasicTypeUnsignedLong ,
215+ "u64" : eBasicTypeUnsignedLongLong ,
216+ "i8" : eBasicTypeSignedChar ,
217+ "i16" : eBasicTypeShort ,
218+ "i32" : eBasicTypeLong ,
219+ "i64" : eBasicTypeLongLong ,
220+ "f16" : eBasicTypeHalf ,
221+ "f32" : eBasicTypeFloat ,
222+ "f64" : eBasicTypeDouble ,
223+ "f128" : eBasicTypeFloat128 ,
224+ "char" : eBasicTypeChar32 ,
225+ }
226+
201227
202228def resolve_msvc_template_arg (arg_name : str , target : SBTarget ) -> SBType :
203229 """
@@ -214,6 +240,17 @@ def resolve_msvc_template_arg(arg_name: str, target: SBTarget) -> SBType:
214240 current version of LLDB, so instead the types are generated via `base_type.GetPointerType()` and
215241 `base_type.GetArrayType()`, which bypass the PDB file and ask clang directly for the type node.
216242 """
243+
244+ # As of LLDB 22, finding primitives based on `FindFirstType` with their rust name no longer
245+ # works. Instead, we can look them up by their `eBasicType` equivalent. For usize and isize,
246+ # we convert them to their bit-sized counterpart before the lookup
247+ if arg_name == "isize" or arg_name == "usize" :
248+ equivalent = f"{ arg_name [0 ]} { target .GetAddressByteSize () * 8 } "
249+ return target .GetBasicType (PRIMITIVE_TYPES [equivalent ])
250+
251+ if (basic_type := PRIMITIVE_TYPES .get (arg_name )) is not None :
252+ return target .GetBasicType (basic_type )
253+
217254 result = target .FindFirstType (arg_name )
218255
219256 if result .IsValid ():
0 commit comments