Re: [RFC] fix testsuite/gdb.cp/printmethod

Daniel Jacobowitz
2005-12-07T23:08:12Z

On Tue, Dec 06, 2005 at 07:10:25PM +0100, Christophe LYON wrote:
> Hi all,
>
> As I explained in
> http://sources.redhat.com/ml/gdb/2005-11/msg00611.html, I think that the
> gdb.cp/printmethod test somewhat relies on G++ not generating code for
> the nonvirt() method.
>
> I propose the following fix.
>
> Christophe.
>
>
> 2005-12-06 Christophe Lyon <christophe.lyon@st.com>
> * gdb.cp/printmethod.cc (main): call virt() and nonvirt() to
> force code generation for these functions.
> * gdb.cp/printmethod.exp: expect &A::nonvirt() instead of error
> message.

I agree with your conclusions; this is fine.

I've checked it in, with some formatting/copyright tweaks, since I
needed it for the attached followup: the error message previously being
tested for was lousy, let's improve it.

--
Daniel Jacobowitz
CodeSourcery, LLC

2005-12-07 Daniel Jacobowitz <dan@codesourcery.com>

* valops.c (value_struct_elt): Clarify error message.

2005-12-07 Christophe Lyon <christophe.lyon@st.com>

* gdb.cp/printmethod.cc (main): Call virt and nonvirt, to force
code generation for these functions.
* gdb.cp/printmethod.exp: Expect "&A::nonvirt()" instead of an
error message.

Index: valops.c
===================================================================
RCS file: /cvs/src/src/gdb/valops.c,v
retrieving revision 1.161
diff -u -p -r1.161 valops.c
--- valops.c 27 May 2005 04:39:32 -0000 1.161
+++ valops.c 7 Dec 2005 22:49:13 -0000
@@ -1587,7 +1587,7 @@ value_struct_elt (struct value **argp, s
v = search_struct_method (name, argp, args, 0, static_memfuncp, t);

if (v == (struct value *) - 1)
- error (_("Cannot take address of a method"));
+ error (_("Cannot take address of method %s."), name);
else if (v == 0)
{
if (TYPE_NFN_FIELDS (t))
Index: testsuite/gdb.cp/printmethod.cc
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/printmethod.cc,v
retrieving revision 1.2
diff -u -p -r1.2 printmethod.cc
--- testsuite/gdb.cp/printmethod.cc 17 Jun 2004 18:30:18 -0000 1.2
+++ testsuite/gdb.cp/printmethod.cc 7 Dec 2005 23:06:43 -0000
@@ -1,6 +1,6 @@
/* This test script is part of GDB, the GNU debugger.

- Copyright 2002, 2004,
+ Copyright 2002, 2004, 2005
Free Software Foundation, Inc.

This program is free software; you can redistribute it and/or modify
@@ -29,6 +29,8 @@ public:
int main()
{
A *theA = new A;
+ theA->virt ();
+ theA->nonvirt ();

return 0; // breakpoint: constructs-done
}
Index: testsuite/gdb.cp/printmethod.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/printmethod.exp,v
retrieving revision 1.1
diff -u -p -r1.1 printmethod.exp
--- testsuite/gdb.cp/printmethod.exp 23 Aug 2003 03:55:59 -0000 1.1
+++ testsuite/gdb.cp/printmethod.exp 7 Dec 2005 23:06:43 -0000
@@ -1,4 +1,4 @@
-# Copyright 2002, 2003 Free Software Foundation, Inc.
+# Copyright 2002, 2003, 2005 Free Software Foundation, Inc.

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -63,7 +63,7 @@ gdb_continue_to_breakpoint "end of const
# The first of these is for PR gdb/653.

gdb_test "print theA->virt" "\\$\[0-9\]* = &A::virt\\((void|)\\)" "print virtual method."
-gdb_test "print theA->nonvirt" "Cannot take address of a method" "print nonvirtual method."
+gdb_test "print theA->nonvirt" "\\$\[0-9\]* = &A::nonvirt\\((void|)\\)" "print nonvirtual method."

gdb_exit
return 0