2012-03-01 Pedro Alves <palves@redhat.com>
[deliverable/binutils-gdb.git] / gdb / sol-thread.c
index 8c7865b0cfbfb78b4fe260288215fdd6c7aae355..3e5d9db2306341c70d2f080dcab75c68a3d6e2c4 100644 (file)
@@ -1,7 +1,6 @@
 /* Solaris threads debugging interface.
 
-   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
-   2007, 2008, 2009 Free Software Foundation, Inc.
+   Copyright (C) 1996-2005, 2007-2012 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
 #include "symfile.h"
 #include "observer.h"
 #include "gdb_string.h"
-#include <sys/procfs.h>
-#include "proc-utils.h"
+#include "procfs.h"
 
 struct target_ops sol_thread_ops;
 
 extern char *procfs_pid_to_str (struct target_ops *ops, ptid_t ptid);
 
-/* Prototypes for supply_gregset etc. */
+/* Prototypes for supply_gregset etc.  */
 #include "gregset.h"
 
 /* This struct is defined by us, but mainly used for the proc_service
@@ -205,7 +203,7 @@ td_err_string (td_err_e errcode)
   return buf;
 }
 
-/* Return the the libthread_db state string assicoated with STATECODE.
+/* Return the libthread_db state string assicoated with STATECODE.
    If STATECODE is unknown, return an appropriate message.  */
 
 static char *
@@ -765,7 +763,7 @@ sol_thread_alive (struct target_ops *ops, ptid_t ptid)
    Which one you have depends on the Solaris version and what patches
    you've applied.  On the theory that there are only two major
    variants, we have configure check the prototype of ps_pdwrite (),
-   and use that info to make appropriate typedefs here. */
+   and use that info to make appropriate typedefs here.  */
 
 #ifdef PROC_SERVICE_IS_OLD
 typedef const struct ps_prochandle *gdb_ps_prochandle_t;
@@ -919,7 +917,7 @@ ps_lgetregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, prgregset_t gregset)
   old_chain = save_inferior_ptid ();
 
   inferior_ptid = BUILD_LWP (lwpid, PIDGET (inferior_ptid));
-  regcache = get_thread_regcache (inferior_ptid);
+  regcache = get_thread_arch_regcache (inferior_ptid, target_gdbarch);
 
   target_fetch_registers (regcache, -1);
   fill_gregset (regcache, (gdb_gregset_t *) gregset, -1);
@@ -941,7 +939,7 @@ ps_lsetregs (gdb_ps_prochandle_t ph, lwpid_t lwpid,
   old_chain = save_inferior_ptid ();
 
   inferior_ptid = BUILD_LWP (lwpid, PIDGET (inferior_ptid));
-  regcache = get_thread_regcache (inferior_ptid);
+  regcache = get_thread_arch_regcache (inferior_ptid, target_gdbarch);
 
   supply_gregset (regcache, (const gdb_gregset_t *) gregset);
   target_store_registers (regcache, -1);
@@ -1049,7 +1047,7 @@ ps_lgetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid,
   old_chain = save_inferior_ptid ();
 
   inferior_ptid = BUILD_LWP (lwpid, PIDGET (inferior_ptid));
-  regcache = get_thread_regcache (inferior_ptid);
+  regcache = get_thread_arch_regcache (inferior_ptid, target_gdbarch);
 
   target_fetch_registers (regcache, -1);
   fill_fpregset (regcache, (gdb_fpregset_t *) fpregset, -1);
@@ -1059,7 +1057,7 @@ ps_lgetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid,
   return PS_OK;
 }
 
-/* Set floating-point regs for LWP */
+/* Set floating-point regs for LWP */
 
 ps_err_e
 ps_lsetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid,
@@ -1071,7 +1069,7 @@ ps_lsetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid,
   old_chain = save_inferior_ptid ();
 
   inferior_ptid = BUILD_LWP (lwpid, PIDGET (inferior_ptid));
-  regcache = get_thread_regcache (inferior_ptid);
+  regcache = get_thread_arch_regcache (inferior_ptid, target_gdbarch);
 
   supply_fpregset (regcache, (const gdb_fpregset_t *) fpregset);
   target_store_registers (regcache, -1);
@@ -1251,7 +1249,8 @@ info_cb (const td_thrhandle_t *th, void *s)
            printf_filtered ("   startfunc: %s\n",
                             SYMBOL_PRINT_NAME (msym));
          else
-           printf_filtered ("   startfunc: 0x%s\n", paddr (ti.ti_startfunc));
+           printf_filtered ("   startfunc: %s\n",
+                            paddress (target_gdbarch, ti.ti_startfunc));
        }
 
       /* If thread is asleep, print function that went to sleep.  */
@@ -1263,12 +1262,13 @@ info_cb (const td_thrhandle_t *th, void *s)
            printf_filtered (" - Sleep func: %s\n",
                             SYMBOL_PRINT_NAME (msym));
          else
-           printf_filtered (" - Sleep func: 0x%s\n", paddr (ti.ti_startfunc));
+           printf_filtered (" - Sleep func: %s\n",
+                            paddress (target_gdbarch, ti.ti_startfunc));
        }
 
       /* Wrap up line, if necessary.  */
       if (ti.ti_state != TD_THR_SLEEP && ti.ti_startfunc == 0)
-       printf_filtered ("\n"); /* don't you hate counting newlines? */
+       printf_filtered ("\n"); /* don't you hate counting newlines?  */
     }
   else
     warning (_("info sol-thread: failed to get info for thread."));
@@ -1287,6 +1287,40 @@ info_solthreads (char *args, int from_tty)
                    TD_SIGNO_MASK, TD_THR_ANY_USER_FLAGS);
 }
 
+/* Callback routine used to find a thread based on the TID part of
+   its PTID.  */
+
+static int
+thread_db_find_thread_from_tid (struct thread_info *thread, void *data)
+{
+  long *tid = (long *) data;
+
+  if (ptid_get_tid (thread->ptid) == *tid)
+    return 1;
+
+  return 0;
+}
+
+static ptid_t
+sol_get_ada_task_ptid (long lwp, long thread)
+{
+  struct thread_info *thread_info =
+    iterate_over_threads (thread_db_find_thread_from_tid, &thread);
+
+  if (thread_info == NULL)
+    {
+      /* The list of threads is probably not up to date.  Find any
+         thread that is missing from the list, and try again.  */
+      sol_find_new_threads (&current_target);
+      thread_info = iterate_over_threads (thread_db_find_thread_from_tid,
+                                          &thread);
+    }
+
+  gdb_assert (thread_info != NULL);
+
+  return (thread_info->ptid);
+}
+
 static void
 init_sol_thread_ops (void)
 {
@@ -1304,6 +1338,7 @@ init_sol_thread_ops (void)
   sol_thread_ops.to_pid_to_str = solaris_pid_to_str;
   sol_thread_ops.to_find_new_threads = sol_find_new_threads;
   sol_thread_ops.to_stratum = thread_stratum;
+  sol_thread_ops.to_get_ada_task_ptid = sol_get_ada_task_ptid;
   sol_thread_ops.to_magic = OPS_MAGIC;
 }
 
This page took 0.027398 seconds and 4 git commands to generate.