Simpify varobj children handling for C++

Vladimir Prus ghost@cs.msu.su
Wed Jan 17 18:57:00 GMT 2007


Daniel Jacobowitz wrote:

> On Mon, Dec 25, 2006 at 11:16:15AM +0300, Vladimir Prus wrote:
>>         * value.c (value_as_address): Use coerce_array_proper
>>         instead of coerce_array so that not fail for references.
>>         (coerce_array_proper): New function.
>>         (coerce_array): Use the above.
> 
> I definitely need more information on this.  What fails beforehand,
> and how did you get there?

In truth, this might not be needed. Previously I found that
value_ind just errors out on references and tried to fix this
in this patch.

>> @@ -950,7 +950,8 @@ value_ind (struct value *arg1)
>>    if (TYPE_CODE (base_type) == TYPE_CODE_INT)
>>      return value_at_lazy (builtin_type_int,
>>  (CORE_ADDR) value_as_long (arg1));
>> -  else if (TYPE_CODE (base_type) == TYPE_CODE_PTR)
>> +  else if (TYPE_CODE (base_type) == TYPE_CODE_PTR
>> +       || TYPE_CODE (base_type) == TYPE_CODE_PTR)
>>      {
>>        struct type *enc_type;
>>        /* We may be pointing to something embedded in a larger object */
> 
> Something tells me you didn't actually need value_ind to handle
> references... :-)

Why? Because that's a bad idea or because varobj code does not 
need to dereference rereferences? The latter is true,
attached version of the patch builds on the 
"fix 'editable' attribute for references" patch I've posted earlier
and now 'adjust_value_for_child_access' asserts that the type
is not reference.
 
>> @@ -1876,6 +1886,10 @@ c_describe_child (struct varobj *parent,
>>        if (cvalue && value)
>>  gdb_value_ind (value, cvalue);
>>  
>> +      /* The get_target_type function calls check_typedef
>> +     on the result.  I'm not sure if showing check_typedefed
>> +     type for the child as opposed to the declared type is
>> +     right.  */
>>        if (ctype)
>>  *ctype = get_target_type (type);
>>        
> 
> It'd be nice if we didn't do that.  We go to some effort to show
> typedefs in the CLI for ptype.

Changed. Revised patch attached, OK?

- Volodya

        Refactor getting children name, value and type access 
        for varobjs in C++.
        * varobj.c (get_type_deref): Remove.
        (adjust_value_for_child_access): New.
        (c_number_of_children): Use the above.
        (c_describe_child): Likewise.
        (enum accessibility): New.
        (match_accessibility): New function.
        (cplus_describe_child): New function.
        (cplus_name_of_child, cplus_value_of_child)
        (cplus_type_of_child): Reimplement in terms
        of cplus_describe_child.
        (cplus_number_of_children): Use 
        adjust_value_for_child_access.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: delta.diff
Type: text/x-diff
Size: 7593 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20070117/a269ac4c/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: path_4_unify_cpp__gdb_mainline.diff
Type: text/x-diff
Size: 19385 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20070117/a269ac4c/attachment-0001.bin>


More information about the Gdb-patches mailing list