|
|
1.1.1.2 root 1: /*
1.1 root 2: * Mach Operating System
3: * Copyright (c) 1991,1990 Carnegie Mellon University
4: * All Rights Reserved.
1.1.1.2 root 5: *
1.1 root 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.
1.1.1.2 root 11: *
1.1 root 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.
1.1.1.2 root 15: *
1.1 root 16: * Carnegie Mellon requests users of this software to return to
1.1.1.2 root 17: *
1.1 root 18: * Software Distribution Coordinator or [email protected]
19: * School of Computer Science
20: * Carnegie Mellon University
21: * Pittsburgh PA 15213-3890
1.1.1.2 root 22: *
1.1 root 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: #if MACH_KDB
32:
33: /*
34: * Trap entry point to kernel debugger.
35: */
36: #include <mach/boolean.h>
37: #include <machine/db_machdep.h>
1.1.1.3 root 38: #include <machine/setjmp.h>
1.1 root 39: #include <ddb/db_command.h>
40: #include <ddb/db_access.h>
41: #include <ddb/db_break.h>
1.1.1.3 root 42: #include <ddb/db_examine.h>
43: #include <ddb/db_output.h>
1.1 root 44: #include <ddb/db_task_thread.h>
1.1.1.3 root 45: #include <ddb/db_trap.h>
1.1.1.4 root 46: #include <ddb/db_run.h>
1.1.1.5 ! root 47: #include <machine/db_interface.h>
! 48: #include <kern/lock.h>
1.1 root 49:
50:
51: extern jmp_buf_t *db_recover;
52:
53: extern int db_inst_count;
54: extern int db_load_count;
55: extern int db_store_count;
56:
57: void
1.1.1.4 root 58: db_task_trap(
59: int type,
60: int code,
61: boolean_t user_space)
1.1 root 62: {
63: jmp_buf_t db_jmpbuf;
64: jmp_buf_t *prev;
65: boolean_t bkpt;
66: boolean_t watchpt;
67: task_t task_space;
68:
1.1.1.5 ! root 69: check_simple_locks_disable();
! 70:
1.1 root 71: task_space = db_target_space(current_thread(), user_space);
72: bkpt = IS_BREAKPOINT_TRAP(type, code);
73: watchpt = IS_WATCHPOINT_TRAP(type, code);
74:
75: db_init_default_thread();
76: db_check_breakpoint_valid();
77: if (db_stop_at_pc(&bkpt, task_space)) {
78: if (db_inst_count) {
79: db_printf("After %d instructions (%d loads, %d stores),\n",
80: db_inst_count, db_load_count, db_store_count);
81: }
82: if (bkpt)
83: db_printf("Breakpoint at ");
84: else if (watchpt)
85: db_printf("Watchpoint at ");
86: else
87: db_printf("Stopped at ");
88: db_dot = PC_REGS(DDB_REGS);
89:
90: prev = db_recover;
91: if (_setjmp(db_recover = &db_jmpbuf) == 0)
92: db_print_loc_and_inst(db_dot, task_space);
93: else
94: db_printf("Trouble printing location %#X.\n", db_dot);
1.1.1.5 ! root 95:
! 96: if (!bkpt && !watchpt && _setjmp(db_recover = &db_jmpbuf) == 0)
! 97: db_stack_trace_cmd(0, 0, -1, "");
1.1 root 98: db_recover = prev;
99:
100: db_command_loop();
101: }
102:
1.1.1.5 ! root 103: check_simple_locks_enable();
1.1 root 104: db_restart_at_pc(watchpt, task_space);
105: }
106:
107: void
1.1.1.4 root 108: db_trap(
109: int type,
110: int code)
1.1 root 111: {
112: db_task_trap(type, code, !DB_VALID_KERN_ADDR(PC_REGS(DDB_REGS)));
113: }
114:
1.1.1.2 root 115: #endif /* MACH_KDB */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.