Changeset View
Changeset View
Standalone View
Standalone View
sys/i386/i386/db_trace.c
Show All 26 Lines | |||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/systm.h> | #include <sys/systm.h> | ||||
#include <sys/kdb.h> | #include <sys/kdb.h> | ||||
#include <sys/proc.h> | #include <sys/proc.h> | ||||
#include <sys/reg.h> | #include <sys/reg.h> | ||||
#include <sys/sysent.h> | |||||
#include <machine/cpu.h> | #include <machine/cpu.h> | ||||
#include <machine/frame.h> | #include <machine/frame.h> | ||||
#include <machine/md_var.h> | #include <machine/md_var.h> | ||||
#include <machine/pcb.h> | #include <machine/pcb.h> | ||||
#include <machine/stack.h> | #include <machine/stack.h> | ||||
#include <vm/vm.h> | #include <vm/vm.h> | ||||
▲ Show 20 Lines • Show All 147 Lines • ▼ Show 20 Lines | |||||
#define INTERRUPT 2 | #define INTERRUPT 2 | ||||
#define SYSCALL 3 | #define SYSCALL 3 | ||||
#define DOUBLE_FAULT 4 | #define DOUBLE_FAULT 4 | ||||
static void db_nextframe(struct i386_frame **, db_addr_t *, struct thread *); | static void db_nextframe(struct i386_frame **, db_addr_t *, struct thread *); | ||||
static int db_numargs(struct i386_frame *); | static int db_numargs(struct i386_frame *); | ||||
static void db_print_stack_entry(const char *, int, char **, int *, db_addr_t, | static void db_print_stack_entry(const char *, int, char **, int *, db_addr_t, | ||||
void *); | void *); | ||||
static void decode_syscall(int, struct thread *); | |||||
/* | /* | ||||
* Figure out how many arguments were passed into the frame at "fp". | * Figure out how many arguments were passed into the frame at "fp". | ||||
*/ | */ | ||||
static int | static int | ||||
db_numargs(fp) | db_numargs(fp) | ||||
struct i386_frame *fp; | struct i386_frame *fp; | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | if (narg < 0) | ||||
db_printf(",..."); | db_printf(",..."); | ||||
db_printf(") at "); | db_printf(") at "); | ||||
db_printsym(callpc, DB_STGY_PROC); | db_printsym(callpc, DB_STGY_PROC); | ||||
if (frame != NULL) | if (frame != NULL) | ||||
db_printf("/frame 0x%r", (register_t)frame); | db_printf("/frame 0x%r", (register_t)frame); | ||||
db_printf("\n"); | db_printf("\n"); | ||||
} | } | ||||
static void | |||||
decode_syscall(int number, struct thread *td) | |||||
{ | |||||
struct proc *p; | |||||
c_db_sym_t sym; | |||||
db_expr_t diff; | |||||
sy_call_t *f; | |||||
const char *symname; | |||||
db_printf(" (%d", number); | |||||
p = (td != NULL) ? td->td_proc : NULL; | |||||
if (p != NULL && 0 <= number && number < p->p_sysent->sv_size) { | |||||
f = p->p_sysent->sv_table[number].sy_call; | |||||
sym = db_search_symbol((db_addr_t)f, DB_STGY_ANY, &diff); | |||||
if (sym != DB_SYM_NULL && diff == 0) { | |||||
db_symbol_values(sym, &symname, NULL); | |||||
db_printf(", %s, %s", p->p_sysent->sv_name, symname); | |||||
} | |||||
} | |||||
db_printf(")"); | |||||
} | |||||
/* | /* | ||||
* Figure out the next frame up in the call stack. | * Figure out the next frame up in the call stack. | ||||
*/ | */ | ||||
static void | static void | ||||
db_nextframe(struct i386_frame **fp, db_addr_t *ip, struct thread *td) | db_nextframe(struct i386_frame **fp, db_addr_t *ip, struct thread *td) | ||||
{ | { | ||||
struct trapframe *tf; | struct trapframe *tf; | ||||
int frame_type; | int frame_type; | ||||
▲ Show 20 Lines • Show All 96 Lines • ▼ Show 20 Lines | db_nextframe(struct i386_frame **fp, db_addr_t *ip, struct thread *td) | ||||
eip = tf->tf_eip; | eip = tf->tf_eip; | ||||
ebp = tf->tf_ebp; | ebp = tf->tf_ebp; | ||||
switch (frame_type) { | switch (frame_type) { | ||||
case TRAP: | case TRAP: | ||||
db_printf("--- trap %#r", tf->tf_trapno); | db_printf("--- trap %#r", tf->tf_trapno); | ||||
break; | break; | ||||
case SYSCALL: | case SYSCALL: | ||||
db_printf("--- syscall"); | db_printf("--- syscall"); | ||||
decode_syscall(tf->tf_eax, td); | db_decode_syscall(tf->tf_eax, td); | ||||
break; | break; | ||||
case INTERRUPT: | case INTERRUPT: | ||||
db_printf("--- interrupt"); | db_printf("--- interrupt"); | ||||
break; | break; | ||||
default: | default: | ||||
panic("The moon has moved again."); | panic("The moon has moved again."); | ||||
} | } | ||||
db_printf(", eip = %#r, esp = %#r, ebp = %#r ---\n", eip, esp, ebp); | db_printf(", eip = %#r, esp = %#r, ebp = %#r ---\n", eip, esp, ebp); | ||||
▲ Show 20 Lines • Show All 213 Lines • Show Last 20 Lines |