]>
git.saurik.com Git - apple/xnu.git/blob - osfmk/ddb/db_trap.c
2 * Copyright (c) 2000-2004 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
;
92 task
= db_current_task();
93 task_space
= db_target_space(current_thread(), user_space
);
94 bkpt
= IS_BREAKPOINT_TRAP(type
, code
);
95 watchpt
= IS_WATCHPOINT_TRAP(type
, code
);
98 * Note: we look up PC values in an address space (task_space),
99 * but print symbols using a (task-specific) symbol table, found
103 /* Elided since walking the thread/task lists before setting up
104 * safe recovery points is incorrect, and could
105 * potentially cause us to loop and fault indefinitely.
108 db_init_default_act();
110 db_check_breakpoint_valid();
112 if (db_stop_at_pc(&bkpt
, task
, task_space
)) {
114 db_printf("After %d instructions (%d loads, %d stores),\n",
115 db_inst_count
, db_load_count
, db_store_count
);
118 db_printf("Breakpoint at ");
120 db_printf("Watchpoint at ");
122 db_printf("Stopped at ");
123 db_dot
= PC_REGS(DDB_REGS
);
126 if (_setjmp(db_recover
= &db_jmpbuf
) == 0) {
128 db_print_loc(db_dot
, task_space
);
130 db_print_inst(db_dot
, task_space
);
131 #else /* !defined(__alpha) */
133 db_print_loc_and_inst(db_dot
, task_space
);
135 db_print_loc_and_inst(db_dot
, task
);
137 #endif /* defined(__alpha) */
139 db_printf("Trouble printing location %#llX.\n", (unsigned long long)db_dot
);
145 db_restart_at_pc(watchpt
, task_space
);