/*-1* SPDX-License-Identifier: MIT-CMU2*3* Mach Operating System4* Copyright (c) 1991,1990 Carnegie Mellon University5* All Rights Reserved.6*7* Permission to use, copy, modify and distribute this software and its8* documentation is hereby granted, provided that both the copyright9* notice and this permission notice appear in all copies of the10* software, derivative works or modified versions, and any portions11* thereof, and that both notices appear in supporting documentation.12*13* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS14* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR15* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.16*17* Carnegie Mellon requests users of this software to return to18*19* Software Distribution Coordinator or [email protected]20* School of Computer Science21* Carnegie Mellon University22* Pittsburgh PA 15213-389023*24* any improvements or extensions that they make and grant Carnegie the25* rights to redistribute these changes.26*27*/28/*29* Author: David B. Golub, Carnegie Mellon University30* Date: 7/9031*/3233/*34* Miscellaneous printing.35*/3637#include <sys/param.h>38#include <sys/kdb.h>39#include <sys/proc.h>4041#include <machine/pcb.h>4243#include <ddb/ddb.h>44#include <ddb/db_variables.h>45#include <ddb/db_sym.h>4647void48db_show_regs(db_expr_t _1, bool _2, db_expr_t _3, char *modif)49{50struct trapframe *oldtf;51struct db_variable *regp;52db_expr_t value, offset;53const char *name;5455/*56* The 'u' modifier instructs us to print the previous trapframe, most57* often containing state from userspace. This is done by temporarily58* switching out kdb_frame.59*60* NB: curthread is used instead of kdb_thread, so that behaviour is61* consistent with regular `show registers`, which always prints62* curthread's trapframe.63*/64oldtf = kdb_frame;65if (modif[0] == 'u') {66if (curthread->td_frame == NULL ||67curthread->td_frame == oldtf) {68db_printf("previous trapframe unavailable");69return;70}71kdb_frame = curthread->td_frame;72}7374for (regp = db_regs; regp < db_eregs; regp++) {75if (!db_read_variable(regp, &value))76continue;77db_printf("%-12s%#*lr", regp->name,78(int)(sizeof(unsigned long) * 2 + 2), (unsigned long)value);79db_find_xtrn_sym_and_offset((db_addr_t)value, &name, &offset);80if (name != NULL && offset <= (unsigned long)db_maxoff &&81offset != value) {82db_printf("\t%s", name);83if (offset != 0)84db_printf("+%+#lr", (long)offset);85}86db_printf("\n");87}88db_print_loc_and_inst(PC_REGS());8990kdb_frame = oldtf;91}929394