ptid_t filter_ptid = *(ptid_t *) data;
struct vstop_notif *vstop_event = (struct vstop_notif *) event;
- if (ptid_match (vstop_event->ptid, filter_ptid))
+ if (vstop_event->ptid.matches (filter_ptid))
{
if (q->free_func != NULL)
q->free_func (event);
ptid_t filter_ptid = *(ptid_t *) data;
struct vstop_notif *vstop_event = (struct vstop_notif *) event;
- if (ptid_match (vstop_event->ptid, filter_ptid))
+ if (vstop_event->ptid.matches (filter_ptid))
return 0;
/* Don't resume fork children that GDB does not know about yet. */
if ((vstop_event->status.kind == TARGET_WAITKIND_FORKED
|| vstop_event->status.kind == TARGET_WAITKIND_VFORKED)
- && ptid_match (vstop_event->status.value.related_pid, filter_ptid))
+ && vstop_event->status.value.related_pid.matches (filter_ptid))
return 0;
return 1;
op = own_buf + strlen ("Qbtrace:");
- if (ptid_equal (cs.general_thread, null_ptid)
- || ptid_equal (cs.general_thread, minus_one_ptid))
+ if (cs.general_thread == null_ptid
+ || cs.general_thread == minus_one_ptid)
{
strcpy (own_buf, "E.Must select a single thread.");
return -1;
op = own_buf + strlen ("Qbtrace-conf:");
- if (ptid_equal (cs.general_thread, null_ptid)
- || ptid_equal (cs.general_thread, minus_one_ptid))
+ if (cs.general_thread == null_ptid
+ || cs.general_thread == minus_one_ptid)
{
strcpy (own_buf, "E.Must select a single thread.");
return -1;
handle_detach (char *own_buf)
{
client_state &cs = get_client_state ();
- require_running_or_return (own_buf);
- int pid;
+ process_info *process;
if (cs.multi_process)
{
/* skip 'D;' */
- pid = strtol (&own_buf[2], NULL, 16);
+ int pid = strtol (&own_buf[2], NULL, 16);
+
+ process = find_process_pid (pid);
}
else
- pid = ptid_get_pid (current_ptid);
-
- if ((tracing && disconnected_tracing) || any_persistent_commands ())
{
- struct process_info *process = find_process_pid (pid);
+ process = (current_thread != nullptr
+ ? get_thread_process (current_thread)
+ : nullptr);
+ }
- if (process == NULL)
- {
- write_enn (own_buf);
- return;
- }
+ if (process == NULL)
+ {
+ write_enn (own_buf);
+ return;
+ }
+ if ((tracing && disconnected_tracing) || any_persistent_commands (process))
+ {
if (tracing && disconnected_tracing)
fprintf (stderr,
"Disconnected tracing in effect, "
"leaving gdbserver attached to the process\n");
- if (any_persistent_commands ())
+ if (any_persistent_commands (process))
fprintf (stderr,
"Persistent commands are present, "
"leaving gdbserver attached to the process\n");
return;
}
- fprintf (stderr, "Detaching from process %d\n", pid);
+ fprintf (stderr, "Detaching from process %d\n", process->pid);
stop_tracing ();
- if (detach_inferior (pid) != 0)
+ if (detach_inferior (process) != 0)
write_enn (own_buf);
else
{
- discard_queued_stop_replies (ptid_t (pid));
+ discard_queued_stop_replies (ptid_t (process->pid));
write_ok (own_buf);
if (extended_protocol || target_running ())
and instead treat this like a normal program exit. */
cs.last_status.kind = TARGET_WAITKIND_EXITED;
cs.last_status.value.integer = 0;
- cs.last_ptid = ptid_t (pid);
+ cs.last_ptid = ptid_t (process->pid);
current_thread = NULL;
}
/* If we are attached, then we can exit. Otherwise, we
need to hang around doing nothing, until the child is
gone. */
- join_inferior (pid);
+ join_inferior (process);
exit (0);
}
}
if (writebuf != NULL)
return -2;
- if (ptid_equal (cs.general_thread, null_ptid)
- || ptid_equal (cs.general_thread, minus_one_ptid))
+ if (cs.general_thread == null_ptid
+ || cs.general_thread == minus_one_ptid)
{
strcpy (cs.own_buf, "E.Must select a single thread.");
return -3;
if (annex[0] != '\0')
return -1;
- if (ptid_equal (cs.general_thread, null_ptid)
- || ptid_equal (cs.general_thread, minus_one_ptid))
+ if (cs.general_thread == null_ptid
+ || cs.general_thread == minus_one_ptid)
{
strcpy (cs.own_buf, "E.Must select a single thread.");
return -3;
if (current_thread == NULL)
{
current_thread
- = find_any_thread_of_pid (ptid_get_pid (cs.general_thread));
+ = find_any_thread_of_pid (cs.general_thread.pid ());
/* Just in case, if we didn't find a thread, then bail out
instead of crashing. */
{
const struct thread_resume *action = &actions[i];
- if (ptid_equal (action->thread, minus_one_ptid)
- || ptid_equal (action->thread, thread->id)
- || ((ptid_get_pid (action->thread)
+ if (action->thread == minus_one_ptid
+ || action->thread == thread->id
+ || ((action->thread.pid ()
== thread->id.pid ())
- && ptid_get_lwp (action->thread) == -1))
+ && action->thread.lwp () == -1))
{
if ((*callback) (action, thread))
return true;
pid = strtol (p, NULL, 16);
else
pid = signal_pid;
- if (pid != 0 && kill_inferior (pid) == 0)
+
+ process_info *proc = find_process_pid (pid);
+
+ if (proc != nullptr && kill_inferior (proc) == 0)
{
cs.last_status.kind = TARGET_WAITKIND_SIGNALLED;
cs.last_status.value.sig = GDB_SIGNAL_KILL;
int n = 0;
int valid_cont_thread;
- valid_cont_thread = (!ptid_equal (cs.cont_thread, null_ptid)
- && !ptid_equal (cs.cont_thread, minus_one_ptid));
+ valid_cont_thread = (cs.cont_thread != null_ptid
+ && cs.cont_thread != minus_one_ptid);
if (step || sig || valid_cont_thread)
{
/* If the last event thread is not found for some reason, look
for some other thread that might have an event to report. */
if (thread == NULL)
- thread = find_thread ([] (thread_info *thread)
+ thread = find_thread ([] (thread_info *thr_arg)
{
- return thread->status_pending_p;
+ return thr_arg->status_pending_p;
});
/* If we're still out of luck, simply pick the first thread in
static void
kill_inferior_callback (process_info *process)
{
- int pid = process->pid;
-
- kill_inferior (pid);
- discard_queued_stop_replies (ptid_t (pid));
+ kill_inferior (process);
+ discard_queued_stop_replies (ptid_t (process->pid));
}
/* Call this when exiting gdbserver with possible inferiors that need
int pid = process->pid;
if (process->attached)
- detach_inferior (pid);
+ detach_inferior (process);
else
- kill_inferior (pid);
+ kill_inferior (process);
discard_queued_stop_replies (ptid_t (pid));
});
#if GDB_SELF_TEST
selftests::run_tests (selftest_filter);
#else
- printf (_("Selftests are not available in a non-development build.\n"));
+ printf (_("Selftests have been disabled for this build.\n"));
#endif
throw_quit ("Quit");
}
client_state &cs = get_client_state ();
int signal;
unsigned int len;
- int res;
CORE_ADDR mem_addr;
unsigned char sig;
int packet_len;
if (cs.own_buf[1] == 'g')
{
- if (ptid_equal (thread_id, null_ptid))
+ if (thread_id == null_ptid)
{
/* GDB is telling us to choose any thread. Check if
the currently selected thread is still valid. If
}
break;
case 'm':
- require_running_or_break (cs.own_buf);
- decode_m_packet (&cs.own_buf[1], &mem_addr, &len);
- res = gdb_read_memory (mem_addr, mem_buf, len);
- if (res < 0)
- write_enn (cs.own_buf);
- else
- bin2hex (mem_buf, cs.own_buf, res);
+ {
+ require_running_or_break (cs.own_buf);
+ decode_m_packet (&cs.own_buf[1], &mem_addr, &len);
+ int res = gdb_read_memory (mem_addr, mem_buf, len);
+ if (res < 0)
+ write_enn (cs.own_buf);
+ else
+ bin2hex (mem_buf, cs.own_buf, res);
+ }
break;
case 'M':
require_running_or_break (cs.own_buf);
}
else if (cs.last_status.kind != TARGET_WAITKIND_IGNORE)
{
- int pid = ptid_get_pid (cs.last_ptid);
+ int pid = cs.last_ptid.pid ();
struct process_info *process = find_process_pid (pid);
int forward_event = !gdb_connected () || process->gdb_detached;