Index: share/man/man4/ddb.4 =================================================================== --- share/man/man4/ddb.4 +++ share/man/man4/ddb.4 @@ -958,11 +958,6 @@ modifier is specified, it displays user registers instead of kernel registers or the currently saved one. .Pp -.Sy Warning : -The support of the -.Cm u -modifier depends on the machine. -If not supported, incorrect information will be displayed. .\" .Pp .It Ic show Cm rman Ar addr Index: sys/ddb/db_print.c =================================================================== --- sys/ddb/db_print.c +++ sys/ddb/db_print.c @@ -49,12 +49,31 @@ #include 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; db_expr_t value, offset; const char *name; + /* + * The 'u' modifier tells us to print the user trapframe. This is done + * by temporarily switching out kdb_frame. + * + * NB: curthread is used instead of kdb_frame, so that behaviour is + * consistent with regular `show registers`, which will always print + * curthread's trapframe. + */ + oldtf = kdb_frame; + if (modif[0] == 'u') { + if (curthread->td_frame == NULL || + curthread->td_frame == kdb_frame) { + db_printf("user trapframe unavailable"); + return; + } + kdb_frame = curthread->td_frame; + } + for (regp = db_regs; regp < db_eregs; regp++) { if (!db_read_variable(regp, &value)) continue; @@ -70,4 +89,6 @@ db_printf("\n"); } db_print_loc_and_inst(PC_REGS()); + + kdb_frame = oldtf; }