This is the mail archive of the archer@sourceware.org mailing list for the Archer 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]

Re: [python] don't report -1 varobj children


Tom Tromey wrote:

> I'm checking this in on the python branch.
> 
> A dynamic varobj should never report that it has -1 children.
> 
> Tom
> 
> 2009-08-18  Tom Tromey  <tromey@redhat.com>
> 
> * varobj.c (varobj_get_num_children): Don't return -1 to the
> caller.
> 
> diff --git a/gdb/varobj.c b/gdb/varobj.c
> index f2a4ab6..f0ad1ac 100644
> --- a/gdb/varobj.c
> +++ b/gdb/varobj.c
> @@ -1052,11 +1052,20 @@ update_dynamic_varobj_children (struct varobj *var,
>  int
>  varobj_get_num_children (struct varobj *var)
>  {
> +  int result = var->num_children;
> +
>    if (var->num_children == -1)
>      {
> -      int changed;
> -      if (!var->pretty_printer)
> -     var->num_children = number_of_children (var);
> +      if (var->pretty_printer)
> +     {
> +       /* If we have a dynamic varobj, don't report -1 children.  */
> +       result = 0;
> +     }
> +      else
> +     {
> +       var->num_children = number_of_children (var);
> +       result = var->num_children;
> +     }
>      }
>  
>    return var->num_children;

It does not seem like assignment of 0 to 'result' has any effect, because 'result'
is not used thereafter. Furthermore, if I change

    return var->num_children;

to

    return result;      

things are still not OK. Give vector<string> variable called 'v2', I see:

        (gdb) -var-create var3 @ v2
        ^done,name="var3",numchild="0",value="std::vector of length 2, capacity 2",
        type="std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >,
        std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >
        >",thread-id="1"

Here, the poor frontend has no clue that the varobj actually has children. (And -var-list-children
will print them). My original complain was that numchild was -1 for std::string -- which is known
to never have children.

- Volodya



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