Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: ppluzhnikov@google.com (Paul Pluzhnikov)
To: gdb-patches@sourceware.org
Cc: dje@google.com
Subject: [patch] Additional fix for gdb/2384.
Date: Fri, 03 Oct 2008 21:38:00 -0000	[thread overview]
Message-ID: <20081003213758.8E7643A6AE9@localhost> (raw)

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  <ppluzhnikov@google.com>

	    PR gdb/2384:
	    * gdbtypes.c (get_vptr_fieldno): baseclass and basetype may have
	    different lifetimes.


2008-10-03  Paul Pluzhnikov  <ppluzhnikov@google.com>

	    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)"
+


             reply	other threads:[~2008-10-03 21:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-03 21:38 Paul Pluzhnikov [this message]
2008-10-03 21:53 ` Daniel Jacobowitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20081003213758.8E7643A6AE9@localhost \
    --to=ppluzhnikov@google.com \
    --cc=dje@google.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox