Patch for PR 9399

Chris Moller cmoller@redhat.com
Wed Dec 9 13:32:00 GMT 2009


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


-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: pr9399.patch
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20091209/9e42fd35/attachment.ksh>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: virtfunc2.cc
Type: text/x-c++src
Size: 1173 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20091209/9e42fd35/attachment.bin>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: virtfunc2.exp
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20091209/9e42fd35/attachment-0001.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: mc-log.diffs
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20091209/9e42fd35/attachment-0002.ksh>


More information about the Gdb-patches mailing list