From patchwork Sun Oct 1 04:06:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 23270 Received: (qmail 103121 invoked by alias); 1 Oct 2017 04:07:28 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 102487 invoked by uid 89); 1 Oct 2017 04:07:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: gproxy10-pub.mail.unifiedlayer.com Received: from gproxy10-pub.mail.unifiedlayer.com (HELO gproxy10-pub.mail.unifiedlayer.com) (69.89.20.226) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 01 Oct 2017 04:07:22 +0000 Received: from CMOut01 (unknown [10.0.90.82]) by gproxy10.mail.unifiedlayer.com (Postfix) with ESMTP id A619414056B for ; Sat, 30 Sep 2017 22:07:20 -0600 (MDT) Received: from box522.bluehost.com ([74.220.219.122]) by CMOut01 with id G47H1w00i2f2jeq0147L65; Sat, 30 Sep 2017 22:07:20 -0600 X-Authority-Analysis: v=2.2 cv=K4VSJ2eI c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=2JCJgTwv5E4A:10 a=zstS-IiYAAAA:8 a=ji_mJUtvZYABwq68hXUA:9 a=4G6NA9xxw8l3yy4pmD5M:22 Received: from 75-166-0-208.hlrn.qwest.net ([75.166.0.208]:43148 helo=pokyo.Home) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1dyVWg-002l9R-5y; Sat, 30 Sep 2017 22:06:46 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA 1/8] Change record_full_gdb_operation_disable_set not to return a cleanup Date: Sat, 30 Sep 2017 22:06:36 -0600 Message-Id: <20171001040643.25162-2-tom@tromey.com> In-Reply-To: <20171001040643.25162-1-tom@tromey.com> References: <20171001040643.25162-1-tom@tromey.com> X-BWhitelist: no X-Exim-ID: 1dyVWg-002l9R-5y X-Source-Sender: 75-166-0-208.hlrn.qwest.net (pokyo.Home) [75.166.0.208]:43148 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-Local-Domain: yes This changes record_full_gdb_operation_disable_set to return a scoped_restore rather than a cleanup, and fixes all the users. ChangeLog 2017-09-30 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 ed5d20c..a415c18 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,15 @@ +2017-09-30 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-09-29 Tom Tromey * target.c (read_whatever_is_readable): Change type of "result". diff --git a/gdb/infrun.c b/gdb/infrun.c index fba0079..e82f61f 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 5073be3..5bd8900 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 7d53b63..728bf59 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 */