mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2025-02-11 13:02:10 +08:00
This patch replaces some code in the record targets with target method delegation. record-full.c stores pointers to many target methods when the record target is pushed. Then it later delegates some calls via these. This is wrong because it violates the target stack contract. In particular it is ok to unpush a target at any stratum, but record-full does not keep track of this, so it could potentially call into an unpushed target. This patch fixes the problem by using the newly-introduced generic approach to target delegation for the methods in question. 2014-02-19 Tom Tromey <tromey@redhat.com> * record-full.c (record_full_beneath_to_resume_ops) (record_full_beneath_to_resume, record_full_beneath_to_wait_ops) (record_full_beneath_to_wait) (record_full_beneath_to_store_registers_ops) (record_full_beneath_to_store_registers) (record_full_beneath_to_xfer_partial_ops) (record_full_beneath_to_xfer_partial) (record_full_beneath_to_insert_breakpoint_ops) (record_full_beneath_to_insert_breakpoint) (record_full_beneath_to_remove_breakpoint_ops) (record_full_beneath_to_remove_breakpoint) (record_full_beneath_to_stopped_by_watchpoint) (record_full_beneath_to_stopped_data_address) (record_full_beneath_to_async, tmp_to_resume_ops, tmp_to_resume) (tmp_to_wait_ops, tmp_to_wait, tmp_to_store_registers_ops) (tmp_to_store_registers, tmp_to_xfer_partial_ops) (tmp_to_xfer_partial, tmp_to_instmp_to_insert_breakpoint_ops) (tmp_to_insert_breakpoint, tmp_to_remove_breakpoint_ops) (tmp_to_remove_breakpoint, tmp_to_stopped_by_watchpoint) (tmp_to_stopped_data_address, tmp_to_async): Remove. (record_full_open_1, record_full_open): Update. Use RECORD_IS_USED. (record_full_resume, record_full_wait_1) (record_full_stopped_by_watchpoint, record_full_stopped_data_address) (record_full_store_registers, record_full_xfer_partial) (record_full_insert_breakpoint, record_full_remove_breakpoint) (record_full_async, record_full_core_xfer_partial): Use target delegation. * target-delegates.c: Rebuild. * target.c (current_xfer_partial): Remove. (update_current_target): Do not INHERIT or de_fault to_insert_breakpoint, to_remove_breakpoint, to_stopped_data_address, to_stopped_by_watchpoint, to_can_async_p, to_is_async_p, to_async. Do not set to_xfer_partial field. (default_xfer_partial): Simplify. (current_xfer_partial): Remove. (target_wait, target_resume): Simplify. (find_default_can_async_p, find_default_is_async_p): Update. (init_dummy_target): Don't set to_can_async_p, to_is_async_p, to_xfer_partial, to_stopped_by_watchpoint, to_stopped_data_address. (target_store_registers): Simplify. (forward_target_remove_breakpoint) (forward_target_insert_breakpoint): Remove. (target_remove_breakpoint, target_insert_breakpoint) (debug_to_insert_breakpoint, debug_to_remove_breakpoint): Update. * target.h (struct target_ops) <to_resume, to_wait, to_store_registers, to_insert_breakpoint, to_remove_breakpoint, to_stopped_by_watchpoint, to_stopped_data_address, to_can_async_p, to_is_async_p, to_async, to_xfer_partial>: Add TARGET_DEFAULT markup. (forward_target_remove_breakpoint) (forward_target_insert_breakpoint): Remove. * record-btrace.c (record_btrace_remove_breakpoint): Delegate directly. (record_btrace_insert_breakpoint): Delegate directly.
167 lines
4.6 KiB
C
167 lines
4.6 KiB
C
/* THIS FILE IS GENERATED -*- buffer-read-only: t -*- */
|
|
/* vi:set ro: */
|
|
|
|
/* To regenerate this file, run:*/
|
|
/* make-target-delegates target.h > target-delegates.c */
|
|
static void
|
|
delegate_resume (struct target_ops *self, ptid_t arg1, int arg2, enum gdb_signal arg3)
|
|
{
|
|
self = self->beneath;
|
|
self->to_resume (self, arg1, arg2, arg3);
|
|
}
|
|
|
|
static void
|
|
tdefault_resume (struct target_ops *self, ptid_t arg1, int arg2, enum gdb_signal arg3)
|
|
{
|
|
noprocess ();
|
|
}
|
|
|
|
static ptid_t
|
|
delegate_wait (struct target_ops *self, ptid_t arg1, struct target_waitstatus *arg2, int arg3)
|
|
{
|
|
self = self->beneath;
|
|
return self->to_wait (self, arg1, arg2, arg3);
|
|
}
|
|
|
|
static ptid_t
|
|
tdefault_wait (struct target_ops *self, ptid_t arg1, struct target_waitstatus *arg2, int arg3)
|
|
{
|
|
noprocess ();
|
|
}
|
|
|
|
static void
|
|
delegate_store_registers (struct target_ops *self, struct regcache *arg1, int arg2)
|
|
{
|
|
self = self->beneath;
|
|
self->to_store_registers (self, arg1, arg2);
|
|
}
|
|
|
|
static void
|
|
tdefault_store_registers (struct target_ops *self, struct regcache *arg1, int arg2)
|
|
{
|
|
noprocess ();
|
|
}
|
|
|
|
static int
|
|
delegate_insert_breakpoint (struct target_ops *self, struct gdbarch *arg1, struct bp_target_info *arg2)
|
|
{
|
|
self = self->beneath;
|
|
return self->to_insert_breakpoint (self, arg1, arg2);
|
|
}
|
|
|
|
static int
|
|
delegate_remove_breakpoint (struct target_ops *self, struct gdbarch *arg1, struct bp_target_info *arg2)
|
|
{
|
|
self = self->beneath;
|
|
return self->to_remove_breakpoint (self, arg1, arg2);
|
|
}
|
|
|
|
static int
|
|
delegate_stopped_by_watchpoint (struct target_ops *self)
|
|
{
|
|
self = self->beneath;
|
|
return self->to_stopped_by_watchpoint (self);
|
|
}
|
|
|
|
static int
|
|
tdefault_stopped_by_watchpoint (struct target_ops *self)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static int
|
|
delegate_stopped_data_address (struct target_ops *self, CORE_ADDR *arg1)
|
|
{
|
|
self = self->beneath;
|
|
return self->to_stopped_data_address (self, arg1);
|
|
}
|
|
|
|
static int
|
|
tdefault_stopped_data_address (struct target_ops *self, CORE_ADDR *arg1)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static int
|
|
delegate_can_async_p (struct target_ops *self)
|
|
{
|
|
self = self->beneath;
|
|
return self->to_can_async_p (self);
|
|
}
|
|
|
|
static int
|
|
delegate_is_async_p (struct target_ops *self)
|
|
{
|
|
self = self->beneath;
|
|
return self->to_is_async_p (self);
|
|
}
|
|
|
|
static void
|
|
delegate_async (struct target_ops *self, async_callback_ftype *arg1, void *arg2)
|
|
{
|
|
self = self->beneath;
|
|
self->to_async (self, arg1, arg2);
|
|
}
|
|
|
|
static void
|
|
tdefault_async (struct target_ops *self, async_callback_ftype *arg1, void *arg2)
|
|
{
|
|
tcomplain ();
|
|
}
|
|
|
|
static enum target_xfer_status
|
|
delegate_xfer_partial (struct target_ops *self, enum target_object arg1, const char *arg2, gdb_byte *arg3, const gdb_byte *arg4, ULONGEST arg5, ULONGEST arg6, ULONGEST *arg7)
|
|
{
|
|
self = self->beneath;
|
|
return self->to_xfer_partial (self, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
|
|
}
|
|
|
|
static enum target_xfer_status
|
|
tdefault_xfer_partial (struct target_ops *self, enum target_object arg1, const char *arg2, gdb_byte *arg3, const gdb_byte *arg4, ULONGEST arg5, ULONGEST arg6, ULONGEST *arg7)
|
|
{
|
|
return TARGET_XFER_E_IO;
|
|
}
|
|
|
|
static void
|
|
install_delegators (struct target_ops *ops)
|
|
{
|
|
if (ops->to_resume == NULL)
|
|
ops->to_resume = delegate_resume;
|
|
if (ops->to_wait == NULL)
|
|
ops->to_wait = delegate_wait;
|
|
if (ops->to_store_registers == NULL)
|
|
ops->to_store_registers = delegate_store_registers;
|
|
if (ops->to_insert_breakpoint == NULL)
|
|
ops->to_insert_breakpoint = delegate_insert_breakpoint;
|
|
if (ops->to_remove_breakpoint == NULL)
|
|
ops->to_remove_breakpoint = delegate_remove_breakpoint;
|
|
if (ops->to_stopped_by_watchpoint == NULL)
|
|
ops->to_stopped_by_watchpoint = delegate_stopped_by_watchpoint;
|
|
if (ops->to_stopped_data_address == NULL)
|
|
ops->to_stopped_data_address = delegate_stopped_data_address;
|
|
if (ops->to_can_async_p == NULL)
|
|
ops->to_can_async_p = delegate_can_async_p;
|
|
if (ops->to_is_async_p == NULL)
|
|
ops->to_is_async_p = delegate_is_async_p;
|
|
if (ops->to_async == NULL)
|
|
ops->to_async = delegate_async;
|
|
if (ops->to_xfer_partial == NULL)
|
|
ops->to_xfer_partial = delegate_xfer_partial;
|
|
}
|
|
|
|
static void
|
|
install_dummy_methods (struct target_ops *ops)
|
|
{
|
|
ops->to_resume = tdefault_resume;
|
|
ops->to_wait = tdefault_wait;
|
|
ops->to_store_registers = tdefault_store_registers;
|
|
ops->to_insert_breakpoint = memory_insert_breakpoint;
|
|
ops->to_remove_breakpoint = memory_remove_breakpoint;
|
|
ops->to_stopped_by_watchpoint = tdefault_stopped_by_watchpoint;
|
|
ops->to_stopped_data_address = tdefault_stopped_data_address;
|
|
ops->to_can_async_p = find_default_can_async_p;
|
|
ops->to_is_async_p = find_default_is_async_p;
|
|
ops->to_async = tdefault_async;
|
|
ops->to_xfer_partial = tdefault_xfer_partial;
|
|
}
|