From 63ed2c123d61e3c4bc00d13b6ea37e7c784475f5 Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Fri, 25 Aug 2006 16:20:17 +0000 Subject: [PATCH] Use the pcb in stoppcbs[] if it is present for threads that were running on other CPUs in system when a dump is written. Submitted by: ups Reviewed by: marcel MFC after: 3 days --- gnu/usr.bin/gdb/kgdb/kthr.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/gnu/usr.bin/gdb/kgdb/kthr.c b/gnu/usr.bin/gdb/kgdb/kthr.c index 9156f1a9cf66..a93026455120 100644 --- a/gnu/usr.bin/gdb/kgdb/kthr.c +++ b/gnu/usr.bin/gdb/kgdb/kthr.c @@ -41,10 +41,14 @@ __FBSDID("$FreeBSD$"); #include #include "kgdb.h" +#include static uintptr_t dumppcb; static int dumptid; +static uintptr_t stoppcbs; +static __cpumask_t stopped_cpus; + static struct kthr *first; struct kthr *curkthr; @@ -91,6 +95,14 @@ kgdb_thr_init(void) else dumptid = -1; + addr = lookup("_stopped_cpus"); + if (addr != 0) + kvm_read(kvm, addr, &stopped_cpus, sizeof(stopped_cpus)); + else + stopped_cpus = 0; + + stoppcbs = lookup("_stoppcbs"); + while (paddr != 0) { if (kvm_read(kvm, paddr, &p, sizeof(p)) != sizeof(p)) warnx("kvm_read: %s", kvm_geterr(kvm)); @@ -101,8 +113,13 @@ kgdb_thr_init(void) kt = malloc(sizeof(*kt)); kt->next = first; kt->kaddr = addr; - kt->pcb = (td.td_tid == dumptid) ? dumppcb : - (uintptr_t)td.td_pcb; + if (td.td_tid == dumptid) + kt->pcb = dumppcb; + else if (td.td_state == TDS_RUNNING && ((1 << td.td_oncpu) & stopped_cpus) + && stoppcbs != 0) + 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;