]>
git.saurik.com Git - apple/xnu.git/blob - osfmk/ddb/db_trap.c
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
26 * Mach Operating System
27 * Copyright (c) 1991,1990 Carnegie Mellon University
28 * All Rights Reserved.
30 * Permission to use, copy, modify and distribute this software and its
31 * documentation is hereby granted, provided that both the copyright
32 * notice and this permission notice appear in all copies of the
33 * software, derivative works or modified versions, and any portions
34 * thereof, and that both notices appear in supporting documentation.
36 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
37 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
38 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
40 * Carnegie Mellon requests users of this software to return to
42 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
43 * School of Computer Science
44 * Carnegie Mellon University
45 * Pittsburgh PA 15213-3890
47 * any improvements or extensions that they make and grant Carnegie Mellon
48 * the rights to redistribute these changes.
53 * Author: David B. Golub, Carnegie Mellon University
58 * Trap entry point to kernel debugger.
60 #include <mach/boolean.h>
61 #include <machine/db_machdep.h>
62 #include <kern/misc_protos.h>
63 #include <ddb/db_access.h>
64 #include <ddb/db_break.h>
65 #include <ddb/db_command.h>
66 #include <ddb/db_examine.h>
67 #include <ddb/db_output.h> /* For db_printf() */
68 #include <ddb/db_run.h>
69 #include <ddb/db_task_thread.h>
70 #include <ddb/db_trap.h>
71 #include <machine/setjmp.h>
73 extern jmp_buf_t
*db_recover
;
75 extern int db_inst_count
;
76 extern int db_load_count
;
77 extern int db_store_count
;
79 #if PARAGON860 && NCPUS > 1
80 extern int db_first_cpu
;
96 task
= db_current_task();
97 task_space
= db_target_space(current_act(), user_space
);
98 bkpt
= IS_BREAKPOINT_TRAP(type
, code
);
99 watchpt
= IS_WATCHPOINT_TRAP(type
, code
);
102 * Note: we look up PC values in an address space (task_space),
103 * but print symbols using a (task-specific) symbol table, found
106 db_init_default_act();
107 db_check_breakpoint_valid();
108 if (db_stop_at_pc(&bkpt
, task
, task_space
)) {
110 db_printf("After %d instructions (%d loads, %d stores),\n",
111 db_inst_count
, db_load_count
, db_store_count
);
114 db_printf("Breakpoint at ");
116 db_printf("Watchpoint at ");
118 db_printf("Stopped at ");
119 db_dot
= PC_REGS(DDB_REGS
);
122 if (_setjmp(db_recover
= &db_jmpbuf
) == 0) {
124 db_print_loc(db_dot
, task_space
);
126 db_print_inst(db_dot
, task_space
);
127 #else /* !defined(__alpha) */
129 db_print_loc_and_inst(db_dot
, task_space
);
131 db_print_loc_and_inst(db_dot
, task
);
133 #endif /* defined(__alpha) */
135 db_printf("Trouble printing location %#X.\n", db_dot
);
141 db_restart_at_pc(watchpt
, task_space
);