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

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