[RFA,04/13] Call some functions in guile/ for effect
Commit Message
This changes a few spots in guile/ to remove a variable declaration
but to still call a function for effect.
gdb/ChangeLog
2018-07-12 Tom Tromey <tom@tromey.com>
* guile/scm-pretty-print.c (gdbscm_apply_val_pretty_printer): Call
value_contents_for_printing for effect.
* guile/scm-cmd.c (gdbscm_dont_repeat): Call
cmdscm_get_valid_command_smob_arg_unsafe for effect.
* guile/scm-block.c (gdbscm_make_block_syms_iter): Call
bkscm_get_valid_block_smob_arg_unsafe for effect.
---
gdb/ChangeLog | 9 +++++++++
gdb/guile/scm-block.c | 5 ++---
gdb/guile/scm-cmd.c | 6 +++---
gdb/guile/scm-pretty-print.c | 4 +++-
4 files changed, 17 insertions(+), 7 deletions(-)
Comments
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.
LGTM, though it would be nice to mention in the comments what is the
desired side-effect (if known).
Simon
>>>>> "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.
Tom
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
>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:
Pedro> ... we can't call value_bytes_available on a lazy value (because that function must
Pedro> be usable with values in the values history, that's why it works with a const value *),
Pedro> so the desired side effect here is fetching a lazy value. So I think we
Pedro> should replace that with:
Pedro> if (value_lazy (val))
Pedro> value_fetch_lazy (val);
Pedro> The Python seems to have the same issue, so I think it'd be
Pedro> a little better to handle both this hunk and the equivalent bit
Pedro> in Python in the same patch, and in its own patch.
I did this
Tom
@@ -613,9 +613,8 @@ bkscm_block_syms_progress_p (SCM scm)
static SCM
gdbscm_make_block_syms_iter (SCM self)
{
- block_smob *b_smob
- = bkscm_get_valid_block_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
- const struct block *block = b_smob->block;
+ /* Call for side effects. */
+ bkscm_get_valid_block_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
SCM progress, iter;
progress = bkscm_make_block_syms_progress_smob ();
@@ -267,9 +267,9 @@ gdbscm_command_valid_p (SCM self)
static SCM
gdbscm_dont_repeat (SCM self)
{
- /* We currently don't need anything from SELF, but still verify it. */
- command_smob *c_smob
- = cmdscm_get_valid_command_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
+ /* We currently don't need anything from SELF, but still verify it.
+ Call for side effects. */
+ cmdscm_get_valid_command_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
dont_repeat ();
@@ -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, TYPE_LENGTH (type)))