This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] -var-update
On Sun, May 21, 2006 at 10:25:24AM +1200, Nick Roberts wrote:
> Yes. Perhaps my summary isn't precise, but it didn't work. My patch uses
> value_at while coerce_ref uses value_at_lazy. The comment says:
>
> Call value_at only if the data needs to be fetched immediately;
> if we can be 'lazy' and defer the fetch, perhaps indefinately, call
> ^^^^^^^^^^^^
> value_at_lazy instead. value_at_lazy simply records the address of
> the data and sets the lazy-evaluation-required flag. The lazy flag
> is tested in the value_contents macro, which is used if and when
> the contents are actually required.
>
> value_contents is not a macro (VALUE_CONTENTS used to be one) but a function,
> and doesn't test the lazy flag.
No:
const gdb_byte *
value_contents (struct value *value)
{
return value_contents_writeable (value);
}
gdb_byte *
value_contents_writeable (struct value *value)
{
if (value->lazy)
value_fetch_lazy (value);
return value_contents_raw (value);
}
If you take a look at the code you're patching, there should be a
nearby call to value_fetch_lazy or gdb_value_fetch_lazy in each case.
You want to be calling coerce_ref before you do that. Also, see the
existing calls to release_value? If you change var->value after that,
you're going to leak memory.
Try calling coerce_ref in here:
if (gdb_evaluate_expression (var->root->exp, &var->value))
{
/* no error */
/* HERE */
release_value (var->value);
if (value_lazy (var->value))
gdb_value_fetch_lazy (var->value);
}
else
var->value = evaluate_type (var->root->exp);
--
Daniel Jacobowitz
CodeSourcery