aboutsummaryrefslogtreecommitdiff
path: root/gdb/python
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2023-06-22 09:00:13 -0600
committerTom Tromey <tromey@adacore.com>2023-07-10 13:17:31 -0600
commitc38bda5104e0011b1255752bec63cb4ffd76449d (patch)
treed520059a2476bd5089d6e1e0ffbc06feacbe0ee7 /gdb/python
parent5b86f10883d37e46aeeafa2818e227737d068dff (diff)
downloadgdb-c38bda5104e0011b1255752bec63cb4ffd76449d.zip
gdb-c38bda5104e0011b1255752bec63cb4ffd76449d.tar.gz
gdb-c38bda5104e0011b1255752bec63cb4ffd76449d.tar.bz2
Handle typedefs in no-op pretty printers
The no-ops pretty-printers that were introduced for DAP have a classic gdb bug: they neglect to call check_typedef. This will cause some strange behavior; for example not showing the children of a variable whose type is a typedef of a structure type. This patch fixes the oversight.
Diffstat (limited to 'gdb/python')
-rw-r--r--gdb/python/lib/gdb/printing.py23
1 files changed, 12 insertions, 11 deletions
diff --git a/gdb/python/lib/gdb/printing.py b/gdb/python/lib/gdb/printing.py
index 353427d..a668bd0 100644
--- a/gdb/python/lib/gdb/printing.py
+++ b/gdb/python/lib/gdb/printing.py
@@ -282,9 +282,9 @@ class NoOpScalarPrinter:
class NoOpArrayPrinter:
"""A no-op pretty printer that wraps an array value."""
- def __init__(self, value):
+ def __init__(self, ty, value):
self.value = value
- (low, high) = self.value.type.range()
+ (low, high) = ty.range()
self.low = low
self.high = high
# This is a convenience to the DAP code and perhaps other
@@ -305,14 +305,15 @@ class NoOpArrayPrinter:
class NoOpStructPrinter:
"""A no-op pretty printer that wraps a struct or union value."""
- def __init__(self, value):
+ def __init__(self, ty, value):
+ self.ty = ty
self.value = value
def to_string(self):
return ""
def children(self):
- for field in self.value.type.fields():
+ for field in self.ty.fields():
if field.name is not None:
yield (field.name, self.value[field])
@@ -327,14 +328,14 @@ def make_visualizer(value):
if result is not None:
# Found a pretty-printer.
pass
- elif value.type.code == gdb.TYPE_CODE_ARRAY:
- result = gdb.printing.NoOpArrayPrinter(value)
- (low, high) = value.type.range()
- result.n_children = high - low + 1
- elif value.type.code in (gdb.TYPE_CODE_STRUCT, gdb.TYPE_CODE_UNION):
- result = gdb.printing.NoOpStructPrinter(value)
else:
- result = gdb.printing.NoOpScalarPrinter(value)
+ ty = value.type.strip_typedefs()
+ if ty.code == gdb.TYPE_CODE_ARRAY:
+ result = gdb.printing.NoOpArrayPrinter(ty, value)
+ elif ty.code in (gdb.TYPE_CODE_STRUCT, gdb.TYPE_CODE_UNION):
+ result = gdb.printing.NoOpStructPrinter(ty, value)
+ else:
+ result = gdb.printing.NoOpScalarPrinter(value)
return result