xref: /netbsd-src/sys/ddb/db_print.c (revision cda4f8f6ee55684e8d311b86c99ea59191e6b74f)
1 /*
2  * Mach Operating System
3  * Copyright (c) 1991,1990 Carnegie Mellon University
4  * All Rights Reserved.
5  *
6  * Permission to use, copy, modify and distribute this software and its
7  * documentation is hereby granted, provided that both the copyright
8  * notice and this permission notice appear in all copies of the
9  * software, derivative works or modified versions, and any portions
10  * thereof, and that both notices appear in supporting documentation.
11  *
12  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS
13  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
14  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
15  *
16  * Carnegie Mellon requests users of this software to return to
17  *
18  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
19  *  School of Computer Science
20  *  Carnegie Mellon University
21  *  Pittsburgh PA 15213-3890
22  *
23  * any improvements or extensions that they make and grant Carnegie the
24  * rights to redistribute these changes.
25  */
26 /*
27  * $Id: db_print.c,v 1.2 1993/05/20 03:39:25 cgd Exp $
28  *
29  * HISTORY
30  * $Log: db_print.c,v $
31  * Revision 1.2  1993/05/20 03:39:25  cgd
32  * add explicit rcs id
33  *
34  * Revision 1.1.1.1  1993/03/21  09:46:27  cgd
35  * initial import of 386bsd-0.1 sources
36  *
37  * Revision 1.1  1992/03/25  21:45:22  pace
38  * Initial revision
39  *
40  * Revision 2.5  91/02/05  17:06:53  mrt
41  * 	Changed to new Mach copyright
42  * 	[91/01/31  16:18:56  mrt]
43  *
44  * Revision 2.4  90/10/25  14:43:54  rwd
45  * 	Changed db_show_regs to print unsigned.
46  * 	[90/10/19            rpd]
47  * 	Generalized the watchpoint support.
48  * 	[90/10/16            rwd]
49  *
50  * Revision 2.3  90/09/09  23:19:52  rpd
51  * 	Avoid totally incorrect guesses of symbol names for small values.
52  * 	[90/08/30  17:39:08  af]
53  *
54  * Revision 2.2  90/08/27  21:51:49  dbg
55  * 	Insist that 'show thread' be called with an explicit address.
56  * 	[90/08/22            dbg]
57  *
58  * 	Fix type for db_maxoff.
59  * 	[90/08/20            dbg]
60  *
61  * 	Do not dereference the "valuep" field of a variable directly,
62  * 	call the new db_read/write_variable functions instead.
63  * 	Reflected changes in symbol lookup functions.
64  * 	[90/08/20            af]
65  * 	Reduce lint.
66  * 	[90/08/10  14:33:44  dbg]
67  *
68  * 	Created.
69  * 	[90/07/25            dbg]
70  *
71  */
72 /*
73  * 	Author: David B. Golub, Carnegie Mellon University
74  *	Date:	7/90
75  */
76 
77 /*
78  * Miscellaneous printing.
79  */
80 #include "param.h"
81 #include "proc.h"
82 
83 #include <machine/db_machdep.h>
84 
85 #include <ddb/db_lex.h>
86 #include <ddb/db_variables.h>
87 #include <ddb/db_sym.h>
88 
89 extern unsigned int	db_maxoff;
90 
91 void
92 db_show_regs()
93 {
94 	int	(*func)();
95 	register struct db_variable *regp;
96 	db_expr_t	value, offset;
97 	char *		name;
98 
99 	for (regp = db_regs; regp < db_eregs; regp++) {
100 	    db_read_variable(regp, &value);
101 	    db_printf("%-12s%#10n", regp->name, value);
102 	    db_find_xtrn_sym_and_offset((db_addr_t)value, &name, &offset);
103 	    if (name != 0 && offset <= db_maxoff && offset != value) {
104 		db_printf("\t%s", name);
105 		if (offset != 0)
106 		    db_printf("+%#r", offset);
107 	    }
108 	    db_printf("\n");
109 	}
110 	db_print_loc_and_inst(PC_REGS(DDB_REGS));
111 }
112 
113