Changeset View
Changeset View
Standalone View
Standalone View
sys/ddb/db_print.c
Show First 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | |||||
#include <machine/pcb.h> | #include <machine/pcb.h> | ||||
#include <ddb/ddb.h> | #include <ddb/ddb.h> | ||||
#include <ddb/db_variables.h> | #include <ddb/db_variables.h> | ||||
#include <ddb/db_sym.h> | #include <ddb/db_sym.h> | ||||
void | void | ||||
db_show_regs(db_expr_t _1, bool _2, db_expr_t _3, char *_4) | db_show_regs(db_expr_t _1, bool _2, db_expr_t _3, char *modif) | ||||
{ | { | ||||
struct trapframe *oldtf; | |||||
struct db_variable *regp; | struct db_variable *regp; | ||||
db_expr_t value, offset; | db_expr_t value, offset; | ||||
const char *name; | const char *name; | ||||
/* | |||||
* The 'u' modifier instructs us to print the previous trapframe, most | |||||
* often containing state from userspace. This is done by temporarily | |||||
* switching out kdb_frame. | |||||
* | |||||
markj: s/kdb_frame/kdb_thread/? | |||||
* NB: curthread is used instead of kdb_thread, so that behaviour is | |||||
* consistent with regular `show registers`, which always prints | |||||
* curthread's trapframe. | |||||
*/ | |||||
oldtf = kdb_frame; | |||||
if (modif[0] == 'u') { | |||||
if (curthread->td_frame == NULL || | |||||
curthread->td_frame == oldtf) { | |||||
db_printf("previous trapframe unavailable"); | |||||
return; | |||||
} | |||||
kdb_frame = curthread->td_frame; | |||||
} | |||||
for (regp = db_regs; regp < db_eregs; regp++) { | for (regp = db_regs; regp < db_eregs; regp++) { | ||||
if (!db_read_variable(regp, &value)) | if (!db_read_variable(regp, &value)) | ||||
continue; | continue; | ||||
db_printf("%-12s%#*lr", regp->name, | db_printf("%-12s%#*lr", regp->name, | ||||
(int)(sizeof(unsigned long) * 2 + 2), (unsigned long)value); | (int)(sizeof(unsigned long) * 2 + 2), (unsigned long)value); | ||||
db_find_xtrn_sym_and_offset((db_addr_t)value, &name, &offset); | db_find_xtrn_sym_and_offset((db_addr_t)value, &name, &offset); | ||||
if (name != NULL && offset <= (unsigned long)db_maxoff && | if (name != NULL && offset <= (unsigned long)db_maxoff && | ||||
offset != value) { | offset != value) { | ||||
db_printf("\t%s", name); | db_printf("\t%s", name); | ||||
if (offset != 0) | if (offset != 0) | ||||
db_printf("+%+#lr", (long)offset); | db_printf("+%+#lr", (long)offset); | ||||
} | } | ||||
db_printf("\n"); | db_printf("\n"); | ||||
} | } | ||||
db_print_loc_and_inst(PC_REGS()); | db_print_loc_and_inst(PC_REGS()); | ||||
kdb_frame = oldtf; | |||||
} | } |
s/kdb_frame/kdb_thread/?