summaryrefslogtreecommitdiff
path: root/gdb/target.c
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2021-03-24 18:07:30 -0400
committerSimon Marchi <simon.marchi@polymtl.ca>2021-03-24 18:07:30 -0400
commitd777bf0df22f1048fd24999ae563e30abcbcfbe7 (patch)
tree2684c5c36d0be37f3b542e5ae60930e5e4be705a /gdb/target.c
parentb64f703b51914e4e335e61492882a8137f75e082 (diff)
gdb: move all "current target" wrapper implementations to target.c
The following patch removes the current_top_target function, replacing uses with `current_inferior ()->top_target ()`. This is a problem for uses in target.h, because they don't have access to the current_inferior function and the inferior structure: target.h can't include inferior.h, otherwise that would make a cyclic inclusion. Avoid this by moving all implementations of the wrappers that call target methods with the current target to target.c. Many of them are changed from a macro to a function, which is an improvement for readability and debuggability, IMO. target_shortname and target_longname were not function-like macros, so a few adjustments are needed. gdb/ChangeLog: * target.h (target_shortname): Change to function declaration. (target_longname): Likewise. (target_attach_no_wait): Likewise. (target_post_attach): Likewise. (target_prepare_to_store): Likewise. (target_supports_enable_disable_tracepoint): Likewise. (target_supports_string_tracing): Likewise. (target_supports_evaluation_of_breakpoint_conditions): Likewise. (target_supports_dumpcore): Likewise. (target_dumpcore): Likewise. (target_can_run_breakpoint_commands): Likewise. (target_files_info): Likewise. (target_post_startup_inferior): Likewise. (target_insert_fork_catchpoint): Likewise. (target_remove_fork_catchpoint): Likewise. (target_insert_vfork_catchpoint): Likewise. (target_remove_vfork_catchpoint): Likewise. (target_insert_exec_catchpoint): Likewise. (target_remove_exec_catchpoint): Likewise. (target_set_syscall_catchpoint): Likewise. (target_rcmd): Likewise. (target_can_lock_scheduler): Likewise. (target_can_async_p): Likewise. (target_is_async_p): Likewise. (target_execution_direction): Likewise. (target_extra_thread_info): Likewise. (target_pid_to_exec_file): Likewise. (target_thread_architecture): Likewise. (target_find_memory_regions): Likewise. (target_make_corefile_notes): Likewise. (target_get_bookmark): Likewise. (target_goto_bookmark): Likewise. (target_stopped_by_watchpoint): Likewise. (target_stopped_by_sw_breakpoint): Likewise. (target_supports_stopped_by_sw_breakpoint): Likewise. (target_stopped_by_hw_breakpoint): Likewise. (target_supports_stopped_by_hw_breakpoint): Likewise. (target_have_steppable_watchpoint): Likewise. (target_can_use_hardware_watchpoint): Likewise. (target_region_ok_for_hw_watchpoint): Likewise. (target_can_do_single_step): Likewise. (target_insert_watchpoint): Likewise. (target_remove_watchpoint): Likewise. (target_insert_hw_breakpoint): Likewise. (target_remove_hw_breakpoint): Likewise. (target_can_accel_watchpoint_condition): Likewise. (target_can_execute_reverse): Likewise. (target_get_ada_task_ptid): Likewise. (target_filesystem_is_local): Likewise. (target_trace_init): Likewise. (target_download_tracepoint): Likewise. (target_can_download_tracepoint): Likewise. (target_download_trace_state_variable): Likewise. (target_enable_tracepoint): Likewise. (target_disable_tracepoint): Likewise. (target_trace_start): Likewise. (target_trace_set_readonly_regions): Likewise. (target_get_trace_status): Likewise. (target_get_tracepoint_status): Likewise. (target_trace_stop): Likewise. (target_trace_find): Likewise. (target_get_trace_state_variable_value): Likewise. (target_save_trace_data): Likewise. (target_upload_tracepoints): Likewise. (target_upload_trace_state_variables): Likewise. (target_get_raw_trace_data): Likewise. (target_get_min_fast_tracepoint_insn_len): Likewise. (target_set_disconnected_tracing): Likewise. (target_set_circular_trace_buffer): Likewise. (target_set_trace_buffer_size): Likewise. (target_set_trace_notes): Likewise. (target_get_tib_address): Likewise. (target_set_permissions): Likewise. (target_static_tracepoint_marker_at): Likewise. (target_static_tracepoint_markers_by_strid): Likewise. (target_traceframe_info): Likewise. (target_use_agent): Likewise. (target_can_use_agent): Likewise. (target_augmented_libraries_svr4_read): Likewise. (target_log_command): Likewise. * target.c (target_shortname): New. (target_longname): New. (target_attach_no_wait): New. (target_post_attach): New. (target_prepare_to_store): New. (target_supports_enable_disable_tracepoint): New. (target_supports_string_tracing): New. (target_supports_evaluation_of_breakpoint_conditions): New. (target_supports_dumpcore): New. (target_dumpcore): New. (target_can_run_breakpoint_commands): New. (target_files_info): New. (target_post_startup_inferior): New. (target_insert_fork_catchpoint): New. (target_remove_fork_catchpoint): New. (target_insert_vfork_catchpoint): New. (target_remove_vfork_catchpoint): New. (target_insert_exec_catchpoint): New. (target_remove_exec_catchpoint): New. (target_set_syscall_catchpoint): New. (target_rcmd): New. (target_can_lock_scheduler): New. (target_can_async_p): New. (target_is_async_p): New. (target_execution_direction): New. (target_extra_thread_info): New. (target_pid_to_exec_file): New. (target_thread_architecture): New. (target_find_memory_regions): New. (target_make_corefile_notes): New. (target_get_bookmark): New. (target_goto_bookmark): New. (target_stopped_by_watchpoint): New. (target_stopped_by_sw_breakpoint): New. (target_supports_stopped_by_sw_breakpoint): New. (target_stopped_by_hw_breakpoint): New. (target_supports_stopped_by_hw_breakpoint): New. (target_have_steppable_watchpoint): New. (target_can_use_hardware_watchpoint): New. (target_region_ok_for_hw_watchpoint): New. (target_can_do_single_step): New. (target_insert_watchpoint): New. (target_remove_watchpoint): New. (target_insert_hw_breakpoint): New. (target_remove_hw_breakpoint): New. (target_can_accel_watchpoint_condition): New. (target_can_execute_reverse): New. (target_get_ada_task_ptid): New. (target_filesystem_is_local): New. (target_trace_init): New. (target_download_tracepoint): New. (target_can_download_tracepoint): New. (target_download_trace_state_variable): New. (target_enable_tracepoint): New. (target_disable_tracepoint): New. (target_trace_start): New. (target_trace_set_readonly_regions): New. (target_get_trace_status): New. (target_get_tracepoint_status): New. (target_trace_stop): New. (target_trace_find): New. (target_get_trace_state_variable_value): New. (target_save_trace_data): New. (target_upload_tracepoints): New. (target_upload_trace_state_variables): New. (target_get_raw_trace_data): New. (target_get_min_fast_tracepoint_insn_len): New. (target_set_disconnected_tracing): New. (target_set_circular_trace_buffer): New. (target_set_trace_buffer_size): New. (target_set_trace_notes): New. (target_get_tib_address): New. (target_set_permissions): New. (target_static_tracepoint_marker_at): New. (target_static_tracepoint_markers_by_strid): New. (target_traceframe_info): New. (target_use_agent): New. (target_can_use_agent): New. (target_augmented_libraries_svr4_read): New. (target_log_command): New. * bfin-tdep.c (bfin_sw_breakpoint_from_kind): Adjust. * infrun.c (set_schedlock_func): Adjust. * mi/mi-main.c (exec_reverse_continue): Adjust. * reverse.c (exec_reverse_once): Adjust. * sh-tdep.c (sh_sw_breakpoint_from_kind): Adjust. * tui/tui-stack.c (tui_locator_window::make_status_line): Adjust. * remote-sim.c (gdbsim_target::detach): Adjust. (gdbsim_target::files_info): Adjust. Change-Id: I72ef56e9a25adeb0b91f1ad05e34c89f77ebeaa8
Diffstat (limited to 'gdb/target.c')
-rw-r--r--gdb/target.c578
1 files changed, 578 insertions, 0 deletions
diff --git a/gdb/target.c b/gdb/target.c
index afc4b2cbbb..9c4af5beaf 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -215,6 +215,584 @@ target_has_execution (inferior *inf)
return false;
}
+const char *
+target_shortname ()
+{
+ return current_top_target ()->shortname ();
+}
+
+/* See target.h. */
+
+bool
+target_attach_no_wait ()
+{
+ return current_top_target ()->attach_no_wait ();
+}
+
+/* See target.h. */
+
+void
+target_post_attach (int pid)
+{
+ return current_top_target ()->post_attach (pid);
+}
+
+/* See target.h. */
+
+void
+target_prepare_to_store (regcache *regcache)
+{
+ return current_top_target ()->prepare_to_store (regcache);
+}
+
+/* See target.h. */
+
+bool
+target_supports_enable_disable_tracepoint ()
+{
+ return current_top_target ()->supports_enable_disable_tracepoint ();
+}
+
+bool
+target_supports_string_tracing ()
+{
+ return current_top_target ()->supports_string_tracing ();
+}
+
+/* See target.h. */
+
+bool
+target_supports_evaluation_of_breakpoint_conditions ()
+{
+ return current_top_target ()->supports_evaluation_of_breakpoint_conditions ();
+}
+
+/* See target.h. */
+
+bool
+target_supports_dumpcore ()
+{
+ return current_top_target ()->supports_dumpcore ();
+}
+
+/* See target.h. */
+
+void
+target_dumpcore (const char *filename)
+{
+ return current_top_target ()->dumpcore (filename);
+}
+
+/* See target.h. */
+
+bool
+target_can_run_breakpoint_commands ()
+{
+ return current_top_target ()->can_run_breakpoint_commands ();
+}
+
+/* See target.h. */
+
+void
+target_files_info ()
+{
+ return current_top_target ()->files_info ();
+}
+
+/* See target.h. */
+
+void
+target_post_startup_inferior (ptid_t ptid)
+{
+ return current_top_target ()->post_startup_inferior (ptid);
+}
+
+/* See target.h. */
+
+int
+target_insert_fork_catchpoint (int pid)
+{
+ return current_top_target ()->insert_fork_catchpoint (pid);
+}
+
+/* See target.h. */
+
+int
+target_remove_fork_catchpoint (int pid)
+{
+ return current_top_target ()->remove_fork_catchpoint (pid);
+}
+
+/* See target.h. */
+
+int
+target_insert_vfork_catchpoint (int pid)
+{
+ return current_top_target ()->insert_vfork_catchpoint (pid);
+}
+
+/* See target.h. */
+
+int
+target_remove_vfork_catchpoint (int pid)
+{
+ return current_top_target ()->remove_vfork_catchpoint (pid);
+}
+
+/* See target.h. */
+
+int
+target_insert_exec_catchpoint (int pid)
+{
+ return current_top_target ()->insert_exec_catchpoint (pid);
+}
+
+/* See target.h. */
+
+int
+target_remove_exec_catchpoint (int pid)
+{
+ return current_top_target ()->remove_exec_catchpoint (pid);
+}
+
+/* See target.h. */
+
+int
+target_set_syscall_catchpoint (int pid, bool needed, int any_count,
+ gdb::array_view<const int> syscall_counts)
+{
+ return current_top_target ()->set_syscall_catchpoint (pid, needed, any_count,
+ syscall_counts);
+}
+
+/* See target.h. */
+
+void
+target_rcmd (const char *command, struct ui_file *outbuf)
+{
+ return current_top_target ()->rcmd (command, outbuf);
+}
+
+/* See target.h. */
+
+bool
+target_can_lock_scheduler ()
+{
+ return (current_top_target ()->get_thread_control_capabilities ()
+ & tc_schedlock) != 0;
+}
+
+/* See target.h. */
+
+bool
+target_can_async_p ()
+{
+ return current_top_target ()->can_async_p ();
+}
+
+/* See target.h. */
+
+bool
+target_is_async_p ()
+{
+ return current_top_target ()->is_async_p ();
+}
+
+exec_direction_kind
+target_execution_direction ()
+{
+ return current_top_target ()->execution_direction ();
+}
+
+/* See target.h. */
+
+const char *
+target_extra_thread_info (thread_info *tp)
+{
+ return current_top_target ()->extra_thread_info (tp);
+}
+
+/* See target.h. */
+
+char *
+target_pid_to_exec_file (int pid)
+{
+ return current_top_target ()->pid_to_exec_file (pid);
+}
+
+/* See target.h. */
+
+gdbarch *
+target_thread_architecture (ptid_t ptid)
+{
+ return current_top_target ()->thread_architecture (ptid);
+}
+
+/* See target.h. */
+
+int
+target_find_memory_regions (find_memory_region_ftype func, void *data)
+{
+ return current_top_target ()->find_memory_regions (func, data);
+}
+
+/* See target.h. */
+
+gdb::unique_xmalloc_ptr<char>
+target_make_corefile_notes (bfd *bfd, int *size_p)
+{
+ return current_top_target ()->make_corefile_notes (bfd, size_p);
+}
+
+gdb_byte *
+target_get_bookmark (const char *args, int from_tty)
+{
+ return current_top_target ()->get_bookmark (args, from_tty);
+}
+
+void
+target_goto_bookmark (const gdb_byte *arg, int from_tty)
+{
+ return current_top_target ()->goto_bookmark (arg, from_tty);
+}
+
+/* See target.h. */
+
+bool
+target_stopped_by_watchpoint ()
+{
+ return current_top_target ()->stopped_by_watchpoint ();
+}
+
+/* See target.h. */
+
+bool
+target_stopped_by_sw_breakpoint ()
+{
+ return current_top_target ()->stopped_by_sw_breakpoint ();
+}
+
+bool
+target_supports_stopped_by_sw_breakpoint ()
+{
+ return current_top_target ()->supports_stopped_by_sw_breakpoint ();
+}
+
+bool
+target_stopped_by_hw_breakpoint ()
+{
+ return current_top_target ()->stopped_by_hw_breakpoint ();
+}
+
+bool
+target_supports_stopped_by_hw_breakpoint ()
+{
+ return current_top_target ()->supports_stopped_by_hw_breakpoint ();
+}
+
+/* See target.h. */
+
+bool
+target_have_steppable_watchpoint ()
+{
+ return current_top_target ()->have_steppable_watchpoint ();
+}
+
+/* See target.h. */
+
+int
+target_can_use_hardware_watchpoint (bptype type, int cnt, int othertype)
+{
+ return current_top_target ()->can_use_hw_breakpoint (type, cnt, othertype);
+}
+
+/* See target.h. */
+
+int
+target_region_ok_for_hw_watchpoint (CORE_ADDR addr, int len)
+{
+ return current_top_target ()->region_ok_for_hw_watchpoint (addr, len);
+}
+
+
+int
+target_can_do_single_step ()
+{
+ return current_top_target ()->can_do_single_step ();
+}
+
+/* See target.h. */
+
+int
+target_insert_watchpoint (CORE_ADDR addr, int len, target_hw_bp_type type,
+ expression *cond)
+{
+ return current_top_target ()->insert_watchpoint (addr, len, type, cond);
+}
+
+/* See target.h. */
+
+int
+target_remove_watchpoint (CORE_ADDR addr, int len, target_hw_bp_type type,
+ expression *cond)
+{
+ return current_top_target ()->remove_watchpoint (addr, len, type, cond);
+}
+
+/* See target.h. */
+
+int
+target_insert_hw_breakpoint (gdbarch *gdbarch, bp_target_info *bp_tgt)
+{
+ return current_top_target ()->insert_hw_breakpoint (gdbarch, bp_tgt);
+}
+
+/* See target.h. */
+
+int
+target_remove_hw_breakpoint (gdbarch *gdbarch, bp_target_info *bp_tgt)
+{
+ return current_top_target ()->remove_hw_breakpoint (gdbarch, bp_tgt);
+}
+
+/* See target.h. */
+
+bool
+target_can_accel_watchpoint_condition (CORE_ADDR addr, int len, int type,
+ expression *cond)
+{
+ return current_top_target ()->can_accel_watchpoint_condition (addr, len, type, cond);
+}
+
+/* See target.h. */
+
+bool
+target_can_execute_reverse ()
+{
+ return current_top_target ()->can_execute_reverse ();
+}
+
+ptid_t
+target_get_ada_task_ptid (long lwp, long tid)
+{
+ return current_top_target ()->get_ada_task_ptid (lwp, tid);
+}
+
+bool
+target_filesystem_is_local ()
+{
+ return current_top_target ()->filesystem_is_local ();
+}
+
+void
+target_trace_init ()
+{
+ return current_top_target ()->trace_init ();
+}
+
+void
+target_download_tracepoint (bp_location *location)
+{
+ return current_top_target ()->download_tracepoint (location);
+}
+
+bool
+target_can_download_tracepoint ()
+{
+ return current_top_target ()->can_download_tracepoint ();
+}
+
+void
+target_download_trace_state_variable (const trace_state_variable &tsv)
+{
+ return current_top_target ()->download_trace_state_variable (tsv);
+}
+
+void
+target_enable_tracepoint (bp_location *loc)
+{
+ return current_top_target ()->enable_tracepoint (loc);
+}
+
+void
+target_disable_tracepoint (bp_location *loc)
+{
+ return current_top_target ()->disable_tracepoint (loc);
+}
+
+void
+target_trace_start ()
+{
+ return current_top_target ()->trace_start ();
+}
+
+void
+target_trace_set_readonly_regions ()
+{
+ current_top_target ()->trace_set_readonly_regions ();
+}
+
+int
+target_get_trace_status (trace_status *ts)
+{
+ return current_top_target ()->get_trace_status (ts);
+}
+
+void
+target_get_tracepoint_status (breakpoint *tp, uploaded_tp *utp)
+{
+ return current_top_target ()->get_tracepoint_status (tp, utp);
+}
+
+void
+target_trace_stop ()
+{
+ return current_top_target ()->trace_stop ();
+}
+
+int
+target_trace_find (trace_find_type type, int num,
+ CORE_ADDR addr1, CORE_ADDR addr2, int *tpp)
+{
+ return current_top_target ()->trace_find (type, num, addr1, addr2, tpp);
+}
+
+bool
+target_get_trace_state_variable_value (int tsv, LONGEST *val)
+{
+ return current_top_target ()->get_trace_state_variable_value (tsv, val);
+}
+
+int
+target_save_trace_data (const char *filename)
+{
+ return current_top_target ()->save_trace_data (filename);
+}
+
+int
+target_upload_tracepoints (uploaded_tp **utpp)
+{
+ return current_top_target ()->upload_tracepoints (utpp);
+}
+
+int
+target_upload_trace_state_variables (uploaded_tsv **utsvp)
+{
+ return current_top_target ()->upload_trace_state_variables (utsvp);
+}
+
+LONGEST
+target_get_raw_trace_data (gdb_byte *buf, ULONGEST offset, LONGEST len)
+{
+ return current_top_target ()->get_raw_trace_data (buf, offset, len);
+}
+
+int
+target_get_min_fast_tracepoint_insn_len ()
+{
+ return current_top_target ()->get_min_fast_tracepoint_insn_len ();
+}
+
+void
+target_set_disconnected_tracing (int val)
+{
+ return current_top_target ()->set_disconnected_tracing (val);
+}
+
+void
+target_set_circular_trace_buffer (int val)
+{
+ return current_top_target ()->set_circular_trace_buffer (val);
+}
+
+void
+target_set_trace_buffer_size (LONGEST val)
+{
+ return current_top_target ()->set_trace_buffer_size (val);
+}
+
+bool
+target_set_trace_notes (const char *user, const char *notes,
+ const char *stopnotes)
+{
+ return current_top_target ()->set_trace_notes (user, notes, stopnotes);
+}
+
+bool
+target_get_tib_address (ptid_t ptid, CORE_ADDR *addr)
+{
+ return current_top_target ()->get_tib_address (ptid, addr);
+}
+
+void
+target_set_permissions ()
+{
+ return current_top_target ()->set_permissions ();
+}
+
+bool
+target_static_tracepoint_marker_at (CORE_ADDR addr,
+ static_tracepoint_marker *marker)
+{
+ return current_top_target ()->static_tracepoint_marker_at (addr, marker);
+}
+
+std::vector<static_tracepoint_marker>
+target_static_tracepoint_markers_by_strid (const char *marker_id)
+{
+ return current_top_target ()->static_tracepoint_markers_by_strid (marker_id);
+}
+
+traceframe_info_up
+target_traceframe_info ()
+{
+ return current_top_target ()->traceframe_info ();
+}
+
+bool
+target_use_agent (bool use)
+{
+ return current_top_target ()->use_agent (use);
+}
+
+bool
+target_can_use_agent ()
+{
+ return current_top_target ()->can_use_agent ();
+}
+
+bool
+target_augmented_libraries_svr4_read ()
+{
+ return current_top_target ()->augmented_libraries_svr4_read ();
+}
+
+bool
+target_supports_memory_tagging ()
+{
+ return current_top_target ()->supports_memory_tagging ();
+}
+
+bool
+target_fetch_memtags (CORE_ADDR address, size_t len, gdb::byte_vector &tags,
+ int type)
+{
+ return current_top_target ()->fetch_memtags (address, len, tags, type);
+}
+
+bool
+target_store_memtags (CORE_ADDR address, size_t len,
+ const gdb::byte_vector &tags, int type)
+{
+ return current_top_target ()->store_memtags (address, len, tags, type);
+}
+
+void
+target_log_command (const char *p)
+{
+ return current_top_target ()->log_command (p);
+}
+
/* This is used to implement the various target commands. */
static void