|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. ! 3: * ! 4: * @APPLE_LICENSE_HEADER_START@ ! 5: * ! 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. ! 11: * ! 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 ! 18: * under the License. ! 19: * ! 20: * @APPLE_LICENSE_HEADER_END@ ! 21: */ ! 22: /* ! 23: * @OSF_COPYRIGHT@ ! 24: */ ! 25: /* ! 26: * Mach Operating System ! 27: * Copyright (c) 1991,1990 Carnegie Mellon University ! 28: * All Rights Reserved. ! 29: * ! 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. ! 35: * ! 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. ! 39: * ! 40: * Carnegie Mellon requests users of this software to return to ! 41: * ! 42: * Software Distribution Coordinator or [email protected] ! 43: * School of Computer Science ! 44: * Carnegie Mellon University ! 45: * Pittsburgh PA 15213-3890 ! 46: * ! 47: * any improvements or extensions that they make and grant Carnegie Mellon ! 48: * the rights to redistribute these changes. ! 49: */ ! 50: /* ! 51: */ ! 52: /* ! 53: * Author: David B. Golub, Carnegie Mellon University ! 54: * Date: 7/90 ! 55: */ ! 56: ! 57: /* ! 58: * Trap entry point to kernel debugger. ! 59: */ ! 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> ! 72: ! 73: extern jmp_buf_t *db_recover; ! 74: ! 75: extern int db_inst_count; ! 76: extern int db_load_count; ! 77: extern int db_store_count; ! 78: ! 79: #if PARAGON860 && NCPUS > 1 ! 80: extern int db_first_cpu; ! 81: #endif ! 82: ! 83: void ! 84: db_task_trap( ! 85: int type, ! 86: int code, ! 87: boolean_t user_space) ! 88: { ! 89: jmp_buf_t db_jmpbuf; ! 90: jmp_buf_t *prev; ! 91: boolean_t bkpt; ! 92: boolean_t watchpt; ! 93: task_t task; ! 94: task_t task_space; ! 95: ! 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); ! 100: ! 101: /* ! 102: * Note: we look up PC values in an address space (task_space), ! 103: * but print symbols using a (task-specific) symbol table, found ! 104: * using task. ! 105: */ ! 106: db_init_default_act(); ! 107: db_check_breakpoint_valid(); ! 108: if (db_stop_at_pc(&bkpt, task, task_space)) { ! 109: if (db_inst_count) { ! 110: db_printf("After %d instructions (%d loads, %d stores),\n", ! 111: db_inst_count, db_load_count, db_store_count); ! 112: } ! 113: if (bkpt) ! 114: db_printf("Breakpoint at "); ! 115: else if (watchpt) ! 116: db_printf("Watchpoint at "); ! 117: else ! 118: db_printf("Stopped at "); ! 119: db_dot = PC_REGS(DDB_REGS); ! 120: ! 121: prev = db_recover; ! 122: if (_setjmp(db_recover = &db_jmpbuf) == 0) { ! 123: #if defined(__alpha) ! 124: db_print_loc(db_dot, task_space); ! 125: db_printf("\n\t"); ! 126: db_print_inst(db_dot, task_space); ! 127: #else /* !defined(__alpha) */ ! 128: #if defined(__ppc__) ! 129: db_print_loc_and_inst(db_dot, task_space); ! 130: #else /* __ppc__ */ ! 131: db_print_loc_and_inst(db_dot, task); ! 132: #endif /* __ppc__ */ ! 133: #endif /* defined(__alpha) */ ! 134: } else ! 135: db_printf("Trouble printing location %#X.\n", db_dot); ! 136: db_recover = prev; ! 137: ! 138: db_command_loop(); ! 139: } ! 140: ! 141: db_restart_at_pc(watchpt, task_space); ! 142: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.