subr_kdb.c (151631) | subr_kdb.c (151634) |
---|---|
1/*- 2 * Copyright (c) 2004 The FreeBSD Project 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 The FreeBSD Project 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/sys/kern/subr_kdb.c 151631 2005-10-24 20:31:04Z jhb $"); | 28__FBSDID("$FreeBSD: head/sys/kern/subr_kdb.c 151634 2005-10-24 21:04:19Z jhb $"); |
29 30#include "opt_kdb.h" 31 32#include <sys/param.h> 33#include <sys/systm.h> 34#include <sys/kdb.h> 35#include <sys/kernel.h> 36#include <sys/malloc.h> 37#include <sys/pcpu.h> 38#include <sys/proc.h> 39#include <sys/smp.h> 40#include <sys/sysctl.h> 41 42#include <machine/kdb.h> 43#include <machine/pcb.h> 44 | 29 30#include "opt_kdb.h" 31 32#include <sys/param.h> 33#include <sys/systm.h> 34#include <sys/kdb.h> 35#include <sys/kernel.h> 36#include <sys/malloc.h> 37#include <sys/pcpu.h> 38#include <sys/proc.h> 39#include <sys/smp.h> 40#include <sys/sysctl.h> 41 42#include <machine/kdb.h> 43#include <machine/pcb.h> 44 |
45#ifdef KDB_STOP_NMI | 45#ifdef SMP 46#if defined (__i386__) || defined(__amd64__) 47#define HAVE_STOPPEDPCBS |
46#include <machine/smp.h> 47#endif | 48#include <machine/smp.h> 49#endif |
48 49/* 50 * KDB_STOP_NMI requires SMP to pick up the right dependencies 51 * (And isn't useful on UP anyway) 52 */ 53#if defined(KDB_STOP_NMI) && !defined(SMP) 54#error "options KDB_STOP_NMI" requires "options SMP" | |
55#endif 56 57int kdb_active = 0; 58void *kdb_jmpbufp = NULL; 59struct kdb_dbbe *kdb_dbbe = NULL; 60struct pcb kdb_pcb; 61struct pcb *kdb_thrctx = NULL; 62struct thread *kdb_thread = NULL; --- 23 unchanged lines hidden (view full) --- 86 * stop_cpus() waits for the other cpus to stop, so we allow it to be 87 * disabled. 88 */ 89#ifdef SMP 90static int kdb_stop_cpus = 1; 91SYSCTL_INT(_debug_kdb, OID_AUTO, stop_cpus, CTLTYPE_INT | CTLFLAG_RW, 92 &kdb_stop_cpus, 0, ""); 93TUNABLE_INT("debug.kdb.stop_cpus", &kdb_stop_cpus); | 50#endif 51 52int kdb_active = 0; 53void *kdb_jmpbufp = NULL; 54struct kdb_dbbe *kdb_dbbe = NULL; 55struct pcb kdb_pcb; 56struct pcb *kdb_thrctx = NULL; 57struct thread *kdb_thread = NULL; --- 23 unchanged lines hidden (view full) --- 81 * stop_cpus() waits for the other cpus to stop, so we allow it to be 82 * disabled. 83 */ 84#ifdef SMP 85static int kdb_stop_cpus = 1; 86SYSCTL_INT(_debug_kdb, OID_AUTO, stop_cpus, CTLTYPE_INT | CTLFLAG_RW, 87 &kdb_stop_cpus, 0, ""); 88TUNABLE_INT("debug.kdb.stop_cpus", &kdb_stop_cpus); |
94 95#ifdef KDB_STOP_NMI 96/* 97 * Provide an alternate method of stopping other CPUs. If another CPU has 98 * disabled interrupts the conventional STOP IPI will be blocked. This 99 * NMI-based stop should get through in that case. 100 */ 101static int kdb_stop_cpus_with_nmi = 1; 102SYSCTL_INT(_debug_kdb, OID_AUTO, stop_cpus_with_nmi, CTLTYPE_INT | CTLFLAG_RW, 103 &kdb_stop_cpus_with_nmi, 0, ""); 104TUNABLE_INT("debug.kdb.stop_cpus_with_nmi", &kdb_stop_cpus_with_nmi); 105#endif /* KDB_STOP_NMI */ 106 | |
107#endif 108 109static int 110kdb_sysctl_available(SYSCTL_HANDLER_ARGS) 111{ 112 struct kdb_dbbe *be, **iter; 113 char *avail, *p; 114 ssize_t len, sz; --- 215 unchanged lines hidden (view full) --- 330} 331 332/* 333 * Thread related support functions. 334 */ 335 336struct pcb * 337kdb_thr_ctx(struct thread *thr) | 89#endif 90 91static int 92kdb_sysctl_available(SYSCTL_HANDLER_ARGS) 93{ 94 struct kdb_dbbe *be, **iter; 95 char *avail, *p; 96 ssize_t len, sz; --- 215 unchanged lines hidden (view full) --- 312} 313 314/* 315 * Thread related support functions. 316 */ 317 318struct pcb * 319kdb_thr_ctx(struct thread *thr) |
338#ifdef KDB_STOP_NMI | |
339{ | 320{ |
321#ifdef HAVE_STOPPEDPCBS |
|
340 struct pcpu *pc; 341 u_int cpuid; | 322 struct pcpu *pc; 323 u_int cpuid; |
324#endif |
|
342 343 if (thr == curthread) 344 return (&kdb_pcb); 345 | 325 326 if (thr == curthread) 327 return (&kdb_pcb); 328 |
329#ifdef HAVE_STOPPEDPCBS |
|
346 SLIST_FOREACH(pc, &cpuhead, pc_allcpu) { 347 cpuid = pc->pc_cpuid; | 330 SLIST_FOREACH(pc, &cpuhead, pc_allcpu) { 331 cpuid = pc->pc_cpuid; |
348 if (pc->pc_curthread == thr && (atomic_load_acq_int(&stopped_cpus) & (1 << cpuid))) | 332 if (pc->pc_curthread == thr && (stopped_cpus & (1 << cpuid))) |
349 return (&stoppcbs[cpuid]); 350 } | 333 return (&stoppcbs[cpuid]); 334 } |
335#endif |
|
351 return (thr->td_pcb); 352} | 336 return (thr->td_pcb); 337} |
353#else 354{ 355 return ((thr == curthread) ? &kdb_pcb : thr->td_pcb); 356} 357#endif /* KDB_STOP_NMI */ | |
358 359struct thread * 360kdb_thr_first(void) 361{ 362 struct proc *p; 363 struct thread *thr; 364 365 p = LIST_FIRST(&allproc); --- 80 unchanged lines hidden (view full) --- 446 return (0); 447 448 critical_enter(); 449 450 kdb_active++; 451 452#ifdef SMP 453 if ((did_stop_cpus = kdb_stop_cpus) != 0) | 338 339struct thread * 340kdb_thr_first(void) 341{ 342 struct proc *p; 343 struct thread *thr; 344 345 p = LIST_FIRST(&allproc); --- 80 unchanged lines hidden (view full) --- 426 return (0); 427 428 critical_enter(); 429 430 kdb_active++; 431 432#ifdef SMP 433 if ((did_stop_cpus = kdb_stop_cpus) != 0) |
454 { 455#ifdef KDB_STOP_NMI 456 if(kdb_stop_cpus_with_nmi) 457 stop_cpus_nmi(PCPU_GET(other_cpus)); 458 else 459#endif /* KDB_STOP_NMI */ | |
460 stop_cpus(PCPU_GET(other_cpus)); | 434 stop_cpus(PCPU_GET(other_cpus)); |
461 } | |
462#endif 463 464 kdb_frame = tf; 465 466 /* Let MD code do its thing first... */ 467 kdb_cpu_trap(type, code); 468 469 makectx(tf, &kdb_pcb); --- 15 unchanged lines hidden --- | 435#endif 436 437 kdb_frame = tf; 438 439 /* Let MD code do its thing first... */ 440 kdb_cpu_trap(type, code); 441 442 makectx(tf, &kdb_pcb); --- 15 unchanged lines hidden --- |