mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-08-06 06:45:56 +08:00
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.
This commit is contained in:
@ -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);
|
||||
|
@ -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}"
|
||||
|
@ -879,7 +879,7 @@ generic_value_print_memberptr
|
||||
cp_print_class_member (valaddr, type, stream, "&");
|
||||
}
|
||||
else
|
||||
generic_value_print (val, stream, recurse, options, decorations);
|
||||
value_print_scalar_formatted (val, options, 0, stream);
|
||||
}
|
||||
|
||||
/* See valprint.h. */
|
||||
|
Reference in New Issue
Block a user