stub doesn't support qC. This is the first stop reported
after an attach, so this is the main thread. Update the
ptid in the thread list. */
- if (in_thread_list (pid_to_ptid (pid)))
+ if (in_thread_list (ptid_t (pid)))
thread_change_ptid (inferior_ptid, currthread);
else
{
pp = unpack_varlen_hex (p + 1, &tid);
if (obuf)
*obuf = pp;
- return ptid_build (pid, tid, 0);
+ return ptid_t (pid, tid, 0);
}
/* No multi-process. Just a tid. */
if (obuf)
*obuf = pp;
- return ptid_build (pid, tid, 0);
+ return ptid_t (pid, tid, 0);
}
static int
remote_target::extra_thread_info (thread_info *tp)
{
struct remote_state *rs = get_remote_state ();
- int result;
int set;
threadref id;
struct gdb_ext_thread_info threadinfo;
- static char display_buf[100]; /* arbitrary... */
- int n = 0; /* position in display_buf */
if (rs->remote_desc == 0) /* paranoia */
internal_error (__FILE__, __LINE__,
server doesn't know about it. */
return NULL;
+ std::string &extra = get_remote_thread_info (tp)->extra;
+
+ /* If already have cached info, use it. */
+ if (!extra.empty ())
+ return extra.c_str ();
+
if (packet_support (PACKET_qXfer_threads) == PACKET_ENABLE)
{
- if (tp->priv != NULL)
- {
- const std::string &extra = get_remote_thread_info (tp)->extra;
- return !extra.empty () ? extra.c_str () : NULL;
- }
- else
- return NULL;
+ /* If we're using qXfer:threads:read, then the extra info is
+ included in the XML. So if we didn't have anything cached,
+ it's because there's really no extra info. */
+ return NULL;
}
if (rs->use_threadextra_query)
getpkt (&rs->buf, &rs->buf_size, 0);
if (rs->buf[0] != 0)
{
- n = std::min (strlen (rs->buf) / 2, sizeof (display_buf));
- result = hex2bin (rs->buf, (gdb_byte *) display_buf, n);
- display_buf [result] = '\0';
- return display_buf;
+ extra.resize (strlen (rs->buf) / 2);
+ hex2bin (rs->buf, (gdb_byte *) &extra[0], extra.size ());
+ return extra.c_str ();
}
}
if (threadinfo.active)
{
if (*threadinfo.shortname)
- n += xsnprintf (&display_buf[0], sizeof (display_buf) - n,
- " Name: %s,", threadinfo.shortname);
+ string_appendf (extra, " Name: %s", threadinfo.shortname);
if (*threadinfo.display)
- n += xsnprintf (&display_buf[n], sizeof (display_buf) - n,
- " State: %s,", threadinfo.display);
+ {
+ if (!extra.empty ())
+ extra += ',';
+ string_appendf (extra, " State: %s", threadinfo.display);
+ }
if (*threadinfo.more_display)
- n += xsnprintf (&display_buf[n], sizeof (display_buf) - n,
- " Priority: %s", threadinfo.more_display);
-
- if (n > 0)
{
- /* For purely cosmetic reasons, clear up trailing commas. */
- if (',' == display_buf[n-1])
- display_buf[n-1] = ' ';
- return display_buf;
+ if (!extra.empty ())
+ extra += ',';
+ string_appendf (extra, " Priority: %s", threadinfo.more_display);
}
+ return extra.c_str ();
}
return NULL;
}
ptid_t
remote_target::get_ada_task_ptid (long lwp, long thread)
{
- return ptid_build (ptid_get_pid (inferior_ptid), lwp, 0);
+ return ptid_t (ptid_get_pid (inferior_ptid), lwp, 0);
}
\f
struct target_waitstatus *ws = &thread->suspend.waitstatus;
switch_to_thread (thread);
- stop_pc = get_frame_pc (get_current_frame ());
+ thread->suspend.stop_pc = get_frame_pc (get_current_frame ());
set_current_sal_from_frame (get_current_frame ());
thread->suspend.waitstatus_pending_p = 0;
{
/* Save the pid as a string before mourning, since that will
unpush the remote target, and we need the string after. */
- std::string infpid = target_pid_to_str (pid_to_ptid (pid));
+ std::string infpid = target_pid_to_str (ptid_t (pid));
target_mourn_inferior (inferior_ptid);
if (print_inferior_events)
if (exec_file)
printf_unfiltered (_("Attaching to program: %s, %s\n"), exec_file,
- target_pid_to_str (pid_to_ptid (pid)));
+ target_pid_to_str (ptid_t (pid)));
else
printf_unfiltered (_("Attaching to %s\n"),
- target_pid_to_str (pid_to_ptid (pid)));
+ target_pid_to_str (ptid_t (pid)));
gdb_flush (gdb_stdout);
}
}
else if (strcmp (rs->buf, "OK") != 0)
error (_("Attaching to %s failed with: %s"),
- target_pid_to_str (pid_to_ptid (pid)),
+ target_pid_to_str (ptid_t (pid)),
rs->buf);
break;
case PACKET_UNKNOWN:
error (_("This target does not support attaching to a process"));
default:
error (_("Attaching to %s failed"),
- target_pid_to_str (pid_to_ptid (pid)));
+ target_pid_to_str (ptid_t (pid)));
}
set_current_inferior (remote_add_inferior (0, pid, 1, 0));
- inferior_ptid = pid_to_ptid (pid);
+ inferior_ptid = ptid_t (pid);
if (target_is_non_stop_p ())
{
if (thread)
inferior_ptid = thread->ptid;
else
- inferior_ptid = pid_to_ptid (pid);
+ inferior_ptid = ptid_t (pid);
/* Invalidate our notion of the remote current thread. */
record_currthread (rs, minus_one_ptid);
ptid_t nptid;
/* All (-1) threads of process. */
- nptid = ptid_build (ptid_get_pid (ptid), -1, 0);
+ nptid = ptid_t (ptid_get_pid (ptid), -1, 0);
p += xsnprintf (p, endp - p, ":");
p = write_ptid (p, endp, nptid);
{
if (get_remote_inferior (inf)->may_wildcard_vcont)
{
- vcont_builder.push_action (pid_to_ptid (inf->pid),
+ vcont_builder.push_action (ptid_t (inf->pid),
false, GDB_SIGNAL_0);
}
}
if (ptid_is_pid (ptid))
/* All (-1) threads of process. */
- nptid = ptid_build (ptid_get_pid (ptid), -1, 0);
+ nptid = ptid_t (ptid_get_pid (ptid), -1, 0);
else
{
/* Small optimization: if we already have a stop reply for
}
else
error (_("unknown stop reply packet: %s"), buf);
- event->ptid = pid_to_ptid (pid);
+ event->ptid = ptid_t (pid);
}
break;
case 'N':
{
int sample_thread = SAMPLE_THREAD;
int pid = ptid_get_pid (inferior_ptid);
- ptid_t ptid = ptid_build (pid, sample_thread, 0);
+ ptid_t ptid = ptid_t (pid, sample_thread, 0);
if (remote_thread_alive (ptid))
printf_filtered ("PASS: Thread alive test\n");
/* Take advantage of the fact that the TID field is not used, to tag
special ptids with it set to != 0. */
- magic_null_ptid = ptid_build (42000, -1, 1);
- not_sent_ptid = ptid_build (42000, -2, 1);
- any_thread_ptid = ptid_build (42000, 0, 1);
+ magic_null_ptid = ptid_t (42000, -1, 1);
+ not_sent_ptid = ptid_t (42000, -2, 1);
+ any_thread_ptid = ptid_t (42000, 0, 1);
}