[PATCH] Fix mi "-var-create" regression

Luis Gustavo luis_gustavo@mentor.com
Wed Oct 10 20:05:00 GMT 2012


After the commit that fixed #13393 
(http://sourceware.org/bugzilla/show_bug.cgi?id=13393), certain calls to 
-var-create with "set print object on" started failing with a 
dereferencing error, like so:

-var-create - * $sp
^error,msg="Attempt to dereference a generic pointer."

This happens because in value.c:value_actual_type we have this check:

       if (TYPE_CODE (result) == TYPE_CODE_PTR
           || TYPE_CODE (result) == TYPE_CODE_REF)
           struct type *real_type;

           real_type = value_rtti_indirect_type (value, NULL, NULL, NULL);
           if (real_type)
               if (real_type_found)
                 *real_type_found = 1;
               result = real_type;

If we reach this point with result being a pointer of reference, we 
execute the if block. This will eventually lead to a call to 
valops.c:get_value_at, where we throw an error in case the target type 
is void (pointers usually have such a target type)

Anton does mention a particular problem with indirect pointers in #13393 
comment #8, but it is not clear if a bug ticket has been filed for that.

The following patch adds a check for target type void, and skips the 
problematic if block accordingly. This fixes the problem and does not 
seem to cause any regressions.

With "set print object off", everything works as it should.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: rtti-print-object.diff
Type: text/x-patch
Size: 951 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20121010/f75c74fa/attachment.bin>

More information about the Gdb-patches mailing list