This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFC 01/32] add "this" pointers to more target APIs
- From: Tom Tromey <tromey at redhat dot com>
- To: gdb-patches at sourceware dot org
- Cc: Tom Tromey <tromey at redhat dot com>
- Date: Mon, 13 Jan 2014 12:12:16 -0700
- Subject: [RFC 01/32] add "this" pointers to more target APIs
- Authentication-results: sourceware.org; auth=none
- References: <1389640367-5571-1-git-send-email-tromey at redhat dot com>
A subsequent pass introduces delegation helper functions to the target
API. This delegation is much cleaner if the target_ops pointer is
directly available at delegation time.
This patch adds the "this" pointer to various to_* methods for this
purpose.
This updates a number of ports which I am unable to test. Please give
them a look-over. Any possible problem here is trivial, though, as
all that is required is adding an argument to a function.
2014-01-08 Tom Tromey <tromey@redhat.com>
* aarch64-linux-nat.c (aarch64_linux_stopped_by_watchpoint):
Add 'ops' argument.
* arm-linux-nat.c (arm_linux_stopped_by_watchpoint): Add
'ops' argument.
* corelow.c (ignore): Add 'ops' argument.
* exec.c (ignore): Add 'ops' argument.
* i386-nat.c (i386_stopped_by_watchpoint): Add 'ops' argument.
* ia64-linux-nat.c (ia64_linux_stopped_by_watchpoint): Add
'ops' argument.
* inf-ttrace.c (inf_ttrace_stopped_by_watchpoint): Add 'ops'
argument.
* linux-nat.c (save_sigtrap): Update.
(linux_nat_stopped_by_watchpoint, linux_nat_is_async_p)
(linux_nat_can_async_p, linux_nat_async): Add 'ops' argument.
(linux_nat_close): Update.
* mem-break.c (memory_insert_breakpoint, memory_remove_breakpoint):
Add 'ops' argument.
* mips-linux-nat.c (mips_linux_stopped_by_watchpoint): Add 'ops'
argument.
* monitor.c (monitor_insert_breakpoint, monitor_remove_breakpoint):
Add 'ops' argument.
* nto-procfs.c (procfs_insert_breakpoint, procfs_remove_breakpoint)
(procfs_stopped_by_watchpoint): Add 'ops' argument.
* ppc-linux-nat.c (ppc_linux_stopped_by_watchpoint): Add 'ops'
argument.
* procfs.c (procfs_stopped_by_watchpoint): Add 'ops' argument.
* record-full.c (record_full_beneath_to_insert_breakpoint)
(record_full_beneath_to_remove_breakpoint)
(record_full_beneath_to_stopped_by_watchpoint)
(record_full_beneath_to_async, tmp_to_insert_breakpoint)
(tmp_to_remove_breakpoint, tmp_to_stopped_by_watchpoint)
(tmp_to_async): Add 'ops' argument.
(record_full_stopped_by_watchpoint, record_full_insert_breakpoint)
(record_full_remove_breakpoint, record_full_async)
(record_full_can_async_p, record_full_is_async_p)
(record_full_core_insert_breakpoint)
(record_full_core_remove_breakpoint): Add 'ops' argument.
* remote-m32r-sdi.c (m32r_insert_breakpoint, m32r_remove_breakpoint)
(m32r_stopped_by_watchpoint): Add 'ops' argument.
* remote-mips.c (mips_insert_breakpoint, mips_remove_breakpoint)
(mips_stopped_by_watchpoint): Add 'ops' argument.
* remote.c (remote_insert_breakpoint, remote_remove_breakpoint)
(remote_stopped_by_watchpoint_p, remote_can_async_p)
(remote_is_async_p, remote_async): Add 'ops' argument.
* s390-nat.c (s390_stopped_by_watchpoint): Add 'ops' argument.
* target.c (update_current_target)
(target_insert_breakpoint, target_remove_breakpoint)
(find_default_can_async_p, find_default_is_async_p): Update.
(init_dummy_target): Update.
(debug_to_insert_breakpoint, debug_to_remove_breakpoint)
(debug_to_stopped_by_watchpoint): Add 'ops' argument.
* target.h (struct target_ops) <to_insert_breakpoint,
to_remove_breakpoint, to_stopped_by_watchpoint, to_can_async_p,
to_is_async_p, to_async>: Add 'ops' argument.
(target_can_async_p, target_is_async_p, target_async)
(target_stopped_by_watchpoint): Update.
(memory_remove_breakpoint, memory_insert_breakpoint): Add 'ops'
argument.
---
gdb/ChangeLog | 61 +++++++++++++++++++++++++++++++++++++++++++++++++
gdb/aarch64-linux-nat.c | 4 ++--
gdb/arm-linux-nat.c | 4 ++--
gdb/corelow.c | 3 ++-
gdb/exec.c | 3 ++-
gdb/i386-nat.c | 4 ++--
gdb/ia64-linux-nat.c | 4 ++--
gdb/inf-ttrace.c | 2 +-
gdb/linux-nat.c | 22 ++++++++----------
gdb/mem-break.c | 6 +++--
gdb/mips-linux-nat.c | 2 +-
gdb/monitor.c | 6 +++--
gdb/nto-procfs.c | 10 ++++----
gdb/ppc-linux-nat.c | 4 ++--
gdb/procfs.c | 2 +-
gdb/record-full.c | 58 +++++++++++++++++++++++++++++-----------------
gdb/remote-m32r-sdi.c | 8 ++++---
gdb/remote-mips.c | 12 ++++++----
gdb/remote.c | 34 +++++++++++++++------------
gdb/s390-linux-nat.c | 2 +-
gdb/target.c | 45 ++++++++++++++++++------------------
gdb/target.h | 31 ++++++++++++++-----------
22 files changed, 212 insertions(+), 115 deletions(-)
diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c
index 256725b..5f4baa5 100644
--- a/gdb/aarch64-linux-nat.c
+++ b/gdb/aarch64-linux-nat.c
@@ -1473,11 +1473,11 @@ aarch64_linux_stopped_data_address (struct target_ops *target,
/* Implement the "to_stopped_by_watchpoint" target_ops method. */
static int
-aarch64_linux_stopped_by_watchpoint (void)
+aarch64_linux_stopped_by_watchpoint (struct target_ops *ops)
{
CORE_ADDR addr;
- return aarch64_linux_stopped_data_address (¤t_target, &addr);
+ return aarch64_linux_stopped_data_address (ops, &addr);
}
/* Implement the "to_watchpoint_addr_within_range" target_ops method. */
diff --git a/gdb/arm-linux-nat.c b/gdb/arm-linux-nat.c
index c43a7e4..0dc6e2a 100644
--- a/gdb/arm-linux-nat.c
+++ b/gdb/arm-linux-nat.c
@@ -1171,10 +1171,10 @@ arm_linux_stopped_data_address (struct target_ops *target, CORE_ADDR *addr_p)
/* Has the target been stopped by hitting a watchpoint? */
static int
-arm_linux_stopped_by_watchpoint (void)
+arm_linux_stopped_by_watchpoint (struct target_ops *ops)
{
CORE_ADDR addr;
- return arm_linux_stopped_data_address (¤t_target, &addr);
+ return arm_linux_stopped_data_address (ops, &addr);
}
static int
diff --git a/gdb/corelow.c b/gdb/corelow.c
index 2869eea..50f89cf 100644
--- a/gdb/corelow.c
+++ b/gdb/corelow.c
@@ -842,7 +842,8 @@ core_xfer_partial (struct target_ops *ops, enum target_object object,
breakpoint_init_inferior). */
static int
-ignore (struct gdbarch *gdbarch, struct bp_target_info *bp_tgt)
+ignore (struct target_ops *ops, struct gdbarch *gdbarch,
+ struct bp_target_info *bp_tgt)
{
return 0;
}
diff --git a/gdb/exec.c b/gdb/exec.c
index 38d2edb..70409d9 100644
--- a/gdb/exec.c
+++ b/gdb/exec.c
@@ -801,7 +801,8 @@ exec_set_section_address (const char *filename, int index, CORE_ADDR address)
breakpoint_init_inferior). */
static int
-ignore (struct gdbarch *gdbarch, struct bp_target_info *bp_tgt)
+ignore (struct target_ops *ops, struct gdbarch *gdbarch,
+ struct bp_target_info *bp_tgt)
{
return 0;
}
diff --git a/gdb/i386-nat.c b/gdb/i386-nat.c
index 0a5deb0..8d54ae0 100644
--- a/gdb/i386-nat.c
+++ b/gdb/i386-nat.c
@@ -756,10 +756,10 @@ i386_stopped_data_address (struct target_ops *ops, CORE_ADDR *addr_p)
}
static int
-i386_stopped_by_watchpoint (void)
+i386_stopped_by_watchpoint (struct target_ops *ops)
{
CORE_ADDR addr = 0;
- return i386_stopped_data_address (¤t_target, &addr);
+ return i386_stopped_data_address (ops, &addr);
}
/* Insert a hardware-assisted breakpoint at BP_TGT->placed_address.
diff --git a/gdb/ia64-linux-nat.c b/gdb/ia64-linux-nat.c
index edc1e23..51fbc81 100644
--- a/gdb/ia64-linux-nat.c
+++ b/gdb/ia64-linux-nat.c
@@ -669,10 +669,10 @@ ia64_linux_stopped_data_address (struct target_ops *ops, CORE_ADDR *addr_p)
}
static int
-ia64_linux_stopped_by_watchpoint (void)
+ia64_linux_stopped_by_watchpoint (struct target_ops *ops)
{
CORE_ADDR addr;
- return ia64_linux_stopped_data_address (¤t_target, &addr);
+ return ia64_linux_stopped_data_address (ops, &addr);
}
static int
diff --git a/gdb/inf-ttrace.c b/gdb/inf-ttrace.c
index eb0adcb..2193569 100644
--- a/gdb/inf-ttrace.c
+++ b/gdb/inf-ttrace.c
@@ -374,7 +374,7 @@ inf_ttrace_region_ok_for_hw_watchpoint (CORE_ADDR addr, int len)
by hitting a "hardware" watchpoint. */
static int
-inf_ttrace_stopped_by_watchpoint (void)
+inf_ttrace_stopped_by_watchpoint (struct target_ops *ops)
{
pid_t pid = ptid_get_pid (inferior_ptid);
lwpid_t lwpid = ptid_get_lwp (inferior_ptid);
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index d2091ca..6d839e6 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -268,10 +268,6 @@ async_file_mark (void)
be awakened anyway. */
}
-static void linux_nat_async (void (*callback)
- (enum inferior_event_type event_type,
- void *context),
- void *context);
static int kill_lwp (int lwpid, int signo);
static int stop_callback (struct lwp_info *lp, void *data);
@@ -2490,7 +2486,7 @@ save_sigtrap (struct lwp_info *lp)
old_chain = save_inferior_ptid ();
inferior_ptid = lp->ptid;
- lp->stopped_by_watchpoint = linux_ops->to_stopped_by_watchpoint ();
+ lp->stopped_by_watchpoint = linux_ops->to_stopped_by_watchpoint (linux_ops);
if (lp->stopped_by_watchpoint)
{
@@ -2508,7 +2504,7 @@ save_sigtrap (struct lwp_info *lp)
/* See save_sigtrap. */
static int
-linux_nat_stopped_by_watchpoint (void)
+linux_nat_stopped_by_watchpoint (struct target_ops *ops)
{
struct lwp_info *lp = find_lwp_pid (inferior_ptid);
@@ -4504,7 +4500,7 @@ linux_trad_target (CORE_ADDR (*register_u_offset)(struct gdbarch *, int, int))
/* target_is_async_p implementation. */
static int
-linux_nat_is_async_p (void)
+linux_nat_is_async_p (struct target_ops *ops)
{
/* NOTE: palves 2008-03-21: We're only async when the user requests
it explicitly with the "set target-async" command.
@@ -4515,7 +4511,7 @@ linux_nat_is_async_p (void)
/* target_can_async_p implementation. */
static int
-linux_nat_can_async_p (void)
+linux_nat_can_async_p (struct target_ops *ops)
{
/* NOTE: palves 2008-03-21: We're only async when the user requests
it explicitly with the "set target-async" command.
@@ -4675,8 +4671,10 @@ linux_async_pipe (int enable)
/* target_async implementation. */
static void
-linux_nat_async (void (*callback) (enum inferior_event_type event_type,
- void *context), void *context)
+linux_nat_async (struct target_ops *ops,
+ void (*callback) (enum inferior_event_type event_type,
+ void *context),
+ void *context)
{
if (callback != NULL)
{
@@ -4761,8 +4759,8 @@ static void
linux_nat_close (void)
{
/* Unregister from the event loop. */
- if (linux_nat_is_async_p ())
- linux_nat_async (NULL, 0);
+ if (linux_nat_is_async_p (linux_ops))
+ linux_nat_async (linux_ops, NULL, 0);
if (linux_ops->to_close)
linux_ops->to_close ();
diff --git a/gdb/mem-break.c b/gdb/mem-break.c
index f06c4ae..7af39d1 100644
--- a/gdb/mem-break.c
+++ b/gdb/mem-break.c
@@ -77,14 +77,16 @@ default_memory_remove_breakpoint (struct gdbarch *gdbarch,
int
-memory_insert_breakpoint (struct gdbarch *gdbarch,
+memory_insert_breakpoint (struct target_ops *ops,
+ struct gdbarch *gdbarch,
struct bp_target_info *bp_tgt)
{
return gdbarch_memory_insert_breakpoint (gdbarch, bp_tgt);
}
int
-memory_remove_breakpoint (struct gdbarch *gdbarch,
+memory_remove_breakpoint (struct target_ops *ops,
+ struct gdbarch *gdbarch,
struct bp_target_info *bp_tgt)
{
return gdbarch_memory_remove_breakpoint (gdbarch, bp_tgt);
diff --git a/gdb/mips-linux-nat.c b/gdb/mips-linux-nat.c
index 9246741..2285b4b 100644
--- a/gdb/mips-linux-nat.c
+++ b/gdb/mips-linux-nat.c
@@ -553,7 +553,7 @@ mips_linux_can_use_hw_breakpoint (int type, int cnt, int ot)
register triggered. */
static int
-mips_linux_stopped_by_watchpoint (void)
+mips_linux_stopped_by_watchpoint (struct target_ops *ops)
{
int n;
int num_valid;
diff --git a/gdb/monitor.c b/gdb/monitor.c
index 2d94d42..248109a 100644
--- a/gdb/monitor.c
+++ b/gdb/monitor.c
@@ -2095,7 +2095,8 @@ monitor_mourn_inferior (struct target_ops *ops)
/* Tell the monitor to add a breakpoint. */
static int
-monitor_insert_breakpoint (struct gdbarch *gdbarch,
+monitor_insert_breakpoint (struct target_ops *ops,
+ struct gdbarch *gdbarch,
struct bp_target_info *bp_tgt)
{
CORE_ADDR addr = bp_tgt->placed_address;
@@ -2132,7 +2133,8 @@ monitor_insert_breakpoint (struct gdbarch *gdbarch,
/* Tell the monitor to remove a breakpoint. */
static int
-monitor_remove_breakpoint (struct gdbarch *gdbarch,
+monitor_remove_breakpoint (struct target_ops *ops,
+ struct gdbarch *gdbarch,
struct bp_target_info *bp_tgt)
{
CORE_ADDR addr = bp_tgt->placed_address;
diff --git a/gdb/nto-procfs.c b/gdb/nto-procfs.c
index 1c2f298..4e3d2d2 100644
--- a/gdb/nto-procfs.c
+++ b/gdb/nto-procfs.c
@@ -75,7 +75,7 @@ static int procfs_insert_hw_watchpoint (CORE_ADDR addr, int len, int type,
static int procfs_remove_hw_watchpoint (CORE_ADDR addr, int len, int type,
struct expression *cond);
-static int procfs_stopped_by_watchpoint (void);
+static int procfs_stopped_by_watchpoint (struct target_ops *ops);
/* These two globals are only ever set in procfs_open(), but are
referenced elsewhere. 'nto_procfs_node' is a flag used to say
@@ -922,14 +922,16 @@ procfs_breakpoint (CORE_ADDR addr, int type, int size)
}
static int
-procfs_insert_breakpoint (struct gdbarch *gdbarch,
+procfs_insert_breakpoint (struct target_ops *ops,
+ struct gdbarch *gdbarch,
struct bp_target_info *bp_tgt)
{
return procfs_breakpoint (bp_tgt->placed_address, _DEBUG_BREAK_EXEC, 0);
}
static int
-procfs_remove_breakpoint (struct gdbarch *gdbarch,
+procfs_remove_breakpoint (struct target_ops *ops,
+ struct gdbarch *gdbarch,
struct bp_target_info *bp_tgt)
{
return procfs_breakpoint (bp_tgt->placed_address, _DEBUG_BREAK_EXEC, -1);
@@ -1508,7 +1510,7 @@ procfs_insert_hw_watchpoint (CORE_ADDR addr, int len, int type,
}
static int
-procfs_stopped_by_watchpoint (void)
+procfs_stopped_by_watchpoint (struct target_ops *ops)
{
return 0;
}
diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c
index d6820be..82ed2c6 100644
--- a/gdb/ppc-linux-nat.c
+++ b/gdb/ppc-linux-nat.c
@@ -2283,10 +2283,10 @@ ppc_linux_stopped_data_address (struct target_ops *target, CORE_ADDR *addr_p)
}
static int
-ppc_linux_stopped_by_watchpoint (void)
+ppc_linux_stopped_by_watchpoint (struct target_ops *ops)
{
CORE_ADDR addr;
- return ppc_linux_stopped_data_address (¤t_target, &addr);
+ return ppc_linux_stopped_data_address (ops, &addr);
}
static int
diff --git a/gdb/procfs.c b/gdb/procfs.c
index ef9bb3d..40a5dd5 100644
--- a/gdb/procfs.c
+++ b/gdb/procfs.c
@@ -4861,7 +4861,7 @@ procfs_can_use_hw_breakpoint (int type, int cnt, int othertype)
fault, else returns zero. */
static int
-procfs_stopped_by_watchpoint (void)
+procfs_stopped_by_watchpoint (struct target_ops *ops)
{
procinfo *pi;
diff --git a/gdb/record-full.c b/gdb/record-full.c
index f9af408..f4d760a 100644
--- a/gdb/record-full.c
+++ b/gdb/record-full.c
@@ -237,16 +237,19 @@ static LONGEST
ULONGEST offset,
LONGEST len);
static int
- (*record_full_beneath_to_insert_breakpoint) (struct gdbarch *,
+ (*record_full_beneath_to_insert_breakpoint) (struct target_ops *,
+ struct gdbarch *,
struct bp_target_info *);
static int
- (*record_full_beneath_to_remove_breakpoint) (struct gdbarch *,
+ (*record_full_beneath_to_remove_breakpoint) (struct target_ops *,
+ struct gdbarch *,
struct bp_target_info *);
-static int (*record_full_beneath_to_stopped_by_watchpoint) (void);
+static int (*record_full_beneath_to_stopped_by_watchpoint) (struct target_ops *);
static int (*record_full_beneath_to_stopped_data_address) (struct target_ops *,
CORE_ADDR *);
static void
- (*record_full_beneath_to_async) (void (*) (enum inferior_event_type, void *),
+ (*record_full_beneath_to_async) (struct target_ops *,
+ void (*) (enum inferior_event_type, void *),
void *);
static void record_full_goto_insn (struct record_full_entry *entry,
@@ -814,14 +817,16 @@ static LONGEST (*tmp_to_xfer_partial) (struct target_ops *ops,
const gdb_byte *writebuf,
ULONGEST offset,
LONGEST len);
-static int (*tmp_to_insert_breakpoint) (struct gdbarch *,
+static int (*tmp_to_insert_breakpoint) (struct target_ops *,
+ struct gdbarch *,
struct bp_target_info *);
-static int (*tmp_to_remove_breakpoint) (struct gdbarch *,
+static int (*tmp_to_remove_breakpoint) (struct target_ops *ops,
+ struct gdbarch *,
struct bp_target_info *);
-static int (*tmp_to_stopped_by_watchpoint) (void);
+static int (*tmp_to_stopped_by_watchpoint) (struct target_ops *);
static int (*tmp_to_stopped_data_address) (struct target_ops *, CORE_ADDR *);
-static int (*tmp_to_stopped_data_address) (struct target_ops *, CORE_ADDR *);
-static void (*tmp_to_async) (void (*) (enum inferior_event_type, void *), void *);
+static void (*tmp_to_async) (struct target_ops *,
+ void (*) (enum inferior_event_type, void *), void *);
static void record_full_restore (void);
@@ -1510,12 +1515,16 @@ record_full_wait (struct target_ops *ops,
}
static int
-record_full_stopped_by_watchpoint (void)
+record_full_stopped_by_watchpoint (struct target_ops *ops)
{
if (RECORD_FULL_IS_REPLAY)
return record_full_hw_watchpoint;
else
- return record_full_beneath_to_stopped_by_watchpoint ();
+ {
+ struct target_ops *beneath = find_target_beneath (ops);
+
+ return record_full_beneath_to_stopped_by_watchpoint (beneath);
+ }
}
static int
@@ -1758,7 +1767,8 @@ record_full_init_record_breakpoints (void)
when recording. */
static int
-record_full_insert_breakpoint (struct gdbarch *gdbarch,
+record_full_insert_breakpoint (struct target_ops *ops,
+ struct gdbarch *gdbarch,
struct bp_target_info *bp_tgt)
{
struct record_full_breakpoint *bp;
@@ -1775,7 +1785,8 @@ record_full_insert_breakpoint (struct gdbarch *gdbarch,
int ret;
old_cleanups = record_full_gdb_operation_disable_set ();
- ret = record_full_beneath_to_insert_breakpoint (gdbarch, bp_tgt);
+ ret = record_full_beneath_to_insert_breakpoint (find_target_beneath (ops),
+ gdbarch, bp_tgt);
do_cleanups (old_cleanups);
if (ret != 0)
@@ -1795,7 +1806,8 @@ record_full_insert_breakpoint (struct gdbarch *gdbarch,
/* "to_remove_breakpoint" method for process record target. */
static int
-record_full_remove_breakpoint (struct gdbarch *gdbarch,
+record_full_remove_breakpoint (struct target_ops *ops,
+ struct gdbarch *gdbarch,
struct bp_target_info *bp_tgt)
{
struct record_full_breakpoint *bp;
@@ -1815,7 +1827,8 @@ record_full_remove_breakpoint (struct gdbarch *gdbarch,
int ret;
old_cleanups = record_full_gdb_operation_disable_set ();
- ret = record_full_beneath_to_remove_breakpoint (gdbarch, bp_tgt);
+ ret = record_full_beneath_to_remove_breakpoint (find_target_beneath (ops),
+ gdbarch, bp_tgt);
do_cleanups (old_cleanups);
if (ret != 0)
@@ -1890,25 +1903,26 @@ record_full_goto_bookmark (gdb_byte *raw_bookmark, int from_tty)
}
static void
-record_full_async (void (*callback) (enum inferior_event_type event_type,
+record_full_async (struct target_ops *ops,
+ void (*callback) (enum inferior_event_type event_type,
void *context), void *context)
{
/* If we're on top of a line target (e.g., linux-nat, remote), then
set it to async mode as well. Will be NULL if we're sitting on
top of the core target, for "record restore". */
if (record_full_beneath_to_async != NULL)
- record_full_beneath_to_async (callback, context);
+ record_full_beneath_to_async (find_target_beneath (ops), callback, context);
}
static int
-record_full_can_async_p (void)
+record_full_can_async_p (struct target_ops *ops)
{
/* We only enable async when the user specifically asks for it. */
return target_async_permitted;
}
static int
-record_full_is_async_p (void)
+record_full_is_async_p (struct target_ops *ops)
{
/* We only enable async when the user specifically asks for it. */
return target_async_permitted;
@@ -2264,7 +2278,8 @@ record_full_core_xfer_partial (struct target_ops *ops,
/* "to_insert_breakpoint" method for prec over corefile. */
static int
-record_full_core_insert_breakpoint (struct gdbarch *gdbarch,
+record_full_core_insert_breakpoint (struct target_ops *ops,
+ struct gdbarch *gdbarch,
struct bp_target_info *bp_tgt)
{
return 0;
@@ -2273,7 +2288,8 @@ record_full_core_insert_breakpoint (struct gdbarch *gdbarch,
/* "to_remove_breakpoint" method for prec over corefile. */
static int
-record_full_core_remove_breakpoint (struct gdbarch *gdbarch,
+record_full_core_remove_breakpoint (struct target_ops *ops,
+ struct gdbarch *gdbarch,
struct bp_target_info *bp_tgt)
{
return 0;
diff --git a/gdb/remote-m32r-sdi.c b/gdb/remote-m32r-sdi.c
index e81b2de..a127b8a 100644
--- a/gdb/remote-m32r-sdi.c
+++ b/gdb/remote-m32r-sdi.c
@@ -1145,7 +1145,8 @@ m32r_mourn_inferior (struct target_ops *ops)
}
static int
-m32r_insert_breakpoint (struct gdbarch *gdbarch,
+m32r_insert_breakpoint (struct target_ops *ops,
+ struct gdbarch *gdbarch,
struct bp_target_info *bp_tgt)
{
CORE_ADDR addr = bp_tgt->placed_address;
@@ -1189,7 +1190,8 @@ m32r_insert_breakpoint (struct gdbarch *gdbarch,
}
static int
-m32r_remove_breakpoint (struct gdbarch *gdbarch,
+m32r_remove_breakpoint (struct target_ops *ops,
+ struct gdbarch *gdbarch,
struct bp_target_info *bp_tgt)
{
CORE_ADDR addr = bp_tgt->placed_address;
@@ -1476,7 +1478,7 @@ m32r_stopped_data_address (struct target_ops *target, CORE_ADDR *addr_p)
}
static int
-m32r_stopped_by_watchpoint (void)
+m32r_stopped_by_watchpoint (struct target_ops *ops)
{
CORE_ADDR addr;
diff --git a/gdb/remote-mips.c b/gdb/remote-mips.c
index e4e5083..44d127a 100644
--- a/gdb/remote-mips.c
+++ b/gdb/remote-mips.c
@@ -2362,27 +2362,29 @@ mips_mourn_inferior (struct target_ops *ops)
target contents. */
static int
-mips_insert_breakpoint (struct gdbarch *gdbarch,
+mips_insert_breakpoint (struct target_ops *ops,
+ struct gdbarch *gdbarch,
struct bp_target_info *bp_tgt)
{
if (monitor_supports_breakpoints)
return mips_set_breakpoint (bp_tgt->placed_address, MIPS_INSN32_SIZE,
BREAK_FETCH);
else
- return memory_insert_breakpoint (gdbarch, bp_tgt);
+ return memory_insert_breakpoint (ops, gdbarch, bp_tgt);
}
/* Remove a breakpoint. */
static int
-mips_remove_breakpoint (struct gdbarch *gdbarch,
+mips_remove_breakpoint (struct target_ops *ops,
+ struct gdbarch *gdbarch,
struct bp_target_info *bp_tgt)
{
if (monitor_supports_breakpoints)
return mips_clear_breakpoint (bp_tgt->placed_address, MIPS_INSN32_SIZE,
BREAK_FETCH);
else
- return memory_remove_breakpoint (gdbarch, bp_tgt);
+ return memory_remove_breakpoint (ops, gdbarch, bp_tgt);
}
/* Tell whether this target can support a hardware breakpoint. CNT
@@ -2449,7 +2451,7 @@ mips_remove_watchpoint (CORE_ADDR addr, int len, int type,
if not. */
static int
-mips_stopped_by_watchpoint (void)
+mips_stopped_by_watchpoint (struct target_ops *ops)
{
return hit_watchpoint;
}
diff --git a/gdb/remote.c b/gdb/remote.c
index 2ac8c36..a91e6aa 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -126,12 +126,14 @@ static void remote_kill (struct target_ops *ops);
static int tohex (int nib);
-static int remote_can_async_p (void);
+static int remote_can_async_p (struct target_ops *);
-static int remote_is_async_p (void);
+static int remote_is_async_p (struct target_ops *);
-static void remote_async (void (*callback) (enum inferior_event_type event_type,
- void *context), void *context);
+static void remote_async (struct target_ops *ops,
+ void (*callback) (enum inferior_event_type event_type,
+ void *context),
+ void *context);
static void sync_remote_interrupt_twice (int signo);
@@ -8204,7 +8206,8 @@ remote_add_target_side_commands (struct gdbarch *gdbarch,
which don't, we insert a traditional memory breakpoint. */
static int
-remote_insert_breakpoint (struct gdbarch *gdbarch,
+remote_insert_breakpoint (struct target_ops *ops,
+ struct gdbarch *gdbarch,
struct bp_target_info *bp_tgt)
{
/* Try the "Z" s/w breakpoint packet if it is not already disabled.
@@ -8260,11 +8263,12 @@ remote_insert_breakpoint (struct gdbarch *gdbarch,
}
}
- return memory_insert_breakpoint (gdbarch, bp_tgt);
+ return memory_insert_breakpoint (ops, gdbarch, bp_tgt);
}
static int
-remote_remove_breakpoint (struct gdbarch *gdbarch,
+remote_remove_breakpoint (struct target_ops *ops,
+ struct gdbarch *gdbarch,
struct bp_target_info *bp_tgt)
{
CORE_ADDR addr = bp_tgt->placed_address;
@@ -8294,7 +8298,7 @@ remote_remove_breakpoint (struct gdbarch *gdbarch,
return (rs->buf[0] == 'E');
}
- return memory_remove_breakpoint (gdbarch, bp_tgt);
+ return memory_remove_breakpoint (ops, gdbarch, bp_tgt);
}
static int
@@ -8448,7 +8452,7 @@ remote_check_watch_resources (int type, int cnt, int ot)
}
static int
-remote_stopped_by_watchpoint (void)
+remote_stopped_by_watchpoint (struct target_ops *ops)
{
struct remote_state *rs = get_remote_state ();
@@ -8461,7 +8465,7 @@ remote_stopped_data_address (struct target_ops *target, CORE_ADDR *addr_p)
struct remote_state *rs = get_remote_state ();
int rc = 0;
- if (remote_stopped_by_watchpoint ())
+ if (remote_stopped_by_watchpoint (target))
{
*addr_p = rs->remote_watch_data_address;
rc = 1;
@@ -11629,7 +11633,7 @@ Specify the serial device it is connected to (e.g. /dev/ttya).";
}
static int
-remote_can_async_p (void)
+remote_can_async_p (struct target_ops *ops)
{
struct remote_state *rs = get_remote_state ();
@@ -11642,7 +11646,7 @@ remote_can_async_p (void)
}
static int
-remote_is_async_p (void)
+remote_is_async_p (struct target_ops *ops)
{
struct remote_state *rs = get_remote_state ();
@@ -11677,8 +11681,10 @@ remote_async_inferior_event_handler (gdb_client_data data)
}
static void
-remote_async (void (*callback) (enum inferior_event_type event_type,
- void *context), void *context)
+remote_async (struct target_ops *ops,
+ void (*callback) (enum inferior_event_type event_type,
+ void *context),
+ void *context)
{
struct remote_state *rs = get_remote_state ();
diff --git a/gdb/s390-linux-nat.c b/gdb/s390-linux-nat.c
index cf3f7d7..5fb342f 100644
--- a/gdb/s390-linux-nat.c
+++ b/gdb/s390-linux-nat.c
@@ -433,7 +433,7 @@ struct watch_area
static struct watch_area *watch_base = NULL;
static int
-s390_stopped_by_watchpoint (void)
+s390_stopped_by_watchpoint (struct target_ops *ops)
{
per_lowcore_bits per_lowcore;
ptrace_area parea;
diff --git a/gdb/target.c b/gdb/target.c
index 85b5037..092d50c 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -95,12 +95,6 @@ static void debug_to_prepare_to_store (struct regcache *);
static void debug_to_files_info (struct target_ops *);
-static int debug_to_insert_breakpoint (struct gdbarch *,
- struct bp_target_info *);
-
-static int debug_to_remove_breakpoint (struct gdbarch *,
- struct bp_target_info *);
-
static int debug_to_can_use_hw_breakpoint (int, int, int);
static int debug_to_insert_hw_breakpoint (struct gdbarch *,
@@ -115,8 +109,6 @@ static int debug_to_insert_watchpoint (CORE_ADDR, int, int,
static int debug_to_remove_watchpoint (CORE_ADDR, int, int,
struct expression *);
-static int debug_to_stopped_by_watchpoint (void);
-
static int debug_to_stopped_data_address (struct target_ops *, CORE_ADDR *);
static int debug_to_watchpoint_addr_within_range (struct target_ops *,
@@ -751,7 +743,7 @@ update_current_target (void)
(int (*) (CORE_ADDR, int, int, struct expression *))
return_minus_one);
de_fault (to_stopped_by_watchpoint,
- (int (*) (void))
+ (int (*) (struct target_ops *))
return_zero);
de_fault (to_stopped_data_address,
(int (*) (struct target_ops *, CORE_ADDR *))
@@ -829,7 +821,9 @@ update_current_target (void)
(char *(*) (int))
return_zero);
de_fault (to_async,
- (void (*) (void (*) (enum inferior_event_type, void*), void*))
+ (void (*) (struct target_ops *,
+ void (*) (enum inferior_event_type, void*),
+ void*))
tcomplain);
de_fault (to_thread_architecture,
default_thread_architecture);
@@ -2472,7 +2466,8 @@ target_insert_breakpoint (struct gdbarch *gdbarch,
return 1;
}
- return (*current_target.to_insert_breakpoint) (gdbarch, bp_tgt);
+ return (*current_target.to_insert_breakpoint) (¤t_target,
+ gdbarch, bp_tgt);
}
int
@@ -2489,7 +2484,8 @@ target_remove_breakpoint (struct gdbarch *gdbarch,
return 1;
}
- return (*current_target.to_remove_breakpoint) (gdbarch, bp_tgt);
+ return (*current_target.to_remove_breakpoint) (¤t_target,
+ gdbarch, bp_tgt);
}
static void
@@ -3141,7 +3137,7 @@ find_default_create_inferior (struct target_ops *ops,
}
static int
-find_default_can_async_p (void)
+find_default_can_async_p (struct target_ops *ignore)
{
struct target_ops *t;
@@ -3151,12 +3147,12 @@ find_default_can_async_p (void)
connected yet. */
t = find_default_run_target (NULL);
if (t && t->to_can_async_p)
- return (t->to_can_async_p) ();
+ return (t->to_can_async_p) (t);
return 0;
}
static int
-find_default_is_async_p (void)
+find_default_is_async_p (struct target_ops *ignore)
{
struct target_ops *t;
@@ -3166,7 +3162,7 @@ find_default_is_async_p (void)
connected yet. */
t = find_default_run_target (NULL);
if (t && t->to_is_async_p)
- return (t->to_is_async_p) ();
+ return (t->to_is_async_p) (t);
return 0;
}
@@ -3768,7 +3764,8 @@ init_dummy_target (void)
dummy_target.to_has_registers = (int (*) (struct target_ops *)) return_zero;
dummy_target.to_has_execution
= (int (*) (struct target_ops *, ptid_t)) return_zero;
- dummy_target.to_stopped_by_watchpoint = return_zero;
+ dummy_target.to_stopped_by_watchpoint
+ = (int (*) (struct target_ops *)) return_zero;
dummy_target.to_stopped_data_address =
(int (*) (struct target_ops *, CORE_ADDR *)) return_zero;
dummy_target.to_magic = OPS_MAGIC;
@@ -4520,12 +4517,13 @@ debug_to_files_info (struct target_ops *target)
}
static int
-debug_to_insert_breakpoint (struct gdbarch *gdbarch,
+debug_to_insert_breakpoint (struct target_ops *ops,
+ struct gdbarch *gdbarch,
struct bp_target_info *bp_tgt)
{
int retval;
- retval = debug_target.to_insert_breakpoint (gdbarch, bp_tgt);
+ retval = debug_target.to_insert_breakpoint (&debug_target, gdbarch, bp_tgt);
fprintf_unfiltered (gdb_stdlog,
"target_insert_breakpoint (%s, xxx) = %ld\n",
@@ -4535,12 +4533,13 @@ debug_to_insert_breakpoint (struct gdbarch *gdbarch,
}
static int
-debug_to_remove_breakpoint (struct gdbarch *gdbarch,
+debug_to_remove_breakpoint (struct target_ops *ops,
+ struct gdbarch *gdbarch,
struct bp_target_info *bp_tgt)
{
int retval;
- retval = debug_target.to_remove_breakpoint (gdbarch, bp_tgt);
+ retval = debug_target.to_remove_breakpoint (&debug_target, gdbarch, bp_tgt);
fprintf_unfiltered (gdb_stdlog,
"target_remove_breakpoint (%s, xxx) = %ld\n",
@@ -4597,11 +4596,11 @@ debug_to_can_accel_watchpoint_condition (CORE_ADDR addr, int len, int rw,
}
static int
-debug_to_stopped_by_watchpoint (void)
+debug_to_stopped_by_watchpoint (struct target_ops *ops)
{
int retval;
- retval = debug_target.to_stopped_by_watchpoint ();
+ retval = debug_target.to_stopped_by_watchpoint (&debug_target);
fprintf_unfiltered (gdb_stdlog,
"target_stopped_by_watchpoint () = %ld\n",
diff --git a/gdb/target.h b/gdb/target.h
index f22e5c6..e00e38c 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -399,8 +399,10 @@ struct target_ops
struct target_ops *target);
void (*to_files_info) (struct target_ops *);
- int (*to_insert_breakpoint) (struct gdbarch *, struct bp_target_info *);
- int (*to_remove_breakpoint) (struct gdbarch *, struct bp_target_info *);
+ int (*to_insert_breakpoint) (struct target_ops *, struct gdbarch *,
+ struct bp_target_info *);
+ int (*to_remove_breakpoint) (struct target_ops *, struct gdbarch *,
+ struct bp_target_info *);
int (*to_can_use_hw_breakpoint) (int, int, int);
int (*to_ranged_break_num_registers) (struct target_ops *);
int (*to_insert_hw_breakpoint) (struct gdbarch *, struct bp_target_info *);
@@ -415,7 +417,7 @@ struct target_ops
CORE_ADDR, CORE_ADDR, int);
int (*to_remove_mask_watchpoint) (struct target_ops *,
CORE_ADDR, CORE_ADDR, int);
- int (*to_stopped_by_watchpoint) (void);
+ int (*to_stopped_by_watchpoint) (struct target_ops *);
int to_have_steppable_watchpoint;
int to_have_continuable_watchpoint;
int (*to_stopped_data_address) (struct target_ops *, CORE_ADDR *);
@@ -480,9 +482,10 @@ struct target_ops
int to_has_thread_control; /* control thread execution */
int to_attach_no_wait;
/* ASYNC target controls */
- int (*to_can_async_p) (void);
- int (*to_is_async_p) (void);
- void (*to_async) (void (*) (enum inferior_event_type, void *), void *);
+ int (*to_can_async_p) (struct target_ops *);
+ int (*to_is_async_p) (struct target_ops *);
+ void (*to_async) (struct target_ops *,
+ void (*) (enum inferior_event_type, void *), void *);
int (*to_supports_non_stop) (void);
/* find_memory_regions support method for gcore */
int (*to_find_memory_regions) (find_memory_region_ftype func, void *data);
@@ -1411,16 +1414,16 @@ extern int default_child_has_execution (struct target_ops *ops,
extern int target_async_permitted;
/* Can the target support asynchronous execution? */
-#define target_can_async_p() (current_target.to_can_async_p ())
+#define target_can_async_p() (current_target.to_can_async_p (¤t_target))
/* Is the target in asynchronous execution mode? */
-#define target_is_async_p() (current_target.to_is_async_p ())
+#define target_is_async_p() (current_target.to_is_async_p (¤t_target))
int target_supports_non_stop (void);
/* Put the target in async mode with the specified callback function. */
#define target_async(CALLBACK,CONTEXT) \
- (current_target.to_async ((CALLBACK), (CONTEXT)))
+ (current_target.to_async (¤t_target, (CALLBACK), (CONTEXT)))
#define target_execution_direction() \
(current_target.to_execution_direction ())
@@ -1494,8 +1497,8 @@ extern char *target_thread_name (struct thread_info *);
/* Returns non-zero if we were stopped by a hardware watchpoint (memory read or
write). Only the INFERIOR_PTID task is being queried. */
-#define target_stopped_by_watchpoint \
- (*current_target.to_stopped_by_watchpoint)
+#define target_stopped_by_watchpoint() \
+ ((*current_target.to_stopped_by_watchpoint) (¤t_target))
/* Non-zero if we have steppable watchpoints */
@@ -1870,10 +1873,12 @@ extern struct target_section_table *target_get_section_table
/* From mem-break.c */
-extern int memory_remove_breakpoint (struct gdbarch *,
+extern int memory_remove_breakpoint (struct target_ops *,
+ struct gdbarch *,
struct bp_target_info *);
-extern int memory_insert_breakpoint (struct gdbarch *,
+extern int memory_insert_breakpoint (struct target_ops *,
+ struct gdbarch *,
struct bp_target_info *);
extern int default_memory_remove_breakpoint (struct gdbarch *,
--
1.8.1.4