Annotation of Gnu-Mach/ddb/db_trap.c, revision 1.1.1.4

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       root       47: 
                     48: 
                     49: extern jmp_buf_t *db_recover;
                     50: 
                     51: extern int             db_inst_count;
                     52: extern int             db_load_count;
                     53: extern int             db_store_count;
                     54: 
                     55: void
1.1.1.4 ! root       56: db_task_trap(
        !            57:        int       type, 
        !            58:        int       code,
        !            59:        boolean_t user_space)
1.1       root       60: {
                     61:        jmp_buf_t db_jmpbuf;
                     62:        jmp_buf_t *prev;
                     63:        boolean_t       bkpt;
                     64:        boolean_t       watchpt;
                     65:        task_t          task_space;
                     66: 
                     67:        task_space = db_target_space(current_thread(), user_space);
                     68:        bkpt = IS_BREAKPOINT_TRAP(type, code);
                     69:        watchpt = IS_WATCHPOINT_TRAP(type, code);
                     70: 
                     71:        db_init_default_thread();
                     72:        db_check_breakpoint_valid();
                     73:        if (db_stop_at_pc(&bkpt, task_space)) {
                     74:            if (db_inst_count) {
                     75:                db_printf("After %d instructions (%d loads, %d stores),\n",
                     76:                          db_inst_count, db_load_count, db_store_count);
                     77:            }
                     78:            if (bkpt)
                     79:                db_printf("Breakpoint at  ");
                     80:            else if (watchpt)
                     81:                db_printf("Watchpoint at  ");
                     82:            else
                     83:                db_printf("Stopped at  ");
                     84:            db_dot = PC_REGS(DDB_REGS);
                     85: 
                     86:            prev = db_recover;
                     87:            if (_setjmp(db_recover = &db_jmpbuf) == 0)
                     88:                db_print_loc_and_inst(db_dot, task_space);
                     89:            else
                     90:                db_printf("Trouble printing location %#X.\n", db_dot);
                     91:            db_recover = prev;
                     92: 
                     93:            db_command_loop();
                     94:        }
                     95: 
                     96:        db_restart_at_pc(watchpt, task_space);
                     97: }
                     98: 
                     99: void
1.1.1.4 ! root      100: db_trap(
        !           101:        int     type, 
        !           102:        int     code)
1.1       root      103: {
                    104:        db_task_trap(type, code, !DB_VALID_KERN_ADDR(PC_REGS(DDB_REGS)));
                    105: }
                    106: 
1.1.1.2   root      107: #endif /* MACH_KDB */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.