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+ eBasicTypeHalf ,
20+ eBasicTypeChar32 ,
1221 eFormatChar ,
1322 eTypeIsInteger ,
1423)
@@ -67,6 +76,9 @@ class LLDBFeature(Flag):
6776 """Added in LLDB 18. Adds functions to `SBType` the inspection of a struct's static fields."""
6877 TypeRecognizers = auto ()
6978 """Added in LLDB 19. Callback-based type matching for synthetic/summary providers."""
79+ Float128 = auto ()
80+ """Added in LLDB 22.1. Adds builtin support for Float 128's, including an `eBasicTypeFloat128`,
81+ a formatter, and handlers in `TypeSystemClang`"""
7082
7183
7284FEATURE_FLAGS : LLDBFeature = LLDBFeature (0 )
@@ -198,6 +210,21 @@ def get_template_args(type_name: str) -> Generator[str, None, None]:
198210
199211MSVC_PTR_PREFIX : List [str ] = ["ref$<" , "ref_mut$<" , "ptr_const$<" , "ptr_mut$<" ]
200212
213+ PRIMITIVE_TYPES : Dict [str , int ] = {
214+ "u8" : eBasicTypeUnsignedChar ,
215+ "u16" : eBasicTypeUnsignedShort ,
216+ "u32" : eBasicTypeUnsignedLong ,
217+ "u64" : eBasicTypeUnsignedLongLong ,
218+ "i8" : eBasicTypeSignedChar ,
219+ "i16" : eBasicTypeShort ,
220+ "i32" : eBasicTypeLong ,
221+ "i64" : eBasicTypeLongLong ,
222+ "f16" : eBasicTypeHalf ,
223+ "f32" : eBasicTypeFloat ,
224+ "f64" : eBasicTypeDouble ,
225+ "char" : eBasicTypeChar32 ,
226+ }
227+
201228
202229def resolve_msvc_template_arg (arg_name : str , target : SBTarget ) -> SBType :
203230 """
@@ -214,6 +241,22 @@ def resolve_msvc_template_arg(arg_name: str, target: SBTarget) -> SBType:
214241 current version of LLDB, so instead the types are generated via `base_type.GetPointerType()` and
215242 `base_type.GetArrayType()`, which bypass the PDB file and ask clang directly for the type node.
216243 """
244+
245+ # As of LLDB 22, finding primitives based on `FindFirstType` with their rust name no longer
246+ # works. Instead, we can look them up by their `eBasicType` equivalent. For usize and isize,
247+ # we convert them to their bit-sized counterpart before the lookup
248+ if arg_name == "isize" or arg_name == "usize" :
249+ equivalent = f"{ arg_name [0 ]} { target .GetAddressByteSize () * 8 } "
250+ return target .GetBasicType (PRIMITIVE_TYPES [equivalent ])
251+
252+ if (basic_type := PRIMITIVE_TYPES .get (arg_name )) is not None :
253+ return target .GetBasicType (basic_type )
254+
255+ if arg_name == "f128" and LLDBFeature .Float128 in FEATURE_FLAGS :
256+ from lldb import eBasicTypeFloat128
257+
258+ return target .GetBasicType (eBasicTypeFloat128 )
259+
217260 result = target .FindFirstType (arg_name )
218261
219262 if result .IsValid ():
0 commit comments