1da2e3ebdSchin 2da2e3ebdSchin /* : : generated by proto : : */ 3da2e3ebdSchin /*********************************************************************** 4da2e3ebdSchin * * 5da2e3ebdSchin * This software is part of the ast package * 6*3e14f97fSRoger A. Faulkner * Copyright (c) 1985-2010 AT&T Intellectual Property * 7da2e3ebdSchin * and is licensed under the * 8da2e3ebdSchin * Common Public License, Version 1.0 * 97c2fbfb3SApril Chin * by AT&T Intellectual Property * 10da2e3ebdSchin * * 11da2e3ebdSchin * A copy of the License is available at * 12da2e3ebdSchin * http://www.opensource.org/licenses/cpl1.0.txt * 13da2e3ebdSchin * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) * 14da2e3ebdSchin * * 15da2e3ebdSchin * Information and Software Systems Research * 16da2e3ebdSchin * AT&T Research * 17da2e3ebdSchin * Florham Park NJ * 18da2e3ebdSchin * * 19da2e3ebdSchin * Glenn Fowler <gsf@research.att.com> * 20da2e3ebdSchin * David Korn <dgk@research.att.com> * 21da2e3ebdSchin * Phong Vo <kpv@research.att.com> * 22da2e3ebdSchin * * 23da2e3ebdSchin ***********************************************************************/ 24da2e3ebdSchin 25da2e3ebdSchin /* 26da2e3ebdSchin * common ast debug definitions 27da2e3ebdSchin * include after the ast headers 28da2e3ebdSchin */ 29da2e3ebdSchin 30da2e3ebdSchin #ifndef _DEBUG_H 31da2e3ebdSchin #if !defined(__PROTO__) 32da2e3ebdSchin #include <prototyped.h> 33da2e3ebdSchin #endif 34da2e3ebdSchin #if !defined(__LINKAGE__) 35da2e3ebdSchin #define __LINKAGE__ /* 2004-08-11 transition */ 36da2e3ebdSchin #endif 37da2e3ebdSchin 38da2e3ebdSchin #define _DEBUG_H 39da2e3ebdSchin 40da2e3ebdSchin #include <ast.h> 41da2e3ebdSchin #include <error.h> 42da2e3ebdSchin 437c2fbfb3SApril Chin #if !defined(DEBUG) && _BLD_DEBUG 447c2fbfb3SApril Chin #define DEBUG _BLD_DEBUG 457c2fbfb3SApril Chin #endif 467c2fbfb3SApril Chin 47da2e3ebdSchin #if DEBUG || _BLD_DEBUG 487c2fbfb3SApril Chin 49da2e3ebdSchin #define debug(x) x 50da2e3ebdSchin #define message(x) do if (error_info.trace < 0) { error x; } while (0) 51da2e3ebdSchin #define messagef(x) do if (error_info.trace < 0) { errorf x; } while (0) 527c2fbfb3SApril Chin 537c2fbfb3SApril Chin #define DEBUG_BEGTIME() debug_elapsed(1) 547c2fbfb3SApril Chin #define DEBUG_GETTIME() debug_elapsed(0) 557c2fbfb3SApril Chin #define DEBUG_ASSERT(p) ((p) ? 0 : (debug_fatal(__FILE__, __LINE__),0)) 567c2fbfb3SApril Chin #define DEBUG_COUNT(n) ((n) += 1) 577c2fbfb3SApril Chin #define DEBUG_TALLY(c,n,v) ((c) ? ((n) += (v)) : (n)) 5834f9b3eeSRoland Mainz #define DEBUG_INCREASE(n) ((n) += 1) 5934f9b3eeSRoland Mainz #define DEBUG_DECREASE(n) ((n) -= 1) 607c2fbfb3SApril Chin #define DEBUG_DECLARE(t,v) t v 617c2fbfb3SApril Chin #define DEBUG_SET(n,v) ((n) = (v)) 627c2fbfb3SApril Chin #define DEBUG_PRINT(fd,s,v) do {char _b[1024];write(fd,_b,sfsprintf(_b,sizeof(_b),s,v));} while(0) 637c2fbfb3SApril Chin #define DEBUG_WRITE(fd,d,n) write((fd),(d),(n)) 647c2fbfb3SApril Chin #define DEBUG_TEMP(temp) (temp) /* debugging stuff that should be removed */ 6534f9b3eeSRoland Mainz #define DEBUG_BREAK break 6634f9b3eeSRoland Mainz #define DEBUG_CONTINUE continue 677c2fbfb3SApril Chin #define DEBUG_GOTO(label) do { debug_fatal(__FILE__, __LINE__); goto label; } while(0) 6834f9b3eeSRoland Mainz #define DEBUG_RETURN(x) do { debug_fatal(__FILE__, __LINE__); return(x); } while(0) 697c2fbfb3SApril Chin 70da2e3ebdSchin #else 717c2fbfb3SApril Chin 72da2e3ebdSchin #define debug(x) 73da2e3ebdSchin #define message(x) 74da2e3ebdSchin #define messagef(x) 757c2fbfb3SApril Chin 767c2fbfb3SApril Chin #define DEBUG_BEGTIME() 777c2fbfb3SApril Chin #define DEBUG_GETTIME() 787c2fbfb3SApril Chin #define DEBUG_ASSERT(p) 797c2fbfb3SApril Chin #define DEBUG_COUNT(n) 807c2fbfb3SApril Chin #define DEBUG_TALLY(c,n,v) 8134f9b3eeSRoland Mainz #define DEBUG_INCREASE(n) 8234f9b3eeSRoland Mainz #define DEBUG_DECREASE(n) 837c2fbfb3SApril Chin #define DEBUG_DECLARE(t,v) 847c2fbfb3SApril Chin #define DEBUG_SET(n,v) 857c2fbfb3SApril Chin #define DEBUG_PRINT(fd,s,v) 867c2fbfb3SApril Chin #define DEBUG_WRITE(fd,d,n) 8734f9b3eeSRoland Mainz #define DEBUG_TEMP(x) 887c2fbfb3SApril Chin #define DEBUG_BREAK break 8934f9b3eeSRoland Mainz #define DEBUG_CONTINUE continue 907c2fbfb3SApril Chin #define DEBUG_GOTO(label) goto label 9134f9b3eeSRoland Mainz #define DEBUG_RETURN(x) return(x) 927c2fbfb3SApril Chin 93da2e3ebdSchin #endif 94da2e3ebdSchin 9534f9b3eeSRoland Mainz #ifndef BREAK 9634f9b3eeSRoland Mainz #define BREAK DEBUG_BREAK 9734f9b3eeSRoland Mainz #endif 9834f9b3eeSRoland Mainz #ifndef CONTINUE 9934f9b3eeSRoland Mainz #define CONTINUE DEBUG_CONTINUE 10034f9b3eeSRoland Mainz #endif 10134f9b3eeSRoland Mainz #ifndef GOTO 10234f9b3eeSRoland Mainz #define GOTO(label) DEBUG_GOTO(label) 10334f9b3eeSRoland Mainz #endif 10434f9b3eeSRoland Mainz #ifndef RETURN 10534f9b3eeSRoland Mainz #define RETURN(x) DEBUG_RETURN(x) 10634f9b3eeSRoland Mainz #endif 10734f9b3eeSRoland Mainz 108da2e3ebdSchin #if _BLD_ast && defined(__EXPORT__) 109da2e3ebdSchin #undef __MANGLE__ 110da2e3ebdSchin #define __MANGLE__ __LINKAGE__ __EXPORT__ 111da2e3ebdSchin #endif 112da2e3ebdSchin 1137c2fbfb3SApril Chin extern __MANGLE__ double debug_elapsed __PROTO__((int)); 1147c2fbfb3SApril Chin extern __MANGLE__ void debug_fatal __PROTO__((const char*, int)); 115da2e3ebdSchin extern __MANGLE__ void systrace __PROTO__((const char*)); 116da2e3ebdSchin 117da2e3ebdSchin #undef __MANGLE__ 118da2e3ebdSchin #define __MANGLE__ __LINKAGE__ 119da2e3ebdSchin 120da2e3ebdSchin #endif 121