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
This commit is contained in:
John Baldwin 2006-08-25 16:20:17 +00:00
parent d2b2ccea4c
commit 63ed2c123d
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=161621

View File

@ -41,10 +41,14 @@ __FBSDID("$FreeBSD$");
#include <frame-unwind.h>
#include "kgdb.h"
#include <machine/pcb.h>
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;