From f70345db73f2253b20100f69bfdfccdb338f458a Mon Sep 17 00:00:00 2001 From: Araq Date: Fri, 23 May 2025 16:14:40 +0200 Subject: [PATCH] GDB script: minor improvements --- tools/debug/nim-gdb.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/tools/debug/nim-gdb.py b/tools/debug/nim-gdb.py index 59e6ee99ced7..2637481aeedb 100644 --- a/tools/debug/nim-gdb.py +++ b/tools/debug/nim-gdb.py @@ -4,6 +4,18 @@ import sys import traceback +# Add compatibility for older GDB versions +if not hasattr(gdb, 'SYMBOL_FUNCTION_DOMAIN'): + gdb.SYMBOL_FUNCTION_DOMAIN = 0 # This is the value used in newer GDB versions + +# Configure demangling for Itanium C++ ABI (which Nim uses) +try: + gdb.execute("set demangle-style gnu-v3") # GNU v3 style handles Itanium mangling + gdb.execute("set print asm-demangle on") + gdb.execute("set print demangle on") +except Exception as e: + gdb.write(f"Warning: Could not configure demangling: {str(e)}\n", gdb.STDERR) + # some feedback that the nim runtime support is loading, isn't a bad # thing at all. gdb.write("Loading Nim Runtime support.\n", gdb.STDERR) @@ -70,12 +82,12 @@ class NimTypeRecognizer: type_map_static = { 'NI': 'system.int', 'NI8': 'int8', 'NI16': 'int16', 'NI32': 'int32', 'NI64': 'int64', - + 'NU': 'uint', 'NU8': 'uint8','NU16': 'uint16', 'NU32': 'uint32', 'NU64': 'uint64', - + 'NF': 'float', 'NF32': 'float32', 'NF64': 'float64', - + 'NIM_BOOL': 'bool', 'NIM_CHAR': 'char', 'NCSTRING': 'cstring', 'NimStringDesc': 'string', 'NimStringV2': 'string' @@ -556,7 +568,7 @@ def children(self): except RuntimeError: inaccessible = True yield "data[{0}]".format(i), "inaccessible" - + ################################################################################ class NimArrayPrinter: