Patch for PR 9399

Chris Moller
Wed Dec 9 13:32:00 GMT 2009

The attached stuff is a patch for PR9399:  "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 <>

            PR gdb/9399
            * valops.c (value_cast_structs): Added test to return NULL if no
            casting needed.

    2009-12-08  Chris Moller <>

           PR gdb/9399
           * gdb.cp/virtfunc2.exp:
           * gdb.cp/ New tests for a patch to fix PR gd/9399
           * gdb.cp/ 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/, and 
mc-log.diffs.  (The patch to 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/ and gdb/testsuite/gdb.cp/virtfunc2.exp.

You can see what the patch does by compiling -g, 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 

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: <>
-------------- next part --------------
A non-text attachment was scrubbed...
Type: text/x-c++src
Size: 1173 bytes
Desc: not available
URL: <>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: virtfunc2.exp
URL: <>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: mc-log.diffs
URL: <>

More information about the Gdb-patches mailing list