public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fix printing destructors with void in parameters for clang programs
@ 2022-09-23 15:50 Bruno Larsen
  2022-09-23 23:00 ` Tom de Vries
  0 siblings, 1 reply; 4+ messages in thread
From: Bruno Larsen @ 2022-09-23 15:50 UTC (permalink / raw)
  To: gdb-patches

When GDB prints the methods of a C++ class, it will always skip the first
parameter, assuming it to be a 'this' pointer. However, when deciding if
it should print "void" for the parameters, it disregards the fact that
the first parameter was skipped, so if the method  only had that
parameter, for instance how clang compiles destructors, we'd see
~foo(void) instead of ~foo().

Fix this behavior by explicitly testing if there were 0 arguments.
---

There is another possibility for a fix, which is to stop ignoring the
first parameter, but there is a comment at that part of the code that
says "some compilers may not support artificial parameters".

I'm not sure how true that still is, and I would certainly like a
solution like that more, since (as keiths points out in here:
https://sourceware.org/bugzilla/show_bug.cgi?id=8218) there is no actual
rule saying that compilers must use an artificial 'this' as the first
parameter.  If anyone knows, please share with the class :)

---
 gdb/c-typeprint.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c
index 3a611cdac5d..8e05bdc81fe 100644
--- a/gdb/c-typeprint.c
+++ b/gdb/c-typeprint.c
@@ -300,7 +300,7 @@ cp_type_print_method_args (struct type *mtype, const char *prefix,
     }
   else if (varargs)
     gdb_printf (stream, "...");
-  else if (language == language_cplus)
+  else if (language == language_cplus && nargs == 0)
     gdb_printf (stream, "void");
 
   gdb_printf (stream, ")");
-- 
2.37.3


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

end of thread, other threads:[~2022-09-27 10:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-23 15:50 [PATCH] Fix printing destructors with void in parameters for clang programs Bruno Larsen
2022-09-23 23:00 ` Tom de Vries
2022-09-26  8:29   ` Bruno Larsen
2022-09-27 10:51     ` Tom de Vries

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).