kthr.c (149954) | kthr.c (161621) |
---|---|
1/* 2 * Copyright (c) 2004 Marcel Moolenaar 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * --- 11 unchanged lines hidden (view full) --- 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> | 1/* 2 * Copyright (c) 2004 Marcel Moolenaar 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * --- 11 unchanged lines hidden (view full) --- 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: head/gnu/usr.bin/gdb/kgdb/kthr.c 149954 2005-09-10 18:25:53Z marcel $"); | 28__FBSDID("$FreeBSD: head/gnu/usr.bin/gdb/kgdb/kthr.c 161621 2006-08-25 16:20:17Z jhb $"); |
29 30#include <sys/param.h> 31#include <sys/proc.h> 32#include <sys/types.h> 33#include <sys/signal.h> 34#include <err.h> 35#include <inttypes.h> 36#include <kvm.h> 37#include <stdio.h> 38#include <stdlib.h> 39 40#include <defs.h> 41#include <frame-unwind.h> 42 43#include "kgdb.h" | 29 30#include <sys/param.h> 31#include <sys/proc.h> 32#include <sys/types.h> 33#include <sys/signal.h> 34#include <err.h> 35#include <inttypes.h> 36#include <kvm.h> 37#include <stdio.h> 38#include <stdlib.h> 39 40#include <defs.h> 41#include <frame-unwind.h> 42 43#include "kgdb.h" |
44#include <machine/pcb.h> |
|
44 45static uintptr_t dumppcb; 46static int dumptid; 47 | 45 46static uintptr_t dumppcb; 47static int dumptid; 48 |
49static uintptr_t stoppcbs; 50static __cpumask_t stopped_cpus; 51 |
|
48static struct kthr *first; 49struct kthr *curkthr; 50 51static uintptr_t 52lookup(const char *sym) 53{ 54 struct nlist nl[2]; 55 --- 30 unchanged lines hidden (view full) --- 86 return (NULL); 87 88 addr = lookup("_dumptid"); 89 if (addr != 0) 90 kvm_read(kvm, addr, &dumptid, sizeof(dumptid)); 91 else 92 dumptid = -1; 93 | 52static struct kthr *first; 53struct kthr *curkthr; 54 55static uintptr_t 56lookup(const char *sym) 57{ 58 struct nlist nl[2]; 59 --- 30 unchanged lines hidden (view full) --- 90 return (NULL); 91 92 addr = lookup("_dumptid"); 93 if (addr != 0) 94 kvm_read(kvm, addr, &dumptid, sizeof(dumptid)); 95 else 96 dumptid = -1; 97 |
98 addr = lookup("_stopped_cpus"); 99 if (addr != 0) 100 kvm_read(kvm, addr, &stopped_cpus, sizeof(stopped_cpus)); 101 else 102 stopped_cpus = 0; 103 104 stoppcbs = lookup("_stoppcbs"); 105 |
|
94 while (paddr != 0) { 95 if (kvm_read(kvm, paddr, &p, sizeof(p)) != sizeof(p)) 96 warnx("kvm_read: %s", kvm_geterr(kvm)); 97 addr = (uintptr_t)TAILQ_FIRST(&p.p_threads); 98 while (addr != 0) { 99 if (kvm_read(kvm, addr, &td, sizeof(td)) != sizeof(td)) 100 warnx("kvm_read: %s", kvm_geterr(kvm)); 101 kt = malloc(sizeof(*kt)); 102 kt->next = first; 103 kt->kaddr = addr; | 106 while (paddr != 0) { 107 if (kvm_read(kvm, paddr, &p, sizeof(p)) != sizeof(p)) 108 warnx("kvm_read: %s", kvm_geterr(kvm)); 109 addr = (uintptr_t)TAILQ_FIRST(&p.p_threads); 110 while (addr != 0) { 111 if (kvm_read(kvm, addr, &td, sizeof(td)) != sizeof(td)) 112 warnx("kvm_read: %s", kvm_geterr(kvm)); 113 kt = malloc(sizeof(*kt)); 114 kt->next = first; 115 kt->kaddr = addr; |
104 kt->pcb = (td.td_tid == dumptid) ? dumppcb : 105 (uintptr_t)td.td_pcb; | 116 if (td.td_tid == dumptid) 117 kt->pcb = dumppcb; 118 else if (td.td_state == TDS_RUNNING && ((1 << td.td_oncpu) & stopped_cpus) 119 && stoppcbs != 0) 120 kt->pcb = (uintptr_t) stoppcbs + sizeof(struct pcb) * td.td_oncpu; 121 else 122 kt->pcb = (uintptr_t)td.td_pcb; |
106 kt->kstack = td.td_kstack; 107 kt->tid = td.td_tid; 108 kt->pid = p.p_pid; 109 kt->paddr = paddr; 110 first = kt; 111 addr = (uintptr_t)TAILQ_NEXT(&td, td_plist); 112 } 113 paddr = (uintptr_t)LIST_NEXT(&p, p_list); --- 84 unchanged lines hidden --- | 123 kt->kstack = td.td_kstack; 124 kt->tid = td.td_tid; 125 kt->pid = p.p_pid; 126 kt->paddr = paddr; 127 first = kt; 128 addr = (uintptr_t)TAILQ_NEXT(&td, td_plist); 129 } 130 paddr = (uintptr_t)LIST_NEXT(&p, p_list); --- 84 unchanged lines hidden --- |