Multi-target support
[deliverable/binutils-gdb.git] / gdb / sol-thread.c
index f8e8df532145079f9b7c604075d8fc50333e0681..bf2325b6a9e7f712d0f110b1efdf435cfaea6ce9 100644 (file)
@@ -1,6 +1,6 @@
 /* Solaris threads debugging interface.
 
-   Copyright (C) 1996-2019 Free Software Foundation, Inc.
+   Copyright (C) 1996-2020 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -22,7 +22,7 @@
    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
@@ -87,7 +87,7 @@ public:
   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;
@@ -253,7 +253,7 @@ td_err_string (td_err_e errcode)
   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 *
@@ -391,7 +391,7 @@ sol_thread_target::detach (inferior *inf, int from_tty)
   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.  */
@@ -461,9 +461,13 @@ sol_thread_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
       /* 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);
+           }
        }
     }
 
@@ -853,7 +857,8 @@ ps_lgetregs (struct ps_prochandle *ph, lwpid_t lwpid, prgregset_t gregset)
 {
   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);
@@ -869,7 +874,8 @@ ps_lsetregs (struct ps_prochandle *ph, lwpid_t lwpid,
 {
   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);
@@ -921,7 +927,8 @@ ps_lgetfpregs (struct ps_prochandle *ph, lwpid_t lwpid,
 {
   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);
@@ -937,7 +944,8 @@ ps_lsetfpregs (struct ps_prochandle *ph, lwpid_t lwpid,
 {
   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);
@@ -997,11 +1005,9 @@ ps_lgetLDT (struct ps_prochandle *ph, lwpid_t lwpid, struct ssd *pldt)    /* ARI: e
 
 /* 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;
@@ -1009,21 +1015,19 @@ sol_thread_target::pid_to_str (ptid_t ptid)
       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
 
@@ -1041,9 +1045,13 @@ sol_update_thread_list_callback (const td_thrhandle_t *th, void *ignored)
     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;
 }
@@ -1113,7 +1121,7 @@ info_cb (const td_thrhandle_t *th, void *s)
 
          printf_filtered ("   startfunc=%s",
                           msym.minsym
-                          ? MSYMBOL_PRINT_NAME (msym.minsym)
+                          ? msym.minsym->print_name ()
                           : paddress (target_gdbarch (), ti.ti_startfunc));
        }
 
@@ -1125,7 +1133,7 @@ info_cb (const td_thrhandle_t *th, void *s)
 
          printf_filtered ("   sleepfunc=%s",
                           msym.minsym
-                          ? MSYMBOL_PRINT_NAME (msym.minsym)
+                          ? msym.minsym->print_name ()
                           : paddress (target_gdbarch (), ti.ti_pc));
        }
 
This page took 0.02868 seconds and 4 git commands to generate.