This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: Cleanup varobjs for invalid expressions
- From: Daniel Jacobowitz <drow at false dot org>
- To: Vladimir Prus <vladimir at codesourcery dot com>
- Cc: gdb-patches at sources dot redhat dot com
- Date: Thu, 29 Mar 2007 13:53:35 -0400
- Subject: Re: Cleanup varobjs for invalid expressions
- References: <200703251520.14762.vladimir@codesourcery.com>
On Sun, Mar 25, 2007 at 02:20:14PM +0300, Vladimir Prus wrote:
>
> Pretty much everywhere in varobj.c, we use a convention
> that varobj value of NULL means that some error occured
> when evaluating the value. However, in some cases
> we try to evaluate at least the type of varobj, and that
> code unintentionally sets varobj value to non-null.
> The result of this is:
>
> -var-create null_ptr * **0
> ^done,name="null_ptr",numchild="0",value="0",type="int"
>
> Clearly, the value of "0" is bogus (on x86).
>
> This patch fixes the problem and changes the above output to:
>
> ^done,name="null_ptr",numchild="0",value="",type="int"
I guess that's better.
> + struct value *value = NULL;
> + {
> + /* Error getting the value. Try to at least get the
> + right type. */
> + struct value *value = evaluate_type (var->root->exp);
> + var->type = value_type (value);
> + }
GDB is already full of -Wshadow problems, but I'd rather we didn't
make it worse - I find it incredibly confusing. The patch is OK if
you give the inner variable some name other than "value".
--
Daniel Jacobowitz
CodeSourcery