Walk the zombproc list as well as the allproc list when enumerating threads
and processes in a kernel image. This allows examination of threads that have exited or are in the late stages of exiting. Tested by: avg Approved by: re (kib) MFC after: 1 week
This commit is contained in:
parent
5ca7dfffdf
commit
6dfd657c01
@ -73,11 +73,52 @@ kgdb_thr_first(void)
|
||||
return (first);
|
||||
}
|
||||
|
||||
struct kthr *
|
||||
kgdb_thr_init(void)
|
||||
static void
|
||||
kgdb_thr_add_procs(uintptr_t paddr)
|
||||
{
|
||||
struct proc p;
|
||||
struct thread td;
|
||||
struct kthr *kt;
|
||||
CORE_ADDR addr;
|
||||
|
||||
while (paddr != 0) {
|
||||
if (kvm_read(kvm, paddr, &p, sizeof(p)) != sizeof(p)) {
|
||||
warnx("kvm_read: %s", kvm_geterr(kvm));
|
||||
break;
|
||||
}
|
||||
addr = (uintptr_t)TAILQ_FIRST(&p.p_threads);
|
||||
while (addr != 0) {
|
||||
if (kvm_read(kvm, addr, &td, sizeof(td)) !=
|
||||
sizeof(td)) {
|
||||
warnx("kvm_read: %s", kvm_geterr(kvm));
|
||||
break;
|
||||
}
|
||||
kt = malloc(sizeof(*kt));
|
||||
kt->next = first;
|
||||
kt->kaddr = addr;
|
||||
if (td.td_tid == dumptid)
|
||||
kt->pcb = dumppcb;
|
||||
else if (td.td_state == TDS_RUNNING && stoppcbs != 0 &&
|
||||
CPU_ISSET(td.td_oncpu, &stopped_cpus))
|
||||
kt->pcb = (uintptr_t)stoppcbs +
|
||||
sizeof(struct pcb) * td.td_oncpu;
|
||||
else
|
||||
kt->pcb = (uintptr_t)td.td_pcb;
|
||||
kt->kstack = td.td_kstack;
|
||||
kt->tid = td.td_tid;
|
||||
kt->pid = p.p_pid;
|
||||
kt->paddr = paddr;
|
||||
kt->cpu = td.td_oncpu;
|
||||
first = kt;
|
||||
addr = (uintptr_t)TAILQ_NEXT(&td, td_plist);
|
||||
}
|
||||
paddr = (uintptr_t)LIST_NEXT(&p, p_list);
|
||||
}
|
||||
}
|
||||
|
||||
struct kthr *
|
||||
kgdb_thr_init(void)
|
||||
{
|
||||
long cpusetsize;
|
||||
struct kthr *kt;
|
||||
CORE_ADDR addr;
|
||||
@ -113,37 +154,11 @@ kgdb_thr_init(void)
|
||||
|
||||
stoppcbs = kgdb_lookup("stoppcbs");
|
||||
|
||||
while (paddr != 0) {
|
||||
if (kvm_read(kvm, paddr, &p, sizeof(p)) != sizeof(p)) {
|
||||
warnx("kvm_read: %s", kvm_geterr(kvm));
|
||||
break;
|
||||
}
|
||||
addr = (uintptr_t)TAILQ_FIRST(&p.p_threads);
|
||||
while (addr != 0) {
|
||||
if (kvm_read(kvm, addr, &td, sizeof(td)) !=
|
||||
sizeof(td)) {
|
||||
warnx("kvm_read: %s", kvm_geterr(kvm));
|
||||
break;
|
||||
}
|
||||
kt = malloc(sizeof(*kt));
|
||||
kt->next = first;
|
||||
kt->kaddr = addr;
|
||||
if (td.td_tid == dumptid)
|
||||
kt->pcb = dumppcb;
|
||||
else if (td.td_state == TDS_RUNNING && stoppcbs != 0 &&
|
||||
CPU_ISSET(td.td_oncpu, &stopped_cpus))
|
||||
kt->pcb = (uintptr_t) stoppcbs + sizeof(struct pcb) * td.td_oncpu;
|
||||
else
|
||||
kt->pcb = (uintptr_t)td.td_pcb;
|
||||
kt->kstack = td.td_kstack;
|
||||
kt->tid = td.td_tid;
|
||||
kt->pid = p.p_pid;
|
||||
kt->paddr = paddr;
|
||||
kt->cpu = td.td_oncpu;
|
||||
first = kt;
|
||||
addr = (uintptr_t)TAILQ_NEXT(&td, td_plist);
|
||||
}
|
||||
paddr = (uintptr_t)LIST_NEXT(&p, p_list);
|
||||
kgdb_thr_add_procs(paddr);
|
||||
addr = kgdb_lookup("zombproc");
|
||||
if (addr != 0) {
|
||||
kvm_read(kvm, addr, &paddr, sizeof(paddr));
|
||||
kgdb_thr_add_procs(paddr);
|
||||
}
|
||||
curkthr = kgdb_thr_lookup_tid(dumptid);
|
||||
if (curkthr == NULL)
|
||||
|
Loading…
Reference in New Issue
Block a user