Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Chris Moller <cmoller@redhat.com>
To: tromey@redhat.com
Cc: gdb-patches@sourceware.org
Subject: Re: Patch for PR 9399
Date: Thu, 10 Dec 2009 18:33:00 -0000	[thread overview]
Message-ID: <4B213EDB.4020609@redhat.com> (raw)
In-Reply-To: <m3iqce4vet.fsf@fleche.redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1531 bytes --]

I fixed all the stuff you mention below, plus I added an FSF copyright 
notice to virtfunc2.cc--somehow, I forgot to do that yesterday--and 
fixed the fix to valops.c.  (The original version worked in archer--more 
or less by pure accident, I suspect--but failed in FSF.--I'd forgotten 
to make sure that type names were non-null before calling strcmp on 
them.  Fixed now.)

I've attached the new patch file and virtfunc2.* files.

On 12/10/09 11:59, Tom Tromey wrote:
>>>>>> "Chris" == Chris Moller<cmoller@redhat.com>  writes:
>>>>>>              
>
> Chris>  The attached stuff is a patch for PR9399:
>
> Chris>  I've assigned that bug to myself.  If you're happy with the patch, let
> Chris>  me know and I'll close the bug.  (Or do whatever you usually do...)
>
> Yeah, what I do is set the target milestone to 7.1 and close as FIXED
> after the patch is committed.
>
> Chris>  +   /* Check to see if any kind of cast is necessary; if not, punt.
> Chris>  +      (Specifically not using strcmp_iw() because no other comparisons against
> Chris>  +      TYPE_NAME() use it.  They all use standard strcmp() instead.) */
>
> Delete this comment.
>
> Chris>  /* This test script is part of GDB, the GNU debugger.
>
> Chris>     Copyright 1993, 1994, 1997, 1998, 1999, 2003, 2004, 2009
>
> Just 2009.
>
> Chris>  # Copyright 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002, 2003, 2004,
> Chris>  # 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
>
> Likewise.
>
> This is ok with those changes.  Thanks.
>
> Tom
>    


[-- Attachment #2: pr9399.patch --]
[-- Type: text/plain, Size: 2077 bytes --]

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 3513692..3d999e3 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2009-12-08  Chris Moller  <cmoller@redhat.com>
+
+	PR gdb/9399
+	* valops.c (value_cast_structs): Added test to return NULL if no
+	casting needed.
+
 2009-09-16  H.J. Lu  <hongjiu.lu@intel.com>
 
 	PR gdb/10649
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index b9039df..c00e954 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+2009-12-08  Chris Moller  <cmoller@redhat.com>
+
+	PR gdb/9399
+	* gdb.cp/virtfunc2.exp: New tests
+	* gdb.cp/virtfunc2.cc: New tests
+	* gdb.cp/Makefile.in: Added tests to EXECUTABLES
+
 2009-09-15  Tom Tromey  <tromey@redhat.com>
 
 	* lib/mi-support.exp (mi_create_varobj): Update.
diff --git a/gdb/testsuite/gdb.cp/Makefile.in b/gdb/testsuite/gdb.cp/Makefile.in
index 0a087c7..c990a64 100644
--- a/gdb/testsuite/gdb.cp/Makefile.in
+++ b/gdb/testsuite/gdb.cp/Makefile.in
@@ -4,7 +4,7 @@ srcdir = @srcdir@
 EXECUTABLES = ambiguous annota2 anon-union cplusfuncs cttiadd \
 	derivation inherit local member-ptr method misc \
         overload ovldbreak ref-typ ref-typ2 templates userdef virtfunc namespace \
-	ref-types ref-params method2 pr9594 gdb2495
+	ref-types ref-params method2 pr9594 gdb2495 virtfunc2
 
 all info install-info dvi install uninstall installcheck check:
 	@echo "Nothing to be done for $@..."
diff --git a/gdb/valops.c b/gdb/valops.c
index 3ad54ec..de24a68 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -232,6 +232,11 @@ value_cast_structs (struct type *type, struct value *v2)
 	       || TYPE_CODE (t2) == TYPE_CODE_UNION)
 	      && !!"Precondition is that value is of STRUCT or UNION kind");
 
+  if ((TYPE_NAME (t1) != NULL)
+      && (TYPE_NAME (t2) != NULL)
+      && !strcmp (TYPE_NAME (t1), TYPE_NAME (t2)))
+    return NULL;
+
   /* Upcasting: look in the type of the source to see if it contains the
      type of the target as a superclass.  If so, we'll need to
      offset the pointer rather than just change its type.  */

[-- Attachment #3: virtfunc2.cc --]
[-- Type: text/x-c++src, Size: 1096 bytes --]

 /* This test script is part of GDB, the GNU debugger.

   Copyright 2009
   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
   the Free Software Foundation; either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
   */

class interface
{
  virtual int do_print3() { return 111111; }
};
 
class Obj : virtual public interface
{
public:
  virtual int do_print() { return 123456; }
};

class Obj2 : Obj,  virtual public interface
{
  virtual int do_print2() { return 654321; }
};

int main(int argc, char** argv) {
  Obj o;
  Obj2 o2;
  return 0;	// marker 1
}

[-- Attachment #4: virtfunc2.exp --]
[-- Type: text/plain, Size: 1680 bytes --]

# Copyright 2009 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
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# This file was written by Chris Moller <moller@redhat.com> based on
# virtfunc.exp

set nl		"\[\r\n\]+"

if { [skip_cplus_tests] } { continue }

load_lib "cp-support.exp"

set testfile "virtfunc2"
set srcfile ${testfile}.cc
set binfile ${objdir}/${subdir}/${testfile}

if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {c++ debug}] != "" } {
     untested virtfunc2.exp
     return -1
}

gdb_exit
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
gdb_load ${binfile}

if ![runto_main] then {
    perror "couldn't run to breakpoint"
    continue
}

# set a breakpoint at the return stmt

gdb_breakpoint [gdb_get_line_number "marker 1"]
gdb_continue_to_breakpoint "marker 1"

gdb_test "print o.do_print()"  "\\$\[0-9\]+ = 123456"
gdb_test "print o.do_print3()"  "\\$\[0-9\]+ = 111111"

gdb_test "print o2.do_print()"  "\\$\[0-9\]+ = 123456"
gdb_test "print o2.do_print2()"  "\\$\[0-9\]+ = 654321"
gdb_test "print o2.do_print3()"  "\\$\[0-9\]+ = 111111"


gdb_exit
return 0


  reply	other threads:[~2009-12-10 18:33 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-09 13:32 Chris Moller
2009-12-09 14:05 ` Daniel Jacobowitz
2009-12-09 15:10   ` Chris Moller
2009-12-10 18:41     ` Daniel Jacobowitz
2009-12-10 19:04       ` Tom Tromey
2009-12-10 19:09         ` Chris Moller
2009-12-10 19:13         ` Daniel Jacobowitz
2009-12-10 16:59 ` Tom Tromey
2009-12-10 18:33   ` Chris Moller [this message]
2009-12-10 18:55     ` Tom Tromey

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=4B213EDB.4020609@redhat.com \
    --to=cmoller@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tromey@redhat.com \
    /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