1 /***********************************************************************
3 * This software is part of the ast package *
4 * Copyright (c) 1985-2010 AT&T Intellectual Property *
5 * and is licensed under the *
6 * Common Public License, Version 1.0 *
7 * by AT&T Intellectual Property *
9 * A copy of the License is available at *
10 * http://www.opensource.org/licenses/cpl1.0.txt *
11 * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
13 * Information and Software Systems Research *
17 * Glenn Fowler <gsf@research.att.com> *
18 * David Korn <dgk@research.att.com> *
19 * Phong Vo <kpv@research.att.com> *
21 ***********************************************************************/
24 * common ast debug definitions
25 * include after the ast headers
34 #if !defined(DEBUG) && _BLD_DEBUG
35 #define DEBUG _BLD_DEBUG
38 #if DEBUG || _BLD_DEBUG
41 #define message(x) do if (error_info.trace < 0) { error x; } while (0)
42 #define messagef(x) do if (error_info.trace < 0) { errorf x; } while (0)
44 #define DEBUG_BEGTIME() debug_elapsed(1)
45 #define DEBUG_GETTIME() debug_elapsed(0)
46 #define DEBUG_ASSERT(p) ((p) ? 0 : (debug_fatal(__FILE__, __LINE__),0))
47 #define DEBUG_COUNT(n) ((n) += 1)
48 #define DEBUG_TALLY(c,n,v) ((c) ? ((n) += (v)) : (n))
49 #define DEBUG_INCREASE(n) ((n) += 1)
50 #define DEBUG_DECREASE(n) ((n) -= 1)
51 #define DEBUG_DECLARE(t,v) t v
52 #define DEBUG_SET(n,v) ((n) = (v))
53 #define DEBUG_PRINT(fd,s,v) do {char _b[1024];write(fd,_b,sfsprintf(_b,sizeof(_b),s,v));} while(0)
54 #define DEBUG_WRITE(fd,d,n) write((fd),(d),(n))
55 #define DEBUG_TEMP(temp) (temp) /* debugging stuff that should be removed */
56 #define DEBUG_BREAK break
57 #define DEBUG_CONTINUE continue
58 #define DEBUG_GOTO(label) do { debug_fatal(__FILE__, __LINE__); goto label; } while(0)
59 #define DEBUG_RETURN(x) do { debug_fatal(__FILE__, __LINE__); return(x); } while(0)
67 #define DEBUG_BEGTIME()
68 #define DEBUG_GETTIME()
69 #define DEBUG_ASSERT(p)
70 #define DEBUG_COUNT(n)
71 #define DEBUG_TALLY(c,n,v)
72 #define DEBUG_INCREASE(n)
73 #define DEBUG_DECREASE(n)
74 #define DEBUG_DECLARE(t,v)
75 #define DEBUG_SET(n,v)
76 #define DEBUG_PRINT(fd,s,v)
77 #define DEBUG_WRITE(fd,d,n)
79 #define DEBUG_BREAK break
80 #define DEBUG_CONTINUE continue
81 #define DEBUG_GOTO(label) goto label
82 #define DEBUG_RETURN(x) return(x)
87 #define BREAK DEBUG_BREAK
90 #define CONTINUE DEBUG_CONTINUE
93 #define GOTO(label) DEBUG_GOTO(label)
96 #define RETURN(x) DEBUG_RETURN(x)
99 #if _BLD_ast && defined(__EXPORT__)
100 #define extern __EXPORT__
103 extern double debug_elapsed(int);
104 extern void debug_fatal(const char*, int);
105 extern void systrace(const char*);