Changeset View
Changeset View
Standalone View
Standalone View
head/sys/ddb/db_thread.c
Show First 20 Lines • Show All 119 Lines • ▼ Show 20 Lines | db_lookup_thread(db_expr_t addr, bool check_pid) | ||||
decaddr = db_hex2dec(addr); | decaddr = db_hex2dec(addr); | ||||
if (decaddr == -1) | if (decaddr == -1) | ||||
return ((struct thread *)addr); | return ((struct thread *)addr); | ||||
td = kdb_thr_lookup(decaddr); | td = kdb_thr_lookup(decaddr); | ||||
if (td != NULL) | if (td != NULL) | ||||
return (td); | return (td); | ||||
if (check_pid) { | if (check_pid) { | ||||
FOREACH_PROC_IN_SYSTEM(p) { | LIST_FOREACH(p, PIDHASH(decaddr), p_hash) { | ||||
if (p->p_pid == decaddr) | if (p->p_pid == decaddr) | ||||
return (FIRST_THREAD_IN_PROC(p)); | return (FIRST_THREAD_IN_PROC(p)); | ||||
} | } | ||||
LIST_FOREACH(p, &zombproc, p_list) { | |||||
if (p->p_pid == decaddr) | |||||
return (FIRST_THREAD_IN_PROC(p)); | |||||
} | } | ||||
} | |||||
return ((struct thread *)addr); | return ((struct thread *)addr); | ||||
} | } | ||||
/* | /* | ||||
* Lookup a process based on a db expression address. We assume that the | * Lookup a process based on a db expression address. We assume that the | ||||
* address was parsed in hexadecimal. We reparse the address in decimal | * address was parsed in hexadecimal. We reparse the address in decimal | ||||
* first and try to treat it as a PID to find an associated process. | * first and try to treat it as a PID to find an associated process. | ||||
* If that fails we treat the addr as a pointer to a process. | * If that fails we treat the addr as a pointer to a process. | ||||
*/ | */ | ||||
struct proc * | struct proc * | ||||
db_lookup_proc(db_expr_t addr) | db_lookup_proc(db_expr_t addr) | ||||
{ | { | ||||
db_expr_t decaddr; | db_expr_t decaddr; | ||||
struct proc *p; | struct proc *p; | ||||
decaddr = db_hex2dec(addr); | decaddr = db_hex2dec(addr); | ||||
if (decaddr != -1) { | if (decaddr != -1) { | ||||
FOREACH_PROC_IN_SYSTEM(p) { | LIST_FOREACH(p, PIDHASH(decaddr), p_hash) { | ||||
if (p->p_pid == decaddr) | |||||
return (p); | |||||
} | |||||
LIST_FOREACH(p, &zombproc, p_list) { | |||||
if (p->p_pid == decaddr) | if (p->p_pid == decaddr) | ||||
return (p); | return (p); | ||||
} | } | ||||
} | } | ||||
return ((struct proc *)addr); | return ((struct proc *)addr); | ||||
} | } |