aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.cp
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2022-10-18 11:32:52 -0600
committerTom Tromey <tromey@adacore.com>2022-10-31 08:49:06 -0600
commit86430497337968e6163aef370c6312e7b5ed6504 (patch)
treecc8e805321dc54a833dcc8fea91acf661a444373 /gdb/testsuite/gdb.cp
parent1bf074fb6b5474f94e315d7047c0500535f0a2ef (diff)
downloadgdb-86430497337968e6163aef370c6312e7b5ed6504.zip
gdb-86430497337968e6163aef370c6312e7b5ed6504.tar.gz
gdb-86430497337968e6163aef370c6312e7b5ed6504.tar.bz2
Fix regression in pointer-to-member printing
PR c++/29243 points out that "info func" on a certain C++ executable will cause an infinite loop in gdb. I tracked this down to a bug introduced by commit 6b5a7bc76 ("Handle member pointers directly in generic_value_print"). Before this commit, the C++ code to print a member pointer would wind up calling value_print_scalar_formatted; but afterward it simply calls generic_value_print and gets into a loop. This patch restores the previous behavior and adds a regression test.
Diffstat (limited to 'gdb/testsuite/gdb.cp')
-rw-r--r--gdb/testsuite/gdb.cp/member-ptr.cc8
-rw-r--r--gdb/testsuite/gdb.cp/member-ptr.exp4
2 files changed, 12 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.cp/member-ptr.cc b/gdb/testsuite/gdb.cp/member-ptr.cc
index 22ffcc5..a563d2e 100644
--- a/gdb/testsuite/gdb.cp/member-ptr.cc
+++ b/gdb/testsuite/gdb.cp/member-ptr.cc
@@ -142,6 +142,11 @@ int Diamond::vget_base ()
return this->Left::x + 2000;
}
+struct Container
+{
+ PMI member;
+};
+
int
func (int x)
{
@@ -205,6 +210,9 @@ int main ()
null_pmi = NULL;
null_pmf = NULL;
+ Container contain;
+ contain.member = &A::j;
+
pmi = NULL; /* Breakpoint 1 here. */
(diamond.*diamond_pfunc_ptr) (20);
diff --git a/gdb/testsuite/gdb.cp/member-ptr.exp b/gdb/testsuite/gdb.cp/member-ptr.exp
index 110497b..5b91bcb 100644
--- a/gdb/testsuite/gdb.cp/member-ptr.exp
+++ b/gdb/testsuite/gdb.cp/member-ptr.exp
@@ -628,3 +628,7 @@ gdb_test "print null_pmi = 0" "$vhn = NULL"
gdb_test "print null_pmf" "$vhn = NULL"
gdb_test "print null_pmf = &A::foo" "$vhn = \\(int \\(A::\\*\\)\\(A \\*( const)?, int\\)\\) $hex <A::foo ?\\(int\\)>"
gdb_test "print null_pmf = 0" "$vhn = NULL"
+
+# Print with a format, bypassing the direct call to the scalar
+# printer. See PR c++/29243.
+gdb_test "print/x contain" " = {member = $hex}"