FreeBSD/Linux Kernel Cross Reference
sys/ddb/db_trap.c
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 * Author: David B. Golub, Carnegie Mellon University
28 * Date: 7/90
29 */
30
31 /*
32 * Trap entry point to kernel debugger.
33 */
34
35 #include <sys/cdefs.h>
36 __FBSDID("$FreeBSD: releng/5.2/sys/ddb/db_trap.c 116176 2003-06-10 22:09:23Z obrien $");
37
38 #include <sys/param.h>
39 #include <sys/systm.h>
40
41 #include <ddb/ddb.h>
42 #include <ddb/db_command.h>
43
44 #include <machine/setjmp.h>
45
46 extern jmp_buf db_jmpbuf;
47
48 void
49 db_trap(type, code)
50 int type, code;
51 {
52 boolean_t bkpt;
53 boolean_t watchpt;
54
55 bkpt = IS_BREAKPOINT_TRAP(type, code);
56 watchpt = IS_WATCHPOINT_TRAP(type, code);
57
58 if (db_stop_at_pc(&bkpt)) {
59 if (db_inst_count) {
60 db_printf("After %d instructions (%d loads, %d stores),\n",
61 db_inst_count, db_load_count, db_store_count);
62 }
63 if (bkpt)
64 db_printf("Breakpoint at\t");
65 else if (watchpt)
66 db_printf("Watchpoint at\t");
67 else
68 db_printf("Stopped at\t");
69 db_dot = PC_REGS(DDB_REGS);
70 if (setjmp(db_jmpbuf) == 0)
71 db_print_loc_and_inst(db_dot);
72
73 db_command_loop();
74 }
75
76 db_restart_at_pc(watchpt);
77 }
Cache object: d7337e3fdaee839bbc6661b779c9ee15
|