db_trap.c revision 1.3 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 * Author: David B. Golub, Carnegie Mellon University
27 * Date: 7/90
28 * $Id: db_trap.c,v 1.3 1993/12/18 04:46:40 mycroft Exp $
29 */
30
31 /*
32 * Trap entry point to kernel debugger.
33 */
34 #include <sys/param.h>
35 #include <sys/proc.h>
36
37 #include <ddb/db_command.h>
38 #include <ddb/db_break.h>
39
40 extern void db_restart_at_pc();
41 extern boolean_t db_stop_at_pc();
42
43 extern int db_inst_count;
44 extern int db_load_count;
45 extern int db_store_count;
46
47 db_trap(type, code)
48 int type, code;
49 {
50 boolean_t bkpt;
51 boolean_t watchpt;
52
53 bkpt = IS_BREAKPOINT_TRAP(type, code);
54 watchpt = IS_WATCHPOINT_TRAP(type, code);
55
56 if (db_stop_at_pc(&bkpt)) {
57 if (db_inst_count) {
58 db_printf("After %d instructions (%d loads, %d stores),\n",
59 db_inst_count, db_load_count, db_store_count);
60 }
61 if (bkpt)
62 db_printf("Breakpoint at\t");
63 else if (watchpt)
64 db_printf("Watchpoint at\t");
65 else
66 db_printf("Stopped at\t");
67 db_dot = PC_REGS(DDB_REGS);
68 db_print_loc_and_inst(db_dot);
69
70 db_command_loop();
71 }
72
73 db_restart_at_pc(watchpt);
74 }
75