db_print.c revision 283248
1130803Smarcel/*-
2130803Smarcel * Mach Operating System
3130803Smarcel * Copyright (c) 1991,1990 Carnegie Mellon University
4130803Smarcel * All Rights Reserved.
5130803Smarcel *
6130803Smarcel * Permission to use, copy, modify and distribute this software and its
7130803Smarcel * documentation is hereby granted, provided that both the copyright
8130803Smarcel * notice and this permission notice appear in all copies of the
9130803Smarcel * software, derivative works or modified versions, and any portions
10130803Smarcel * thereof, and that both notices appear in supporting documentation.
11130803Smarcel *
12130803Smarcel * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS
13130803Smarcel * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
14130803Smarcel * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
15130803Smarcel *
16130803Smarcel * Carnegie Mellon requests users of this software to return to
17130803Smarcel *
18130803Smarcel *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
19130803Smarcel *  School of Computer Science
20130803Smarcel *  Carnegie Mellon University
21130803Smarcel *  Pittsburgh PA 15213-3890
22130803Smarcel *
23130803Smarcel * any improvements or extensions that they make and grant Carnegie the
24130803Smarcel * rights to redistribute these changes.
25130803Smarcel *
26130803Smarcel */
27130803Smarcel/*
28130803Smarcel *	Author: David B. Golub, Carnegie Mellon University
29130803Smarcel *	Date:	7/90
30130803Smarcel */
31130803Smarcel
32130803Smarcel/*
33130803Smarcel * Miscellaneous printing.
34130803Smarcel */
35130803Smarcel
36130803Smarcel#include <sys/cdefs.h>
37130803Smarcel__FBSDID("$FreeBSD: head/sys/ddb/db_print.c 283248 2015-05-21 15:16:18Z pfg $");
38130803Smarcel
39130803Smarcel#include <sys/param.h>
40130803Smarcel#include <sys/kdb.h>
41130803Smarcel#include <sys/proc.h>
42130803Smarcel
43130803Smarcel#include <machine/pcb.h>
44130803Smarcel
45130803Smarcel#include <ddb/ddb.h>
46130803Smarcel#include <ddb/db_variables.h>
47130803Smarcel#include <ddb/db_sym.h>
48130803Smarcel
49130803Smarcelvoid
50130803Smarceldb_show_regs(db_expr_t _1, bool _2, db_expr_t _3, char *_4)
51130803Smarcel{
52130803Smarcel	struct db_variable *regp;
53130803Smarcel	db_expr_t value, offset;
54130803Smarcel	const char *name;
55130803Smarcel
56130803Smarcel	for (regp = db_regs; regp < db_eregs; regp++) {
57130803Smarcel		if (!db_read_variable(regp, &value))
58130803Smarcel			continue;
59130803Smarcel		db_printf("%-12s%#10lr", regp->name, (unsigned long)value);
60130803Smarcel		db_find_xtrn_sym_and_offset((db_addr_t)value, &name, &offset);
61130803Smarcel		if (name != NULL && offset <= (unsigned long)db_maxoff &&
62130803Smarcel		    offset != value) {
63130803Smarcel			db_printf("\t%s", name);
64130803Smarcel			if (offset != 0)
65130803Smarcel				db_printf("+%+#lr", (long)offset);
66130803Smarcel		}
67130803Smarcel		db_printf("\n");
68130803Smarcel	}
69130803Smarcel	db_print_loc_and_inst(PC_REGS());
70130803Smarcel}
71130803Smarcel