From: Simon Marchi <simon.marchi@polymtl.ca>
To: George Barrett <bob@bob131.so>, gdb-patches@sourceware.org
Subject: Re: [PATCH v2] guile: stop procedures on invalid breakpoints
Date: Thu, 17 Jun 2021 10:54:54 -0400 [thread overview]
Message-ID: <4b423e32-89c0-97ad-d99a-7d083ebeb5af@polymtl.ca> (raw)
In-Reply-To: <&3who0-hc2sl7.6ynkv0/vea0fv3jcc&dmgggr7u3vzuqjsj5m5d@mail.bob131.so>
> diff --git a/gdb/guile/scm-breakpoint.c b/gdb/guile/scm-breakpoint.c
> index 4ff197e48a4..3c741d712b7 100644
> --- a/gdb/guile/scm-breakpoint.c
> +++ b/gdb/guile/scm-breakpoint.c
> @@ -326,6 +326,26 @@ bpscm_get_valid_breakpoint_smob_arg_unsafe (SCM self, int arg_pos,
>
> return bp_smob;
> }
> +
> +/* Returns the breakpoint smob in SELF, verifying it's either valid or
> + originates from Scheme.
> + Throws an exception if SELF is not a <gdb:breakpoint> object,
> + or is invalid and not allocated from Scheme. */
> +
> +static breakpoint_smob *
> +bpscm_get_valid_or_scm_breakpoint_smob_arg_unsafe (SCM self, int arg_pos,
> + const char *func_name)
> +{
> + breakpoint_smob *bp_smob
> + = bpscm_get_breakpoint_smob_arg_unsafe (self, arg_pos, func_name);
> +
> + if (!bpscm_is_valid (bp_smob) && !bp_smob->is_scheme_bkpt)
> + gdbscm_invalid_object_error (func_name, arg_pos, self,
> + _("<gdb:breakpoint>"));
> +
> +
> + return bp_smob;
Remove extra empty line above.
> +}
> \f
> /* Breakpoint methods. */
>
> @@ -914,7 +934,8 @@ static SCM
> gdbscm_breakpoint_stop (SCM self)
> {
> breakpoint_smob *bp_smob
> - = bpscm_get_valid_breakpoint_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
> + = bpscm_get_valid_or_scm_breakpoint_smob_arg_unsafe (self, SCM_ARG1,
> + FUNC_NAME);
>
> return bp_smob->stop;
> }
> @@ -926,33 +947,36 @@ static SCM
> gdbscm_set_breakpoint_stop_x (SCM self, SCM newvalue)
> {
> breakpoint_smob *bp_smob
> - = bpscm_get_valid_breakpoint_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
> - const struct extension_language_defn *extlang = NULL;
> + = bpscm_get_valid_or_scm_breakpoint_smob_arg_unsafe (self, SCM_ARG1,
> + FUNC_NAME);
>
> SCM_ASSERT_TYPE (gdbscm_is_procedure (newvalue)
> || gdbscm_is_false (newvalue),
> newvalue, SCM_ARG2, FUNC_NAME,
> _("procedure or #f"));
>
> - if (bp_smob->bp->cond_string != NULL)
> - extlang = get_ext_lang_defn (EXT_LANG_GDB);
> - if (extlang == NULL)
> - extlang = get_breakpoint_cond_ext_lang (bp_smob->bp, EXT_LANG_GUILE);
> - if (extlang != NULL)
> - {
> - char *error_text
> - = xstrprintf (_("Only one stop condition allowed. There is"
> - " currently a %s stop condition defined for"
> - " this breakpoint."),
> - ext_lang_capitalized_name (extlang));
> -
> - scm_dynwind_begin ((scm_t_dynwind_flags) 0);
> - gdbscm_dynwind_xfree (error_text);
> - gdbscm_out_of_range_error (FUNC_NAME, SCM_ARG1, self, error_text);
> - /* The following line, while unnecessary, is present for completeness
> - sake. */
> - scm_dynwind_end ();
> - }
> + if (bp_smob->bp != nullptr) {
> + const struct extension_language_defn *extlang = nullptr;
> + if (bp_smob->bp->cond_string != nullptr)
> + extlang = get_ext_lang_defn (EXT_LANG_GDB);
> + if (extlang == nullptr)
> + extlang = get_breakpoint_cond_ext_lang (bp_smob->bp, EXT_LANG_GUILE);
> + if (extlang != nullptr)
> + {
> + char *error_text
> + = xstrprintf (_("Only one stop condition allowed. There is"
> + " currently a %s stop condition defined for"
> + " this breakpoint."),
> + ext_lang_capitalized_name (extlang));
> +
> + scm_dynwind_begin ((scm_t_dynwind_flags) 0);
> + gdbscm_dynwind_xfree (error_text);
> + gdbscm_out_of_range_error (FUNC_NAME, SCM_ARG1, self, error_text);
> + /* The following line, while unnecessary, is present for
> + completeness sake. */
> + scm_dynwind_end ();
> + }
> + }
Format the if above with the usual style:
if (...)
{
...
}
The patch LGTM with those fixed. Again, we will be able to merge it
once your copyright assignment is complete, just remind us then.
Simon
prev parent reply other threads:[~2021-06-17 14:55 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-09 13:53 George Barrett
2021-06-12 10:08 ` Eli Zaretskii
2021-06-17 14:54 ` Simon Marchi [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4b423e32-89c0-97ad-d99a-7d083ebeb5af@polymtl.ca \
--to=simon.marchi@polymtl.ca \
--cc=bob@bob131.so \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).