Index: sys/amd64/amd64/db_trace.c =================================================================== --- sys/amd64/amd64/db_trace.c +++ sys/amd64/amd64/db_trace.c @@ -188,7 +188,6 @@ #define TRAP_INTERRUPT 5 static void db_nextframe(struct amd64_frame **, db_addr_t *, struct thread *); -static int db_numargs(struct amd64_frame *); static void db_print_stack_entry(const char *, int, char **, long *, db_addr_t, void *); static void decode_syscall(int, struct thread *); @@ -198,62 +197,12 @@ int access, struct dbreg *d); int amd64_clr_watch(int watchnum, struct dbreg *d); -/* - * Figure out how many arguments were passed into the frame at "fp". - */ -static int -db_numargs(fp) - struct amd64_frame *fp; -{ -#if 1 - return (0); /* regparm, needs dwarf2 info */ -#else - long *argp; - int inst; - int args; - - argp = (long *)db_get_value((long)&fp->f_retaddr, 8, FALSE); - /* - * XXX etext is wrong for LKMs. We should attempt to interpret - * the instruction at the return address in all cases. This - * may require better fault handling. - */ - if (argp < (long *)btext || argp >= (long *)etext) { - args = 5; - } else { - inst = db_get_value((long)argp, 4, FALSE); - if ((inst & 0xff) == 0x59) /* popl %ecx */ - args = 1; - else if ((inst & 0xffff) == 0xc483) /* addl $Ibs, %esp */ - args = ((inst >> 16) & 0xff) / 4; - else - args = 5; - } - return (args); -#endif -} - static void -db_print_stack_entry(name, narg, argnp, argp, callpc, frame) - const char *name; - int narg; - char **argnp; - long *argp; - db_addr_t callpc; - void *frame; +db_print_stack_entry(const char *name, int narg, char **argnp, long *argp, + db_addr_t callpc, void *frame) { - db_printf("%s(", name); -#if 0 - while (narg) { - if (argnp) - db_printf("%s=", *argnp++); - db_printf("%lr", (long)db_get_value((long)argp, 8, FALSE)); - argp++; - if (--narg != 0) - db_printf(","); - } -#endif - db_printf(") at "); + + db_printf("%s() at ", name); db_printsym(callpc, DB_STGY_PROC); if (frame != NULL) db_printf("/frame 0x%lx", (register_t)frame); @@ -384,8 +333,8 @@ } static int -db_backtrace(struct thread *td, struct trapframe *tf, - struct amd64_frame *frame, db_addr_t pc, int count) +db_backtrace(struct thread *td, struct amd64_frame *frame, db_addr_t pc, + int count) { struct amd64_frame *actframe; #define MAXNARG 16 @@ -405,41 +354,9 @@ sym = db_search_symbol(pc, DB_STGY_ANY, &offset); db_symbol_values(sym, &name, NULL); - /* - * Attempt to determine a (possibly fake) frame that gives - * the caller's pc. It may differ from `frame' if the - * current function never sets up a standard frame or hasn't - * set one up yet or has just discarded one. The last two - * cases can be guessed fairly reliably for code generated - * by gcc. The first case is too much trouble to handle in - * general because the amount of junk on the stack depends - * on the pc (the special handling of "calltrap", etc. in - * db_nextframe() works because the `next' pc is special). - */ actframe = frame; if (first) { - if (tf != NULL) { - int instr; - - instr = db_get_value(pc, 4, FALSE); - if ((instr & 0xffffffff) == 0xe5894855) { - /* pushq %rbp; movq %rsp, %rbp */ - actframe = (void *)(get_rsp(tf) - 8); - } else if ((instr & 0xffffff) == 0xe58948) { - /* movq %rsp, %rbp */ - actframe = (void *)get_rsp(tf); - if (tf->tf_rbp == 0) { - /* Fake frame better. */ - frame = actframe; - } - } else if ((instr & 0xff) == 0xc3) { - /* ret */ - actframe = (void *)(get_rsp(tf) - 8); - } else if (offset == 0) { - /* Probably an assembler symbol. */ - actframe = (void *)(get_rsp(tf) - 8); - } - } else if (strcmp(name, "fork_trampoline") == 0) { + if (strcmp(name, "fork_trampoline") == 0) { /* * Don't try to walk back on a stack for a * process that hasn't actually been run yet. @@ -456,7 +373,7 @@ if (sym != NULL && db_sym_numargs(sym, &narg, argnames)) { argnp = argnames; } else { - narg = db_numargs(frame); + narg = 0; } db_print_stack_entry(name, narg, argnp, argp, pc, actframe); @@ -495,7 +412,7 @@ frame = (struct amd64_frame *)rbp; callpc = (db_addr_t)db_get_value((long)&frame->f_retaddr, 8, FALSE); frame = frame->f_frame; - db_backtrace(curthread, NULL, frame, callpc, -1); + db_backtrace(curthread, frame, callpc, -1); } int @@ -504,8 +421,8 @@ struct pcb *ctx; ctx = kdb_thr_ctx(thr); - return (db_backtrace(thr, NULL, (struct amd64_frame *)ctx->pcb_rbp, - ctx->pcb_rip, count)); + return (db_backtrace(thr, (struct amd64_frame *)ctx->pcb_rbp, + ctx->pcb_rip, count)); } int