Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/subr_kdb.c
Show First 20 Lines • Show All 580 Lines • ▼ Show 20 Lines | #endif | ||||
return (thr->td_pcb); | return (thr->td_pcb); | ||||
} | } | ||||
struct thread * | struct thread * | ||||
kdb_thr_first(void) | kdb_thr_first(void) | ||||
{ | { | ||||
struct proc *p; | struct proc *p; | ||||
struct thread *thr; | struct thread *thr; | ||||
u_int i; | |||||
FOREACH_PROC_IN_SYSTEM(p) { | for (i = 0; i <= pidhash; i++) { | ||||
LIST_FOREACH(p, &pidhashtbl[i], p_hash) { | |||||
if (p->p_flag & P_INMEM) { | if (p->p_flag & P_INMEM) { | ||||
thr = FIRST_THREAD_IN_PROC(p); | thr = FIRST_THREAD_IN_PROC(p); | ||||
if (thr != NULL) | if (thr != NULL) | ||||
return (thr); | return (thr); | ||||
} | } | ||||
} | } | ||||
} | |||||
return (NULL); | return (NULL); | ||||
} | } | ||||
struct thread * | struct thread * | ||||
kdb_thr_from_pid(pid_t pid) | kdb_thr_from_pid(pid_t pid) | ||||
{ | { | ||||
struct proc *p; | struct proc *p; | ||||
FOREACH_PROC_IN_SYSTEM(p) { | LIST_FOREACH(p, PIDHASH(pid), p_hash) { | ||||
if (p->p_flag & P_INMEM && p->p_pid == pid) | if (p->p_flag & P_INMEM && p->p_pid == pid) | ||||
return (FIRST_THREAD_IN_PROC(p)); | return (FIRST_THREAD_IN_PROC(p)); | ||||
} | } | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
struct thread * | struct thread * | ||||
kdb_thr_lookup(lwpid_t tid) | kdb_thr_lookup(lwpid_t tid) | ||||
{ | { | ||||
struct thread *thr; | struct thread *thr; | ||||
thr = kdb_thr_first(); | thr = kdb_thr_first(); | ||||
while (thr != NULL && thr->td_tid != tid) | while (thr != NULL && thr->td_tid != tid) | ||||
thr = kdb_thr_next(thr); | thr = kdb_thr_next(thr); | ||||
return (thr); | return (thr); | ||||
} | } | ||||
struct thread * | struct thread * | ||||
kdb_thr_next(struct thread *thr) | kdb_thr_next(struct thread *thr) | ||||
{ | { | ||||
struct proc *p; | struct proc *p; | ||||
u_int hash; | |||||
p = thr->td_proc; | p = thr->td_proc; | ||||
thr = TAILQ_NEXT(thr, td_plist); | thr = TAILQ_NEXT(thr, td_plist); | ||||
do { | |||||
if (thr != NULL) | if (thr != NULL) | ||||
return (thr); | return (thr); | ||||
p = LIST_NEXT(p, p_list); | hash = p->p_pid & pidhash; | ||||
if (p != NULL && (p->p_flag & P_INMEM)) | for (;;) { | ||||
thr = FIRST_THREAD_IN_PROC(p); | p = LIST_NEXT(p, p_hash); | ||||
} while (p != NULL); | while (p == NULL) { | ||||
if (++hash > pidhash) | |||||
return (NULL); | return (NULL); | ||||
p = LIST_FIRST(&pidhashtbl[hash]); | |||||
} | |||||
if (p->p_flag & P_INMEM) | |||||
return (FIRST_THREAD_IN_PROC(p)); | |||||
} | |||||
} | } | ||||
int | int | ||||
kdb_thr_select(struct thread *thr) | kdb_thr_select(struct thread *thr) | ||||
{ | { | ||||
if (thr == NULL) | if (thr == NULL) | ||||
return (EINVAL); | return (EINVAL); | ||||
kdb_thread = thr; | kdb_thread = thr; | ||||
▲ Show 20 Lines • Show All 78 Lines • Show Last 20 Lines |