|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. ! 3: * ! 4: * @APPLE_LICENSE_HEADER_START@ ! 5: * ! 6: * The contents of this file constitute Original Code as defined in and ! 7: * are subject to the Apple Public Source License Version 1.1 (the ! 8: * "License"). You may not use this file except in compliance with the ! 9: * License. Please obtain a copy of the License at ! 10: * http://www.apple.com/publicsource and read it before using this file. ! 11: * ! 12: * This Original Code and all software distributed under the License are ! 13: * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER ! 14: * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, ! 15: * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, ! 16: * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the ! 17: * License for the specific language governing rights and limitations ! 18: * under the License. ! 19: * ! 20: * @APPLE_LICENSE_HEADER_END@ ! 21: */ ! 22: /* ! 23: * @OSF_COPYRIGHT@ ! 24: */ ! 25: /* ! 26: * HISTORY ! 27: * ! 28: * Revision 1.1.1.1 1998/09/22 21:05:48 wsanchez ! 29: * Import of Mac OS X kernel (~semeria) ! 30: * ! 31: * Revision 1.1.1.1 1998/03/07 02:26:09 wsanchez ! 32: * Import of OSF Mach kernel (~mburg) ! 33: * ! 34: * Revision 1.1.11.1 1997/03/27 18:47:01 barbou ! 35: * Merge smp_shared merges into mainline. ! 36: * [1996/09/19 13:55:17 addis] ! 37: * Make tr_indent NCPU safe. ! 38: * [95/10/09 rwd] ! 39: * Added TR_INIT() macro. ! 40: * Change from NMK16.1 [93/09/22 paire] ! 41: * [94/02/04 paire] ! 42: * [97/02/25 barbou] ! 43: * ! 44: * Revision 1.1.6.1 1995/02/23 16:34:23 alanl ! 45: * Taken from DIPC2_SHARED. Change to !FREE Copyright. ! 46: * [95/01/05 rwd] ! 47: * ! 48: * Revision 1.1.4.4 1994/08/18 01:07:26 alanl ! 49: * + Allow tracing strictly based on MACH_TR; ! 50: * don't also require MACH_ASSERT (alanl). ! 51: * + ANSI-fication: cast tr arguments (alanl). ! 52: * + Added tr_indent and macros to use it (sjs). ! 53: * [1994/08/18 01:06:09 alanl] ! 54: * ! 55: * Revision 1.1.4.3 1994/08/08 17:59:35 rwd ! 56: * Include mach_tr.h ! 57: * [94/08/08 rwd] ! 58: * ! 59: * Revision 1.1.4.2 1994/08/05 19:36:08 mmp ! 60: * Added prototype for db_show_tr. ! 61: * ! 62: * Conditionalize on MACH_TR ! 63: * [94/07/20 rwd] ! 64: * ! 65: * Revision 1.1.4.1 1994/08/04 01:43:04 mmp ! 66: * DIPC: moved from norma/ to ddb/. Updated includes. ! 67: * [1994/08/03 13:37:46 mmp] ! 68: * ! 69: * Revision 1.1.9.1 1994/03/07 16:55:24 paire ! 70: * Added ANSI prototypes. ! 71: * [94/02/15 paire] ! 72: * ! 73: * Added TR_INIT() macro. ! 74: * Change from NMK16.1 [93/09/22 paire] ! 75: * [94/02/04 paire] ! 76: * ! 77: * Revision 1.1.2.2 1993/06/02 23:57:10 jeffc ! 78: * Added to OSF/1 R1.3 from NMK15.0. ! 79: * [1993/06/02 21:22:08 jeffc] ! 80: * ! 81: * Revision 1.1 1992/09/30 02:34:09 robert ! 82: * Initial revision ! 83: * ! 84: * $EndLog$ ! 85: */ ! 86: ! 87: /* ! 88: * File: ddb/tr.h ! 89: * Author: Alan Langerman, Jeffrey Heller ! 90: * Date: 1992 ! 91: * ! 92: * Internal trace routines. Like old-style XPRs but ! 93: * less formatting. ! 94: */ ! 95: ! 96: #include <mach_assert.h> ! 97: #include <mach_tr.h> ! 98: ! 99: #include <kern/cpu_number.h> ! 100: ! 101: /* ! 102: * Originally, we only wanted tracing when ! 103: * MACH_TR and MACH_ASSERT were turned on ! 104: * together. Now, there's no reason why ! 105: * MACH_TR and MACH_ASSERT can't be completely ! 106: * orthogonal. ! 107: */ ! 108: #define TRACE_BUFFER (MACH_TR) ! 109: ! 110: /* ! 111: * Log events in a circular trace buffer for future debugging. ! 112: * Events are unsigned integers. Each event has a descriptive ! 113: * message. ! 114: * ! 115: * TR_DECL must be used at the beginning of a routine using ! 116: * one of the tr calls. The macro should be passed the name ! 117: * of the function surrounded by quotation marks, e.g., ! 118: * TR_DECL("netipc_recv_intr"); ! 119: * and should be terminated with a semi-colon. The TR_DECL ! 120: * must be the *last* declaration in the variable declaration ! 121: * list, or syntax errors will be introduced when TRACE_BUFFER ! 122: * is turned off. ! 123: */ ! 124: #ifndef _DDB_TR_H_ ! 125: #define _DDB_TR_H_ ! 126: ! 127: #if TRACE_BUFFER ! 128: ! 129: #include <machine/db_machdep.h> ! 130: ! 131: #define __ui__ (unsigned int) ! 132: #define TR_INIT() tr_init() ! 133: #define TR_SHOW(a,b,c) show_tr((a),(b),(c)) ! 134: #define TR_DECL(funcname) char *__ntr_func_name__ = funcname ! 135: #define tr1(msg) \ ! 136: tr(__ntr_func_name__, __FILE__, __LINE__, (msg), \ ! 137: 0,0,0,0) ! 138: #define tr2(msg,tag1) \ ! 139: tr(__ntr_func_name__, __FILE__, __LINE__, (msg), \ ! 140: __ui__(tag1),0,0,0) ! 141: #define tr3(msg,tag1,tag2) \ ! 142: tr(__ntr_func_name__, __FILE__, __LINE__, (msg), \ ! 143: __ui__(tag1),__ui__(tag2),0,0) ! 144: #define tr4(msg,tag1,tag2,tag3) \ ! 145: tr(__ntr_func_name__, __FILE__, __LINE__, (msg), \ ! 146: __ui__(tag1),__ui__(tag2),__ui__(tag3),0) ! 147: #define tr5(msg,tag1,tag2,tag3,tag4) \ ! 148: tr(__ntr_func_name__, __FILE__, __LINE__, (msg), \ ! 149: __ui__(tag1),__ui__(tag2),__ui__(tag3),__ui__(tag4)) ! 150: ! 151: /* ! 152: * Adjust tr log indentation based on function ! 153: * call graph. ! 154: */ ! 155: #if NCPUS == 1 ! 156: extern int tr_indent; ! 157: #define tr_start() tr_indent++ ! 158: #define tr_stop() tr_indent-- ! 159: #else /* NCPUS == 1 */ ! 160: extern int tr_indent[NCPUS]; ! 161: #define tr_start() tr_indent[cpu_number()]++ ! 162: #define tr_stop() (--tr_indent[cpu_number()]<0?tr_indent[cpu_number()]=0:0); ! 163: #endif /* NCPUS == 1 */ ! 164: ! 165: extern void tr_init(void); ! 166: extern void tr( ! 167: char *funcname, ! 168: char *file, ! 169: unsigned int lineno, ! 170: char *fmt, ! 171: unsigned int tag1, ! 172: unsigned int tag2, ! 173: unsigned int tag3, ! 174: unsigned int tag4); ! 175: ! 176: extern void db_show_tr( ! 177: db_expr_t addr, ! 178: boolean_t have_addr, ! 179: db_expr_t count, ! 180: char * modif); ! 181: ! 182: #else /* TRACE_BUFFER */ ! 183: ! 184: #define TR_INIT() ! 185: #define TR_SHOW(a,b,c) ! 186: #define TR_DECL(funcname) ! 187: #define tr1(msg) ! 188: #define tr2(msg, tag1) ! 189: #define tr3(msg, tag1, tag2) ! 190: #define tr4(msg, tag1, tag2, tag3) ! 191: #define tr5(msg, tag1, tag2, tag3, tag4) ! 192: #define tr_start() ! 193: #define tr_stop() ! 194: ! 195: #endif /* TRACE_BUFFER */ ! 196: ! 197: #endif /* _DDB_TR_H_ */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.