14887Schin /*********************************************************************** 24887Schin * * 34887Schin * This software is part of the ast package * 4*12068SRoger.Faulkner@Oracle.COM * Copyright (c) 1985-2010 AT&T Intellectual Property * 54887Schin * and is licensed under the * 64887Schin * Common Public License, Version 1.0 * 78462SApril.Chin@Sun.COM * by AT&T Intellectual Property * 84887Schin * * 94887Schin * A copy of the License is available at * 104887Schin * http://www.opensource.org/licenses/cpl1.0.txt * 114887Schin * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) * 124887Schin * * 134887Schin * Information and Software Systems Research * 144887Schin * AT&T Research * 154887Schin * Florham Park NJ * 164887Schin * * 174887Schin * Glenn Fowler <gsf@research.att.com> * 184887Schin * David Korn <dgk@research.att.com> * 194887Schin * Phong Vo <kpv@research.att.com> * 204887Schin * * 214887Schin ***********************************************************************/ 224887Schin #pragma prototyped 234887Schin /* 244887Schin * common ast debug definitions 254887Schin * include after the ast headers 264887Schin */ 274887Schin 284887Schin #ifndef _DEBUG_H 294887Schin #define _DEBUG_H 304887Schin 314887Schin #include <ast.h> 324887Schin #include <error.h> 334887Schin 348462SApril.Chin@Sun.COM #if !defined(DEBUG) && _BLD_DEBUG 358462SApril.Chin@Sun.COM #define DEBUG _BLD_DEBUG 368462SApril.Chin@Sun.COM #endif 378462SApril.Chin@Sun.COM 384887Schin #if DEBUG || _BLD_DEBUG 398462SApril.Chin@Sun.COM 404887Schin #define debug(x) x 414887Schin #define message(x) do if (error_info.trace < 0) { error x; } while (0) 424887Schin #define messagef(x) do if (error_info.trace < 0) { errorf x; } while (0) 438462SApril.Chin@Sun.COM 448462SApril.Chin@Sun.COM #define DEBUG_BEGTIME() debug_elapsed(1) 458462SApril.Chin@Sun.COM #define DEBUG_GETTIME() debug_elapsed(0) 468462SApril.Chin@Sun.COM #define DEBUG_ASSERT(p) ((p) ? 0 : (debug_fatal(__FILE__, __LINE__),0)) 478462SApril.Chin@Sun.COM #define DEBUG_COUNT(n) ((n) += 1) 488462SApril.Chin@Sun.COM #define DEBUG_TALLY(c,n,v) ((c) ? ((n) += (v)) : (n)) 4910898Sroland.mainz@nrubsig.org #define DEBUG_INCREASE(n) ((n) += 1) 5010898Sroland.mainz@nrubsig.org #define DEBUG_DECREASE(n) ((n) -= 1) 518462SApril.Chin@Sun.COM #define DEBUG_DECLARE(t,v) t v 528462SApril.Chin@Sun.COM #define DEBUG_SET(n,v) ((n) = (v)) 538462SApril.Chin@Sun.COM #define DEBUG_PRINT(fd,s,v) do {char _b[1024];write(fd,_b,sfsprintf(_b,sizeof(_b),s,v));} while(0) 548462SApril.Chin@Sun.COM #define DEBUG_WRITE(fd,d,n) write((fd),(d),(n)) 558462SApril.Chin@Sun.COM #define DEBUG_TEMP(temp) (temp) /* debugging stuff that should be removed */ 5610898Sroland.mainz@nrubsig.org #define DEBUG_BREAK break 5710898Sroland.mainz@nrubsig.org #define DEBUG_CONTINUE continue 588462SApril.Chin@Sun.COM #define DEBUG_GOTO(label) do { debug_fatal(__FILE__, __LINE__); goto label; } while(0) 5910898Sroland.mainz@nrubsig.org #define DEBUG_RETURN(x) do { debug_fatal(__FILE__, __LINE__); return(x); } while(0) 608462SApril.Chin@Sun.COM 614887Schin #else 628462SApril.Chin@Sun.COM 634887Schin #define debug(x) 644887Schin #define message(x) 654887Schin #define messagef(x) 668462SApril.Chin@Sun.COM 678462SApril.Chin@Sun.COM #define DEBUG_BEGTIME() 688462SApril.Chin@Sun.COM #define DEBUG_GETTIME() 698462SApril.Chin@Sun.COM #define DEBUG_ASSERT(p) 708462SApril.Chin@Sun.COM #define DEBUG_COUNT(n) 718462SApril.Chin@Sun.COM #define DEBUG_TALLY(c,n,v) 7210898Sroland.mainz@nrubsig.org #define DEBUG_INCREASE(n) 7310898Sroland.mainz@nrubsig.org #define DEBUG_DECREASE(n) 748462SApril.Chin@Sun.COM #define DEBUG_DECLARE(t,v) 758462SApril.Chin@Sun.COM #define DEBUG_SET(n,v) 768462SApril.Chin@Sun.COM #define DEBUG_PRINT(fd,s,v) 778462SApril.Chin@Sun.COM #define DEBUG_WRITE(fd,d,n) 7810898Sroland.mainz@nrubsig.org #define DEBUG_TEMP(x) 798462SApril.Chin@Sun.COM #define DEBUG_BREAK break 8010898Sroland.mainz@nrubsig.org #define DEBUG_CONTINUE continue 818462SApril.Chin@Sun.COM #define DEBUG_GOTO(label) goto label 8210898Sroland.mainz@nrubsig.org #define DEBUG_RETURN(x) return(x) 838462SApril.Chin@Sun.COM 844887Schin #endif 854887Schin 8610898Sroland.mainz@nrubsig.org #ifndef BREAK 8710898Sroland.mainz@nrubsig.org #define BREAK DEBUG_BREAK 8810898Sroland.mainz@nrubsig.org #endif 8910898Sroland.mainz@nrubsig.org #ifndef CONTINUE 9010898Sroland.mainz@nrubsig.org #define CONTINUE DEBUG_CONTINUE 9110898Sroland.mainz@nrubsig.org #endif 9210898Sroland.mainz@nrubsig.org #ifndef GOTO 9310898Sroland.mainz@nrubsig.org #define GOTO(label) DEBUG_GOTO(label) 9410898Sroland.mainz@nrubsig.org #endif 9510898Sroland.mainz@nrubsig.org #ifndef RETURN 9610898Sroland.mainz@nrubsig.org #define RETURN(x) DEBUG_RETURN(x) 9710898Sroland.mainz@nrubsig.org #endif 9810898Sroland.mainz@nrubsig.org 994887Schin #if _BLD_ast && defined(__EXPORT__) 1004887Schin #define extern __EXPORT__ 1014887Schin #endif 1024887Schin 1038462SApril.Chin@Sun.COM extern double debug_elapsed(int); 1048462SApril.Chin@Sun.COM extern void debug_fatal(const char*, int); 1054887Schin extern void systrace(const char*); 1064887Schin 1074887Schin #undef extern 1084887Schin 1094887Schin #endif 110