From: Hannes Domani Date: Thu, 8 Oct 2020 15:38:32 +0000 (+0200) Subject: Handle void results as unformatted prints X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3d87245cc1a4310264d9cb0e4566517d3455a7f5;p=binutils-gdb.git Handle void results as unformatted prints When printing void results without any format letter, they are output as expected: (gdb) p $abcd $1 = void (gdb) p (void)10 $2 = void But if any format letter (besides s) is used, it always outputs zero: (gdb) p/x $abcd $3 = 0x0 (gdb) p/x (void)10 $4 = 0x0 So this adds void results to the types handled like unformatted prints. gdb/ChangeLog: 2020-10-09 Hannes Domani PR exp/26714 * printcmd.c (print_formatted): Handle void results as unformatted prints. gdb/testsuite/ChangeLog: 2020-10-09 Hannes Domani PR exp/26714 * gdb.base/printcmds.exp: Add tests for void results. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 28fa696e3d5..5df537c2792 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2020-10-09 Hannes Domani + + PR exp/26714 + * printcmd.c (print_formatted): Handle void results as + unformatted prints. + 2020-10-09 Andrew Burgess * arch/aarch32.c (aarch32_create_target_description): Release the diff --git a/gdb/printcmd.c b/gdb/printcmd.c index d3b1075ed8f..f9b42cfda71 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -311,6 +311,7 @@ print_formatted (struct value *val, int size, } if (options->format == 0 || options->format == 's' + || type->code () == TYPE_CODE_VOID || type->code () == TYPE_CODE_REF || type->code () == TYPE_CODE_ARRAY || type->code () == TYPE_CODE_STRING diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 3d88199c63c..e1b623b7fec 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2020-10-09 Hannes Domani + + PR exp/26714 + * gdb.base/printcmds.exp: Add tests for void results. + 2020-10-09 Jan Vrany * gdb.mi/mi-cmd-param-changed.exp: Check that notification is diff --git a/gdb/testsuite/gdb.base/printcmds.exp b/gdb/testsuite/gdb.base/printcmds.exp index 0a96b228b89..08a09613031 100644 --- a/gdb/testsuite/gdb.base/printcmds.exp +++ b/gdb/testsuite/gdb.base/printcmds.exp @@ -1005,6 +1005,11 @@ gdb_test "print sizeof (\$cvar)" " = 4" # Similarly, printf of a string convenience var should work without a target. test_printf_convenience_var "no target" +# Test void results. +gdb_test "p (void)10" " = void" +gdb_test "p/x (void)10" " = void" +gdb_test "p \$abcd" " = void" + # GDB used to complete the explicit location options even when # printing expressions. gdb_test_no_output "complete p -function"