|
6 | 6 | from detail.decode_ieee_type import decode_decimal64 |
7 | 7 | from detail.decode_ieee_type import decode_decimal128 |
8 | 8 | from detail.decode_fast_type import decode_decimal_fast32 |
| 9 | +from detail.decode_fast_type import decode_decimal_fast64 |
| 10 | + |
9 | 11 | import lldb |
10 | 12 |
|
11 | 13 | def decimal32_summary(valobj, internal_dict): |
@@ -69,12 +71,29 @@ def decimal_fast32_summary(valobj, internal_dict): |
69 | 71 | except Exception as e: |
70 | 72 | return f"<invalid decimal_fast32_t: {e}>" |
71 | 73 |
|
| 74 | +def decimal_fast64_summary(valobj, internal_dict): |
| 75 | + """ |
| 76 | + Custom summary for decimal_fast32_t type |
| 77 | + Displays in scientific notation |
| 78 | + """ |
| 79 | + |
| 80 | + try: |
| 81 | + val = valobj.GetNonSyntheticValue() |
| 82 | + significand = val.GetChildMemberWithName("significand_").GetValueAsUnsigned() |
| 83 | + exp = val.GetChildMemberWithName("exponent_").GetValueAsUnsigned() |
| 84 | + sign = val.GetChildMemberWithName("sign_").GetValueAsUnsigned() |
| 85 | + return decode_decimal_fast64(significand, exp, sign) |
| 86 | + |
| 87 | + except Exception as e: |
| 88 | + return f"<invalid decimal_fast64_t: {e}>" |
| 89 | + |
72 | 90 | def __lldb_init_module(debugger, internal_dict): |
73 | 91 | decimal32_pattern = r"^(const )?(boost::decimal::decimal32_t|(\w+::)*decimal32_t)( &| \*)?$" |
74 | 92 | decimal64_pattern = r"^(const )?(boost::decimal::decimal64_t|(\w+::)*decimal64_t)( &| \*)?$" |
75 | 93 | decimal128_pattern = r"^(const )?(boost::decimal::decimal128_t|(\w+::)*decimal128_t)( &| \*)?$" |
76 | 94 |
|
77 | 95 | decimal_fast32_pattern = r"^(const )?(boost::decimal::decimal_fast32_t|(\w+::)*decimal_fast32_t)( &| \*)?$" |
| 96 | + decimal_fast64_pattern = r"^(const )?(boost::decimal::decimal_fast64_t|(\w+::)*decimal_fast64_t)( &| \*)?$" |
78 | 97 |
|
79 | 98 | debugger.HandleCommand( |
80 | 99 | f'type summary add -x "{decimal32_pattern}" -e -F decimal_printer.decimal32_summary' |
@@ -112,6 +131,15 @@ def __lldb_init_module(debugger, internal_dict): |
112 | 131 |
|
113 | 132 | print("decimal_fast32_t printer loaded successfully") |
114 | 133 |
|
| 134 | + debugger.HandleCommand( |
| 135 | + f'type summary add -x "{decimal_fast64_pattern}" -e -F decimal_printer.decimal_fast64_summary' |
| 136 | + ) |
| 137 | + debugger.HandleCommand( |
| 138 | + f'type synthetic add -x "{decimal_fast64_pattern}" -l decimal_printer.DecimalFastSyntheticProvider' |
| 139 | + ) |
| 140 | + |
| 141 | + print("decimal_fast64_t printer loaded successfully") |
| 142 | + |
115 | 143 | class DecimalSyntheticProvider: |
116 | 144 | def __init__(self, valobj, internal_dict): |
117 | 145 | self.valobj = valobj |
|
0 commit comments