[RFA 2/2] Remove prepare_re_set_context
Simon Marchi
simon.marchi@polymtl.ca
Tue Oct 10 18:56:00 GMT 2017
On 2017-10-09 19:47, Tom Tromey wrote:
> prepare_re_set_context returns a null cleanup and doesn't seem
> generally useful. This patch removes it plus a few more cleanups; and
> changes breakpoint_re_set to use scoped_restore rather than its own
> manual mechanism.
>
> ChangeLog
> 2017-10-09 Tom Tromey <tom@tromey.com>
>
> * breakpoint.c (prepare_re_set_context): Remove.
> (breakpoint_re_set_one): Update. Don't use cleanups.
> (breakpoint_re_set): Use scoped_restore, std::string, and
> scoped_restore_current_language.
> ---
> gdb/ChangeLog | 7 +++++++
> gdb/breakpoint.c | 36 ++++++++++--------------------------
> 2 files changed, 17 insertions(+), 26 deletions(-)
>
> diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
> index e56858286c..2eba1e9c48 100644
> --- a/gdb/breakpoint.c
> +++ b/gdb/breakpoint.c
> @@ -14088,17 +14088,6 @@ decode_location_default (struct breakpoint *b,
> return {};
> }
>
> -/* Prepare the global context for a re-set of breakpoint B. */
> -
> -static struct cleanup *
> -prepare_re_set_context (struct breakpoint *b)
> -{
> - input_radix = b->input_radix;
> - set_language (b->language);
> -
> - return make_cleanup (null_cleanup, NULL);
> -}
> -
> /* Reset a breakpoint given it's struct breakpoint * BINT.
> The value we return ends up being the return value from
> catch_errors.
> Unused in this case. */
> @@ -14108,11 +14097,11 @@ breakpoint_re_set_one (void *bint)
> {
> /* Get past catch_errs. */
> struct breakpoint *b = (struct breakpoint *) bint;
> - struct cleanup *cleanups;
>
> - cleanups = prepare_re_set_context (b);
> + input_radix = b->input_radix;
> + set_language (b->language);
> +
> b->ops->re_set (b);
> - do_cleanups (cleanups);
> return 0;
> }
>
> @@ -14123,13 +14112,10 @@ void
> breakpoint_re_set (void)
> {
> struct breakpoint *b, *b_tmp;
> - enum language save_language;
> - int save_input_radix;
> -
> - save_language = current_language->la_language;
> - save_input_radix = input_radix;
>
> {
> + scoped_restore_current_language save_language;
> + scoped_restore save_input_radix = make_scoped_restore
> (&input_radix);
> scoped_restore_current_pspace_and_thread restore_pspace_thread;
>
> /* Note: we must not try to insert locations until after all
> @@ -14140,14 +14126,12 @@ breakpoint_re_set (void)
> ALL_BREAKPOINTS_SAFE (b, b_tmp)
> {
> /* Format possible error msg. */
> - char *message = xstrprintf ("Error in re-setting breakpoint %d: ",
> - b->number);
> - struct cleanup *cleanups = make_cleanup (xfree, message);
> - catch_errors (breakpoint_re_set_one, b, message, RETURN_MASK_ALL);
> - do_cleanups (cleanups);
> + std::string message
> + = string_printf ("Error in re-setting breakpoint %d: ",
> + b->number);
> + catch_errors (breakpoint_re_set_one, b, message.c_str (),
> + RETURN_MASK_ALL);
> }
> - set_language (save_language);
> - input_radix = save_input_radix;
>
> jit_breakpoint_re_set ();
> }
LGTM.
More information about the Gdb-patches
mailing list