#include "gdbsupport/gdb_sys_time.h"
-#include "event-loop.h"
+#include "gdbsupport/event-loop.h"
#include "event-top.h"
#include "inf-loop.h"
#include "gdbsupport/byte-vector.h"
#include <algorithm>
#include <unordered_map>
+#include "async-event.h"
/* The remote target. */
const struct btrace_config *btrace_conf (const struct btrace_target_info *) override;
bool augmented_libraries_svr4_read () override;
- int follow_fork (int, int) override;
+ bool follow_fork (bool, bool) override;
void follow_exec (struct inferior *, const char *) override;
int insert_fork_catchpoint (int) override;
int remove_fork_catchpoint (int) override;
it is named remote_follow_fork in anticipation of using it for the
remote target as well. */
-int
-remote_target::follow_fork (int follow_child, int detach_fork)
+bool
+remote_target::follow_fork (bool follow_child, bool detach_fork)
{
struct remote_state *rs = get_remote_state ();
enum target_waitkind kind = inferior_thread ()->pending_follow.kind;
remote_detach_pid (child_pid);
}
}
- return 0;
+
+ return false;
}
/* Target follow-exec function for remote targets. Save EXECD_PATHNAME
event->ptid = minus_one_ptid;
break;
}
-
- if (target_is_non_stop_p () && event->ptid == null_ptid)
- error (_("No process or thread specified in stop reply: %s"), buf);
}
/* When the stub wants to tell GDB about a new notification reply, it
non-exited thread in the current target. */
if (ptid == null_ptid)
{
+ /* Some stop events apply to all threads in an inferior, while others
+ only apply to a single thread. */
+ bool is_stop_for_all_threads
+ = (status->kind == TARGET_WAITKIND_EXITED
+ || status->kind == TARGET_WAITKIND_SIGNALLED);
+
for (thread_info *thr : all_non_exited_threads (this))
{
- if (ptid != null_ptid)
+ if (ptid != null_ptid
+ && (!is_stop_for_all_threads
+ || ptid.pid () != thr->ptid.pid ()))
{
static bool warned = false;
if (!warned)
{
/* If you are seeing this warning then the remote target
- has multiple threads and either sent an 'S' stop
- packet, or a 'T' stop packet without a thread-id. In
- both of these cases GDB is unable to know which thread
- just stopped and is now having to guess. The correct
- action is to fix the remote target to send the correct
- packet (a 'T' packet and include a thread-id). */
- warning (_("multi-threaded target stopped without sending "
- "a thread-id, using first non-exited thread"));
+ has stopped without specifying a thread-id, but the
+ target does have multiple threads (or inferiors), and
+ so GDB is having to guess which thread stopped.
+
+ Examples of what might cause this are the target
+ sending and 'S' stop packet, or a 'T' stop packet and
+ not including a thread-id.
+
+ Additionally, the target might send a 'W' or 'X
+ packet without including a process-id, when the target
+ has multiple running inferiors. */
+ if (is_stop_for_all_threads)
+ warning (_("multi-inferior target stopped without "
+ "sending a process-id, using first "
+ "non-exited inferior"));
+ else
+ warning (_("multi-threaded target stopped without "
+ "sending a thread-id, using first "
+ "non-exited thread"));
warned = true;
}
break;
}
- ptid = thr->ptid;
+
+ /* If this is a stop for all threads then don't use a particular
+ threads ptid, instead create a new ptid where only the pid
+ field is set. */
+ if (is_stop_for_all_threads)
+ ptid = ptid_t (thr->ptid.pid ());
+ else
+ ptid = thr->ptid;
}
gdb_assert (ptid != null_ptid);
}
remote_file_delete (argv[0], from_tty);
}
-static void
-remote_command (const char *args, int from_tty)
-{
- help_list (remote_cmdlist, "remote ", all_commands, gdb_stdout);
-}
-
bool
remote_target::can_execute_reverse ()
{
encode_actions_rsp (loc, &tdp_actions, &stepping_actions);
tpaddr = loc->address;
- sprintf_vma (addrbuf, tpaddr);
+ strcpy (addrbuf, phex (tpaddr, sizeof (CORE_ADDR)));
ret = snprintf (buf.data (), buf.size (), "QTDP:%x:%s:%c:%lx:%x",
b->number, addrbuf, /* address */
(b->enable_state == bp_enabled ? 'E' : 'D'),
remote_target::enable_tracepoint (struct bp_location *location)
{
struct remote_state *rs = get_remote_state ();
- char addr_buf[40];
- sprintf_vma (addr_buf, location->address);
xsnprintf (rs->buf.data (), get_remote_packet_size (), "QTEnable:%x:%s",
- location->owner->number, addr_buf);
+ location->owner->number,
+ phex (location->address, sizeof (CORE_ADDR)));
putpkt (rs->buf);
remote_get_noisy_reply ();
if (rs->buf[0] == '\0')
remote_target::disable_tracepoint (struct bp_location *location)
{
struct remote_state *rs = get_remote_state ();
- char addr_buf[40];
- sprintf_vma (addr_buf, location->address);
xsnprintf (rs->buf.data (), get_remote_packet_size (), "QTDisable:%x:%s",
- location->owner->number, addr_buf);
+ location->owner->number,
+ phex (location->address, sizeof (CORE_ADDR)));
putpkt (rs->buf);
remote_get_noisy_reply ();
if (rs->buf[0] == '\0')
}
}
-static void
-set_remote_cmd (const char *args, int from_tty)
-{
- help_list (remote_set_cmdlist, "set remote ", all_commands, gdb_stdout);
-}
-
static void
show_remote_cmd (const char *args, int from_tty)
{
/* set/show remote ... */
- add_prefix_cmd ("remote", class_maintenance, set_remote_cmd, _("\
+ add_basic_prefix_cmd ("remote", class_maintenance, _("\
Remote protocol specific variables.\n\
Configure various remote-protocol specific variables such as\n\
the packets being used."),
- &remote_set_cmdlist, "set remote ",
- 0 /* allow-unknown */, &setlist);
+ &remote_set_cmdlist, "set remote ",
+ 0 /* allow-unknown */, &setlist);
add_prefix_cmd ("remote", class_maintenance, show_remote_cmd, _("\
Remote protocol specific variables.\n\
Configure various remote-protocol specific variables such as\n\
`Z' packets is %s. */
&remote_set_cmdlist, &remote_show_cmdlist);
- add_prefix_cmd ("remote", class_files, remote_command, _("\
+ add_basic_prefix_cmd ("remote", class_files, _("\
Manipulate files on the remote system.\n\
Transfer files to and from the remote target system."),
- &remote_cmdlist, "remote ",
- 0 /* allow-unknown */, &cmdlist);
+ &remote_cmdlist, "remote ",
+ 0 /* allow-unknown */, &cmdlist);
add_cmd ("put", class_files, remote_put_command,
_("Copy a local file to the remote system."),