mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-08-06 14:49:38 +08:00
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
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user