|
|
1.1 root 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 "AS IS"
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 [email protected]
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 Mellon
24: * the rights to redistribute these changes.
25: */
26: /*
27: * Author: David B. Golub, Carnegie Mellon University
28: * Date: 7/90
29: */
30:
31: #include "mach_kdb.h"
32: #if MACH_KDB
33:
34: /*
35: * Trap entry point to kernel debugger.
36: */
37: #include <mach/boolean.h>
38: #include <machine/db_machdep.h>
39: #include <ddb/db_command.h>
40: #include <ddb/db_access.h>
41: #include <ddb/db_break.h>
42: #include <ddb/db_task_thread.h>
43:
44:
45:
46: extern jmp_buf_t *db_recover;
47:
48: extern void db_restart_at_pc();
49: extern boolean_t db_stop_at_pc();
50:
51: extern int db_inst_count;
52: extern int db_load_count;
53: extern int db_store_count;
54:
55: void
56: db_task_trap(type, code, user_space)
57: int type, code;
58: boolean_t user_space;
59: {
60: jmp_buf_t db_jmpbuf;
61: jmp_buf_t *prev;
62: boolean_t bkpt;
63: boolean_t watchpt;
64: void db_init_default_thread();
65: void db_check_breakpoint_valid();
66: task_t task_space;
67:
68: task_space = db_target_space(current_thread(), user_space);
69: bkpt = IS_BREAKPOINT_TRAP(type, code);
70: watchpt = IS_WATCHPOINT_TRAP(type, code);
71:
72: db_init_default_thread();
73: db_check_breakpoint_valid();
74: if (db_stop_at_pc(&bkpt, task_space)) {
75: if (db_inst_count) {
76: db_printf("After %d instructions (%d loads, %d stores),\n",
77: db_inst_count, db_load_count, db_store_count);
78: }
79: if (bkpt)
80: db_printf("Breakpoint at ");
81: else if (watchpt)
82: db_printf("Watchpoint at ");
83: else
84: db_printf("Stopped at ");
85: db_dot = PC_REGS(DDB_REGS);
86:
87: prev = db_recover;
88: if (_setjmp(db_recover = &db_jmpbuf) == 0)
89: db_print_loc_and_inst(db_dot, task_space);
90: else
91: db_printf("Trouble printing location %#X.\n", db_dot);
92: db_recover = prev;
93:
94: db_command_loop();
95: }
96:
97: db_restart_at_pc(watchpt, task_space);
98: }
99:
100: void
101: db_trap(type, code)
102: int type, code;
103: {
104: db_task_trap(type, code, !DB_VALID_KERN_ADDR(PC_REGS(DDB_REGS)));
105: }
106:
107: #endif MACH_KDB
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.