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