Skip to content

Commit af6be4f

Browse files
authored
GDB script: minor improvements (#24965)
1 parent 49e66e8 commit af6be4f

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

tools/debug/nim-gdb.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@
44
import sys
55
import traceback
66

7+
# Add compatibility for older GDB versions
8+
if not hasattr(gdb, 'SYMBOL_FUNCTION_DOMAIN'):
9+
gdb.SYMBOL_FUNCTION_DOMAIN = 0 # This is the value used in newer GDB versions
10+
11+
# Configure demangling for Itanium C++ ABI (which Nim uses)
12+
try:
13+
gdb.execute("set demangle-style gnu-v3") # GNU v3 style handles Itanium mangling
14+
gdb.execute("set print asm-demangle on")
15+
gdb.execute("set print demangle on")
16+
except Exception as e:
17+
gdb.write(f"Warning: Could not configure demangling: {str(e)}\n", gdb.STDERR)
18+
719
# some feedback that the nim runtime support is loading, isn't a bad
820
# thing at all.
921
gdb.write("Loading Nim Runtime support.\n", gdb.STDERR)
@@ -70,12 +82,12 @@ class NimTypeRecognizer:
7082
type_map_static = {
7183
'NI': 'system.int', 'NI8': 'int8', 'NI16': 'int16', 'NI32': 'int32',
7284
'NI64': 'int64',
73-
85+
7486
'NU': 'uint', 'NU8': 'uint8','NU16': 'uint16', 'NU32': 'uint32',
7587
'NU64': 'uint64',
76-
88+
7789
'NF': 'float', 'NF32': 'float32', 'NF64': 'float64',
78-
90+
7991
'NIM_BOOL': 'bool',
8092

8193
'NIM_CHAR': 'char', 'NCSTRING': 'cstring', 'NimStringDesc': 'string', 'NimStringV2': 'string'
@@ -556,7 +568,7 @@ def children(self):
556568
except RuntimeError:
557569
inaccessible = True
558570
yield "data[{0}]".format(i), "inaccessible"
559-
571+
560572
################################################################################
561573

562574
class NimArrayPrinter:

0 commit comments

Comments
 (0)