db_trap.c revision 1.2.4.1 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 (at) 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_trap.c,v 1.2.4.1 1993/11/14 22:48:44 mycroft Exp $
28 *
29 * HISTORY
30 * $Log: db_trap.c,v $
31 * Revision 1.2.4.1 1993/11/14 22:48:44 mycroft
32 * Canonicalize all #includes.
33 *
34 * Revision 1.2 1993/05/20 03:39:34 cgd
35 * add explicit rcs id
36 *
37 * Revision 1.1.1.1 1993/03/21 09:46:27 cgd
38 * initial import of 386bsd-0.1 sources
39 *
40 * Revision 1.1 1992/03/25 21:45:31 pace
41 * Initial revision
42 *
43 * Revision 2.5 91/02/05 17:07:16 mrt
44 * Changed to new Mach copyright
45 * [91/01/31 16:19:35 mrt]
46 *
47 * Revision 2.4 91/01/08 15:09:17 rpd
48 * Changed db_stop_at_pc's arguments.
49 * Print db_inst_count, db_load_count, db_store_count.
50 * [90/11/27 rpd]
51 *
52 * Revision 2.3 90/10/25 14:44:11 rwd
53 * From rpd.
54 * [90/10/19 17:03:17 rwd]
55 *
56 * Generalized the watchpoint support.
57 * [90/10/16 rwd]
58 * Added watchpoint support.
59 * [90/10/16 rpd]
60 *
61 * Revision 2.2 90/08/27 21:52:52 dbg
62 * Assign to db_dot before calling the print function.
63 * [90/08/20 af]
64 * Reduce lint.
65 * [90/08/07 dbg]
66 * Created.
67 * [90/07/25 dbg]
68 *
69 */
70 /*
71 * Author: David B. Golub, Carnegie Mellon University
72 * Date: 7/90
73 */
74
75 /*
76 * Trap entry point to kernel debugger.
77 */
78 #include <sys/param.h>
79 #include <sys/proc.h>
80
81 #include <ddb/db_command.h>
82 #include <ddb/db_break.h>
83
84 extern void db_restart_at_pc();
85 extern boolean_t db_stop_at_pc();
86
87 extern int db_inst_count;
88 extern int db_load_count;
89 extern int db_store_count;
90
91 db_trap(type, code)
92 int type, code;
93 {
94 boolean_t bkpt;
95 boolean_t watchpt;
96
97 bkpt = IS_BREAKPOINT_TRAP(type, code);
98 watchpt = IS_WATCHPOINT_TRAP(type, code);
99
100 if (db_stop_at_pc(&bkpt)) {
101 if (db_inst_count) {
102 db_printf("After %d instructions (%d loads, %d stores),\n",
103 db_inst_count, db_load_count, db_store_count);
104 }
105 if (bkpt)
106 db_printf("Breakpoint at\t");
107 else if (watchpt)
108 db_printf("Watchpoint at\t");
109 else
110 db_printf("Stopped at\t");
111 db_dot = PC_REGS(DDB_REGS);
112 db_print_loc_and_inst(db_dot);
113
114 db_command_loop();
115 }
116
117 db_restart_at_pc(watchpt);
118 }
119