diff options
author | Tom Tromey <tromey@adacore.com> | 2023-09-05 09:13:14 -0600 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2023-09-19 13:28:42 -0600 |
commit | a56e5dce69bfad45ee6977a916ccea283e087e8b (patch) | |
tree | b148946dc952568db690c2ed14569d70efd8545c /gdb/python | |
parent | 76fc0f62138e0fa1ec1feeefed7e603d52e83af7 (diff) | |
download | binutils-a56e5dce69bfad45ee6977a916ccea283e087e8b.zip binutils-a56e5dce69bfad45ee6977a916ccea283e087e8b.tar.gz binutils-a56e5dce69bfad45ee6977a916ccea283e087e8b.tar.bz2 |
Handle pointers and references correctly in DAP
A user pointed out that the current DAP variable code does not let the
client deference a pointer. Oops!
Fixing this oversight is simple enough -- adding a new no-op
pretty-printer for pointers and references is quite simple.
However, doing this naive caused a regession in scopes.exp, which
expected there to be no children of a 'const char *' variable. This
problem was fixed by the preceding patches in the series, which ensure
that a C type of this kind is recognized as a string.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30821
Diffstat (limited to 'gdb/python')
-rw-r--r-- | gdb/python/lib/gdb/printing.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/gdb/python/lib/gdb/printing.py b/gdb/python/lib/gdb/printing.py index 1a761a6..223a699 100644 --- a/gdb/python/lib/gdb/printing.py +++ b/gdb/python/lib/gdb/printing.py @@ -280,6 +280,20 @@ class NoOpScalarPrinter: return self.value.format_string(raw=True) +class NoOpPointerReferencePrinter: + """A no-op pretty printer that wraps a pointer or reference.""" + + def __init__(self, value): + self.value = value + self.num_children = 1 + + def to_string(self): + return self.value.format_string(deref_refs=False) + + def children(self): + yield "value", self.value.referenced_value() + + class NoOpArrayPrinter: """A no-op pretty printer that wraps an array value.""" @@ -354,6 +368,8 @@ def make_visualizer(value): result = gdb.printing.NoOpArrayPrinter(ty, value) elif ty.code in (gdb.TYPE_CODE_STRUCT, gdb.TYPE_CODE_UNION): result = gdb.printing.NoOpStructPrinter(ty, value) + elif ty.code in (gdb.TYPE_CODE_PTR, gdb.TYPE_CODE_REF, gdb.TYPE_CODE_RVALUE_REF): + result = NoOpPointerReferencePrinter(value) else: result = gdb.printing.NoOpScalarPrinter(value) return result |