From patchwork Sun Sep 10 21:50:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 22811 Received: (qmail 42508 invoked by alias); 10 Sep 2017 21:50:52 -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 42476 invoked by uid 89); 10 Sep 2017 21:50:51 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=restoration, underneath X-HELO: gproxy4-pub.mail.unifiedlayer.com Received: from gproxy4-pub.mail.unifiedlayer.com (HELO gproxy4-pub.mail.unifiedlayer.com) (69.89.23.142) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 10 Sep 2017 21:50:48 +0000 Received: from cmgw2 (unknown [10.0.90.83]) by gproxy4.mail.unifiedlayer.com (Postfix) with ESMTP id C3E21175D73 for ; Sun, 10 Sep 2017 15:50:46 -0600 (MDT) Received: from box522.bluehost.com ([74.220.219.122]) by cmgw2 with id 7xqj1w0172f2jeq01xqm64; Sun, 10 Sep 2017 15:50:46 -0600 X-Authority-Analysis: v=2.2 cv=dZfw5Tfe c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=2JCJgTwv5E4A:10 a=zstS-IiYAAAA:8 a=iHUdmGLXG5mKKVf0atcA:9 a=QvDG5Qlfv73x2OPa:21 a=BT0lQxmwcgrCN-lx:21 a=4G6NA9xxw8l3yy4pmD5M:22 Received: from 75-166-76-94.hlrn.qwest.net ([75.166.76.94]:39396 helo=bapiya.Home) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1drA7n-0020eg-Cp; Sun, 10 Sep 2017 15:50:43 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA 8/8] Remove make_show_memory_breakpoints_cleanup Date: Sun, 10 Sep 2017 15:50:37 -0600 Message-Id: <20170910215037.24329-9-tom@tromey.com> In-Reply-To: <20170910215037.24329-1-tom@tromey.com> References: <20170910215037.24329-1-tom@tromey.com> X-BWhitelist: no X-Exim-ID: 1drA7n-0020eg-Cp X-Source-Sender: 75-166-76-94.hlrn.qwest.net (bapiya.Home) [75.166.76.94]:39396 X-Source-Auth: tom+tromey.com X-Email-Count: 9 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-Local-Domain: yes This removes make_show_memory_breakpoints_cleanup, replacing it with make_scoped_restore_show_memory_breakpoints and updating all callers. ChangeLog 2017-09-10 Tom Tromey * breakpoint.c (program_breakpoint_here_p): Update. * target.c (make_scoped_restore_show_memory_breakpoints): Rename from make_show_memory_breakpoints_cleanup. Return a scoped_restore_tmpl. (restore_show_memory_breakpoints): Remove. * ppc-linux-tdep.c (ppc_linux_memory_remove_breakpoint): Update. * mem-break.c (memory_validate_breakpoint): Update. * ia64-tdep.c (ia64_memory_insert_breakpoint): Update. (ia64_memory_remove_breakpoint): Update. (ia64_breakpoint_from_pc): Update. * target.h (make_scoped_restore_show_memory_breakpoints): Rename from make_show_memory_breakpoints_cleanup. --- gdb/ChangeLog | 15 +++++++++++++++ gdb/breakpoint.c | 6 ++---- gdb/ia64-tdep.c | 39 ++++++++++++++------------------------- gdb/mem-break.c | 10 +++------- gdb/ppc-linux-tdep.c | 5 ++--- gdb/target.c | 16 +++------------- gdb/target.h | 8 +++++--- 7 files changed, 44 insertions(+), 55 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index f757ab5..faec9a1 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,20 @@ 2017-09-10 Tom Tromey + * breakpoint.c (program_breakpoint_here_p): Update. + * target.c (make_scoped_restore_show_memory_breakpoints): Rename + from make_show_memory_breakpoints_cleanup. Return a + scoped_restore_tmpl. + (restore_show_memory_breakpoints): Remove. + * ppc-linux-tdep.c (ppc_linux_memory_remove_breakpoint): Update. + * mem-break.c (memory_validate_breakpoint): Update. + * ia64-tdep.c (ia64_memory_insert_breakpoint): Update. + (ia64_memory_remove_breakpoint): Update. + (ia64_breakpoint_from_pc): Update. + * target.h (make_scoped_restore_show_memory_breakpoints): Rename + from make_show_memory_breakpoints_cleanup. + +2017-09-10 Tom Tromey + * d-namespace.c (d_lookup_symbol): Use std::string. (find_symbol_in_baseclass): Likewise. diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 123420c..cf6e6e4 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -8994,7 +8994,6 @@ program_breakpoint_here_p (struct gdbarch *gdbarch, CORE_ADDR address) CORE_ADDR addr; const gdb_byte *bpoint; gdb_byte *target_mem; - struct cleanup *cleanup; int retval = 0; addr = address; @@ -9009,14 +9008,13 @@ program_breakpoint_here_p (struct gdbarch *gdbarch, CORE_ADDR address) /* Enable the automatic memory restoration from breakpoints while we read the memory. Otherwise we could say about our temporary breakpoints they are permanent. */ - cleanup = make_show_memory_breakpoints_cleanup (0); + scoped_restore restore_memory + = make_scoped_restore_show_memory_breakpoints (0); if (target_read_memory (address, target_mem, len) == 0 && memcmp (target_mem, bpoint, len) == 0) retval = 1; - do_cleanups (cleanup); - return retval; } diff --git a/gdb/ia64-tdep.c b/gdb/ia64-tdep.c index 5fc32a8..222bb33 100644 --- a/gdb/ia64-tdep.c +++ b/gdb/ia64-tdep.c @@ -644,7 +644,6 @@ ia64_memory_insert_breakpoint (struct gdbarch *gdbarch, long long instr_breakpoint; int val; int templ; - struct cleanup *cleanup; if (slotnum > 2) error (_("Can't insert breakpoint for slot numbers greater than 2.")); @@ -656,13 +655,11 @@ ia64_memory_insert_breakpoint (struct gdbarch *gdbarch, Otherwise, we could possibly store into the shadow parts of the adjacent placed breakpoints. It is due to our SHADOW_CONTENTS overlapping the real breakpoint instruction bits region. */ - cleanup = make_show_memory_breakpoints_cleanup (0); + scoped_restore restore_memory_0 + = make_scoped_restore_show_memory_breakpoints (0); val = target_read_memory (addr, bundle, BUNDLE_LEN); if (val != 0) - { - do_cleanups (cleanup); - return val; - } + return val; /* SHADOW_SLOTNUM saves the original slot number as expected by the caller for addressing the SHADOW_CONTENTS placement. */ @@ -703,13 +700,11 @@ ia64_memory_insert_breakpoint (struct gdbarch *gdbarch, restoration mechanism kicks in and we would possibly remove parts of the adjacent placed breakpoints. It is due to our SHADOW_CONTENTS overlapping the real breakpoint instruction bits region. */ - make_show_memory_breakpoints_cleanup (1); + scoped_restore restore_memory_1 + = make_scoped_restore_show_memory_breakpoints (1); val = target_read_memory (addr, bundle, BUNDLE_LEN); if (val != 0) - { - do_cleanups (cleanup); - return val; - } + return val; /* Breakpoints already present in the code will get deteacted and not get reinserted by bp_loc_is_permanent. Multiple breakpoints at the same @@ -725,7 +720,6 @@ ia64_memory_insert_breakpoint (struct gdbarch *gdbarch, val = target_write_memory (addr + shadow_slotnum, bundle + shadow_slotnum, bp_tgt->shadow_len); - do_cleanups (cleanup); return val; } @@ -739,7 +733,6 @@ ia64_memory_remove_breakpoint (struct gdbarch *gdbarch, long long instr_breakpoint, instr_saved; int val; int templ; - struct cleanup *cleanup; addr &= ~0x0f; @@ -748,13 +741,11 @@ ia64_memory_remove_breakpoint (struct gdbarch *gdbarch, mechanism kicks in and we would possibly remove parts of the adjacent placed breakpoints. It is due to our SHADOW_CONTENTS overlapping the real breakpoint instruction bits region. */ - cleanup = make_show_memory_breakpoints_cleanup (1); + scoped_restore restore_memory_1 + = make_scoped_restore_show_memory_breakpoints (1); val = target_read_memory (addr, bundle_mem, BUNDLE_LEN); if (val != 0) - { - do_cleanups (cleanup); - return val; - } + return val; /* SHADOW_SLOTNUM saves the original slot number as expected by the caller for addressing the SHADOW_CONTENTS placement. */ @@ -772,7 +763,6 @@ ia64_memory_remove_breakpoint (struct gdbarch *gdbarch, warning (_("Cannot remove breakpoint at address %s from non-existing " "X-type slot, memory has changed underneath"), paddress (gdbarch, bp_tgt->placed_address)); - do_cleanups (cleanup); return -1; } if (template_encoding_table[templ][slotnum] == L) @@ -792,7 +782,6 @@ ia64_memory_remove_breakpoint (struct gdbarch *gdbarch, warning (_("Cannot remove breakpoint at address %s, " "no break instruction at such address."), paddress (gdbarch, bp_tgt->placed_address)); - do_cleanups (cleanup); return -1; } @@ -808,7 +797,6 @@ ia64_memory_remove_breakpoint (struct gdbarch *gdbarch, replace_slotN_contents (bundle_mem, instr_saved, slotnum); val = target_write_raw_memory (addr, bundle_mem, BUNDLE_LEN); - do_cleanups (cleanup); return val; } @@ -837,7 +825,6 @@ ia64_breakpoint_from_pc (struct gdbarch *gdbarch, long long instr_fetched; int val; int templ; - struct cleanup *cleanup; if (slotnum > 2) error (_("Can't insert breakpoint for slot numbers greater than 2.")); @@ -846,9 +833,11 @@ ia64_breakpoint_from_pc (struct gdbarch *gdbarch, /* Enable the automatic memory restoration from breakpoints while we read our instruction bundle to match bp_loc_is_permanent. */ - cleanup = make_show_memory_breakpoints_cleanup (0); - val = target_read_memory (addr, bundle, BUNDLE_LEN); - do_cleanups (cleanup); + { + scoped_restore restore_memory_0 + = make_scoped_restore_show_memory_breakpoints (0); + val = target_read_memory (addr, bundle, BUNDLE_LEN); + } /* The memory might be unreachable. This can happen, for instance, when the user inserts a breakpoint at an invalid address. */ diff --git a/gdb/mem-break.c b/gdb/mem-break.c index e35d0a5..8e2debf 100644 --- a/gdb/mem-break.c +++ b/gdb/mem-break.c @@ -107,8 +107,6 @@ memory_validate_breakpoint (struct gdbarch *gdbarch, int val; int bplen; gdb_byte cur_contents[BREAKPOINT_MAX]; - struct cleanup *cleanup; - int ret; /* Determine appropriate breakpoint contents and size for this address. */ @@ -118,14 +116,12 @@ memory_validate_breakpoint (struct gdbarch *gdbarch, return 0; /* Make sure we see the memory breakpoints. */ - cleanup = make_show_memory_breakpoints_cleanup (1); + scoped_restore restore_memory + = make_scoped_restore_show_memory_breakpoints (1); val = target_read_memory (addr, cur_contents, bplen); /* If our breakpoint is no longer at the address, this means that the program modified the code on us, so it is wrong to put back the old value. */ - ret = (val == 0 && memcmp (bp, cur_contents, bplen) == 0); - - do_cleanups (cleanup); - return ret; + return (val == 0 && memcmp (bp, cur_contents, bplen) == 0); } diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c index b6e5362..df664ea 100644 --- a/gdb/ppc-linux-tdep.c +++ b/gdb/ppc-linux-tdep.c @@ -218,13 +218,13 @@ ppc_linux_memory_remove_breakpoint (struct gdbarch *gdbarch, int val; int bplen; gdb_byte old_contents[BREAKPOINT_MAX]; - struct cleanup *cleanup; /* Determine appropriate breakpoint contents and size for this address. */ bp = gdbarch_breakpoint_from_pc (gdbarch, &addr, &bplen); /* Make sure we see the memory breakpoints. */ - cleanup = make_show_memory_breakpoints_cleanup (1); + scoped_restore restore_memory + = make_scoped_restore_show_memory_breakpoints (1); val = target_read_memory (addr, old_contents, bplen); /* If our breakpoint is no longer at the address, this means that the @@ -233,7 +233,6 @@ ppc_linux_memory_remove_breakpoint (struct gdbarch *gdbarch, if (val == 0 && memcmp (bp, old_contents, bplen) == 0) val = target_write_raw_memory (addr, bp_tgt->shadow_contents, bplen); - do_cleanups (cleanup); return val; } diff --git a/gdb/target.c b/gdb/target.c index 2f7f317..3e2b4d0 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -1302,20 +1302,10 @@ memory_xfer_partial (struct target_ops *ops, enum target_object object, return res; } -static void -restore_show_memory_breakpoints (void *arg) -{ - show_memory_breakpoints = (uintptr_t) arg; -} - -struct cleanup * -make_show_memory_breakpoints_cleanup (int show) +scoped_restore_tmpl +make_scoped_restore_show_memory_breakpoints (int show) { - int current = show_memory_breakpoints; - - show_memory_breakpoints = show; - return make_cleanup (restore_show_memory_breakpoints, - (void *) (uintptr_t) current); + return make_scoped_restore (&show_memory_breakpoints, show); } /* For docs see target.h, to_xfer_partial. */ diff --git a/gdb/target.h b/gdb/target.h index 796717f..a3f00ab 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -42,6 +42,7 @@ struct inferior; #include "infrun.h" /* For enum exec_direction_kind. */ #include "breakpoint.h" /* For enum bptype. */ +#include "common/scoped_restore.h" /* This include file defines the interface between the main part of the debugger, and the part which is target-specific, or @@ -2441,9 +2442,10 @@ extern int remote_timeout; -/* Set the show memory breakpoints mode to show, and installs a cleanup - to restore it back to the current value. */ -extern struct cleanup *make_show_memory_breakpoints_cleanup (int show); +/* Set the show memory breakpoints mode to show, and return a + scoped_restore to restore it back to the current value. */ +extern scoped_restore_tmpl + make_scoped_restore_show_memory_breakpoints (int show); extern int may_write_registers; extern int may_write_memory;