/* Solaris threads debugging interface.
- Copyright (C) 1996-2018 Free Software Foundation, Inc.
+ Copyright (C) 1996-2020 Free Software Foundation, Inc.
This file is part of GDB.
to provide access to the Solaris user-mode thread implementation.
Solaris threads are true user-mode threads, which are invoked via
- the thr_* and pthread_* (native and POSIX respectivly) interfaces.
+ the thr_* and pthread_* (native and POSIX respectively) interfaces.
These are mostly implemented in user-space, with all thread context
kept in various structures that live in the user's heap. These
should not be confused with lightweight processes (LWPs), which are
class sol_thread_target final : public target_ops
{
public:
- sol_thread_target ()
- { this->to_stratum = thread_stratum; }
-
const target_info &info () const override
{ return thread_db_target_info; }
+ strata stratum () const override { return thread_stratum; }
+
void detach (inferior *, int) override;
ptid_t wait (ptid_t, struct target_waitstatus *, int) override;
void resume (ptid_t, int, enum gdb_signal) override;
void mourn_inferior () override;
- const char *pid_to_str (ptid_t) override;
+ std::string pid_to_str (ptid_t) override;
ptid_t get_ada_task_ptid (long lwp, long thread) override;
void fetch_registers (struct regcache *, int) override;
return buf;
}
-/* Return the libthread_db state string assicoated with STATECODE.
+/* Return the libthread_db state string associated with STATECODE.
If STATECODE is unknown, return an appropriate message. */
static const char *
beneath->detach (inf, from_tty);
}
-/* Resume execution of process PTID. If STEP is nozero, then just
+/* Resume execution of process PTID. If STEP is nonzero, then just
single step it. If SIGNAL is nonzero, restart it with that signal
activated. We may have to convert PTID from a thread ID to an LWP
ID for procfs. */
/* See if we have a new thread. */
if (rtnval.tid_p () && rtnval != save_ptid)
{
- thread_info *thr = find_thread_ptid (rtnval);
+ thread_info *thr = find_thread_ptid (current_inferior (), rtnval);
if (thr == NULL || thr->state == THREAD_EXITED)
- add_thread (rtnval);
+ {
+ process_stratum_target *proc_target
+ = current_inferior ()->process_target ();
+ add_thread (proc_target, rtnval);
+ }
}
}
{
ptid_t ptid = ptid_t (inferior_ptid.pid (), lwpid, 0);
struct regcache *regcache
- = get_thread_arch_regcache (ptid, target_gdbarch ());
+ = get_thread_arch_regcache (current_inferior ()->process_target (),
+ ptid, target_gdbarch ());
target_fetch_registers (regcache, -1);
fill_gregset (regcache, (gdb_gregset_t *) gregset, -1);
{
ptid_t ptid = ptid_t (inferior_ptid.pid (), lwpid, 0);
struct regcache *regcache
- = get_thread_arch_regcache (ptid, target_gdbarch ());
+ = get_thread_arch_regcache (current_inferior ()->process_target (),
+ ptid, target_gdbarch ());
supply_gregset (regcache, (const gdb_gregset_t *) gregset);
target_store_registers (regcache, -1);
{
ptid_t ptid = ptid_t (inferior_ptid.pid (), lwpid, 0);
struct regcache *regcache
- = get_thread_arch_regcache (ptid, target_gdbarch ());
+ = get_thread_arch_regcache (current_inferior ()->process_target (),
+ ptid, target_gdbarch ());
target_fetch_registers (regcache, -1);
fill_fpregset (regcache, (gdb_fpregset_t *) fpregset, -1);
{
ptid_t ptid = ptid_t (inferior_ptid.pid (), lwpid, 0);
struct regcache *regcache
- = get_thread_arch_regcache (ptid, target_gdbarch ());
+ = get_thread_arch_regcache (current_inferior ()->process_target (),
+ ptid, target_gdbarch ());
supply_fpregset (regcache, (const gdb_fpregset_t *) fpregset);
target_store_registers (regcache, -1);
/* Convert PTID to printable form. */
-const char *
+std::string
sol_thread_target::pid_to_str (ptid_t ptid)
{
- static char buf[100];
-
if (ptid.tid_p ())
{
ptid_t lwp;
lwp = thread_to_lwp (ptid, -2);
if (lwp.pid () == -1)
- xsnprintf (buf, sizeof (buf), "Thread %ld (defunct)",
- ptid.tid ());
+ return string_printf ("Thread %ld (defunct)",
+ ptid.tid ());
else if (lwp.pid () != -2)
- xsnprintf (buf, sizeof (buf), "Thread %ld (LWP %ld)",
- ptid.tid (), lwp.lwp ());
+ return string_printf ("Thread %ld (LWP %ld)",
+ ptid.tid (), lwp.lwp ());
else
- xsnprintf (buf, sizeof (buf), "Thread %ld ",
- ptid.tid ());
+ return string_printf ("Thread %ld ",
+ ptid.tid ());
}
else if (ptid.lwp () != 0)
- xsnprintf (buf, sizeof (buf), "LWP %ld ", ptid.lwp ());
+ return string_printf ("LWP %ld ", ptid.lwp ());
else
- xsnprintf (buf, sizeof (buf), "process %d ", ptid.pid ());
-
- return buf;
+ return string_printf ("process %d ", ptid.pid ());
}
\f
return -1;
ptid_t ptid = ptid_t (inferior_ptid.pid (), 0, ti.ti_tid);
- thread_info *thr = find_thread_ptid (ptid);
+ thread_info *thr = find_thread_ptid (current_inferior (), ptid);
if (thr == NULL || thr->state == THREAD_EXITED)
- add_thread (ptid);
+ {
+ process_stratum_target *proc_target
+ = current_inferior ()->process_target ();
+ add_thread (proc_target, ptid);
+ }
return 0;
}
printf_filtered (" startfunc=%s",
msym.minsym
- ? MSYMBOL_PRINT_NAME (msym.minsym)
+ ? msym.minsym->print_name ()
: paddress (target_gdbarch (), ti.ti_startfunc));
}
printf_filtered (" sleepfunc=%s",
msym.minsym
- ? MSYMBOL_PRINT_NAME (msym.minsym)
+ ? msym.minsym->print_name ()
: paddress (target_gdbarch (), ti.ti_pc));
}