public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Handle void results as unformatted prints
       [not found] <20201008205608.51142-1-ssbssa.ref@yahoo.de>
@ 2020-10-08 20:56 ` Hannes Domani
  2020-10-09  3:40   ` Simon Marchi
  0 siblings, 1 reply; 3+ messages in thread
From: Hannes Domani @ 2020-10-08 20:56 UTC (permalink / raw)
  To: gdb-patches

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-08  Hannes Domani  <ssbssa@yahoo.de>

	PR exp/26714
	* printcmd.c (print_formatted): Handle void results as
	unformatted prints.

gdb/testsuite/ChangeLog:

2020-10-08  Hannes Domani  <ssbssa@yahoo.de>

	PR exp/26714
	* gdb.base/printcmds.exp: Add tests for void results.
---
 gdb/printcmd.c                       | 1 +
 gdb/testsuite/gdb.base/printcmds.exp | 4 ++++
 2 files changed, 5 insertions(+)

diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index 309d2cabff..23a95997be 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/gdb.base/printcmds.exp b/gdb/testsuite/gdb.base/printcmds.exp
index 0a96b228b8..2ba011964b 100644
--- a/gdb/testsuite/gdb.base/printcmds.exp
+++ b/gdb/testsuite/gdb.base/printcmds.exp
@@ -1005,6 +1005,10 @@ 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 used to complete the explicit location options even when
 # printing expressions.
 gdb_test_no_output "complete p -function"
-- 
2.27.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Handle void results as unformatted prints
  2020-10-08 20:56 ` [PATCH] Handle void results as unformatted prints Hannes Domani
@ 2020-10-09  3:40   ` Simon Marchi
  2020-10-09 11:54     ` Hannes Domani
  0 siblings, 1 reply; 3+ messages in thread
From: Simon Marchi @ 2020-10-09  3:40 UTC (permalink / raw)
  To: Hannes Domani, gdb-patches

On 2020-10-08 4:56 p.m., Hannes Domani via Gdb-patches wrote:
> 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

Thanks, this is, OK.  Although, for completeness in your test, can you
also add test to print a convenience variable that doesn't exist, as you
have shown above (the first "p $abcd")?

Simon

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Handle void results as unformatted prints
  2020-10-09  3:40   ` Simon Marchi
@ 2020-10-09 11:54     ` Hannes Domani
  0 siblings, 0 replies; 3+ messages in thread
From: Hannes Domani @ 2020-10-09 11:54 UTC (permalink / raw)
  To: gdb-patches, Simon Marchi

 Am Freitag, 9. Oktober 2020, 05:40:49 MESZ hat Simon Marchi <simark@simark.ca> Folgendes geschrieben:

> On 2020-10-08 4:56 p.m., Hannes Domani via Gdb-patches wrote:
>
> > 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
>
>
> Thanks, this is, OK.  Although, for completeness in your test, can you
> also add test to print a convenience variable that doesn't exist, as you
> have shown above (the first "p $abcd")?

Pushed with this change, thanks.


Hannes

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-10-09 11:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20201008205608.51142-1-ssbssa.ref@yahoo.de>
2020-10-08 20:56 ` [PATCH] Handle void results as unformatted prints Hannes Domani
2020-10-09  3:40   ` Simon Marchi
2020-10-09 11:54     ` Hannes Domani

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).