aboutsummaryrefslogtreecommitdiff
path: root/gdb/target.h
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2013-07-12 13:00:34 -0600
committerTom Tromey <tromey@redhat.com>2014-02-19 07:45:25 -0700
commit6b84065d0e65d86f5c38bf139ec68101ea65d802 (patch)
tree5ea660c51169821ad323fe79ab5abcae09a45dcd /gdb/target.h
parent1101cb7b3b05d857c8bccc848bc5664155c82730 (diff)
downloadgdb-6b84065d0e65d86f5c38bf139ec68101ea65d802.zip
gdb-6b84065d0e65d86f5c38bf139ec68101ea65d802.tar.gz
gdb-6b84065d0e65d86f5c38bf139ec68101ea65d802.tar.bz2
add target method delegation
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.
Diffstat (limited to 'gdb/target.h')
-rw-r--r--gdb/target.h51
1 files changed, 22 insertions, 29 deletions
diff --git a/gdb/target.h b/gdb/target.h
index be8c965..25b54d9 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -407,11 +407,14 @@ struct target_ops
void (*to_post_attach) (int);
void (*to_detach) (struct target_ops *ops, const char *, int);
void (*to_disconnect) (struct target_ops *, char *, int);
- void (*to_resume) (struct target_ops *, ptid_t, int, enum gdb_signal);
+ void (*to_resume) (struct target_ops *, ptid_t, int, enum gdb_signal)
+ TARGET_DEFAULT_NORETURN (noprocess ());
ptid_t (*to_wait) (struct target_ops *,
- ptid_t, struct target_waitstatus *, int);
+ ptid_t, struct target_waitstatus *, int)
+ TARGET_DEFAULT_NORETURN (noprocess ());
void (*to_fetch_registers) (struct target_ops *, struct regcache *, int);
- void (*to_store_registers) (struct target_ops *, struct regcache *, int);
+ void (*to_store_registers) (struct target_ops *, struct regcache *, int)
+ TARGET_DEFAULT_NORETURN (noprocess ());
void (*to_prepare_to_store) (struct target_ops *, struct regcache *);
/* Transfer LEN bytes of memory between GDB address MYADDR and
@@ -442,9 +445,11 @@ struct target_ops
void (*to_files_info) (struct target_ops *);
int (*to_insert_breakpoint) (struct target_ops *, struct gdbarch *,
- struct bp_target_info *);
+ struct bp_target_info *)
+ TARGET_DEFAULT_FUNC (memory_insert_breakpoint);
int (*to_remove_breakpoint) (struct target_ops *, struct gdbarch *,
- struct bp_target_info *);
+ struct bp_target_info *)
+ TARGET_DEFAULT_FUNC (memory_remove_breakpoint);
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 *);
@@ -459,10 +464,12 @@ 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) (struct target_ops *);
+ int (*to_stopped_by_watchpoint) (struct target_ops *)
+ TARGET_DEFAULT_RETURN (0);
int to_have_steppable_watchpoint;
int to_have_continuable_watchpoint;
- int (*to_stopped_data_address) (struct target_ops *, CORE_ADDR *);
+ int (*to_stopped_data_address) (struct target_ops *, CORE_ADDR *)
+ TARGET_DEFAULT_RETURN (0);
int (*to_watchpoint_addr_within_range) (struct target_ops *,
CORE_ADDR, CORE_ADDR, int);
@@ -524,10 +531,12 @@ struct target_ops
int to_has_thread_control; /* control thread execution */
int to_attach_no_wait;
/* ASYNC target controls */
- int (*to_can_async_p) (struct target_ops *);
- int (*to_is_async_p) (struct target_ops *);
- void (*to_async) (struct target_ops *,
- async_callback_ftype *, void *);
+ int (*to_can_async_p) (struct target_ops *)
+ TARGET_DEFAULT_FUNC (find_default_can_async_p);
+ int (*to_is_async_p) (struct target_ops *)
+ TARGET_DEFAULT_FUNC (find_default_is_async_p);
+ void (*to_async) (struct target_ops *, async_callback_ftype *, void *)
+ TARGET_DEFAULT_NORETURN (tcomplain ());
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);
@@ -582,7 +591,8 @@ struct target_ops
gdb_byte *readbuf,
const gdb_byte *writebuf,
ULONGEST offset, ULONGEST len,
- ULONGEST *xfered_len);
+ ULONGEST *xfered_len)
+ TARGET_DEFAULT_RETURN (TARGET_XFER_E_IO);
/* Returns the memory map for the target. A return value of NULL
means that no memory map is available. If a memory address
@@ -1190,29 +1200,12 @@ int target_write_memory_blocks (VEC(memory_write_request_s) *requests,
/* 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
message) otherwise. */
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. */
extern int target_remove_breakpoint (struct gdbarch *gdbarch,