From 070365117b5727394e271399c5738a27bf9716d5 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Fri, 29 Sep 2017 21:49:04 -0600 Subject: [PATCH] Change record_full_gdb_operation_disable_set not to return a cleanup This changes record_full_gdb_operation_disable_set to return a scoped_restore rather than a cleanup, and fixes all the users. ChangeLog 2017-10-03 Tom Tromey * record-full.h (record_full_gdb_operation_disable_set): Return scoped_restore_tmpl. * infrun.c (adjust_pc_after_break): Update. (handle_signal_stop): Update. * record-full.c (record_full_gdb_operation_disable_set): Return scoped_restore_tmpl. (record_full_wait_1, record_full_insert_breakpoint) (record_full_remove_breakpoint, record_full_save) (record_full_goto_insn): Update. --- gdb/ChangeLog | 12 ++++++++++++ gdb/infrun.c | 15 +++++++-------- gdb/record-full.c | 34 ++++++++++++---------------------- gdb/record-full.h | 2 +- 4 files changed, 32 insertions(+), 31 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index e0cf4c02709..2415a07094f 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,15 @@ +2017-10-03 Tom Tromey + + * record-full.h (record_full_gdb_operation_disable_set): Return + scoped_restore_tmpl. + * infrun.c (adjust_pc_after_break): Update. + (handle_signal_stop): Update. + * record-full.c (record_full_gdb_operation_disable_set): Return + scoped_restore_tmpl. + (record_full_wait_1, record_full_insert_breakpoint) + (record_full_remove_breakpoint, record_full_save) + (record_full_goto_insn): Update. + 2017-10-02 Tom Tromey PR rust/22236: diff --git a/gdb/infrun.c b/gdb/infrun.c index fba00795ac7..e82f61f079f 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -4178,10 +4178,11 @@ adjust_pc_after_break (struct thread_info *thread, || (target_is_non_stop_p () && moribund_breakpoint_here_p (aspace, breakpoint_pc))) { - struct cleanup *old_cleanups = make_cleanup (null_cleanup, NULL); + gdb::optional> restore_operation_disable; if (record_full_is_used ()) - record_full_gdb_operation_disable_set (); + restore_operation_disable.emplace + (record_full_gdb_operation_disable_set ()); /* When using hardware single-step, a SIGTRAP is reported for both a completed single-step and a software breakpoint. Need to @@ -4205,8 +4206,6 @@ adjust_pc_after_break (struct thread_info *thread, || (thread->stepped_breakpoint && thread->prev_pc == breakpoint_pc)) regcache_write_pc (regcache, breakpoint_pc); - - do_cleanups (old_cleanups); } } @@ -6008,14 +6007,14 @@ handle_signal_stop (struct execution_control_state *ecs) decr_pc = gdbarch_decr_pc_after_break (gdbarch); if (decr_pc != 0) { - struct cleanup *old_cleanups = make_cleanup (null_cleanup, NULL); + gdb::optional> + restore_operation_disable; if (record_full_is_used ()) - record_full_gdb_operation_disable_set (); + restore_operation_disable.emplace + (record_full_gdb_operation_disable_set ()); regcache_write_pc (regcache, stop_pc + decr_pc); - - do_cleanups (old_cleanups); } } else diff --git a/gdb/record-full.c b/gdb/record-full.c index 5073be3c5b7..5bd890044e2 100644 --- a/gdb/record-full.c +++ b/gdb/record-full.c @@ -670,16 +670,10 @@ record_full_message_wrapper_safe (struct regcache *regcache, static int record_full_gdb_operation_disable = 0; -struct cleanup * +scoped_restore_tmpl record_full_gdb_operation_disable_set (void) { - struct cleanup *old_cleanups = NULL; - - old_cleanups = - make_cleanup_restore_integer (&record_full_gdb_operation_disable); - record_full_gdb_operation_disable = 1; - - return old_cleanups; + return make_scoped_restore (&record_full_gdb_operation_disable, 1); } /* Flag set to TRUE for target_stopped_by_watchpoint. */ @@ -1051,7 +1045,8 @@ record_full_wait_1 (struct target_ops *ops, ptid_t ptid, struct target_waitstatus *status, int options) { - struct cleanup *set_cleanups = record_full_gdb_operation_disable_set (); + scoped_restore restore_operation_disable + = record_full_gdb_operation_disable_set (); if (record_debug) fprintf_unfiltered (gdb_stdlog, @@ -1334,7 +1329,6 @@ replay_out: signal (SIGINT, handle_sigint); - do_cleanups (set_cleanups); return inferior_ptid; } @@ -1653,12 +1647,11 @@ record_full_insert_breakpoint (struct target_ops *ops, However, we do have to insert software single-step breakpoints, in case the target can't hardware step. To keep things simple, we always insert. */ - struct cleanup *old_cleanups; int ret; - old_cleanups = record_full_gdb_operation_disable_set (); + scoped_restore restore_operation_disable + = record_full_gdb_operation_disable_set (); ret = ops->beneath->to_insert_breakpoint (ops->beneath, gdbarch, bp_tgt); - do_cleanups (old_cleanups); if (ret != 0) return ret; @@ -1711,14 +1704,12 @@ record_full_remove_breakpoint (struct target_ops *ops, { if (bp->in_target_beneath) { - struct cleanup *old_cleanups; int ret; - old_cleanups = record_full_gdb_operation_disable_set (); + scoped_restore restore_operation_disable + = record_full_gdb_operation_disable_set (); ret = ops->beneath->to_remove_breakpoint (ops->beneath, gdbarch, bp_tgt, reason); - do_cleanups (old_cleanups); - if (ret != 0) return ret; } @@ -2549,7 +2540,6 @@ record_full_save (struct target_ops *self, const char *recfilename) uint32_t magic; struct regcache *regcache; struct gdbarch *gdbarch; - struct cleanup *set_cleanups; int save_size = 0; asection *osec = NULL; int bfd_offset = 0; @@ -2573,7 +2563,8 @@ record_full_save (struct target_ops *self, const char *recfilename) gdbarch = get_regcache_arch (regcache); /* Disable the GDB operation record. */ - set_cleanups = record_full_gdb_operation_disable_set (); + scoped_restore restore_operation_disable + = record_full_gdb_operation_disable_set (); /* Reverse execute to the begin of record list. */ while (1) @@ -2737,7 +2728,6 @@ record_full_save (struct target_ops *self, const char *recfilename) record_full_list = record_full_list->prev; } - do_cleanups (set_cleanups); unlink_file.keep (); /* Succeeded. */ @@ -2753,7 +2743,8 @@ static void record_full_goto_insn (struct record_full_entry *entry, enum exec_direction_kind dir) { - struct cleanup *set_cleanups = record_full_gdb_operation_disable_set (); + scoped_restore restore_operation_disable + = record_full_gdb_operation_disable_set (); struct regcache *regcache = get_current_regcache (); struct gdbarch *gdbarch = get_regcache_arch (regcache); @@ -2771,7 +2762,6 @@ record_full_goto_insn (struct record_full_entry *entry, else record_full_list = record_full_list->next; } while (record_full_list != entry); - do_cleanups (set_cleanups); } /* Alias for "target record-full". */ diff --git a/gdb/record-full.h b/gdb/record-full.h index 7d53b635e49..728bf59958b 100644 --- a/gdb/record-full.h +++ b/gdb/record-full.h @@ -29,6 +29,6 @@ extern int record_full_arch_list_add_end (void); /* Returns true if the process record target is open. */ extern int record_full_is_used (void); -extern struct cleanup *record_full_gdb_operation_disable_set (void); +extern scoped_restore_tmpl record_full_gdb_operation_disable_set (); #endif /* RECORD_FULL_H */ -- 2.30.2