/* 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.
#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 */
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);
/* 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() */
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. */
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)
{
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)
{
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;
}