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/kern/debug.c

Version: -  FREEBSD  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    1 /* 
    2  * Mach Operating System
    3  * Copyright (c) 1993 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 "AS IS"
   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 Mellon
   24  * the rights to redistribute these changes.
   25  */
   26 /*
   27  * HISTORY
   28  * $Log:        debug.c,v $
   29  * Revision 2.23  93/01/27  09:34:42  danner
   30  *      Updated copyright.
   31  *      [93/01/12            berman]
   32  *      Changed sun conditional to be sun3, and added sun4 code
   33  *      in Debugger().
   34  *      [93/01/11            berman]
   35  * 
   36  * Revision 2.22  93/01/14  17:33:54  danner
   37  *      Added alpha, simplified.
   38  *      [92/11/30            af]
   39  * 
   40  * Revision 2.21  92/08/03  17:36:45  jfriedl
   41  *      removed silly prototypes
   42  *      Added pc532 support [Johannes Helander (jvh@cs.hut.fi)]
   43  *      [92/08/02            jfriedl]
   44  * 
   45  * Revision 2.20  92/05/21  17:13:07  jfriedl
   46  *      Added void type to functions that needed it.
   47  *      [92/05/16            jfriedl]
   48  * 
   49  * Revision 2.19  92/02/19  11:19:26  elf
   50  *      Added cpu number print, locking to print in Assert for
   51  *       multiprocessor case.
   52  *      [92/01/12            danner]
   53  * 
   54  * Revision 2.18  91/12/10  16:32:45  jsb
   55  *      Fixes from Intel
   56  *      [91/12/10  15:51:54  jsb]
   57  * 
   58  * Revision 2.17  91/08/03  18:18:47  jsb
   59  *      Replaced obsolete NORMA tag with NORMA_IPC.
   60  *      [91/07/27  18:13:01  jsb]
   61  * 
   62  * Revision 2.16  91/07/31  17:44:28  dbg
   63  *      Minor SUN changes.
   64  *      [91/07/12            dbg]
   65  * 
   66  * Revision 2.15  91/07/09  23:16:17  danner
   67  *      Luna88k support.
   68  *      [91/06/26            danner]
   69  * 
   70  * Revision 2.14  91/06/17  15:46:57  jsb
   71  *      Renamed NORMA conditionals.
   72  *      [91/06/17  10:49:18  jsb]
   73  * 
   74  * Revision 2.13  91/05/14  16:40:46  mrt
   75  *      Correcting copyright
   76  * 
   77  * Revision 2.12  91/03/16  14:49:39  rpd
   78  *      In panic, only call halt_cpu when not calling Debugger.
   79  *      [91/03/12            rpd]
   80  * 
   81  * Revision 2.11  91/02/05  17:25:52  mrt
   82  *      Changed to new Mach copyright
   83  *      [91/02/01  16:11:43  mrt]
   84  * 
   85  * Revision 2.10  90/12/14  11:02:02  jsb
   86  *      NORMA_IPC support: print node number as well as cpu in panic.
   87  *      [90/12/13  21:40:37  jsb]
   88  * 
   89  * Revision 2.9  90/12/04  14:51:00  jsb
   90  *      Added i860 support for Debugger function.
   91  *      [90/12/04  11:01:25  jsb]
   92  * 
   93  * Revision 2.8  90/11/05  14:30:49  rpd
   94  *      Added Assert.
   95  *      [90/11/04            rpd]
   96  * 
   97  * Revision 2.7  90/10/25  14:45:10  rwd
   98  *      Change sun3 debugger invocation.
   99  *      [90/10/17            rwd]
  100  * 
  101  * Revision 2.6  90/09/09  23:20:09  rpd
  102  *      Fixed panic and log to supply cnputc to _doprnt.
  103  *      [90/09/09            rpd]
  104  * 
  105  * Revision 2.5  90/09/09  14:32:03  rpd
  106  *      Use decl_simple_lock_data.
  107  *      [90/08/30            rpd]
  108  * 
  109  * Revision 2.4  90/08/27  22:02:14  dbg
  110  *      Pass extra argument to _doprnt.
  111  *      [90/08/21            dbg]
  112  * 
  113  * Revision 2.3  90/05/03  15:46:53  dbg
  114  *      Added i386 case.
  115  *      [90/02/21            dbg]
  116  * 
  117  * Revision 2.2  89/11/29  14:09:04  af
  118  *      Added mips case, RCS-ed.
  119  *      [89/10/28            af]
  120  * 
  121  */
  122 
  123 #include <mach_kdb.h>
  124 #include <norma_ipc.h>
  125 #include <cpus.h>
  126 
  127 #include <kern/cpu_number.h>
  128 #include <kern/lock.h>
  129 #include <sys/varargs.h>
  130 #include <kern/thread.h>
  131 
  132 
  133 
  134 extern void cnputc();
  135 void Debugger();
  136 
  137 #if     MACH_KDB
  138 extern int db_breakpoints_inserted;
  139 #endif
  140 
  141 #if NCPUS>1
  142 simple_lock_data_t Assert_print_lock; /* uninited, we take our chances */
  143 #endif
  144 
  145 void Assert(file, line)
  146         char *file;
  147         int line;
  148 {
  149 #if NCPUS > 1
  150         simple_lock(&Assert_print_lock);
  151         printf("{%d} Assertion failed: file \"%s\", line %d\n", 
  152                cpu_number(), file, line);
  153         simple_unlock(&Assert_print_lock);
  154 #else
  155         printf("Assertion failed: file \"%s\", line %d\n", file, line);
  156 #endif
  157 
  158 #if     MACH_KDB
  159         if (db_breakpoints_inserted)
  160 #endif
  161         Debugger("assertion failure");
  162 }
  163 
  164 void Debugger(message)
  165         char *  message;
  166 {
  167 #ifdef  lint
  168         message++;
  169 #endif  /* lint */
  170 
  171 #if     defined(vax) || defined(PC532)
  172         asm("bpt");
  173 #endif  /* vax */
  174 
  175 #ifdef  sun3
  176         current_thread()->pcb->flag |= TRACE_KDB;
  177         asm("orw  #0x00008000,sr");
  178 #endif  /* sun3 */
  179 #ifdef  sun4
  180         current_thread()->pcb->pcb_flag |= TRACE_KDB;
  181         asm("ta 0x81");
  182 #endif  /* sun4 */
  183 
  184 #if     defined(mips ) || defined(luna88k) || defined(i860) || defined(alpha)
  185         gimmeabreak();
  186 #endif
  187 
  188 #ifdef  i386
  189         asm("int3");
  190 #endif
  191 }
  192 
  193 char                    *panicstr;
  194 decl_simple_lock_data(, panic_lock)
  195 int                     paniccpu;
  196 
  197 void
  198 panic_init()
  199 {
  200         simple_lock_init(&panic_lock);
  201 }
  202 
  203 /*VARARGS1*/
  204 void
  205 panic(s, va_alist)
  206         char *  s;
  207         va_dcl
  208 {
  209         va_list listp;
  210 #if     NORMA_IPC
  211         extern int _node_self;  /* node_self() may not be callable yet */
  212 #endif  /* NORMA_IPC */
  213 
  214         simple_lock(&panic_lock);
  215         if (panicstr) {
  216             if (cpu_number() != paniccpu) {
  217                 simple_unlock(&panic_lock);
  218                 halt_cpu();
  219                 /* NOTREACHED */
  220             }
  221         }
  222         else {
  223             panicstr = s;
  224             paniccpu = cpu_number();
  225         }
  226         simple_unlock(&panic_lock);
  227         printf("panic");
  228 #if     NORMA_IPC
  229         printf("(node %U)", _node_self);
  230 #endif
  231 #if     NCPUS > 1
  232         printf("(cpu %U)", paniccpu);
  233 #endif
  234         printf(": ");
  235         va_start(listp);
  236         _doprnt(s, &listp, cnputc, 0);
  237         va_end(listp);
  238         printf("\n");
  239 
  240 #if     MACH_KDB
  241         Debugger("panic");
  242 #else
  243         halt_cpu();
  244 #endif
  245 }
  246 
  247 /*
  248  * We'd like to use BSD's log routines here...
  249  */
  250 /*VARARGS2*/
  251 void
  252 log(level, fmt, va_alist)
  253         int     level;
  254         char *  fmt;
  255         va_dcl
  256 {
  257         va_list listp;
  258 
  259 #ifdef lint
  260         level++;
  261 #endif
  262         va_start(listp);
  263         _doprnt(fmt, &listp, cnputc, 0);
  264         va_end(listp);
  265 }

Cache object: 2a6d7facf17958b07c74a5f176a49bb6


[ 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.