1 /* 2 * BEGIN illumos section 3 * This is an unstable interface; changes may be made 4 * without notice. 5 * END illumos section 6 */ 7 /*********************************************************************** 8 * * 9 * This software is part of the ast package * 10 * Copyright (c) 1985-2011 AT&T Intellectual Property * 11 * and is licensed under the * 12 * Eclipse Public License, Version 1.0 * 13 * by AT&T Intellectual Property * 14 * * 15 * A copy of the License is available at * 16 * http://www.eclipse.org/org/documents/epl-v10.html * 17 * (with md5 checksum b35adb5213ca9657e911e9befb180842) * 18 * * 19 * Information and Software Systems Research * 20 * AT&T Research * 21 * Florham Park NJ * 22 * * 23 * Glenn Fowler <gsf@research.att.com> * 24 * David Korn <dgk@research.att.com> * 25 * Phong Vo <kpv@research.att.com> * 26 * * 27 ***********************************************************************/ 28 #pragma prototyped 29 /* 30 * common ast debug definitions 31 * include after the ast headers 32 */ 33 34 #ifndef _DEBUG_H 35 #define _DEBUG_H 36 37 #include <ast.h> 38 #include <error.h> 39 40 #if !defined(DEBUG) && _BLD_DEBUG 41 #define DEBUG _BLD_DEBUG 42 #endif 43 44 #if DEBUG || _BLD_DEBUG 45 46 #define debug(x) x 47 #define message(x) do if (error_info.trace < 0) { error x; } while (0) 48 #define messagef(x) do if (error_info.trace < 0) { errorf x; } while (0) 49 50 #define DEBUG_BEGTIME() debug_elapsed(1) 51 #define DEBUG_GETTIME() debug_elapsed(0) 52 #define DEBUG_ASSERT(p) ((p) ? 0 : (debug_fatal(__FILE__, __LINE__),0)) 53 #define DEBUG_COUNT(n) ((n) += 1) 54 #define DEBUG_TALLY(c,n,v) ((c) ? ((n) += (v)) : (n)) 55 #define DEBUG_INCREASE(n) ((n) += 1) 56 #define DEBUG_DECREASE(n) ((n) -= 1) 57 #define DEBUG_DECLARE(t,v) t v 58 #define DEBUG_SET(n,v) ((n) = (v)) 59 #define DEBUG_PRINT(fd,s,v) do {char _b[1024];write(fd,_b,sfsprintf(_b,sizeof(_b),s,v));} while(0) 60 #define DEBUG_WRITE(fd,d,n) write((fd),(d),(n)) 61 #define DEBUG_TEMP(temp) (temp) /* debugging stuff that should be removed */ 62 #define DEBUG_BREAK break 63 #define DEBUG_CONTINUE continue 64 #define DEBUG_GOTO(label) do { debug_fatal(__FILE__, __LINE__); goto label; } while(0) 65 #define DEBUG_RETURN(x) do { debug_fatal(__FILE__, __LINE__); return(x); } while(0) 66 67 #else 68 69 #define debug(x) 70 #define message(x) 71 #define messagef(x) 72 73 #define DEBUG_BEGTIME() 74 #define DEBUG_GETTIME() 75 #define DEBUG_ASSERT(p) 76 #define DEBUG_COUNT(n) 77 #define DEBUG_TALLY(c,n,v) 78 #define DEBUG_INCREASE(n) 79 #define DEBUG_DECREASE(n) 80 #define DEBUG_DECLARE(t,v) 81 #define DEBUG_SET(n,v) 82 #define DEBUG_PRINT(fd,s,v) 83 #define DEBUG_WRITE(fd,d,n) 84 #define DEBUG_TEMP(x) 85 #define DEBUG_BREAK break 86 #define DEBUG_CONTINUE continue 87 #define DEBUG_GOTO(label) goto label 88 #define DEBUG_RETURN(x) return(x) 89 90 #endif 91 92 #ifndef BREAK 93 #define BREAK DEBUG_BREAK 94 #endif 95 #ifndef CONTINUE 96 #define CONTINUE DEBUG_CONTINUE 97 #endif 98 #ifndef GOTO 99 #define GOTO(label) DEBUG_GOTO(label) 100 #endif 101 #ifndef RETURN 102 #define RETURN(x) DEBUG_RETURN(x) 103 #endif 104 105 #if _BLD_ast && defined(__EXPORT__) 106 #define extern __EXPORT__ 107 #endif 108 109 extern double debug_elapsed(int); 110 extern void debug_fatal(const char*, int); 111 extern void systrace(const char*); 112 113 #undef extern 114 115 #endif 116