FreeBSD kernel kern code
|
#include <sys/cdefs.h>
#include "opt_kdb.h"
#include "opt_stack.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/cons.h>
#include <sys/kdb.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/lock.h>
#include <sys/pcpu.h>
#include <sys/proc.h>
#include <sys/sbuf.h>
#include <sys/smp.h>
#include <sys/stack.h>
#include <sys/sysctl.h>
#include <machine/kdb.h>
#include <machine/pcb.h>
Go to the source code of this file.
Macros | |
#define | KDB_BREAK_TO_DEBUGGER 0 |
#define | KDB_ALT_BREAK_TO_DEBUGGER 0 |
#define | KEY_CR 13 /* CR '\r' */ |
#define | KEY_TILDE 126 /* ~ */ |
#define | KEY_CRTLB 2 /* ^B */ |
#define | KEY_CRTLP 16 /* ^P */ |
#define | KEY_CRTLR 18 /* ^R */ |
Enumerations | |
enum | { KDB_ALT_BREAK_SEEN_NONE , KDB_ALT_BREAK_SEEN_CR , KDB_ALT_BREAK_SEEN_CR_TILDE } |
Functions | |
__FBSDID ("$FreeBSD$") | |
KDB_BACKEND (null, NULL, NULL, NULL, NULL) | |
static int | kdb_sysctl_available (SYSCTL_HANDLER_ARGS) |
static int | kdb_sysctl_current (SYSCTL_HANDLER_ARGS) |
static int | kdb_sysctl_enter (SYSCTL_HANDLER_ARGS) |
static int | kdb_sysctl_panic (SYSCTL_HANDLER_ARGS) |
static int | kdb_sysctl_panic_str (SYSCTL_HANDLER_ARGS) |
static int | kdb_sysctl_trap (SYSCTL_HANDLER_ARGS) |
static int | kdb_sysctl_trap_code (SYSCTL_HANDLER_ARGS) |
static int | kdb_sysctl_stack_overflow (SYSCTL_HANDLER_ARGS) |
static | SYSCTL_NODE (_debug, OID_AUTO, kdb, CTLFLAG_RW|CTLFLAG_MPSAFE, NULL, "KDB nodes") |
SYSCTL_PROC (_debug_kdb, OID_AUTO, available, CTLTYPE_STRING|CTLFLAG_RD|CTLFLAG_MPSAFE, NULL, 0, kdb_sysctl_available, "A", "list of available KDB backends") | |
SYSCTL_PROC (_debug_kdb, OID_AUTO, current, CTLTYPE_STRING|CTLFLAG_RW|CTLFLAG_MPSAFE, NULL, 0, kdb_sysctl_current, "A", "currently selected KDB backend") | |
SYSCTL_PROC (_debug_kdb, OID_AUTO, enter, CTLTYPE_INT|CTLFLAG_RW|CTLFLAG_SECURE|CTLFLAG_MPSAFE, NULL, 0, kdb_sysctl_enter, "I", "set to enter the debugger") | |
SYSCTL_PROC (_debug_kdb, OID_AUTO, panic, CTLTYPE_INT|CTLFLAG_RW|CTLFLAG_SECURE|CTLFLAG_MPSAFE, NULL, 0, kdb_sysctl_panic, "I", "set to panic the kernel") | |
SYSCTL_PROC (_debug_kdb, OID_AUTO, panic_str, CTLTYPE_STRING|CTLFLAG_RW|CTLFLAG_SECURE|CTLFLAG_MPSAFE, NULL, 0, kdb_sysctl_panic_str, "A", "trigger a kernel panic, using the provided string as the panic message") | |
SYSCTL_PROC (_debug_kdb, OID_AUTO, trap, CTLTYPE_INT|CTLFLAG_RW|CTLFLAG_SECURE|CTLFLAG_MPSAFE, NULL, 0, kdb_sysctl_trap, "I", "set to cause a page fault via data access") | |
SYSCTL_PROC (_debug_kdb, OID_AUTO, trap_code, CTLTYPE_INT|CTLFLAG_RW|CTLFLAG_SECURE|CTLFLAG_MPSAFE, NULL, 0, kdb_sysctl_trap_code, "I", "set to cause a page fault via code access") | |
SYSCTL_PROC (_debug_kdb, OID_AUTO, stack_overflow, CTLTYPE_INT|CTLFLAG_RW|CTLFLAG_SECURE|CTLFLAG_MPSAFE, NULL, 0, kdb_sysctl_stack_overflow, "I", "set to cause a stack overflow") | |
SYSCTL_INT (_debug_kdb, OID_AUTO, break_to_debugger, CTLFLAG_RWTUN|CTLFLAG_SECURE, &kdb_break_to_debugger, 0, "Enable break to debugger") | |
SYSCTL_INT (_debug_kdb, OID_AUTO, alt_break_to_debugger, CTLFLAG_RWTUN|CTLFLAG_SECURE, &kdb_alt_break_to_debugger, 0, "Enable alternative break to debugger") | |
static void | kdb_stack_overflow (volatile int *x) __noinline |
void | kdb_panic (const char *msg) |
void | kdb_reboot (void) |
int | kdb_break (void) |
static int | kdb_alt_break_state (int key, int *state) |
static int | kdb_alt_break_internal (int key, int *state, int force_gdb) |
int | kdb_alt_break (int key, int *state) |
int | kdb_alt_break_gdb (int key, int *state) |
void | kdb_backtrace (void) |
void | kdb_backtrace_thread (struct thread *td) |
int | kdb_dbbe_select (const char *name) |
void | kdb_enter (const char *why, const char *msg) |
void | kdb_init (void) |
void * | kdb_jmpbuf (jmp_buf new) |
void | kdb_reenter (void) |
void | kdb_reenter_silent (void) |
struct pcb * | kdb_thr_ctx (struct thread *thr) |
struct thread * | kdb_thr_first (void) |
struct thread * | kdb_thr_from_pid (pid_t pid) |
struct thread * | kdb_thr_lookup (lwpid_t tid) |
struct thread * | kdb_thr_next (struct thread *thr) |
int | kdb_thr_select (struct thread *thr) |
int | kdb_trap (int type, int code, struct trapframe *tf) |
Variables | |
u_char __read_frequently | kdb_active = 0 |
static void * | kdb_jmpbufp = NULL |
struct kdb_dbbe * | kdb_dbbe = NULL |
static struct pcb | kdb_pcb |
struct pcb * | kdb_thrctx = NULL |
struct thread * | kdb_thread = NULL |
struct trapframe * | kdb_frame = NULL |
static int | kdb_break_to_debugger = KDB_BREAK_TO_DEBUGGER |
static int | kdb_alt_break_to_debugger = KDB_ALT_BREAK_TO_DEBUGGER |
const char *volatile | kdb_why = KDB_WHY_UNSET |
#define KDB_ALT_BREAK_TO_DEBUGGER 0 |
Definition at line 73 of file subr_kdb.c.
#define KDB_BREAK_TO_DEBUGGER 0 |
Definition at line 67 of file subr_kdb.c.
#define KEY_CR 13 /* CR '\r' */ |
Definition at line 317 of file subr_kdb.c.
#define KEY_CRTLB 2 /* ^B */ |
Definition at line 319 of file subr_kdb.c.
#define KEY_CRTLP 16 /* ^P */ |
Definition at line 320 of file subr_kdb.c.
#define KEY_CRTLR 18 /* ^R */ |
Definition at line 321 of file subr_kdb.c.
#define KEY_TILDE 126 /* ~ */ |
Definition at line 318 of file subr_kdb.c.
anonymous enum |
Enumerator | |
---|---|
KDB_ALT_BREAK_SEEN_NONE | |
KDB_ALT_BREAK_SEEN_CR | |
KDB_ALT_BREAK_SEEN_CR_TILDE |
Definition at line 324 of file subr_kdb.c.
__FBSDID | ( | "$FreeBSD$" | ) |
int kdb_alt_break | ( | int | key, |
int * | state | ||
) |
Definition at line 404 of file subr_kdb.c.
References kdb_alt_break_internal().
int kdb_alt_break_gdb | ( | int | key, |
int * | state | ||
) |
Definition at line 416 of file subr_kdb.c.
References kdb_alt_break_internal().
|
static |
Definition at line 376 of file subr_kdb.c.
References kdb_alt_break_state(), kdb_alt_break_to_debugger, kdb_dbbe_select(), kdb_enter(), kdb_panic(), and kdb_reboot().
Referenced by kdb_alt_break(), and kdb_alt_break_gdb().
|
static |
Definition at line 341 of file subr_kdb.c.
References KDB_ALT_BREAK_SEEN_CR, KDB_ALT_BREAK_SEEN_CR_TILDE, KDB_ALT_BREAK_SEEN_NONE, KEY_CR, KEY_CRTLB, KEY_CRTLP, KEY_CRTLR, and KEY_TILDE.
Referenced by kdb_alt_break_internal().
KDB_BACKEND | ( | null | , |
NULL | , | ||
NULL | , | ||
NULL | , | ||
NULL | |||
) |
void kdb_backtrace | ( | void | ) |
Definition at line 429 of file subr_kdb.c.
References kdb_dbbe, printf(), st, stack_print_ddb(), and stack_zero().
Referenced by _isitmyx(), adopt(), kdb_reenter(), kdb_switch(), sdt_probe_stub(), vpanic(), and watchdog_fire().
void kdb_backtrace_thread | ( | struct thread * | td | ) |
Definition at line 453 of file subr_kdb.c.
References kdb_dbbe, printf(), st, and stack_print_ddb().
Referenced by propagate_priority().
int kdb_break | ( | void | ) |
Definition at line 331 of file subr_kdb.c.
References kdb_break_to_debugger, and kdb_enter().
int kdb_dbbe_select | ( | const char * | name | ) |
Definition at line 475 of file subr_kdb.c.
References kdb_dbbe, and name.
Referenced by kdb_alt_break_internal(), and kdb_sysctl_current().
void kdb_enter | ( | const char * | why, |
const char * | msg | ||
) |
Definition at line 498 of file subr_kdb.c.
References kdb_active, kdb_dbbe, kdb_why, and printf().
Referenced by kdb_alt_break_internal(), kdb_break(), kdb_sysctl_enter(), vpanic(), watchdog_fire(), and witness_enter_debugger().
void kdb_init | ( | void | ) |
Definition at line 514 of file subr_kdb.c.
References kdb_active, kdb_dbbe, and printf().
void * kdb_jmpbuf | ( | jmp_buf | new | ) |
Definition at line 548 of file subr_kdb.c.
References kdb_jmpbufp.
void kdb_panic | ( | const char * | msg | ) |
Definition at line 292 of file subr_kdb.c.
References panic(), and printf().
Referenced by kdb_alt_break_internal().
void kdb_reboot | ( | void | ) |
Definition at line 300 of file subr_kdb.c.
References printf(), and shutdown_nice().
Referenced by kdb_alt_break_internal().
void kdb_reenter | ( | void | ) |
Definition at line 558 of file subr_kdb.c.
References kdb_active, kdb_backtrace(), kdb_jmpbufp, and printf().
Referenced by kdb_switch().
void kdb_reenter_silent | ( | void | ) |
Definition at line 571 of file subr_kdb.c.
References kdb_active, and kdb_jmpbufp.
|
static |
Definition at line 264 of file subr_kdb.c.
References kdb_stack_overflow().
Referenced by kdb_stack_overflow(), and kdb_sysctl_stack_overflow().
|
static |
Definition at line 147 of file subr_kdb.c.
References kdb_dbbe, sbuf_delete(), sbuf_finish(), sbuf_new_for_sysctl(), and sbuf_printf().
|
static |
Definition at line 164 of file subr_kdb.c.
References buf, kdb_active, kdb_dbbe, kdb_dbbe_select(), and sysctl_handle_string().
|
static |
Definition at line 182 of file subr_kdb.c.
References kdb_active, kdb_enter(), sysctl_handle_int(), and sysctl_wire_old_buffer().
|
static |
Definition at line 200 of file subr_kdb.c.
References panic(), sysctl_handle_int(), and sysctl_wire_old_buffer().
|
static |
Definition at line 216 of file subr_kdb.c.
References buf, panic(), and sysctl_handle_string().
|
static |
Definition at line 274 of file subr_kdb.c.
References kdb_stack_overflow(), sysctl_handle_int(), and sysctl_wire_old_buffer().
|
static |
Definition at line 230 of file subr_kdb.c.
References addr, sysctl_handle_int(), and sysctl_wire_old_buffer().
|
static |
Definition at line 246 of file subr_kdb.c.
References sysctl_handle_int(), and sysctl_wire_old_buffer().
struct pcb * kdb_thr_ctx | ( | struct thread * | thr | ) |
Definition at line 585 of file subr_kdb.c.
References kdb_pcb.
Referenced by kdb_thr_select().
struct thread * kdb_thr_first | ( | void | ) |
Definition at line 605 of file subr_kdb.c.
References pidhash, and pidhashtbl.
Referenced by kdb_thr_lookup().
struct thread * kdb_thr_from_pid | ( | pid_t | pid | ) |
Definition at line 626 of file subr_kdb.c.
struct thread * kdb_thr_lookup | ( | lwpid_t | tid | ) |
Definition at line 638 of file subr_kdb.c.
References kdb_thr_first(), and kdb_thr_next().
struct thread * kdb_thr_next | ( | struct thread * | thr | ) |
Definition at line 649 of file subr_kdb.c.
References pidhash, and pidhashtbl.
Referenced by kdb_thr_lookup().
int kdb_thr_select | ( | struct thread * | thr | ) |
Definition at line 675 of file subr_kdb.c.
References kdb_thr_ctx(), kdb_thrctx, and kdb_thread.
Referenced by kdb_trap().
int kdb_trap | ( | int | type, |
int | code, | ||
struct trapframe * | tf | ||
) |
Definition at line 688 of file subr_kdb.c.
References all_cpus, cngrab(), cnungrab(), kdb_active, kdb_dbbe, kdb_frame, kdb_pcb, kdb_thr_select(), printf(), and type.
SYSCTL_INT | ( | _debug_kdb | , |
OID_AUTO | , | ||
alt_break_to_debugger | , | ||
CTLFLAG_RWTUN| | CTLFLAG_SECURE, | ||
& | kdb_alt_break_to_debugger, | ||
0 | , | ||
"Enable alternative break to debugger" | |||
) |
SYSCTL_INT | ( | _debug_kdb | , |
OID_AUTO | , | ||
break_to_debugger | , | ||
CTLFLAG_RWTUN| | CTLFLAG_SECURE, | ||
& | kdb_break_to_debugger, | ||
0 | , | ||
"Enable break to debugger" | |||
) |
|
static |
SYSCTL_PROC | ( | _debug_kdb | , |
OID_AUTO | , | ||
available | , | ||
CTLTYPE_STRING|CTLFLAG_RD| | CTLFLAG_MPSAFE, | ||
NULL | , | ||
0 | , | ||
kdb_sysctl_available | , | ||
"A" | , | ||
"list of available KDB backends" | |||
) |
SYSCTL_PROC | ( | _debug_kdb | , |
OID_AUTO | , | ||
current | , | ||
CTLTYPE_STRING|CTLFLAG_RW| | CTLFLAG_MPSAFE, | ||
NULL | , | ||
0 | , | ||
kdb_sysctl_current | , | ||
"A" | , | ||
"currently selected KDB backend" | |||
) |
SYSCTL_PROC | ( | _debug_kdb | , |
OID_AUTO | , | ||
enter | , | ||
CTLTYPE_INT|CTLFLAG_RW|CTLFLAG_SECURE| | CTLFLAG_MPSAFE, | ||
NULL | , | ||
0 | , | ||
kdb_sysctl_enter | , | ||
"I" | , | ||
"set to enter the debugger" | |||
) |
SYSCTL_PROC | ( | _debug_kdb | , |
OID_AUTO | , | ||
panic | , | ||
CTLTYPE_INT|CTLFLAG_RW|CTLFLAG_SECURE| | CTLFLAG_MPSAFE, | ||
NULL | , | ||
0 | , | ||
kdb_sysctl_panic | , | ||
"I" | , | ||
"set to panic the kernel" | |||
) |
SYSCTL_PROC | ( | _debug_kdb | , |
OID_AUTO | , | ||
panic_str | , | ||
CTLTYPE_STRING|CTLFLAG_RW|CTLFLAG_SECURE| | CTLFLAG_MPSAFE, | ||
NULL | , | ||
0 | , | ||
kdb_sysctl_panic_str | , | ||
"A" | , | ||
"trigger a kernel | panic, | ||
using the provided string as the panic message" | |||
) |
SYSCTL_PROC | ( | _debug_kdb | , |
OID_AUTO | , | ||
stack_overflow | , | ||
CTLTYPE_INT|CTLFLAG_RW|CTLFLAG_SECURE| | CTLFLAG_MPSAFE, | ||
NULL | , | ||
0 | , | ||
kdb_sysctl_stack_overflow | , | ||
"I" | , | ||
"set to cause a stack overflow" | |||
) |
SYSCTL_PROC | ( | _debug_kdb | , |
OID_AUTO | , | ||
trap | , | ||
CTLTYPE_INT|CTLFLAG_RW|CTLFLAG_SECURE| | CTLFLAG_MPSAFE, | ||
NULL | , | ||
0 | , | ||
kdb_sysctl_trap | , | ||
"I" | , | ||
"set to cause a page fault via data access" | |||
) |
SYSCTL_PROC | ( | _debug_kdb | , |
OID_AUTO | , | ||
trap_code | , | ||
CTLTYPE_INT|CTLFLAG_RW|CTLFLAG_SECURE| | CTLFLAG_MPSAFE, | ||
NULL | , | ||
0 | , | ||
kdb_sysctl_trap_code | , | ||
"I" | , | ||
"set to cause a page fault via code access" | |||
) |
u_char __read_frequently kdb_active = 0 |
Definition at line 56 of file subr_kdb.c.
Referenced by __lockmgr_args(), __mtx_lock_flags(), __rw_rlock_int(), __rw_try_rlock_int(), __rw_try_wlock_int(), _mtx_lock_indefinite_check(), _mtx_trylock_flags_int(), _rw_wlock_cookie(), _sx_slock_int(), _sx_xlock(), cncheckc(), cngrab(), cnputc(), cnungrab(), critical_exit_preempt(), kdb_enter(), kdb_init(), kdb_reenter(), kdb_reenter_silent(), kdb_sysctl_current(), kdb_sysctl_enter(), kdb_trap(), kern_reboot(), kmsan_report_hook(), kmsan_report_inline(), ktr_tracepoint(), mi_switch(), pause_sbt(), putchar(), sbuf_tty_drain(), sx_try_slock_int(), sx_try_xlock_int(), sysctl_handle_string(), vpanic(), and witness_checkorder().
|
static |
Definition at line 77 of file subr_kdb.c.
Referenced by kdb_alt_break_internal().
|
static |
Definition at line 76 of file subr_kdb.c.
Referenced by kdb_break().
struct kdb_dbbe* kdb_dbbe = NULL |
Definition at line 58 of file subr_kdb.c.
Referenced by kdb_backtrace(), kdb_backtrace_thread(), kdb_dbbe_select(), kdb_enter(), kdb_init(), kdb_sysctl_available(), kdb_sysctl_current(), and kdb_trap().
struct trapframe* kdb_frame = NULL |
Definition at line 62 of file subr_kdb.c.
Referenced by kdb_trap().
|
static |
Definition at line 57 of file subr_kdb.c.
Referenced by kdb_jmpbuf(), kdb_reenter(), and kdb_reenter_silent().
|
static |
Definition at line 59 of file subr_kdb.c.
Referenced by kdb_thr_ctx(), and kdb_trap().
struct pcb* kdb_thrctx = NULL |
Definition at line 60 of file subr_kdb.c.
Referenced by kdb_thr_select().
struct thread* kdb_thread = NULL |
Definition at line 61 of file subr_kdb.c.
Referenced by kdb_thr_select().
const char* volatile kdb_why = KDB_WHY_UNSET |
Definition at line 144 of file subr_kdb.c.
Referenced by kdb_enter().