X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=gdb%2Fremote.c;h=ae06c4ba79155ed37478e1d45af8148f6c3c5ce6;hb=aedbe3bb9f03be12ad714adca1fefc391317bd94;hp=767c69444b84ae00b3ceddd59ff1b31bfa3426c1;hpb=eedc3f4f0a02c9774277bd1a34aab6ebdc32f797;p=binutils-gdb.git diff --git a/gdb/remote.c b/gdb/remote.c index 767c69444b8..ae06c4ba791 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -42,12 +42,12 @@ #include "cli/cli-setshow.h" #include "target-descriptions.h" #include "gdb_bfd.h" -#include "common/filestuff.h" -#include "common/rsp-low.h" +#include "gdbsupport/filestuff.h" +#include "gdbsupport/rsp-low.h" #include "disasm.h" #include "location.h" -#include "common/gdb_sys_time.h" +#include "gdbsupport/gdb_sys_time.h" #include "event-loop.h" #include "event-top.h" @@ -68,13 +68,13 @@ #include "tracepoint.h" #include "ax.h" #include "ax-gdb.h" -#include "common/agent.h" +#include "gdbsupport/agent.h" #include "btrace.h" #include "record-btrace.h" #include -#include "common/scoped_restore.h" -#include "common/environ.h" -#include "common/byte-vector.h" +#include "gdbsupport/scoped_restore.h" +#include "gdbsupport/environ.h" +#include "gdbsupport/byte-vector.h" #include /* The remote target. */ @@ -485,6 +485,9 @@ public: int handle_len, inferior *inf) override; + gdb::byte_vector thread_info_to_thread_handle (struct thread_info *tp) + override; + void stop (ptid_t) override; void interrupt () override; @@ -664,7 +667,7 @@ public: const struct btrace_config *btrace_conf (const struct btrace_target_info *) override; bool augmented_libraries_svr4_read () override; int follow_fork (int, int) override; - void follow_exec (struct inferior *, char *) override; + void follow_exec (struct inferior *, const char *) override; int insert_fork_catchpoint (int) override; int remove_fork_catchpoint (int) override; int insert_vfork_catchpoint (int) override; @@ -764,7 +767,7 @@ public: /* Remote specific methods. */ char *remote_get_noisy_reply (); int remote_query_attached (int pid); - inferior *remote_add_inferior (int fake_pid_p, int pid, int attached, + inferior *remote_add_inferior (bool fake_pid_p, int pid, int attached, int try_open_exec); ptid_t remote_current_thread (ptid_t oldpid); @@ -966,7 +969,8 @@ public: }; /* Per-program-space data key. */ -static const struct program_space_data *remote_pspace_data; +static const struct program_space_key> + remote_pspace_data; /* The variable registered as the control variable used by the remote exec-file commands. While the remote exec-file setting is @@ -1226,16 +1230,6 @@ remote_target::get_remote_state () return &m_remote_state; } -/* Cleanup routine for the remote module's pspace data. */ - -static void -remote_pspace_data_cleanup (struct program_space *pspace, void *arg) -{ - char *remote_exec_file = (char *) arg; - - xfree (remote_exec_file); -} - /* Fetch the remote exec-file from the current program space. */ static const char * @@ -1243,9 +1237,7 @@ get_remote_exec_file (void) { char *remote_exec_file; - remote_exec_file - = (char *) program_space_data (current_program_space, - remote_pspace_data); + remote_exec_file = remote_pspace_data.get (current_program_space); if (remote_exec_file == NULL) return ""; @@ -1256,13 +1248,12 @@ get_remote_exec_file (void) static void set_pspace_remote_exec_file (struct program_space *pspace, - char *remote_exec_file) + const char *remote_exec_file) { - char *old_file = (char *) program_space_data (pspace, remote_pspace_data); + char *old_file = remote_pspace_data.get (pspace); xfree (old_file); - set_program_space_data (pspace, remote_pspace_data, - xstrdup (remote_exec_file)); + remote_pspace_data.set (pspace, xstrdup (remote_exec_file)); } /* The "set/show remote exec-file" set command hook. */ @@ -1834,10 +1825,10 @@ add_packet_config_cmd (struct packet_config *config, const char *name, config->name = name; config->title = title; - set_doc = xstrprintf ("Set use of remote protocol `%s' (%s) packet", + set_doc = xstrprintf ("Set use of remote protocol `%s' (%s) packet.", name, title); show_doc = xstrprintf ("Show current use of remote " - "protocol `%s' (%s) packet", + "protocol `%s' (%s) packet.", name, title); /* set/show TITLE-packet {auto,on,off} */ cmd_name = xstrprintf ("%s-packet", title); @@ -2351,7 +2342,7 @@ remote_target::remote_query_attached (int pid) if no main executable is open already. */ inferior * -remote_target::remote_add_inferior (int fake_pid_p, int pid, int attached, +remote_target::remote_add_inferior (bool fake_pid_p, int pid, int attached, int try_open_exec) { struct inferior *inf; @@ -2492,7 +2483,7 @@ remote_target::remote_notice_new_inferior (ptid_t currthread, int executing) if (find_inferior_pid (currthread.pid ()) == NULL) { struct remote_state *rs = get_remote_state (); - int fake_pid_p = !remote_multi_process_p (rs); + bool fake_pid_p = !remote_multi_process_p (rs); inf = remote_add_inferior (fake_pid_p, currthread.pid (), -1, 1); @@ -4049,7 +4040,7 @@ remote_target::~remote_target () if (rs->remote_async_inferior_event_token) delete_async_event_handler (&rs->remote_async_inferior_event_token); - remote_notif_state_xfree (rs->notif_state); + delete rs->notif_state; } /* Query the remote side for the text, data and bss offsets. */ @@ -4308,7 +4299,7 @@ void remote_target::add_current_inferior_and_thread (char *wait_status) { struct remote_state *rs = get_remote_state (); - int fake_pid_p = 0; + bool fake_pid_p = false; inferior_ptid = null_ptid; @@ -4318,7 +4309,7 @@ remote_target::add_current_inferior_and_thread (char *wait_status) if (curr_ptid != null_ptid) { if (!remote_multi_process_p (rs)) - fake_pid_p = 1; + fake_pid_p = true; } else { @@ -4327,7 +4318,7 @@ remote_target::add_current_inferior_and_thread (char *wait_status) double duty as both the pid of the target process (if it has such), and as a flag indicating that a target is active. */ curr_ptid = magic_null_ptid; - fake_pid_p = 1; + fake_pid_p = true; } remote_add_inferior (fake_pid_p, curr_ptid.pid (), -1, 1); @@ -5760,7 +5751,7 @@ remote_target::follow_fork (int follow_child, int detach_fork) follow-exec-mode is "new". */ void -remote_target::follow_exec (struct inferior *inf, char *execd_pathname) +remote_target::follow_exec (struct inferior *inf, const char *execd_pathname) { /* We know that this is a target file name, so if it has the "target:" prefix we strip it off before saving it in the program space. */ @@ -5844,7 +5835,7 @@ extended_remote_target::attach (const char *args, int from_tty) target_pid_to_str (ptid_t (pid)).c_str ()); } - set_current_inferior (remote_add_inferior (0, pid, 1, 0)); + set_current_inferior (remote_add_inferior (false, pid, 1, 0)); inferior_ptid = ptid_t (pid); @@ -9458,6 +9449,20 @@ remote_target::read_frame (gdb::char_vector *buf_p) } } +/* Set this to the maximum number of seconds to wait instead of waiting forever + in target_wait(). If this timer times out, then it generates an error and + the command is aborted. This replaces most of the need for timeouts in the + GDB test suite, and makes it possible to distinguish between a hung target + and one with slow communications. */ + +static int watchdog = 0; +static void +show_watchdog (struct ui_file *file, int from_tty, + struct cmd_list_element *c, const char *value) +{ + fprintf_filtered (file, _("Watchdog timer is %s.\n"), value); +} + /* Read a packet from the remote machine, with error checking, and store it in *BUF. Resize *BUF if necessary to hold the result. If FOREVER, wait forever rather than timing out; this is used (in @@ -10361,9 +10366,9 @@ remote_target::remove_watchpoint (CORE_ADDR addr, int len, } -int remote_hw_watchpoint_limit = -1; -int remote_hw_watchpoint_length_limit = -1; -int remote_hw_breakpoint_limit = -1; +static int remote_hw_watchpoint_limit = -1; +static int remote_hw_watchpoint_length_limit = -1; +static int remote_hw_breakpoint_limit = -1; int remote_target::region_ok_for_hw_watchpoint (CORE_ADDR addr, int len) @@ -11381,15 +11386,15 @@ init_remote_threadtests (void) { add_com ("tlist", class_obscure, threadlist_test_cmd, _("Fetch and print the remote list of " - "thread identifiers, one pkt only")); + "thread identifiers, one pkt only.")); add_com ("tinfo", class_obscure, threadinfo_test_cmd, - _("Fetch and display info about one thread")); + _("Fetch and display info about one thread.")); add_com ("tset", class_obscure, threadset_test_cmd, - _("Test setting to a different thread")); + _("Test setting to a different thread.")); add_com ("tupd", class_obscure, threadlist_update_test_cmd, - _("Iterate through updating all remote thread info")); + _("Iterate through updating all remote thread info.")); add_com ("talive", class_obscure, threadalive_test, - _(" Remote thread alive test ")); + _("Remote thread alive test.")); } #endif /* 0 */ @@ -13695,6 +13700,11 @@ remote_target::remote_btrace_maybe_reopen () int warned = 0; #endif + /* Don't bother walking the entirety of the remote thread list when + we know the feature isn't supported by the remote. */ + if (packet_support (PACKET_qXfer_btrace_conf) != PACKET_ENABLE) + return; + scoped_restore_current_thread restore_thread; for (thread_info *tp : all_non_exited_threads ()) @@ -13998,6 +14008,13 @@ remote_target::thread_handle_to_thread_info (const gdb_byte *thread_handle, return NULL; } +gdb::byte_vector +remote_target::thread_info_to_thread_handle (struct thread_info *tp) +{ + remote_thread_info *priv = get_remote_thread_info (tp); + return priv->thread_handle; +} + bool remote_target::can_async_p () { @@ -14253,10 +14270,6 @@ _initialize_remote (void) remote_g_packet_data_handle = gdbarch_data_register_pre_init (remote_g_packet_data_init); - remote_pspace_data - = register_program_space_data_with_cleanup (NULL, - remote_pspace_data_cleanup); - add_target (remote_target_info, remote_target::open); add_target (extended_remote_target_info, extended_remote_target::open); @@ -14270,15 +14283,15 @@ _initialize_remote (void) /* set/show remote ... */ add_prefix_cmd ("remote", class_maintenance, set_remote_cmd, _("\ -Remote protocol specific variables\n\ +Remote protocol specific variables.\n\ Configure various remote-protocol specific variables such as\n\ -the packets being used"), +the packets being used."), &remote_set_cmdlist, "set remote ", 0 /* allow-unknown */, &setlist); add_prefix_cmd ("remote", class_maintenance, show_remote_cmd, _("\ -Remote protocol specific variables\n\ +Remote protocol specific variables.\n\ Configure various remote-protocol specific variables such as\n\ -the packets being used"), +the packets being used."), &remote_show_cmdlist, "show remote ", 0 /* allow-unknown */, &showlist); @@ -14322,8 +14335,8 @@ Valid value is \"Ctrl-C\", \"BREAK\" or \"BREAK-g\". The default is \"Ctrl-C\"." add_setshow_boolean_cmd ("interrupt-on-connect", class_support, &interrupt_on_connect, _("\ -Set whether interrupt-sequence is sent to remote target when gdb connects to."), _(" \ -Show whether interrupt-sequence is sent to remote target when gdb connects to."), _(" \ +Set whether interrupt-sequence is sent to remote target when gdb connects to."), _("\ +Show whether interrupt-sequence is sent to remote target when gdb connects to."), _("\ If set, interrupt sequence is sent to remote target."), NULL, NULL, &remote_set_cmdlist, &remote_show_cmdlist); @@ -14691,8 +14704,8 @@ Show the maximum size of the address (in bits) in a memory packet."), NULL, documentation). */ add_setshow_auto_boolean_cmd ("Z-packet", class_obscure, &remote_Z_packet_detect, _("\ -Set use of remote protocol `Z' packets"), _("\ -Show use of remote protocol `Z' packets "), _("\ +Set use of remote protocol `Z' packets."), _("\ +Show use of remote protocol `Z' packets."), _("\ When set, GDB will attempt to use the remote breakpoint and watchpoint\n\ packets."), set_remote_protocol_Z_packet_cmd, @@ -14702,7 +14715,7 @@ packets."), &remote_set_cmdlist, &remote_show_cmdlist); add_prefix_cmd ("remote", class_files, remote_command, _("\ -Manipulate files on the remote system\n\ +Manipulate files on the remote system.\n\ Transfer files to and from the remote target system."), &remote_cmdlist, "remote ", 0 /* allow-unknown */, &cmdlist); @@ -14721,8 +14734,8 @@ Transfer files to and from the remote target system."), add_setshow_string_noescape_cmd ("exec-file", class_files, &remote_exec_file_var, _("\ -Set the remote pathname for \"run\""), _("\ -Show the remote pathname for \"run\""), NULL, +Set the remote pathname for \"run\"."), _("\ +Show the remote pathname for \"run\"."), NULL, set_remote_exec_file, show_remote_exec_file, &remote_set_cmdlist, @@ -14742,6 +14755,16 @@ stepping is supported by the target. The default is on."), &setlist, &showlist); + add_setshow_zinteger_cmd ("watchdog", class_maintenance, &watchdog, _("\ +Set watchdog timer."), _("\ +Show watchdog timer."), _("\ +When non-zero, this timeout is used instead of waiting forever for a target\n\ +to finish a low-level step or continue operation. If the specified amount\n\ +of time passes without a response from the target, an error occurs."), + NULL, + show_watchdog, + &setlist, &showlist); + /* Eventually initialize fileio. See fileio.c */ initialize_remote_fileio (remote_set_cmdlist, remote_show_cmdlist); }