added my responsibility for the `cpm' port
[unix-history] / sys / ddb / db_trap.c
CommitLineData
15637ed4
RG
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.
15637ed4 25 *
4c45483e 26 * $Id: db_trap.c,v 1.2 1993/10/16 16:47:28 rgrimes Exp $
15637ed4 27 */
cbeffc91 28
15637ed4
RG
29/*
30 * Author: David B. Golub, Carnegie Mellon University
31 * Date: 7/90
32 */
33
34/*
35 * Trap entry point to kernel debugger.
36 */
37#include "param.h"
4c45483e 38#include "systm.h"
15637ed4 39#include "proc.h"
4c45483e 40#include "ddb/ddb.h"
15637ed4
RG
41#include <ddb/db_command.h>
42#include <ddb/db_break.h>
43
44extern void db_restart_at_pc();
45extern boolean_t db_stop_at_pc();
46
47extern int db_inst_count;
48extern int db_load_count;
49extern int db_store_count;
50
4c45483e 51void
15637ed4
RG
52db_trap(type, code)
53 int type, code;
54{
55 boolean_t bkpt;
56 boolean_t watchpt;
57
58 bkpt = IS_BREAKPOINT_TRAP(type, code);
59 watchpt = IS_WATCHPOINT_TRAP(type, code);
60
61 if (db_stop_at_pc(&bkpt)) {
62 if (db_inst_count) {
63 db_printf("After %d instructions (%d loads, %d stores),\n",
64 db_inst_count, db_load_count, db_store_count);
65 }
66 if (bkpt)
67 db_printf("Breakpoint at\t");
68 else if (watchpt)
69 db_printf("Watchpoint at\t");
70 else
71 db_printf("Stopped at\t");
72 db_dot = PC_REGS(DDB_REGS);
73 db_print_loc_and_inst(db_dot);
74
75 db_command_loop();
76 }
77
78 db_restart_at_pc(watchpt);
79}