public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fix gdb.python/py-format-string.exp with Clang
@ 2020-10-14 15:59 Gary Benson
  2020-10-22 18:53 ` Tom Tromey
  0 siblings, 1 reply; 3+ messages in thread
From: Gary Benson @ 2020-10-14 15:59 UTC (permalink / raw)
  To: gdb-patches

Hi all,

GDB includes the virtual table pointer when formatting polymorphic
C++ objects for printing, but GCC and Clang name these differently:
GCC emits a DW_AT_name of "_vptr.Base" when describing the virtual
table pointer of a type derived from type "Base", whereas Clang
will emit "_vptr$Base" in this situation.  This patch fixes a
testcase which failed because of this.

Checked on Fedora 32 x86_64, with GCC and Clang.  Ok to commit?

Cheers,
Gary

---
gdb/testsuite/ChangeLog:

	* gdb.python/py-format-string.exp (test_deref_refs): Treat
	"_vptr$Base" as correct, in addition to "_vptr.Base".
	(test_mixed): Likewise.
---
 gdb/testsuite/ChangeLog                       | 6 ++++++
 gdb/testsuite/gdb.python/py-format-string.exp | 4 ++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/gdb/testsuite/gdb.python/py-format-string.exp b/gdb/testsuite/gdb.python/py-format-string.exp
index 792d60c..b7acc24 100644
--- a/gdb/testsuite/gdb.python/py-format-string.exp
+++ b/gdb/testsuite/gdb.python/py-format-string.exp
@@ -509,7 +509,7 @@ proc test_deref_refs {} {
   if { $current_lang == "c++" } {
     check_var_with_bool_opt "deref_refs" "a_point_t_ref"
     check_var_with_bool_opt "deref_refs" "a_base_ref" \
-      "${default_ref_regexp}: \\{_vptr\\.Base = ${default_pointer_regexp} <vtable for Deriv\\+16>, a = 42, static a_static_member = 2019\\}"
+	"${default_ref_regexp}: \\{_vptr\[.\$\]Base = ${default_pointer_regexp} <vtable for Deriv\\+16>, a = 42, static a_static_member = 2019\\}"
   }
 }
 
@@ -905,7 +905,7 @@ proc test_mixed {} {
 
     check_format_string "a_base_ref" \
       "deref_refs=True, static_members=False" \
-      "${default_ref_regexp}: \\{_vptr\\.Base = ${default_pointer_regexp} <vtable for Deriv\\+16>, a = 42\\}"
+      "${default_ref_regexp}: \\{_vptr\[.\$\]Base = ${default_pointer_regexp} <vtable for Deriv\\+16>, a = 42\\}"
   }
 }
 
-- 
1.8.3.1


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

* Re: [PATCH] Fix gdb.python/py-format-string.exp with Clang
  2020-10-14 15:59 [PATCH] Fix gdb.python/py-format-string.exp with Clang Gary Benson
@ 2020-10-22 18:53 ` Tom Tromey
  2020-10-27 17:04   ` Gary Benson
  0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2020-10-22 18:53 UTC (permalink / raw)
  To: Gary Benson via Gdb-patches

>>>>> "Gary" == Gary Benson via Gdb-patches <gdb-patches@sourceware.org> writes:

Gary> Hi all,
Gary> GDB includes the virtual table pointer when formatting polymorphic
Gary> C++ objects for printing, but GCC and Clang name these differently:
Gary> GCC emits a DW_AT_name of "_vptr.Base" when describing the virtual
Gary> table pointer of a type derived from type "Base", whereas Clang
Gary> will emit "_vptr$Base" in this situation.  This patch fixes a
Gary> testcase which failed because of this.

Gary> Checked on Fedora 32 x86_64, with GCC and Clang.  Ok to commit?

This is ok.  Thank you.

Tom

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

* Re: [PATCH] Fix gdb.python/py-format-string.exp with Clang
  2020-10-22 18:53 ` Tom Tromey
@ 2020-10-27 17:04   ` Gary Benson
  0 siblings, 0 replies; 3+ messages in thread
From: Gary Benson @ 2020-10-27 17:04 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Gary Benson via Gdb-patches

Tom Tromey wrote:
> >>>>> "Gary" == Gary Benson via Gdb-patches <gdb-patches@sourceware.org> writes:
> 
> Gary> GDB includes the virtual table pointer when formatting polymorphic
> Gary> C++ objects for printing, but GCC and Clang name these differently:
> Gary> GCC emits a DW_AT_name of "_vptr.Base" when describing the virtual
> Gary> table pointer of a type derived from type "Base", whereas Clang
> Gary> will emit "_vptr$Base" in this situation.  This patch fixes a
> Gary> testcase which failed because of this.
> 
> Gary> Checked on Fedora 32 x86_64, with GCC and Clang.  Ok to commit?
> 
> This is ok.  Thank you.

I've pushed this now, thanks for the review!

Cheers,
Gary

-- 
Gary Benson - he / him / his
Principal Software Engineer, Red Hat


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

end of thread, other threads:[~2020-10-27 17:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-14 15:59 [PATCH] Fix gdb.python/py-format-string.exp with Clang Gary Benson
2020-10-22 18:53 ` Tom Tromey
2020-10-27 17:04   ` Gary Benson

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