+2014-01-16 Markus Metzger <markus.t.metzger@intel.com>
+
+ * target.h (target_ops) <to_insert_breakpoint>
+ <to_remove_breakpoint>: Add target_ops parameter.
+ (forward_target_insert_breakpoint): New.
+ (forward_target_remove_breakpoint): New.
+ (memory_remove_breakpoint, memory_insert_breakpoint):
+ Add target_ops parameter.
+ * target.c (target_insert_breakpoint): Split into this and ...
+ (forward_target_insert_breakpoint): ... this.
+ (target_remove_breakpoint): Split into this and ...
+ (forward_target_remove_breakpoint): ... this.
+ (debug_to_insert_breakpoint): Add target_ops parameter.
+ Call forward_target_insert_breakpoint.
+ (debug_to_remove_breakpoint): Add target_ops parameter.
+ Call forward_target_remove_breakpoint.
+ (update_current_target): Do not inherit or default to_insert_breakpoint
+ and to_remove_breakpoint.
+ * corelow.c (ignore): Add target_ops parameter.
+ * exec.c (ignore): Add target_ops parameter.
+ * mem-break.c (memory_insert_breakpoint, memory_remove_breakpoint):
+ Add target_ops parameter.
+ * monitor.c (monitor_insert_breakpoint, monitor_remove_breakpoint):
+ Add target_ops parameter.
+ * nto-procfs.c (procfs_insert_breakpoint, procfs_remove_breakpoint):
+ Add target_ops parameter.
+ * record-full.c (record_full_beneath_to_insert_breakpoint)
+ (record_full_beneath_to_remove_breakpoint, tmp_to_insert_breakpoint)
+ (tmp_to_remove_breakpoint, record_full_insert_breakpoint)
+ (record_full_remove_breakpoint, record_full_core_insert_breakpoint)
+ (record_full_core_remove_breakpoint): Add target_ops parameter.
+ Update users.
+ (record_full_beneath_to_insert_breakpoint_ops)
+ (record_full_beneath_to_remove_breakpoint_ops)
+ (tmp_to_insert_breakpoint_ops, tmp_to_remove_breakpoint_ops): New.
+ (record_full_open): Initialize tmp_to_insert_breakpoint_ops,
+ tmp_to_remove_breakpoint_ops,
+ record_full_beneath_to_insert_breakpoint_ops, and
+ record_full_beneath_to_remove_breakpoint_ops.
+ * remote-m32r-sdi.c (m32r_insert_breakpoint)
+ (m32r_remove_breakpoint): Add target_ops parameter.
+ * remote-mips.c (mips_insert_breakpoint, mips_remove_breakpoint):
+ Add target_ops parameter.
+ * remote.c (remote_insert_breakpoint, remote_remove_breakpoint):
+ Add target_ops parameter.
+
2014-01-16 Jan Kratochvil <jan.kratochvil@redhat.com>
Markus Metzger <markus.t.metzger@intel.com>
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;
}
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;
}
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);
/* 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;
/* 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;
}
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);
static struct target_ops *record_full_beneath_to_xfer_partial_ops;
static target_xfer_partial_ftype *record_full_beneath_to_xfer_partial;
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 struct target_ops *record_full_beneath_to_insert_breakpoint_ops;
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 struct target_ops *record_full_beneath_to_remove_breakpoint_ops;
static int (*record_full_beneath_to_stopped_by_watchpoint) (void);
static int (*record_full_beneath_to_stopped_data_address) (struct target_ops *,
CORE_ADDR *);
int regno);
static struct target_ops *tmp_to_xfer_partial_ops;
static target_xfer_partial_ftype *tmp_to_xfer_partial;
-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 struct target_ops *tmp_to_insert_breakpoint_ops;
+static int (*tmp_to_remove_breakpoint) (struct target_ops *, struct gdbarch *,
struct bp_target_info *);
+static struct target_ops *tmp_to_remove_breakpoint_ops;
static int (*tmp_to_stopped_by_watchpoint) (void);
static int (*tmp_to_stopped_data_address) (struct target_ops *, CORE_ADDR *);
static int (*tmp_to_stopped_data_address) (struct target_ops *, CORE_ADDR *);
tmp_to_stopped_by_watchpoint = NULL;
tmp_to_stopped_data_address = NULL;
tmp_to_async = NULL;
+ tmp_to_insert_breakpoint_ops = NULL;
+ tmp_to_remove_breakpoint_ops = NULL;
/* Set the beneath function pointers. */
for (t = current_target.beneath; t != NULL; t = t->beneath)
tmp_to_xfer_partial_ops = t;
}
if (!tmp_to_insert_breakpoint)
- tmp_to_insert_breakpoint = t->to_insert_breakpoint;
+ {
+ tmp_to_insert_breakpoint = t->to_insert_breakpoint;
+ tmp_to_insert_breakpoint_ops = t;
+ }
if (!tmp_to_remove_breakpoint)
- tmp_to_remove_breakpoint = t->to_remove_breakpoint;
+ {
+ tmp_to_remove_breakpoint = t->to_remove_breakpoint;
+ tmp_to_remove_breakpoint_ops = t;
+ }
if (!tmp_to_stopped_by_watchpoint)
tmp_to_stopped_by_watchpoint = t->to_stopped_by_watchpoint;
if (!tmp_to_stopped_data_address)
record_full_beneath_to_xfer_partial_ops = tmp_to_xfer_partial_ops;
record_full_beneath_to_xfer_partial = tmp_to_xfer_partial;
record_full_beneath_to_insert_breakpoint = tmp_to_insert_breakpoint;
+ record_full_beneath_to_insert_breakpoint_ops = tmp_to_insert_breakpoint_ops;
record_full_beneath_to_remove_breakpoint = tmp_to_remove_breakpoint;
+ record_full_beneath_to_remove_breakpoint_ops = tmp_to_remove_breakpoint_ops;
record_full_beneath_to_stopped_by_watchpoint = tmp_to_stopped_by_watchpoint;
record_full_beneath_to_stopped_data_address = tmp_to_stopped_data_address;
record_full_beneath_to_async = tmp_to_async;
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;
int ret;
old_cleanups = record_full_gdb_operation_disable_set ();
- ret = record_full_beneath_to_insert_breakpoint (gdbarch, bp_tgt);
+ ops = record_full_beneath_to_insert_breakpoint_ops;
+ ret = record_full_beneath_to_insert_breakpoint (ops, gdbarch,
+ bp_tgt);
do_cleanups (old_cleanups);
if (ret != 0)
/* "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;
int ret;
old_cleanups = record_full_gdb_operation_disable_set ();
- ret = record_full_beneath_to_remove_breakpoint (gdbarch, bp_tgt);
+ ops = record_full_beneath_to_remove_breakpoint_ops;
+ ret = record_full_beneath_to_remove_breakpoint (ops, gdbarch,
+ bp_tgt);
do_cleanups (old_cleanups);
if (ret != 0)
/* "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;
/* "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;
}
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;
}
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;
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
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.
throw_error (NOT_SUPPORTED_ERROR, _("\
Target doesn't support breakpoints that have target side commands."));
- 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;
return (rs->buf[0] == 'E');
}
- return memory_remove_breakpoint (gdbarch, bp_tgt);
+ return memory_remove_breakpoint (ops, gdbarch, bp_tgt);
}
static int
static void debug_to_files_info (struct target_ops *);
-static int debug_to_insert_breakpoint (struct gdbarch *,
+static int debug_to_insert_breakpoint (struct target_ops *, struct gdbarch *,
struct bp_target_info *);
-static int debug_to_remove_breakpoint (struct gdbarch *,
+static int debug_to_remove_breakpoint (struct target_ops *, struct gdbarch *,
struct bp_target_info *);
static int debug_to_can_use_hw_breakpoint (int, int, int);
INHERIT (to_prepare_to_store, t);
INHERIT (deprecated_xfer_memory, t);
INHERIT (to_files_info, t);
- INHERIT (to_insert_breakpoint, t);
- INHERIT (to_remove_breakpoint, t);
+ /* Do not inherit to_insert_breakpoint. */
+ /* Do not inherit to_remove_breakpoint. */
INHERIT (to_can_use_hw_breakpoint, t);
INHERIT (to_insert_hw_breakpoint, t);
INHERIT (to_remove_hw_breakpoint, t);
de_fault (to_files_info,
(void (*) (struct target_ops *))
target_ignore);
- de_fault (to_insert_breakpoint,
- memory_insert_breakpoint);
- de_fault (to_remove_breakpoint,
- memory_remove_breakpoint);
de_fault (to_can_use_hw_breakpoint,
(int (*) (int, int, int))
return_zero);
return extract_unsigned_integer (buf, len, byte_order);
}
+/* See target.h. */
+
+int
+forward_target_insert_breakpoint (struct target_ops *ops,
+ struct gdbarch *gdbarch,
+ struct bp_target_info *bp_tgt)
+{
+ for (; ops != NULL; ops = ops->beneath)
+ if (ops->to_insert_breakpoint != NULL)
+ return ops->to_insert_breakpoint (ops, gdbarch, bp_tgt);
+
+ return memory_insert_breakpoint (ops, gdbarch, bp_tgt);
+}
+
+/* See target.h. */
+
int
target_insert_breakpoint (struct gdbarch *gdbarch,
struct bp_target_info *bp_tgt)
return 1;
}
- return (*current_target.to_insert_breakpoint) (gdbarch, bp_tgt);
+ return forward_target_insert_breakpoint (¤t_target, gdbarch, bp_tgt);
}
+/* See target.h. */
+
int
-target_remove_breakpoint (struct gdbarch *gdbarch,
- struct bp_target_info *bp_tgt)
+forward_target_remove_breakpoint (struct target_ops *ops,
+ struct gdbarch *gdbarch,
+ struct bp_target_info *bp_tgt)
{
/* This is kind of a weird case to handle, but the permission might
have been changed after breakpoints were inserted - in which case
return 1;
}
- return (*current_target.to_remove_breakpoint) (gdbarch, bp_tgt);
+ for (; ops != NULL; ops = ops->beneath)
+ if (ops->to_remove_breakpoint != NULL)
+ return ops->to_remove_breakpoint (ops, gdbarch, bp_tgt);
+
+ return memory_remove_breakpoint (ops, gdbarch, bp_tgt);
+}
+
+/* See target.h. */
+
+int
+target_remove_breakpoint (struct gdbarch *gdbarch,
+ struct bp_target_info *bp_tgt)
+{
+ return forward_target_remove_breakpoint (¤t_target, gdbarch, bp_tgt);
}
static void
}
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 = forward_target_insert_breakpoint (&debug_target, gdbarch, bp_tgt);
fprintf_unfiltered (gdb_stdlog,
"target_insert_breakpoint (%s, xxx) = %ld\n",
}
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 = forward_target_remove_breakpoint (&debug_target, gdbarch, bp_tgt);
fprintf_unfiltered (gdb_stdlog,
"target_remove_breakpoint (%s, xxx) = %ld\n",
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 *);
#define target_files_info() \
(*current_target.to_files_info) (¤t_target)
+/* Insert a hardware breakpoint at address BP_TGT->placed_address in
+ the target machine. Returns 0 for success, and returns non-zero or
+ throws an error (with a detailed failure reason error code and
+ message) otherwise.
+ Start the target search at OPS. */
+
+extern int forward_target_insert_breakpoint (struct target_ops *ops,
+ struct gdbarch *gdbarch,
+ struct bp_target_info *bp_tgt);
+
/* Insert a hardware breakpoint at address BP_TGT->placed_address in
the target machine. Returns 0 for success, and returns non-zero or
throws an error (with a detailed failure reason error code and
extern int target_insert_breakpoint (struct gdbarch *gdbarch,
struct bp_target_info *bp_tgt);
+/* Remove a breakpoint at address BP_TGT->placed_address in the target
+ machine. Result is 0 for success, non-zero for error.
+ Start the target search at OPS. */
+
+extern int forward_target_remove_breakpoint (struct target_ops *ops,
+ struct gdbarch *gdbarch,
+ struct bp_target_info *bp_tgt);
/* Remove a breakpoint at address BP_TGT->placed_address in the target
machine. Result is 0 for success, non-zero for error. */
/* 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 *,