Remove make_show_memory_breakpoints_cleanup
This removes make_show_memory_breakpoints_cleanup, replacing it with make_scoped_restore_show_memory_breakpoints and updating all callers. ChangeLog 2017-09-11 Tom Tromey <tom@tromey.com> * 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<int>. (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.
This commit is contained in:
parent
8fbc99ef16
commit
cb85b21ba1
7 changed files with 46 additions and 58 deletions
|
@ -1,3 +1,18 @@
|
||||||
|
2017-09-11 Tom Tromey <tom@tromey.com>
|
||||||
|
|
||||||
|
* 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<int>.
|
||||||
|
(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-11 Tom Tromey <tom@tromey.com>
|
2017-09-11 Tom Tromey <tom@tromey.com>
|
||||||
|
|
||||||
* d-namespace.c (d_lookup_symbol): Use std::string.
|
* d-namespace.c (d_lookup_symbol): Use std::string.
|
||||||
|
|
|
@ -8994,8 +8994,6 @@ program_breakpoint_here_p (struct gdbarch *gdbarch, CORE_ADDR address)
|
||||||
CORE_ADDR addr;
|
CORE_ADDR addr;
|
||||||
const gdb_byte *bpoint;
|
const gdb_byte *bpoint;
|
||||||
gdb_byte *target_mem;
|
gdb_byte *target_mem;
|
||||||
struct cleanup *cleanup;
|
|
||||||
int retval = 0;
|
|
||||||
|
|
||||||
addr = address;
|
addr = address;
|
||||||
bpoint = gdbarch_breakpoint_from_pc (gdbarch, &addr, &len);
|
bpoint = gdbarch_breakpoint_from_pc (gdbarch, &addr, &len);
|
||||||
|
@ -9009,15 +9007,14 @@ program_breakpoint_here_p (struct gdbarch *gdbarch, CORE_ADDR address)
|
||||||
/* Enable the automatic memory restoration from breakpoints while
|
/* Enable the automatic memory restoration from breakpoints while
|
||||||
we read the memory. Otherwise we could say about our temporary
|
we read the memory. Otherwise we could say about our temporary
|
||||||
breakpoints they are permanent. */
|
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
|
if (target_read_memory (address, target_mem, len) == 0
|
||||||
&& memcmp (target_mem, bpoint, len) == 0)
|
&& memcmp (target_mem, bpoint, len) == 0)
|
||||||
retval = 1;
|
return 1;
|
||||||
|
|
||||||
do_cleanups (cleanup);
|
return 0;
|
||||||
|
|
||||||
return retval;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return 1 if LOC is pointing to a permanent breakpoint,
|
/* Return 1 if LOC is pointing to a permanent breakpoint,
|
||||||
|
|
|
@ -644,7 +644,6 @@ ia64_memory_insert_breakpoint (struct gdbarch *gdbarch,
|
||||||
long long instr_breakpoint;
|
long long instr_breakpoint;
|
||||||
int val;
|
int val;
|
||||||
int templ;
|
int templ;
|
||||||
struct cleanup *cleanup;
|
|
||||||
|
|
||||||
if (slotnum > 2)
|
if (slotnum > 2)
|
||||||
error (_("Can't insert breakpoint for slot numbers greater than 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
|
Otherwise, we could possibly store into the shadow parts of the adjacent
|
||||||
placed breakpoints. It is due to our SHADOW_CONTENTS overlapping the real
|
placed breakpoints. It is due to our SHADOW_CONTENTS overlapping the real
|
||||||
breakpoint instruction bits region. */
|
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);
|
val = target_read_memory (addr, bundle, BUNDLE_LEN);
|
||||||
if (val != 0)
|
if (val != 0)
|
||||||
{
|
return val;
|
||||||
do_cleanups (cleanup);
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* SHADOW_SLOTNUM saves the original slot number as expected by the caller
|
/* SHADOW_SLOTNUM saves the original slot number as expected by the caller
|
||||||
for addressing the SHADOW_CONTENTS placement. */
|
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
|
restoration mechanism kicks in and we would possibly remove parts of the
|
||||||
adjacent placed breakpoints. It is due to our SHADOW_CONTENTS overlapping
|
adjacent placed breakpoints. It is due to our SHADOW_CONTENTS overlapping
|
||||||
the real breakpoint instruction bits region. */
|
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);
|
val = target_read_memory (addr, bundle, BUNDLE_LEN);
|
||||||
if (val != 0)
|
if (val != 0)
|
||||||
{
|
return val;
|
||||||
do_cleanups (cleanup);
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Breakpoints already present in the code will get deteacted and not get
|
/* Breakpoints already present in the code will get deteacted and not get
|
||||||
reinserted by bp_loc_is_permanent. Multiple breakpoints at the same
|
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,
|
val = target_write_memory (addr + shadow_slotnum, bundle + shadow_slotnum,
|
||||||
bp_tgt->shadow_len);
|
bp_tgt->shadow_len);
|
||||||
|
|
||||||
do_cleanups (cleanup);
|
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -739,7 +733,6 @@ ia64_memory_remove_breakpoint (struct gdbarch *gdbarch,
|
||||||
long long instr_breakpoint, instr_saved;
|
long long instr_breakpoint, instr_saved;
|
||||||
int val;
|
int val;
|
||||||
int templ;
|
int templ;
|
||||||
struct cleanup *cleanup;
|
|
||||||
|
|
||||||
addr &= ~0x0f;
|
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
|
mechanism kicks in and we would possibly remove parts of the adjacent
|
||||||
placed breakpoints. It is due to our SHADOW_CONTENTS overlapping the real
|
placed breakpoints. It is due to our SHADOW_CONTENTS overlapping the real
|
||||||
breakpoint instruction bits region. */
|
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);
|
val = target_read_memory (addr, bundle_mem, BUNDLE_LEN);
|
||||||
if (val != 0)
|
if (val != 0)
|
||||||
{
|
return val;
|
||||||
do_cleanups (cleanup);
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* SHADOW_SLOTNUM saves the original slot number as expected by the caller
|
/* SHADOW_SLOTNUM saves the original slot number as expected by the caller
|
||||||
for addressing the SHADOW_CONTENTS placement. */
|
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 "
|
warning (_("Cannot remove breakpoint at address %s from non-existing "
|
||||||
"X-type slot, memory has changed underneath"),
|
"X-type slot, memory has changed underneath"),
|
||||||
paddress (gdbarch, bp_tgt->placed_address));
|
paddress (gdbarch, bp_tgt->placed_address));
|
||||||
do_cleanups (cleanup);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (template_encoding_table[templ][slotnum] == L)
|
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, "
|
warning (_("Cannot remove breakpoint at address %s, "
|
||||||
"no break instruction at such address."),
|
"no break instruction at such address."),
|
||||||
paddress (gdbarch, bp_tgt->placed_address));
|
paddress (gdbarch, bp_tgt->placed_address));
|
||||||
do_cleanups (cleanup);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -808,7 +797,6 @@ ia64_memory_remove_breakpoint (struct gdbarch *gdbarch,
|
||||||
replace_slotN_contents (bundle_mem, instr_saved, slotnum);
|
replace_slotN_contents (bundle_mem, instr_saved, slotnum);
|
||||||
val = target_write_raw_memory (addr, bundle_mem, BUNDLE_LEN);
|
val = target_write_raw_memory (addr, bundle_mem, BUNDLE_LEN);
|
||||||
|
|
||||||
do_cleanups (cleanup);
|
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -837,7 +825,6 @@ ia64_breakpoint_from_pc (struct gdbarch *gdbarch,
|
||||||
long long instr_fetched;
|
long long instr_fetched;
|
||||||
int val;
|
int val;
|
||||||
int templ;
|
int templ;
|
||||||
struct cleanup *cleanup;
|
|
||||||
|
|
||||||
if (slotnum > 2)
|
if (slotnum > 2)
|
||||||
error (_("Can't insert breakpoint for slot numbers greater than 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
|
/* Enable the automatic memory restoration from breakpoints while
|
||||||
we read our instruction bundle to match bp_loc_is_permanent. */
|
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);
|
scoped_restore restore_memory_0
|
||||||
do_cleanups (cleanup);
|
= 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,
|
/* The memory might be unreachable. This can happen, for instance,
|
||||||
when the user inserts a breakpoint at an invalid address. */
|
when the user inserts a breakpoint at an invalid address. */
|
||||||
|
|
|
@ -107,8 +107,6 @@ memory_validate_breakpoint (struct gdbarch *gdbarch,
|
||||||
int val;
|
int val;
|
||||||
int bplen;
|
int bplen;
|
||||||
gdb_byte cur_contents[BREAKPOINT_MAX];
|
gdb_byte cur_contents[BREAKPOINT_MAX];
|
||||||
struct cleanup *cleanup;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
/* Determine appropriate breakpoint contents and size for this
|
/* Determine appropriate breakpoint contents and size for this
|
||||||
address. */
|
address. */
|
||||||
|
@ -118,14 +116,12 @@ memory_validate_breakpoint (struct gdbarch *gdbarch,
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* Make sure we see the memory breakpoints. */
|
/* 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);
|
val = target_read_memory (addr, cur_contents, bplen);
|
||||||
|
|
||||||
/* If our breakpoint is no longer at the address, this means that
|
/* 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 program modified the code on us, so it is wrong to put back
|
||||||
the old value. */
|
the old value. */
|
||||||
ret = (val == 0 && memcmp (bp, cur_contents, bplen) == 0);
|
return (val == 0 && memcmp (bp, cur_contents, bplen) == 0);
|
||||||
|
|
||||||
do_cleanups (cleanup);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -218,13 +218,13 @@ ppc_linux_memory_remove_breakpoint (struct gdbarch *gdbarch,
|
||||||
int val;
|
int val;
|
||||||
int bplen;
|
int bplen;
|
||||||
gdb_byte old_contents[BREAKPOINT_MAX];
|
gdb_byte old_contents[BREAKPOINT_MAX];
|
||||||
struct cleanup *cleanup;
|
|
||||||
|
|
||||||
/* Determine appropriate breakpoint contents and size for this address. */
|
/* Determine appropriate breakpoint contents and size for this address. */
|
||||||
bp = gdbarch_breakpoint_from_pc (gdbarch, &addr, &bplen);
|
bp = gdbarch_breakpoint_from_pc (gdbarch, &addr, &bplen);
|
||||||
|
|
||||||
/* Make sure we see the memory breakpoints. */
|
/* 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);
|
val = target_read_memory (addr, old_contents, bplen);
|
||||||
|
|
||||||
/* If our breakpoint is no longer at the address, this means that the
|
/* 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)
|
if (val == 0 && memcmp (bp, old_contents, bplen) == 0)
|
||||||
val = target_write_raw_memory (addr, bp_tgt->shadow_contents, bplen);
|
val = target_write_raw_memory (addr, bp_tgt->shadow_contents, bplen);
|
||||||
|
|
||||||
do_cleanups (cleanup);
|
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
16
gdb/target.c
16
gdb/target.c
|
@ -1302,20 +1302,10 @@ memory_xfer_partial (struct target_ops *ops, enum target_object object,
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
scoped_restore_tmpl<int>
|
||||||
restore_show_memory_breakpoints (void *arg)
|
make_scoped_restore_show_memory_breakpoints (int show)
|
||||||
{
|
{
|
||||||
show_memory_breakpoints = (uintptr_t) arg;
|
return make_scoped_restore (&show_memory_breakpoints, show);
|
||||||
}
|
|
||||||
|
|
||||||
struct cleanup *
|
|
||||||
make_show_memory_breakpoints_cleanup (int show)
|
|
||||||
{
|
|
||||||
int current = show_memory_breakpoints;
|
|
||||||
|
|
||||||
show_memory_breakpoints = show;
|
|
||||||
return make_cleanup (restore_show_memory_breakpoints,
|
|
||||||
(void *) (uintptr_t) current);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* For docs see target.h, to_xfer_partial. */
|
/* For docs see target.h, to_xfer_partial. */
|
||||||
|
|
|
@ -42,6 +42,7 @@ struct inferior;
|
||||||
|
|
||||||
#include "infrun.h" /* For enum exec_direction_kind. */
|
#include "infrun.h" /* For enum exec_direction_kind. */
|
||||||
#include "breakpoint.h" /* For enum bptype. */
|
#include "breakpoint.h" /* For enum bptype. */
|
||||||
|
#include "common/scoped_restore.h"
|
||||||
|
|
||||||
/* This include file defines the interface between the main part
|
/* This include file defines the interface between the main part
|
||||||
of the debugger, and the part which is target-specific, or
|
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
|
/* Set the show memory breakpoints mode to show, and return a
|
||||||
to restore it back to the current value. */
|
scoped_restore to restore it back to the current value. */
|
||||||
extern struct cleanup *make_show_memory_breakpoints_cleanup (int show);
|
extern scoped_restore_tmpl<int>
|
||||||
|
make_scoped_restore_show_memory_breakpoints (int show);
|
||||||
|
|
||||||
extern int may_write_registers;
|
extern int may_write_registers;
|
||||||
extern int may_write_memory;
|
extern int may_write_memory;
|
||||||
|
|
Loading…
Add table
Reference in a new issue