aboutsummaryrefslogtreecommitdiff
path: root/linuxthreads_db/td_thr_getgregs.c
diff options
context:
space:
mode:
Diffstat (limited to 'linuxthreads_db/td_thr_getgregs.c')
-rw-r--r--linuxthreads_db/td_thr_getgregs.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/linuxthreads_db/td_thr_getgregs.c b/linuxthreads_db/td_thr_getgregs.c
index e8a87b1..549c7d8 100644
--- a/linuxthreads_db/td_thr_getgregs.c
+++ b/linuxthreads_db/td_thr_getgregs.c
@@ -28,12 +28,16 @@ td_thr_getgregs (const td_thrhandle_t *th, prgregset_t gregs)
LOG (__FUNCTION__);
- /* We have to get the PID for this thread. */
+ /* We have to get the state and the PID for this thread. */
if (ps_pdread (th->th_ta_p->ph, th->th_unique, &pds,
sizeof (struct _pthread_descr_struct)) != PS_OK)
return TD_ERR;
- if (ps_lgetregs (th->th_ta_p->ph, pds.p_pid, gregs) != PS_OK)
+ /* If the thread already terminated we return all zeroes. */
+ if (pds.p_terminated)
+ memset (gregs, '\0', sizeof (gregs));
+ /* Otherwise get the register content through the callback. */
+ else if (ps_lgetregs (th->th_ta_p->ph, pds.p_pid, gregs) != PS_OK)
return TD_ERR;
return TD_OK;