Re: [RFA 04/13] Call some functions in guile/ for effect

Pedro Alves
2018-07-16T13:54:36Z

On 07/14/2018 01:39 PM, Tom Tromey wrote:
>>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:
>
> Simon> On 2018-07-12 04:51 PM, Tom Tromey wrote:
>>> This changes a few spots in guile/ to remove a variable declaration
>>> but to still call a function for effect.
>
> Simon> LGTM, though it would be nice to mention in the comments what is the
> Simon> desired side-effect (if known).
>
> I really do not know, I just noticed that those functions can throw.

No idea on the guile bits, but for this one:

> --- a/gdb/guile/scm-pretty-print.c
> +++ b/gdb/guile/scm-pretty-print.c
> @@ -970,7 +970,9 @@ gdbscm_apply_val_pretty_printer (const struct extension_language_defn *extlang,
> struct cleanup *cleanups;
> enum ext_lang_rc result = EXT_LANG_RC_NOP;
> enum string_repr_result print_result;
> - const gdb_byte *valaddr = value_contents_for_printing (val);
> +
> + /* Call for side effects. */
> + value_contents_for_printing (val);
>
> /* No pretty-printer support for unavailable values. */
> if (!value_bytes_available (val, embedded_offset

... we can't call value_bytes_available on a lazy value (because that function must
be usable with values in the values history, that's why it works with a const value *),
so the desired side effect here is fetching a lazy value. So I think we
should replace that with:

if (value_lazy (val))
value_fetch_lazy (val);

The Python seems to have the same issue, so I think it'd be
a little better to handle both this hunk and the equivalent bit
in Python in the same patch, and in its own patch.

Thanks,
Pedro Alves