summaryrefslogtreecommitdiff
path: root/gdb/sol-thread.c
diff options
context:
space:
mode:
authorPedro Alves <pedro@codesourcery.com>2008-09-08 21:31:53 +0000
committerPedro Alves <pedro@codesourcery.com>2008-09-08 21:31:53 +0000
commit6ef86b2071a727b3201732a3146680bcaa5d52c5 (patch)
tree44160614e9b4491176e34daaec3232d7197ce07b /gdb/sol-thread.c
parent2cdd388b596cbc2f6919e198751e3eeac9ba4598 (diff)
downloadgdb-6ef86b2071a727b3201732a3146680bcaa5d52c5.tar.gz
* procfs.c (to_attach): Create a procinfo for the current lwp.
Add it to gdb's thread list. (procfs_fetch_registers, procfs_store_registers): Assume there's always an lwp. (procfs_wait): Don't add the main thread here. (procfs_init_inferior): Create a procinfo for the main lwp here. Change main thread's ptid with thread_change_ptid. (procfs_notice_thread): Check for exited threads. (procfs_corefile_thread_callback): Remove check for the main process. (procfs_make_note_section): Assume there is always a thread. * sol-thread.c (sol_thread_attach): Clear sol_thread_active before attaching. Change the main thread ptid with thread_change_ptid. (sol_thread_detach): Clear sol_thread_active. (sol_thread_wait): Check for exited threads. (sol_thread_create_inferior): Clear sol_thread_active before creating a new inferior. Change the main thread ptid with thread_change_ptid. (sol_thread_mourn_inferior): Clear sol_thread_active. (sol_find_new_threads_callback): Check for exited threads.
Diffstat (limited to 'gdb/sol-thread.c')
-rw-r--r--gdb/sol-thread.c33
1 files changed, 18 insertions, 15 deletions
diff --git a/gdb/sol-thread.c b/gdb/sol-thread.c
index 51a39262397..f36e4ea6238 100644
--- a/gdb/sol-thread.c
+++ b/gdb/sol-thread.c
@@ -253,7 +253,7 @@ td_state_string (td_thr_state_e statecode)
/* Convert a POSIX or Solaris thread ID into a LWP ID. If THREAD_ID
doesn't exist, that's an error. If it's an inactive thread, return
- DEFAULT_LPW.
+ DEFAULT_LWP.
NOTE: This function probably shouldn't call error(). */
@@ -350,6 +350,7 @@ sol_thread_open (char *arg, int from_tty)
static void
sol_thread_attach (char *args, int from_tty)
{
+ sol_thread_active = 0;
procfs_ops.to_attach (args, from_tty);
/* Must get symbols from shared libraries before libthread_db can run! */
@@ -357,14 +358,13 @@ sol_thread_attach (char *args, int from_tty)
if (sol_thread_active)
{
+ ptid_t ptid;
printf_filtered ("sol-thread active.\n");
main_ph.ptid = inferior_ptid; /* Save for xfer_memory. */
push_target (&sol_thread_ops);
- inferior_ptid = lwp_to_thread (inferior_ptid);
- if (PIDGET (inferior_ptid) == -1)
- inferior_ptid = main_ph.ptid;
- else
- add_thread (inferior_ptid);
+ ptid = lwp_to_thread (inferior_ptid);
+ if (PIDGET (ptid) != -1)
+ thread_change_ptid (inferior_ptid, ptid);
}
/* FIXME: Might want to iterate over all the threads and register
@@ -381,6 +381,7 @@ sol_thread_attach (char *args, int from_tty)
static void
sol_thread_detach (char *args, int from_tty)
{
+ sol_thread_active = 0;
inferior_ptid = pid_to_ptid (PIDGET (main_ph.ptid));
unpush_target (&sol_thread_ops);
procfs_ops.to_detach (args, from_tty);
@@ -419,7 +420,7 @@ sol_thread_resume (ptid_t ptid, int step, enum target_signal signo)
do_cleanups (old_chain);
}
-/* Wait for any threads to stop. We may have to convert PIID from a
+/* Wait for any threads to stop. We may have to convert PTID from a
thread ID to an LWP ID, and vice versa on the way out. */
static ptid_t
@@ -460,7 +461,8 @@ sol_thread_wait (ptid_t ptid, struct target_waitstatus *ourstatus)
/* See if we have a new thread. */
if (is_thread (rtnval)
&& !ptid_equal (rtnval, save_ptid)
- && !in_thread_list (rtnval))
+ && (!in_thread_list (rtnval)
+ || is_exited (rtnval)))
add_thread (rtnval);
}
@@ -754,21 +756,21 @@ static void
sol_thread_create_inferior (char *exec_file, char *allargs, char **env,
int from_tty)
{
+ sol_thread_active = 0;
procfs_ops.to_create_inferior (exec_file, allargs, env, from_tty);
if (sol_thread_active && !ptid_equal (inferior_ptid, null_ptid))
{
+ ptid_t ptid;
+
/* Save for xfer_memory. */
main_ph.ptid = inferior_ptid;
push_target (&sol_thread_ops);
- inferior_ptid = lwp_to_thread (inferior_ptid);
- if (PIDGET (inferior_ptid) == -1)
- inferior_ptid = main_ph.ptid;
-
- if (!in_thread_list (inferior_ptid))
- add_thread (inferior_ptid);
+ ptid = lwp_to_thread (inferior_ptid);
+ if (PIDGET (ptid) != -1)
+ thread_change_ptid (inferior_ptid, ptid);
}
}
@@ -822,6 +824,7 @@ sol_thread_new_objfile (struct objfile *objfile)
static void
sol_thread_mourn_inferior (void)
{
+ sol_thread_active = 0;
unpush_target (&sol_thread_ops);
procfs_ops.to_mourn_inferior ();
}
@@ -1366,7 +1369,7 @@ sol_find_new_threads_callback (const td_thrhandle_t *th, void *ignored)
return -1;
ptid = BUILD_THREAD (ti.ti_tid, PIDGET (inferior_ptid));
- if (!in_thread_list (ptid))
+ if (!in_thread_list (ptid) || is_exited (ptid))
add_thread (ptid);
return 0;