From ddd2795c52228cbbdf11aa95e11b68647b10df88 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Tue, 29 Jul 2025 07:48:21 -0600 Subject: 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 --- gdb/python/lib/gdb/printing.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'gdb/python') 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) -- cgit v1.1