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
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=225017
@ -73,11 +73,52 @@ kgdb_thr_first(void)
|
|||||||
return (first);
|
return (first);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct kthr *
|
static void
|
||||||
kgdb_thr_init(void)
|
kgdb_thr_add_procs(uintptr_t paddr)
|
||||||
{
|
{
|
||||||
struct proc p;
|
struct proc p;
|
||||||
struct thread td;
|
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;
|
long cpusetsize;
|
||||||
struct kthr *kt;
|
struct kthr *kt;
|
||||||
CORE_ADDR addr;
|
CORE_ADDR addr;
|
||||||
@ -113,37 +154,11 @@ kgdb_thr_init(void)
|
|||||||
|
|
||||||
stoppcbs = kgdb_lookup("stoppcbs");
|
stoppcbs = kgdb_lookup("stoppcbs");
|
||||||
|
|
||||||
while (paddr != 0) {
|
kgdb_thr_add_procs(paddr);
|
||||||
if (kvm_read(kvm, paddr, &p, sizeof(p)) != sizeof(p)) {
|
addr = kgdb_lookup("zombproc");
|
||||||
warnx("kvm_read: %s", kvm_geterr(kvm));
|
if (addr != 0) {
|
||||||
break;
|
kvm_read(kvm, addr, &paddr, sizeof(paddr));
|
||||||
}
|
kgdb_thr_add_procs(paddr);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
curkthr = kgdb_thr_lookup_tid(dumptid);
|
curkthr = kgdb_thr_lookup_tid(dumptid);
|
||||||
if (curkthr == NULL)
|
if (curkthr == NULL)
|
||||||
|
Loading…
Reference in New Issue
Block a user