From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11962 invoked by alias); 3 Oct 2008 21:38:52 -0000 Received: (qmail 11953 invoked by uid 22791); 3 Oct 2008 21:38:51 -0000 X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.33.17) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 03 Oct 2008 21:38:14 +0000 Received: from spaceape23.eur.corp.google.com (spaceape23.eur.corp.google.com [172.28.16.75]) by smtp-out.google.com with ESMTP id m93Lc2Ee001715 for ; Fri, 3 Oct 2008 22:38:02 +0100 Received: from localhost (elbrus.corp.google.com [172.18.116.17]) by spaceape23.eur.corp.google.com with ESMTP id m93LbxZa017159; Fri, 3 Oct 2008 14:37:59 -0700 Received: by localhost (Postfix, from userid 74925) id 8E7643A6AE9; Fri, 3 Oct 2008 14:37:58 -0700 (PDT) To: gdb-patches@sourceware.org Cc: dje@google.com Subject: [patch] Additional fix for gdb/2384. Message-Id: <20081003213758.8E7643A6AE9@localhost> Date: Fri, 03 Oct 2008 21:38:00 -0000 From: ppluzhnikov@google.com (Paul Pluzhnikov) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-10/txt/msg00098.txt.bz2 Greetings, This is rather on the obvious side. I've discovered that Doug Evans' fix for gdb/2384 was incomplete. Attached modified testsuite/gdb.cp/gdb2384* demonstrates the problem, and gdbtypes.c change fixes it. OK? -- Paul Pluzhnikov 2008-10-03 Paul Pluzhnikov PR gdb/2384: * gdbtypes.c (get_vptr_fieldno): baseclass and basetype may have different lifetimes. 2008-10-03 Paul Pluzhnikov PR gdb/2384: * gdb.cp/gdb2384.exp: Extended to test more cases. * gdb.cp/gdb2384.cc: Likewise. * gdb.cp/gdb2384-base.h: Likewise. * gdb.cp/gdb2384-base.cc: Likewise. Index: gdbtypes.c =================================================================== RCS file: /cvs/src/src/gdb/gdbtypes.c,v retrieving revision 1.151 diff -u -p -u -r1.151 gdbtypes.c --- gdbtypes.c 2 Oct 2008 22:06:07 -0000 1.151 +++ gdbtypes.c 3 Oct 2008 21:24:00 -0000 @@ -1324,7 +1324,7 @@ get_vptr_fieldno (struct type *type, str { /* If the type comes from a different objfile we can't cache it, it may have a different lifetime. PR 2384 */ - if (TYPE_OBJFILE (type) == TYPE_OBJFILE (baseclass)) + if (TYPE_OBJFILE (type) == TYPE_OBJFILE (basetype)) { TYPE_VPTR_FIELDNO (type) = fieldno; TYPE_VPTR_BASETYPE (type) = basetype; Index: testsuite/gdb.cp/gdb2384-base.cc =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/gdb2384-base.cc,v retrieving revision 1.2 diff -u -p -u -r1.2 gdb2384-base.cc --- testsuite/gdb.cp/gdb2384-base.cc 3 Feb 2008 22:17:05 -0000 1.2 +++ testsuite/gdb.cp/gdb2384-base.cc 3 Oct 2008 21:24:00 -0000 @@ -28,3 +28,8 @@ base::meth () { return x; } + +derived::derived (int _x) + : base (_x) +{ +} Index: testsuite/gdb.cp/gdb2384-base.h =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/gdb2384-base.h,v retrieving revision 1.2 diff -u -p -u -r1.2 gdb2384-base.h --- testsuite/gdb.cp/gdb2384-base.h 3 Feb 2008 22:17:05 -0000 1.2 +++ testsuite/gdb.cp/gdb2384-base.h 3 Oct 2008 21:24:00 -0000 @@ -23,3 +23,9 @@ class base int x; virtual int meth (); }; + +class derived : public base +{ + public: + derived (int _x); +}; Index: testsuite/gdb.cp/gdb2384.cc =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/gdb2384.cc,v retrieving revision 1.2 diff -u -p -u -r1.2 gdb2384.cc --- testsuite/gdb.cp/gdb2384.cc 3 Feb 2008 22:17:05 -0000 1.2 +++ testsuite/gdb.cp/gdb2384.cc 3 Oct 2008 21:24:00 -0000 @@ -18,23 +18,36 @@ #include "gdb2384-base.h" -class derived : public base +class derived1 : public base { public: - derived (int); + derived1 (int); }; -derived::derived (int _x) +derived1::derived1 (int _x) : base (_x) { } +class derived2 : public derived +{ + public: + derived2 (int); +}; + +derived2::derived2 (int _x) + : derived (_x) +{ +} + int g; int main () { - derived d (42); - g = d.meth (); // set breakpoint here + derived1 d1 (42); + derived2 d2 (24); + g = d1.meth (); // set breakpoint here + g = d2.meth (); // set breakpoint here (second) return 0; } Index: testsuite/gdb.cp/gdb2384.exp =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.cp/gdb2384.exp,v retrieving revision 1.1 diff -u -p -u -r1.1 gdb2384.exp --- testsuite/gdb.cp/gdb2384.exp 3 Feb 2008 22:13:30 -0000 1.1 +++ testsuite/gdb.cp/gdb2384.exp 3 Oct 2008 21:24:00 -0000 @@ -55,46 +55,41 @@ gdb_reinitialize_dir $srcdir/$subdir gdb_load ${binfile} gdb_load_shlibs ${sofile} -set bp_location [gdb_get_line_number "set breakpoint here"] -# Set a breakpoint with multiple locations. - -gdb_test "break $srcfile:$bp_location" \ - "Breakpoint.*at.* file .*$srcfile, line.*" \ - "set breakpoint" - -gdb_run_cmd -gdb_expect { - -re "Breakpoint \[0-9\]+,.*main \\(.*\\).*$gdb_prompt $" { - pass "run to breakpoint" - } - -re "$gdb_prompt $" { - fail "run to breakpoint" - } - timeout { - fail "run to breakpoint (timeout)" - } +if ![runto_main] then { + perror "couldn't run to breakpoint" + return -1 } -gdb_test "print d.meth ()" \ +gdb_breakpoint [gdb_get_line_number "set breakpoint here"] +gdb_continue_to_breakpoint "set breakpoint here" + +gdb_test "print d1.meth ()" \ ".*42.*" \ - "print d.meth ()" + "print d1.meth ()" # Now try again. gdb's without the fix will hopefully segv here -gdb_run_cmd -gdb_expect { - -re "Breakpoint \[0-9\]+,.*main \\(.*\\).*$gdb_prompt $" { - pass "run to breakpoint #2" - } - -re "$gdb_prompt $" { - fail "run to breakpoint #2" - } - timeout { - fail "run to breakpoint #2 (timeout)" - } -} - -gdb_test "print d.meth ()" \ +runto_main +gdb_breakpoint [gdb_get_line_number "set breakpoint here"] +gdb_continue_to_breakpoint "set breakpoint here" +gdb_test "print d1.meth ()" \ ".*42.*" \ "gdb2384" + +# second case + +runto_main +gdb_breakpoint [gdb_get_line_number "set breakpoint here (second)"] +gdb_continue_to_breakpoint "set breakpoint here (second)" +gdb_test "print d2.meth ()" \ + ".*24.*" \ + "print d2.meth()" + +runto_main +gdb_breakpoint [gdb_get_line_number "set breakpoint here (second)"] +gdb_continue_to_breakpoint "set breakpoint here (second)" +gdb_test "print d2.meth ()" \ + ".*24.*" \ + "gdb2384 (second)" +