MCPcopy Create free account
hub / github.com/F-Stack/f-stack / db_backtrace

Function db_backtrace

freebsd/i386/i386/db_trace.c:435–592  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

433}
434
435static int
436db_backtrace(struct thread *td, struct trapframe *tf, struct i386_frame *frame,
437 db_addr_t pc, register_t sp, int count)
438{
439 struct i386_frame *actframe;
440#define MAXNARG 16
441 char *argnames[MAXNARG], **argnp = NULL;
442 const char *name;
443 int *argp;
444 db_expr_t offset;
445 c_db_sym_t sym;
446 int instr, narg;
447 bool first;
448
449 if (db_segsize(tf) == 16) {
450 db_printf(
451"--- 16-bit%s, cs:eip = %#x:%#x, ss:esp = %#x:%#x, ebp = %#x, tf = %p ---\n",
452 (tf->tf_eflags & PSL_VM) ? " (vm86)" : "",
453 tf->tf_cs, tf->tf_eip,
454 TF_HAS_STACKREGS(tf) ? tf->tf_ss : rss(),
455 TF_HAS_STACKREGS(tf) ? tf->tf_esp : (intptr_t)&tf->tf_esp,
456 tf->tf_ebp, tf);
457 return (0);
458 }
459
460 /* 'frame' can be null initially. Just print the pc then. */
461 if (frame == NULL)
462 goto out;
463
464 /*
465 * If an indirect call via an invalid pointer caused a trap,
466 * %pc contains the invalid address while the return address
467 * of the unlucky caller has been saved by CPU on the stack
468 * just before the trap frame. In this case, try to recover
469 * the caller's address so that the first frame is assigned
470 * to the right spot in the right function, for that is where
471 * the failure actually happened.
472 *
473 * This trick depends on the fault address stashed in tf_err
474 * by trap_fatal() before entering KDB.
475 */
476 if (kdb_frame && pc == kdb_frame->tf_err) {
477 /*
478 * Find where the trap frame actually ends.
479 * It won't contain tf_esp or tf_ss unless crossing rings.
480 */
481 if (TF_HAS_STACKREGS(kdb_frame))
482 instr = (int)(kdb_frame + 1);
483 else
484 instr = (int)&kdb_frame->tf_esp;
485 pc = db_get_value(instr, 4, false);
486 }
487
488 if (count == -1)
489 count = 1024;
490
491 first = true;
492 while (count-- && !db_pager_quit) {

Callers 2

db_trace_selfFunction · 0.70
db_trace_threadFunction · 0.70

Calls 12

db_segsizeFunction · 0.85
db_printfFunction · 0.85
db_get_valueFunction · 0.85
db_search_symbolFunction · 0.85
db_symbol_valuesFunction · 0.85
get_espFunction · 0.85
strcmpFunction · 0.85
db_sym_numargsFunction · 0.85
db_numargsFunction · 0.85
db_print_stack_entryFunction · 0.70
db_nextframeFunction · 0.70
rssFunction · 0.50

Tested by

no test coverage detected