Deleted Added
full compact
28c28
< __FBSDID("$FreeBSD: head/lib/libthread_db/libpthread_db.c 133342 2004-08-08 22:37:53Z davidxu $");
---
> __FBSDID("$FreeBSD: head/lib/libthread_db/libpthread_db.c 133802 2004-08-16 03:30:16Z davidxu $");
30d29
< #include <link.h>
42,44d40
< #include "rtld.h"
<
< #include "libpthread.h"
134a131,144
> #define LOOKUP_VAL(proc, sym, val) \
> ret = ps_pglobal_lookup(proc, NULL, sym, &vaddr);\
> if (ret != 0) { \
> TDBG("can not find symbol: %s\n", sym); \
> ret = TD_NOLIBTHREAD; \
> goto error; \
> } \
> ret = ps_pread(proc, vaddr, val, sizeof(int)); \
> if (ret != 0) { \
> TDBG("can not read value of %s\n", sym);\
> ret = TD_NOLIBTHREAD; \
> goto error; \
> }
>
135a146
> psaddr_t vaddr;
155c166,182
<
---
> LOOKUP_VAL(ph, "_thread_off_dtv", &ta->thread_off_dtv);
> LOOKUP_VAL(ph, "_thread_off_kse_locklevel", &ta->thread_off_kse_locklevel);
> LOOKUP_VAL(ph, "_thread_off_kse", &ta->thread_off_kse);
> LOOKUP_VAL(ph, "_thread_off_tlsindex", &ta->thread_off_tlsindex);
> LOOKUP_VAL(ph, "_thread_off_attr_flags", &ta->thread_off_attr_flags);
> LOOKUP_VAL(ph, "_thread_size_key", &ta->thread_size_key);
> LOOKUP_VAL(ph, "_thread_off_tcb", &ta->thread_off_tcb);
> LOOKUP_VAL(ph, "_thread_off_linkmap", &ta->thread_off_linkmap);
> LOOKUP_VAL(ph, "_thread_off_tmbx", &ta->thread_off_tmbx);
> LOOKUP_VAL(ph, "_thread_off_thr_locklevel", &ta->thread_off_thr_locklevel);
> LOOKUP_VAL(ph, "_thread_off_next", &ta->thread_off_next);
> LOOKUP_VAL(ph, "_thread_off_state", &ta->thread_off_state);
> LOOKUP_VAL(ph, "_thread_max_keys", &ta->thread_max_keys);
> LOOKUP_VAL(ph, "_thread_off_key_allocated", &ta->thread_off_key_allocated);
> 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);
214c241
< pt + offsetof(struct pthread, tcb),
---
> pt + ta->thread_off_tcb,
219,220c246,247
< tcb_addr + offsetof(struct tcb,
< tcb_tmbx.tm_lwp),
---
> tcb_addr + ta->thread_off_tmbx +
> offsetof(struct kse_thr_mailbox, tm_lwp),
234c261
< pt + offsetof(struct pthread, tle.tqe_next),
---
> pt + ta->thread_off_next,
249c276
< pt + offsetof(struct pthread, tcb),
---
> pt + ta->thread_off_tcb,
255c282
< pt + offsetof(struct pthread, tle.tqe_next),
---
> pt + ta->thread_off_next,
288c315
< ret = ps_pread(ta->ph, pt + offsetof(struct pthread, tcb),
---
> ret = ps_pread(ta->ph, pt + ta->thread_off_tcb,
292c319,320
< ptr += offsetof(struct tcb, tcb_tmbx.tm_lwp);
---
> ptr += ta->thread_off_tmbx +
> offsetof(struct kse_thr_mailbox, tm_lwp);
307c335
< pt + offsetof(struct pthread, tle.tqe_next),
---
> pt + ta->thread_off_next,
353c381
< pt + offsetof(struct pthread, tle.tqe_next), &pt,
---
> pt + ta->thread_off_next, &pt,
364,365c392,394
< struct pthread_key keytable[PTHREAD_KEYS_MAX];
< int i, ret;
---
> char *keytable;
> void *destructor;
> int i, ret, allocated;
368a398,400
> keytable = malloc(ta->thread_max_keys * ta->thread_size_key);
> if (keytable == NULL)
> return (TD_MALLOC);
370c402
< sizeof(keytable));
---
> ta->thread_max_keys * ta->thread_size_key);
373,377c405,413
<
< for (i = 0; i < PTHREAD_KEYS_MAX; i++) {
< if (keytable[i].allocated) {
< ret = (ki)(i, keytable[i].destructor, arg);
< if (ret != 0)
---
> for (i = 0; i < ta->thread_max_keys; i++) {
> allocated = *(int *)(keytable + i * ta->thread_size_key +
> ta->thread_off_key_allocated);
> destructor = *(void **)(keytable + i * ta->thread_size_key +
> ta->thread_off_key_destructor);
> if (allocated) {
> ret = (ki)(i, destructor, arg);
> if (ret != 0) {
> free(keytable);
378a415
> }
380a418
> free(keytable);
436c474
< offsetof(struct pthread, attr.flags),
---
> ta->thread_off_attr_flags,
441,442c479,480
< offsetof(struct pthread, tcb),
< &tcb_addr, sizeof(tcb_addr));
---
> ta->thread_off_tcb,
> &tcb_addr, sizeof(tcb_addr));
445c483
< tmbx_addr = tcb_addr + offsetof(struct tcb, tcb_tmbx);
---
> tmbx_addr = tcb_addr + ta->thread_off_tmbx;
453c491
< if (attrflags & THR_SIGNAL_THREAD)
---
> if (attrflags & 0x200)
460,461c498
< ptr = ta->map[th->th_tid].thr +
< offsetof(struct pthread, kse);
---
> ptr = ta->map[th->th_tid].thr + ta->thread_off_kse;
465,466c502,503
< ret = ps_pread(ta->ph, ptr + offsetof(struct kse,
< k_locklevel), &locklevel, sizeof(int));
---
> ret = ps_pread(ta->ph, ptr + ta->thread_off_kse_locklevel,
> &locklevel, sizeof(int));
471c508
< offsetof(struct pthread, locklevel);
---
> ta->thread_off_thr_locklevel;
551,552c588
< struct pthread pt;
< int ret;
---
> psaddr_t tcb_addr;
553a590,591
> int state;
> int ret;
570,572c608,609
<
< ret = ps_pread(ta->ph, (psaddr_t)(ta->map[th->th_tid].thr),
< &pt, sizeof(pt));
---
> ret = ps_pread(ta->ph, ta->map[th->th_tid].thr + ta->thread_off_tcb,
> &tcb_addr, sizeof(tcb_addr));
575,576c612,613
< if (pt.magic != THR_MAGIC)
< return (TD_BADTH);
---
> ret = ps_pread(ta->ph, ta->map[th->th_tid].thr + ta->thread_off_state,
> &state, sizeof(state));
578c615,616
< ((psaddr_t)pt.tcb) + offsetof(struct tcb, tcb_tmbx.tm_lwp),
---
> tcb_addr + ta->thread_off_tmbx +
> offsetof(struct kse_thr_mailbox, tm_lwp),
583c621,622
< ((psaddr_t)pt.tcb) + offsetof(struct tcb, tcb_tmbx.tm_dflags),
---
> tcb_addr + ta->thread_off_tmbx +
> offsetof(struct kse_thr_mailbox, tm_dflags),
589,594c628
< info->ti_tls = (char *)pt.specific;
< info->ti_startfunc = (psaddr_t)pt.start_routine;
< info->ti_stkbase = (psaddr_t) pt.attr.stackaddr_attr;
< info->ti_stksize = pt.attr.stacksize_attr;
< switch (pt.state) {
< case PS_RUNNING:
---
> if (state == ta->thread_state_running)
596,608c630
< break;
< case PS_LOCKWAIT:
< case PS_MUTEX_WAIT:
< case PS_COND_WAIT:
< case PS_SIGSUSPEND:
< case PS_SIGWAIT:
< case PS_JOIN:
< case PS_SUSPENDED:
< case PS_DEADLOCK:
< case PS_SLEEP_WAIT:
< info->ti_state = TD_THR_SLEEP;
< break;
< case PS_DEAD:
---
> else if (state == ta->thread_state_zoombie)
610,615c632,633
< break;
< default:
< info->ti_state = TD_THR_UNKNOWN;
< break;
< }
<
---
> else
> info->ti_state = TD_THR_SLEEP;
618,622d635
< info->ti_pri = pt.active_priority;
< info->ti_sigmask = pt.sigmask;
< info->ti_traceme = 0;
< info->ti_pending = pt.sigpend;
< info->ti_events = 0;
646,647c659
< ret = ps_pread(ta->ph, ta->map[th->th_tid].thr +
< offsetof(struct pthread, tcb),
---
> ret = ps_pread(ta->ph, ta->map[th->th_tid].thr + ta->thread_off_tcb,
651c663
< tmbx_addr = tcb_addr + offsetof(struct tcb, tcb_tmbx);
---
> tmbx_addr = tcb_addr + ta->thread_off_tmbx;
689,690c701
< ret = ps_pread(ta->ph, ta->map[th->th_tid].thr +
< offsetof(struct pthread, tcb),
---
> ret = ps_pread(ta->ph, ta->map[th->th_tid].thr + ta->thread_off_tcb,
694c705
< tmbx_addr = tcb_addr + offsetof(struct tcb, tcb_tmbx);
---
> tmbx_addr = tcb_addr + ta->thread_off_tmbx;
731c742
< offsetof(struct pthread, tcb),
---
> ta->thread_off_tcb,
735c746
< tmbx_addr = tcb_addr + offsetof(struct tcb, tcb_tmbx);
---
> tmbx_addr = tcb_addr + ta->thread_off_tmbx;
778c789
< offsetof(struct pthread, tcb),
---
> ta->thread_off_tcb,
782c793
< tmbx_addr = tcb_addr + offsetof(struct tcb, tcb_tmbx);
---
> tmbx_addr = tcb_addr + ta->thread_off_tmbx;
853c864
< offsetof(struct pthread, tcb),
---
> ta->thread_off_tcb,
859,860c870,873
< ret = ps_pread(ta->ph, tcb_addr + offsetof(struct tcb,
< tcb_tmbx.tm_dflags), &dflags, sizeof(uint32_t));
---
> ret = ps_pread(ta->ph,
> tcb_addr + ta->thread_off_tmbx +
> offsetof(struct kse_thr_mailbox, tm_dflags),
> &dflags, sizeof(uint32_t));
867,868c880,883
< ret = ps_pwrite(ta->ph, tcb_addr + offsetof(struct tcb,
< tcb_tmbx.tm_dflags), &dflags, sizeof(uint32_t));
---
> ret = ps_pwrite(ta->ph,
> tcb_addr + ta->thread_off_tmbx +
> offsetof(struct kse_thr_mailbox, tm_dflags),
> &dflags, sizeof(uint32_t));
872,873c887,890
< ret = ps_pread(ta->ph, tcb_addr + offsetof(struct tcb,
< tcb_tmbx.tm_lwp), &lwp, sizeof(lwpid_t));
---
> ret = ps_pread(ta->ph,
> tcb_addr + ta->thread_off_tmbx +
> offsetof(struct kse_thr_mailbox, tm_lwp),
> &lwp, sizeof(lwpid_t));
879c896
< tmbx_addr = tcb_addr + offsetof(struct tcb, tcb_tmbx);
---
> tmbx_addr = tcb_addr + ta->thread_off_tmbx;
925,926c942
< #if 0
< Obj_Entry *obj_entry;
---
> char *obj_entry;
932,933c948
< obj_entry = (Obj_Entry *)
< (((char *)_linkmap) - offsetof(Obj_Entry, linkmap));
---
> obj_entry = (char *)_linkmap - ta->thread_off_linkmap;
937c952
< ((char *)obj_entry) + offsetof(Obj_Entry, tlsindex),
---
> obj_entry + ta->thread_off_tlsindex,
944c959
< offsetof(struct pthread, tcb),
---
> ta->thread_off_tcb,
949d963
< #ifdef TLS_DTV_AT_TCB
951c965
< ret = ps_pread(ta->ph, tcb_addr + offsetof(struct tcb, tcb_dtv),
---
> ret = ps_pread(ta->ph, tcb_addr + ta->thread_off_dtv,
955,966d968
< #else
< #ifdef TLS_DTV_AT_TP
< ret = ps_pread(ta->ph, tcb_addr + offsetof(struct tcb, tcb_tp),
< &tcb_tp, sizeof(tcb_tp));
< if (ret != 0)
< return (P2T(ret));
< ret = ps_pread(ta->ph, tcb_tp + offsetof(struct tp, tp_dtv),
< &dtv_addr, sizeof(dtv_addr));
< #else
< #error "Either TLS_DTV_AT_TP or TLS_DTV_AT_TCB must be defined."
< #endif
< #endif
974d975
< #endif