db_print.c revision 145053
1175164Sjhb/*-
2175164Sjhb * Mach Operating System
3175164Sjhb * Copyright (c) 1991,1990 Carnegie Mellon University
4175164Sjhb * All Rights Reserved.
5175164Sjhb *
6175164Sjhb * Permission to use, copy, modify and distribute this software and its
7175164Sjhb * documentation is hereby granted, provided that both the copyright
8175164Sjhb * notice and this permission notice appear in all copies of the
9175164Sjhb * software, derivative works or modified versions, and any portions
10175164Sjhb * thereof, and that both notices appear in supporting documentation.
11175164Sjhb *
12175164Sjhb * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS
13175164Sjhb * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
14175164Sjhb * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
15175164Sjhb *
16175164Sjhb * Carnegie Mellon requests users of this software to return to
17175164Sjhb *
18175164Sjhb *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
19175164Sjhb *  School of Computer Science
20175164Sjhb *  Carnegie Mellon University
21175164Sjhb *  Pittsburgh PA 15213-3890
22175164Sjhb *
23175164Sjhb * any improvements or extensions that they make and grant Carnegie the
24175164Sjhb * rights to redistribute these changes.
25175164Sjhb *
26175164Sjhb */
27175164Sjhb/*
28175164Sjhb * 	Author: David B. Golub, Carnegie Mellon University
29175164Sjhb *	Date:	7/90
30175164Sjhb */
31175164Sjhb
32175164Sjhb/*
33175164Sjhb * Miscellaneous printing.
34175164Sjhb */
35175164Sjhb
36175164Sjhb#include <sys/cdefs.h>
37175164Sjhb__FBSDID("$FreeBSD: head/sys/ddb/db_print.c 145053 2005-04-14 05:25:40Z peter $");
38175164Sjhb
39175164Sjhb#include <sys/param.h>
40175164Sjhb#include <sys/kdb.h>
41175164Sjhb#include <sys/proc.h>
42175164Sjhb
43175164Sjhb#include <machine/pcb.h>
44175164Sjhb
45175164Sjhb#include <ddb/ddb.h>
46175164Sjhb#include <ddb/db_variables.h>
47175164Sjhb#include <ddb/db_sym.h>
48175164Sjhb
49180059Sjhbvoid
50180059Sjhbdb_show_regs(db_expr_t _1, boolean_t _2, db_expr_t _3, char *_4)
51180059Sjhb{
52180059Sjhb	struct db_variable *regp;
53175164Sjhb	db_expr_t value, offset;
54175164Sjhb	const char *name;
55175164Sjhb
56175164Sjhb	for (regp = db_regs; regp < db_eregs; regp++) {
57175164Sjhb		if (!db_read_variable(regp, &value))
58223692Sjonathan			continue;
59223692Sjonathan		db_printf("%-12s%#10lr", regp->name, (unsigned long)value);
60175164Sjhb		db_find_xtrn_sym_and_offset((db_addr_t)value, &name, &offset);
61223692Sjonathan		if (name != NULL && offset <= (unsigned long)db_maxoff &&
62175164Sjhb		    offset != value) {
63175164Sjhb			db_printf("\t%s", name);
64175164Sjhb			if (offset != 0)
65175164Sjhb				db_printf("+%+#lr", (long)offset);
66175164Sjhb		}
67175164Sjhb		db_printf("\n");
68175164Sjhb	}
69175164Sjhb	db_print_loc_and_inst(PC_REGS());
70175164Sjhb}
71224914Skib