MFC following revisions:

libpthread_db.c		1.11-1.14
	libpthread_db.h		1.4
	libthr_db.c		1.12
This commit is contained in:
davidxu 2006-05-23 11:37:20 +00:00
parent b498504cfb
commit b52bed3a5a
3 changed files with 44 additions and 4 deletions

View File

@ -180,6 +180,8 @@ pt_ta_new(struct ps_prochandle *ph, td_thragent_t **pta)
LOOKUP_VAL(ph, "_thread_off_key_destructor", &ta->thread_off_key_destructor);
LOOKUP_VAL(ph, "_thread_state_running", &ta->thread_state_running);
LOOKUP_VAL(ph, "_thread_state_zoombie", &ta->thread_state_zoombie);
LOOKUP_VAL(ph, "_thread_off_sigmask", &ta->thread_off_sigmask);
LOOKUP_VAL(ph, "_thread_off_sigpend", &ta->thread_off_sigpend);
dbg = getpid();
/*
* If this fails it probably means we're debugging a core file and
@ -264,8 +266,8 @@ pt_ta_map_id2thr(const td_thragent_t *ta, thread_t id, td_thrhandle_t *th)
return (P2T(ret));
}
/* check lwp */
ret = ptrace(PT_GETREGS, ta->map[id].lwp, (caddr_t)&gregs, 0);
if (ret != 0) {
ret = ps_lgetregs(ta->ph, ta->map[id].lwp, gregs);
if (ret != PS_OK) {
/* no longer exists */
ta->map[id].type = PT_NONE;
return (TD_NOTHR);
@ -528,7 +530,7 @@ pt_dbsuspend(const td_thrhandle_t *th, int suspend)
} else {
struct ptrace_lwpinfo pl;
if (ptrace(PT_LWPINFO, lwp, (caddr_t) &pl, sizeof(pl)))
if (ps_linfo(ta->ph, lwp, (caddr_t)&pl))
return (TD_ERR);
if (suspend) {
if (!(pl.pl_flags & PL_FLAG_BOUND))
@ -590,13 +592,17 @@ static td_err_e
pt_thr_get_info(const td_thrhandle_t *th, td_thrinfo_t *info)
{
const td_thragent_t *ta = th->th_ta;
struct ptrace_lwpinfo linfo;
psaddr_t tcb_addr;
uint32_t dflags;
lwpid_t lwp;
int state;
int ret;
int attrflags;
TDBG_FUNC();
bzero(info, sizeof(*info));
ret = pt_validate(th);
if (ret)
return (ret);
@ -610,6 +616,12 @@ pt_thr_get_info(const td_thrhandle_t *th, td_thrinfo_t *info)
info->ti_type = TD_THR_SYSTEM;
return (TD_OK);
}
ret = ps_pread(ta->ph, ta->map[th->th_tid].thr +
ta->thread_off_attr_flags,
&attrflags, sizeof(attrflags));
if (ret != 0)
return (P2T(ret));
ret = ps_pread(ta->ph, ta->map[th->th_tid].thr + ta->thread_off_tcb,
&tcb_addr, sizeof(tcb_addr));
if (ret != 0)
@ -628,8 +640,33 @@ pt_thr_get_info(const td_thrhandle_t *th, td_thrinfo_t *info)
&dflags, sizeof(dflags));
if (ret != 0)
return (P2T(ret));
ret = ps_pread(ta->ph, tcb_addr + ta->thread_off_tmbx +
offsetof(struct kse_thr_mailbox, tm_lwp), &lwp, sizeof(lwpid_t));
if (ret != 0)
return (P2T(ret));
info->ti_ta_p = th->th_ta;
info->ti_tid = th->th_tid;
if (attrflags & PTHREAD_SCOPE_SYSTEM) {
ret = ps_linfo(ta->ph, lwp, &linfo);
if (ret == PS_OK) {
info->ti_sigmask = linfo.pl_sigmask;
info->ti_pending = linfo.pl_siglist;
} else
return (ret);
} else {
ret = ps_pread(ta->ph,
ta->map[th->th_tid].thr + ta->thread_off_sigmask,
&info->ti_sigmask, sizeof(sigset_t));
if (ret)
return (ret);
ret = ps_pread(ta->ph,
ta->map[th->th_tid].thr + ta->thread_off_sigpend,
&info->ti_pending, sizeof(sigset_t));
if (ret)
return (ret);
}
if (state == ta->thread_state_running)
info->ti_state = TD_THR_RUN;
else if (state == ta->thread_state_zoombie)

View File

@ -73,6 +73,8 @@ struct td_thragent {
int thread_off_key_destructor;
int thread_state_zoombie;
int thread_state_running;
int thread_off_sigmask;
int thread_off_sigpend;
struct pt_map *map;
int map_len;
};

View File

@ -501,7 +501,8 @@ pt_thr_get_info(const td_thrhandle_t *th, td_thrinfo_t *info)
if (ret == PS_OK) {
info->ti_sigmask = linfo.pl_sigmask;
info->ti_pending = linfo.pl_siglist;
}
} else
return (ret);
if (state == ta->thread_state_running)
info->ti_state = TD_THR_RUN;
else if (state == ta->thread_state_zoombie)