1 /* $OpenBSD: db_trap.c,v 1.16 2011/04/03 16:46:19 drahn Exp $ */
2 /* $NetBSD: db_trap.c,v 1.9 1996/02/05 01:57:18 christos Exp $ */
5 * Mach Operating System
6 * Copyright (c) 1993,1992,1991,1990 Carnegie Mellon University
9 * Permission to use, copy, modify and distribute this software and its
10 * documentation is hereby granted, provided that both the copyright
11 * notice and this permission notice appear in all copies of the
12 * software, derivative works or modified versions, and any portions
13 * thereof, and that both notices appear in supporting documentation.
15 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
16 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
17 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
19 * Carnegie Mellon requests users of this software to return to
21 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
22 * School of Computer Science
23 * Carnegie Mellon University
24 * Pittsburgh PA 15213-3890
26 * any improvements or extensions that they make and grant Carnegie Mellon
27 * the rights to redistribute these changes.
29 * Author: David B. Golub, Carnegie Mellon University
34 * Trap entry point to kernel debugger.
36 #include <sys/param.h>
38 #include <sys/systm.h>
40 #include <uvm/uvm_extern.h>
42 #include <machine/db_machdep.h>
44 #include <ddb/db_run.h>
45 #include <ddb/db_command.h>
46 #include <ddb/db_break.h>
47 #include <ddb/db_output.h>
48 #include <ddb/db_sym.h>
49 #include <ddb/db_extern.h>
50 #include <ddb/db_interface.h>
51 #include <ddb/db_var.h>
54 db_trap(int type
, int code
)
60 bkpt
= IS_BREAKPOINT_TRAP(type
, code
);
61 watchpt
= IS_WATCHPOINT_TRAP(type
, code
);
63 if (db_stop_at_pc(DDB_REGS
, &bkpt
)) {
65 db_printf("After %d instructions\n", db_inst_count
);
68 db_printf("Breakpoint at\t");
70 db_printf("Watchpoint at\t");
72 db_printf("Stopped at\t");
73 db_dot
= PC_REGS(DDB_REGS
);
74 db_print_loc_and_inst(db_dot
);
77 * Just in case we do not have any usable console driver,
78 * give the user a traceback.
81 db_stack_trace_print(db_dot
, 0, 10 /* arbitrary */, "",
85 if (panicstr
!= NULL
) {
86 if (db_print_position() != 0)
88 db_printf("RUN AT LEAST 'trace' AND 'ps' AND INCLUDE "
89 "OUTPUT WHEN REPORTING THIS PANIC!\n");
91 db_printf("IF RUNNING SMP, USE 'mach ddbcpu <#>' AND "
92 "'trace' ON OTHER PROCESSORS, TOO.\n");
94 db_printf("DO NOT EVEN BOTHER REPORTING THIS WITHOUT "
95 "INCLUDING THAT INFORMATION!\n");
101 db_restart_at_pc(DDB_REGS
, watchpt
);