44
55from detail .decode_decimal32 import decode_decimal32
66from detail .decode_decimal64 import decode_decimal64
7+ from detail .decode_decimal128 import decode_decimal128
78import lldb
89
910def decimal32_summary (valobj , internal_dict ):
@@ -34,9 +35,27 @@ def decimal64_summary(valobj, internal_dict):
3435 except Exception as e :
3536 return f"<invalid decimal64_t: { e } >"
3637
38+ def decimal128_summary (valobj , internal_dict ):
39+ """
40+ Custom summary for decimal128_t type
41+ Displays in scientific notation with cohort preservation
42+ """
43+
44+ try :
45+ val = valobj .GetNonSyntheticValue ()
46+ bits = val .GetChildMemberWithName ("bits_" ).GetValueAsUnsigned ()
47+ bits_high = bits .GetChildMemberWithName ("high" ).GetValueAsUnsigned ()
48+ bits_low = bits .GetChildMemberWithName ("low" ).GetValueAsUnsigned ()
49+ combined_bits = (bits_high << 64 ) | bits_low
50+ return decode_decimal128 (combined_bits , bits_high )
51+
52+ except Exception as e :
53+ return f"<invalid decimal64_t: { e } >"
54+
3755def __lldb_init_module (debugger , internal_dict ):
3856 decimal32_pattern = r"^(const )?(boost::decimal::decimal32_t|(\w+::)*decimal32_t)( &| \*)?$"
3957 decimal64_pattern = r"^(const )?(boost::decimal::decimal64_t|(\w+::)*decimal64_t)( &| \*)?$"
58+ decimal128_pattern = r"^(const )?(boost::decimal::decimal128_t|(\w+::)*decimal128_t)( &| \*)?$"
4059
4160 debugger .HandleCommand (
4261 f'type summary add -x "{ decimal32_pattern } " -e -F decimal_printer.decimal32_summary'
@@ -56,6 +75,15 @@ def __lldb_init_module(debugger, internal_dict):
5675
5776 print ("decimal64_t printer loaded successfully" )
5877
78+ debugger .HandleCommand (
79+ f'type summary add -x "{ decimal128_pattern } " -e -F decimal_printer.decimal128_summary'
80+ )
81+ debugger .HandleCommand (
82+ f'type synthetic add -x "{ decimal128_pattern } " -l decimal_printer.DecimalSyntheticProvider'
83+ )
84+
85+ print ("decimal128_t printer loaded successfully" )
86+
5987class DecimalSyntheticProvider :
6088 def __init__ (self , valobj , internal_dict ):
6189 self .valobj = valobj
0 commit comments