This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] MI: Free values when updating
- From: Vladimir Prus <ghost at cs dot msu dot su>
- To: Nick Roberts <nickrob at snap dot net dot nz>, gdb-patches at sources dot redhat dot com
- Date: Tue, 23 Jan 2007 10:55:01 +0300
- Subject: Re: [PATCH] MI: Free values when updating
- References: <17845.48393.877158.536969@kahikatea.snap.net.nz>
Nick Roberts wrote:
> The recent changes to varobj.c have resulted in values computed with
> -var-update not being freed automatically. ÂThis makes computation longer
> and progressively so as currently free_all_values doesn't always get
> called.
>
> Nick                     Â
> http://www.inet.net.nz/~nickrob
>
>
> 2007-01-23 ÂNick Roberts Â<nickrob@snap.net.nz>
>
> * varobj.c (install_new_value): Don't call release_value when
> updating.
>
>
> *** varobj.cÂÂÂÂ16 Jan 2007 18:34:59 +1300ÂÂÂÂÂÂ1.79
> --- varobj.cÂÂÂÂ23 Jan 2007 18:26:57 +1300
> *************** install_new_value (struct varobj *var, s
> *** 917,923 ****
> /* We are not interested in the address of references, and given
> that in C++ a reference is not rebindable, it cannot
> meaningfully change. ÂSo, get hold of the real value. Â*/
> ! Â if (value)
> {
> value = coerce_ref (value);
> release_value (value);
> --- 917,923 ----
> /* We are not interested in the address of references, and given
> that in C++ a reference is not rebindable, it cannot
> meaningfully change. ÂSo, get hold of the real value. Â*/
> ! Â if (initial && value)
I don't understand this change at all. It means that if you have
a reference variable then:
1. For initial value, dereferenced value will be saved
2. For second and subsequent values, the value of reference itself will
be saved.
This is exactly what the code block in question tries to prevent --
it tries to make sure we always store dereferenced value.
When I try to run tests with this patch applied, I get:
Running ../.././gdb/testsuite/gdb.mi/mi-var-cmd.exp ...
ERROR: Couldn't send -var-create i * i to GDB.
ERROR: Couldn't send -var-create l * l to GDB.
ERROR: Couldn't send -var-create linteger * linteger to GDB.
and many more errors like this. Did you run the testsuite after change?
Can you explain where the memory leak comes from. At the end of the function I see:
if (var->value != NULL)
value_free (var->value);
and the value passed to function itself does not have release_value called on it,
so should be freed automatically.
- Volodya