public inbox for archer@sourceware.org
 help / color / mirror / Atom feed
* [python] don't report -1 varobj children
@ 2009-08-18 18:58 Tom Tromey
  2009-08-19  5:53 ` Vladimir Prus
  0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2009-08-18 18:58 UTC (permalink / raw)
  To: Project Archer

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;

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [python] don't report -1 varobj children
  2009-08-18 18:58 [python] don't report -1 varobj children Tom Tromey
@ 2009-08-19  5:53 ` Vladimir Prus
  2009-08-19 16:43   ` Tom Tromey
  0 siblings, 1 reply; 3+ messages in thread
From: Vladimir Prus @ 2009-08-19  5:53 UTC (permalink / raw)
  To: archer

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [python] don't report -1 varobj children
  2009-08-19  5:53 ` Vladimir Prus
@ 2009-08-19 16:43   ` Tom Tromey
  0 siblings, 0 replies; 3+ messages in thread
From: Tom Tromey @ 2009-08-19 16:43 UTC (permalink / raw)
  To: Vladimir Prus; +Cc: archer

>>>>> "Volodya" == Vladimir Prus <vladimir@codesourcery.com> writes:

Volodya> It does not seem like assignment of 0 to 'result' has any
Volodya> effect, because 'result' is not used thereafter.

Yeah, what was I thinking?  I must have only tested an old build, or
something bogus like that.

I'll fix this up shortly.

Tom

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-08-19 16:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-18 18:58 [python] don't report -1 varobj children Tom Tromey
2009-08-19  5:53 ` Vladimir Prus
2009-08-19 16:43   ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).