summaryrefslogtreecommitdiffstats
path: root/gnu
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2011-08-19 21:28:40 +0000
committerjhb <jhb@FreeBSD.org>2011-08-19 21:28:40 +0000
commitb4f786b37ce4b6136102a83cc5b80e17d89ebf9d (patch)
tree4677ea515a4a1ea921eff48dc1556d84b8517155 /gnu
parent38a6f4d885042522e28dfa46881edee10f76a0cd (diff)
downloadFreeBSD-src-b4f786b37ce4b6136102a83cc5b80e17d89ebf9d.zip
FreeBSD-src-b4f786b37ce4b6136102a83cc5b80e17d89ebf9d.tar.gz
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
Diffstat (limited to 'gnu')
-rw-r--r--gnu/usr.bin/gdb/kgdb/kthr.c81
1 files changed, 48 insertions, 33 deletions
diff --git a/gnu/usr.bin/gdb/kgdb/kthr.c b/gnu/usr.bin/gdb/kgdb/kthr.c
index 461f408..b12d07c 100644
--- a/gnu/usr.bin/gdb/kgdb/kthr.c
+++ b/gnu/usr.bin/gdb/kgdb/kthr.c
@@ -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)
OpenPOWER on IntegriCloud