diff options
author | Tom Tromey <tromey@adacore.com> | 2025-07-29 07:48:21 -0600 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2025-08-11 07:39:10 -0600 |
commit | ddd2795c52228cbbdf11aa95e11b68647b10df88 (patch) | |
tree | 830a5899a4f514f4de280f65b56b41faecd968b0 /gdb/python | |
parent | 3c64cee8151d925ac3c438026074a2a1491e275f (diff) | |
download | binutils-ddd2795c52228cbbdf11aa95e11b68647b10df88.zip binutils-ddd2795c52228cbbdf11aa95e11b68647b10df88.tar.gz binutils-ddd2795c52228cbbdf11aa95e11b68647b10df88.tar.bz2 |
Do not allow DAP clients to dereference "void *"
While investigating a different bug, I noticed that the DAP code would
report a "void *"-typed register as having children -- however,
requesting the children of this register would fail.
The issue here is that a plain "void *" can't be dereferenced. This
patch changes the default visualizer to treat a "void *" as a scalar.
This adds a new test; but also arranges to examine all the returned
registers -- this was the first thing I attempted and it seemed
reasonable to have a test that double-checks that all the registers
really can be dereferenced as appropriate.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33228
Diffstat (limited to 'gdb/python')
-rw-r--r-- | gdb/python/lib/gdb/printing.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/gdb/python/lib/gdb/printing.py b/gdb/python/lib/gdb/printing.py index cba27d2..cda033f 100644 --- a/gdb/python/lib/gdb/printing.py +++ b/gdb/python/lib/gdb/printing.py @@ -415,11 +415,17 @@ def make_visualizer(value): result = NoOpArrayPrinter(ty, value) elif ty.code in (gdb.TYPE_CODE_STRUCT, gdb.TYPE_CODE_UNION): result = NoOpStructPrinter(ty, value) - elif ty.code in ( - gdb.TYPE_CODE_PTR, - gdb.TYPE_CODE_REF, - gdb.TYPE_CODE_RVALUE_REF, + elif ( + ty.code + in ( + gdb.TYPE_CODE_PTR, + gdb.TYPE_CODE_REF, + gdb.TYPE_CODE_RVALUE_REF, + ) + and ty.target().code != gdb.TYPE_CODE_VOID ): + # Note we avoid "void *" here because those pointers can't + # be dereferenced without a cast. result = NoOpPointerReferencePrinter(value) else: result = NoOpScalarPrinter(value) |