* gdbarch.sh (GET_LONGJMP_TARGET): Add rule.
[deliverable/binutils-gdb.git] / gdb / sol-thread.c
index 97f3e2426a9e810776772ccdd07d5c1c9d0432c1..50caed39d99a8539b9b2201af37ba0a2f8c92497 100644 (file)
@@ -1,5 +1,5 @@
 /* Low level interface for debugging Solaris threads for GDB, the GNU debugger.
-   Copyright 1996, 1997, 1998, 1999, 2000, 2001
+   Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002
    Free Software Foundation, Inc.
 
    This file is part of GDB.
@@ -60,6 +60,7 @@
 #include "gdbcmd.h"
 #include "gdbcore.h"
 #include "regcache.h"
+#include "symfile.h"
 
 extern struct target_ops sol_thread_ops;       /* Forward declaration */
 extern struct target_ops sol_core_ops; /* Forward declaration */
@@ -97,8 +98,6 @@ static struct ps_prochandle main_ph;
 static td_thragent_t *main_ta;
 static int sol_thread_active = 0;
 
-static struct cleanup *save_inferior_ptid (void);
-static void restore_inferior_ptid (void *pid);
 static char *td_err_string (td_err_e errcode);
 static char *td_state_string (td_thr_state_e statecode);
 static ptid_t thread_to_lwp (ptid_t thread_id, int default_lwp);
@@ -113,14 +112,15 @@ static void init_sol_core_ops (void);
 /* Default definitions: These must be defined in tm.h 
    if they are to be shared with a process module such as procfs.  */
 
-#define THREAD_FLAG            0x80000000
-#define is_thread(ARG)         (((ARG) & THREAD_FLAG) != 0)
-#define is_lwp(ARG)            (((ARG) & THREAD_FLAG) == 0)
-#define GET_LWP(PID)           TIDGET (PID)
-#define GET_THREAD(PID)                TIDGET (PID)
-#define BUILD_LWP(TID, PID)    MERGEPID (PID, TID)
+#define GET_PID(ptid)          ptid_get_pid (ptid)
+#define GET_LWP(ptid)          ptid_get_lwp (ptid)
+#define GET_THREAD(ptid)       ptid_get_tid (ptid)
 
-#define BUILD_THREAD(TID, PID) (MERGEPID (PID, TID) | THREAD_FLAG)
+#define is_lwp(ptid)           (GET_LWP (ptid) != 0)
+#define is_thread(ptid)                (GET_THREAD (ptid) != 0)
+
+#define BUILD_LWP(lwp, pid)    ptid_build (pid, lwp, 0)
+#define BUILD_THREAD(tid, pid) ptid_build (pid, 0, tid)
 
 /* Pointers to routines from lithread_db resolved by dlopen() */
 
@@ -395,50 +395,6 @@ lwp_to_thread (ptid_t lwp)
   return BUILD_THREAD (ti.ti_tid, PIDGET (lwp));
 }
 \f
-/*
-
-   LOCAL FUNCTION
-
-   save_inferior_ptid - Save inferior_ptid on the cleanup list
-   restore_inferior_ptid - Restore inferior_ptid from the cleanup list
-
-   SYNOPSIS
-
-   struct cleanup *save_inferior_ptid ()
-   void restore_inferior_ptid (int pid)
-
-   DESCRIPTION
-
-   These two functions act in unison to restore inferior_ptid in
-   case of an error.
-
-   NOTES
-
-   inferior_ptid is a global variable that needs to be changed by many of
-   these routines before calling functions in procfs.c.  In order to
-   guarantee that inferior_ptid gets restored (in case of errors), you
-   need to call save_inferior_ptid before changing it.  At the end of the
-   function, you should invoke do_cleanups to restore it.
-
- */
-
-
-static struct cleanup *
-save_inferior_ptid (void)
-{
-  ptid_t *saved_ptid = xmalloc (sizeof (ptid_t));
-  *saved_ptid = inferior_ptid;
-  return make_cleanup (restore_inferior_ptid, saved_ptid);
-}
-
-static void
-restore_inferior_ptid (void *data)
-{
-  ptid_t *saved_ptid = data;
-  inferior_ptid = *saved_ptid;
-  xfree (saved_ptid);
-}
-\f
 
 /* Most target vector functions from here on actually just pass through to
    procfs.c, as they don't need to do anything specific for threads.  */
@@ -460,7 +416,7 @@ sol_thread_attach (char *args, int from_tty)
   procfs_ops.to_attach (args, from_tty);
 
   /* Must get symbols from solibs before libthread_db can run! */
-  SOLIB_ADD ((char *) 0, from_tty, (struct target_ops *) 0);
+  SOLIB_ADD ((char *) 0, from_tty, (struct target_ops *) 0, auto_solib_add);
 
   if (sol_thread_active)
     {
@@ -1554,6 +1510,22 @@ info_solthreads (char *args, int from_tty)
                    TD_SIGNO_MASK, TD_THR_ANY_USER_FLAGS);
 }
 
+static int
+sol_find_memory_regions (int (*func) (CORE_ADDR, 
+                                     unsigned long, 
+                                     int, int, int, 
+                                     void *), 
+                        void *data)
+{
+  return procfs_ops.to_find_memory_regions (func, data);
+}
+
+static char *
+sol_make_note_section (bfd *obfd, int *note_size)
+{
+  return procfs_ops.to_make_corefile_notes (obfd, note_size);
+}
+
 static int
 ignore (CORE_ADDR addr, char *contents)
 {
@@ -1605,6 +1577,8 @@ init_sol_thread_ops (void)
   sol_thread_ops.to_has_thread_control = tc_none;
   sol_thread_ops.to_sections = 0;
   sol_thread_ops.to_sections_end = 0;
+  sol_thread_ops.to_find_memory_regions = sol_find_memory_regions;
+  sol_thread_ops.to_make_corefile_notes = sol_make_note_section;
   sol_thread_ops.to_magic = OPS_MAGIC;
 }
 
This page took 0.025849 seconds and 4 git commands to generate.