| 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 |
| 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 Software.Distribution@CS.CMU.EDU |
| 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 the |
| 24 | * rights to redistribute these changes. |
| 25 | */ |
| 26 | /* |
| 27 | * HISTORY |
| 28 | * $Log: db_trap.c,v $ |
| 29 | * Revision 1.1 1992/03/25 21:45:31 pace |
| 30 | * Initial revision |
| 31 | * |
| 32 | * Revision 2.5 91/02/05 17:07:16 mrt |
| 33 | * Changed to new Mach copyright |
| 34 | * [91/01/31 16:19:35 mrt] |
| 35 | * |
| 36 | * Revision 2.4 91/01/08 15:09:17 rpd |
| 37 | * Changed db_stop_at_pc's arguments. |
| 38 | * Print db_inst_count, db_load_count, db_store_count. |
| 39 | * [90/11/27 rpd] |
| 40 | * |
| 41 | * Revision 2.3 90/10/25 14:44:11 rwd |
| 42 | * From rpd. |
| 43 | * [90/10/19 17:03:17 rwd] |
| 44 | * |
| 45 | * Generalized the watchpoint support. |
| 46 | * [90/10/16 rwd] |
| 47 | * Added watchpoint support. |
| 48 | * [90/10/16 rpd] |
| 49 | * |
| 50 | * Revision 2.2 90/08/27 21:52:52 dbg |
| 51 | * Assign to db_dot before calling the print function. |
| 52 | * [90/08/20 af] |
| 53 | * Reduce lint. |
| 54 | * [90/08/07 dbg] |
| 55 | * Created. |
| 56 | * [90/07/25 dbg] |
| 57 | * |
| 58 | */ |
| 59 | /* |
| 60 | * Author: David B. Golub, Carnegie Mellon University |
| 61 | * Date: 7/90 |
| 62 | */ |
| 63 | |
| 64 | /* |
| 65 | * Trap entry point to kernel debugger. |
| 66 | */ |
| 67 | #include "param.h" |
| 68 | #include "proc.h" |
| 69 | #include <ddb/db_command.h> |
| 70 | #include <ddb/db_break.h> |
| 71 | |
| 72 | extern void db_restart_at_pc(); |
| 73 | extern boolean_t db_stop_at_pc(); |
| 74 | |
| 75 | extern int db_inst_count; |
| 76 | extern int db_load_count; |
| 77 | extern int db_store_count; |
| 78 | |
| 79 | db_trap(type, code) |
| 80 | int type, code; |
| 81 | { |
| 82 | boolean_t bkpt; |
| 83 | boolean_t watchpt; |
| 84 | |
| 85 | bkpt = IS_BREAKPOINT_TRAP(type, code); |
| 86 | watchpt = IS_WATCHPOINT_TRAP(type, code); |
| 87 | |
| 88 | if (db_stop_at_pc(&bkpt)) { |
| 89 | if (db_inst_count) { |
| 90 | db_printf("After %d instructions (%d loads, %d stores),\n", |
| 91 | db_inst_count, db_load_count, db_store_count); |
| 92 | } |
| 93 | if (bkpt) |
| 94 | db_printf("Breakpoint at\t"); |
| 95 | else if (watchpt) |
| 96 | db_printf("Watchpoint at\t"); |
| 97 | else |
| 98 | db_printf("Stopped at\t"); |
| 99 | db_dot = PC_REGS(DDB_REGS); |
| 100 | db_print_loc_and_inst(db_dot); |
| 101 | |
| 102 | db_command_loop(); |
| 103 | } |
| 104 | |
| 105 | db_restart_at_pc(watchpt); |
| 106 | } |