Skip to content

GDB script: minor improvements #24965

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: devel
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions tools/debug/nim-gdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -556,7 +568,7 @@ def children(self):
except RuntimeError:
inaccessible = True
yield "data[{0}]".format(i), "inaccessible"

################################################################################

class NimArrayPrinter:
Expand Down
Loading