The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/ddb/db_trap.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*      $NetBSD: db_trap.c,v 1.22 2005/02/26 23:04:17 perry Exp $       */
    2 
    3 /*
    4  * Mach Operating System
    5  * Copyright (c) 1991,1990 Carnegie Mellon University
    6  * All Rights Reserved.
    7  *
    8  * Permission to use, copy, modify and distribute this software and its
    9  * documentation is hereby granted, provided that both the copyright
   10  * notice and this permission notice appear in all copies of the
   11  * software, derivative works or modified versions, and any portions
   12  * thereof, and that both notices appear in supporting documentation.
   13  *
   14  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
   15  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
   16  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
   17  *
   18  * Carnegie Mellon requests users of this software to return to
   19  *
   20  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
   21  *  School of Computer Science
   22  *  Carnegie Mellon University
   23  *  Pittsburgh PA 15213-3890
   24  *
   25  * any improvements or extensions that they make and grant Carnegie the
   26  * rights to redistribute these changes.
   27  *
   28  *      Author: David B. Golub, Carnegie Mellon University
   29  *      Date:   7/90
   30  */
   31 
   32 /*
   33  * Trap entry point to kernel debugger.
   34  */
   35 
   36 #include <sys/cdefs.h>
   37 __KERNEL_RCSID(0, "$NetBSD: db_trap.c,v 1.22 2005/02/26 23:04:17 perry Exp $");
   38 
   39 #include <sys/param.h>
   40 #include <sys/proc.h>
   41 
   42 #include <machine/db_machdep.h>
   43 
   44 #include <ddb/db_run.h>
   45 #include <ddb/db_command.h>
   46 #include <ddb/db_break.h>
   47 #include <ddb/db_output.h>
   48 #include <ddb/db_sym.h>
   49 #include <ddb/db_extern.h>
   50 
   51 /*
   52  * db_trap_callback can be hooked by MD port code to handle special
   53  * cases such as disabling hardware watchdogs while in DDB.
   54  */
   55 void (*db_trap_callback)(int);
   56 
   57 int db_trap_type;
   58 
   59 void
   60 db_trap(int type, int code)
   61 {
   62         boolean_t       bkpt;
   63         boolean_t       watchpt;
   64 
   65         db_trap_type = type;
   66 
   67         bkpt = IS_BREAKPOINT_TRAP(type, code);
   68         watchpt = IS_WATCHPOINT_TRAP(type, code);
   69 
   70         if (db_trap_callback) db_trap_callback(1);
   71 
   72         if (db_stop_at_pc(DDB_REGS, &bkpt)) {
   73                 if (db_inst_count) {
   74                         db_printf("After %d instructions "
   75                             "(%d loads, %d stores),\n",
   76                             db_inst_count, db_load_count, db_store_count);
   77                 }
   78                 if (curlwp != NULL) {
   79                         if (bkpt)
   80                                 db_printf("Breakpoint");
   81                         else if (watchpt)
   82                                 db_printf("Watchpoint");
   83                         else
   84                                 db_printf("Stopped");
   85                         if (curproc == NULL)
   86                                 db_printf("; curlwp = %p,"
   87                                     " curproc is NULL at\t", curlwp);
   88                         else
   89                                 db_printf(" in pid %d.%d (%s) at\t",
   90                                     curproc->p_pid, curlwp->l_lid,
   91                                     curproc->p_comm);
   92                 } else if (bkpt)
   93                         db_printf("Breakpoint at\t");
   94                 else if (watchpt)
   95                         db_printf("Watchpoint at\t");
   96                 else
   97                         db_printf("Stopped at\t");
   98                 db_dot = PC_REGS(DDB_REGS);
   99                 db_print_loc_and_inst(db_dot);
  100 
  101                 db_command_loop();
  102         }
  103 
  104         db_restart_at_pc(DDB_REGS, watchpt);
  105 
  106         if (db_trap_callback)
  107                 db_trap_callback(0);
  108 }

Cache object: 58ffc8753b6804fad034ff8db8529d78


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.