This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Patch for PR 9399


The attached stuff is a patch for PR9399:

http://sourceware.org/bugzilla/show_bug.cgi?id=9399 "gdb can't call or print a const function that uses virtual inheritance"

The bug was in valops.c:value_cast_structs() which could do spurious upcasts or downcasts. The fix tests whether any casts at all are necessary and, if not, returns a NULL.

The patch hits two ChangeLogs, one for the fix, in .../gdb/ChangeLog, the other for the testcase in gdb/testsuite/ChangeLog. Respectively, they are:

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-12-08 Chris Moller <cmoller@redhat.com>


          PR gdb/9399
          * gdb.cp/virtfunc2.exp:
          * gdb.cp/virtfunc2.cc: New tests for a patch to fix PR gd/9399
          * gdb.cp/Makefile.in: Added tests to EXECUTABLES

(These are both included in the attached patch file.)

The patch file includes the patch to gdb/valops.c, gdb/ChangeLog, gdb/testsuite/ChangeLog, gdb/testsuite/gdb.cp/Makefile.in, and mc-log.diffs. (The patch to Makefile.in is to incorporate the testcase for 'make check'; mc-log.diffs are the diffs between before and after runs of 'make check') I can't do a 'cvs add' so the the testcase expects and .cc file are attached separately as gdb/testsuite/gdb.cp/virtfunc2.cc and gdb/testsuite/gdb.cp/virtfunc2.exp.

You can see what the patch does by compiling -g virtfunc.cc, gdb-ing it, breaking in the return stmt at // marker1, and doing things like "print o.do_print()". Without the patch, gdb tries to access location 0x0; with the patch it does the right thing. (There are more tests in virtfunc2.exp)

I've included the diff between the before and after 'make check' logs. I don't think the patch breaks anything--most of the diffs are with respect to the different directories used for before and after builds. Starting at line 131 in mc-log.diffs, you can see the new tests, virtfunc2, and, following that, the six new expected passes.

I've assigned that bug to myself. If you're happy with the patch, let me know and I'll close the bug. (Or do whatever you usually do...)

Have fun,
Chris Moller
Red Hat


Attachment: pr9399.patch
Description: Text document

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

   Copyright 1993, 1994, 1997, 1998, 1999, 2003, 2004, 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 const int do_print3() const { return 111111; }
};
 
class Obj : virtual public interface
{
public:
  virtual const int do_print() const { return 123456; }
};

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

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

Attachment: virtfunc2.exp
Description: Text document

Attachment: mc-log.diffs
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]