summaryrefslogtreecommitdiff
path: root/dmake/dbug/malloc/debug.h
blob: 069d1dc77639b6d013f8dfc27d5315f87e5734e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/*
 * (c) Copyright 1990 Conor P. Cahill (uunet!virtech!cpcahil).
 * You may copy, distribute, and use this software as long as this
 * copyright statement is not removed.
 */
/************************************************************************/
/*                                  */
/* this include sets up some macro functions which can be used while    */
/* debugging the program, and then left in the code, but turned of by   */
/* just not defining "DEBUG".  This way your production version of  */
/* the program will not be filled with bunches of debugging junk    */
/*                                  */
/************************************************************************/
/*
 * $Id: debug.h,v 1.2 2006-07-25 10:07:24 rt Exp $
 */

#ifdef DEBUG

#if DEBUG == 1          /* if default level         */
#undef DEBUG
#define DEBUG   100     /*   use level 100          */
#endif

#include <stdio.h>

#define DEBUG0(val,str)\
                {\
                  if( DEBUG > val ) \
                    fprintf(stderr,"%s(%d): %s\n",\
                        __FILE__,__LINE__,str);\
                }
#define DEBUG1(val,str,a1)\
                    {\
                  char _debugbuf[100];\
                  if( DEBUG > val )\
                   {\
                    sprintf(_debugbuf,str,a1);\
                    fprintf(stderr,"%s(%d): %s\n",\
                        __FILE__,__LINE__,_debugbuf);\
                   }\
                       }

#define DEBUG2(val,str,a1,a2)\
                    {\
                 char _debugbuf[100];\
                  if( DEBUG > val )\
                   {\
                    sprintf(_debugbuf,str,a1,a2);\
                    fprintf(stderr,"%s(%d): %s\n",\
                        __FILE__,__LINE__,_debugbuf);\
                   }\
                       }

#define DEBUG3(val,str,a1,a2,a3)\
                    {\
                  char _debugbuf[100];\
                  if( DEBUG > val )\
                   {\
                    sprintf(_debugbuf,str,a1,a2,a3);\
                    fprintf(stderr,"%s(%d): %s\n",\
                        __FILE__,__LINE__,_debugbuf);\
                   }\
                       }

#define DEBUG4(val,str,a1,a2,a3,a4)\
                     {\
                  char _debugbuf[100];\
                  if( DEBUG > val )\
                   {\
                    sprintf(_debugbuf,str,a1,a2,a3,a4);\
                    fprintf(stderr,"%s(%d): %s\n",\
                        __FILE__,__LINE__,_debugbuf);\
                   }\
                       }

#define DEBUG5(val,str,a1,a2,a3,a4,a5)\
                     {\
                  char _debugbuf[100];\
                  if( DEBUG > val )\
                   {\
                    sprintf(_debugbuf,str,a1,a2,a3,a4,a5);\
                    fprintf(stderr,"%s(%d): %s\n",\
                        __FILE__,__LINE__,_debugbuf);\
                   }\
                       }

#else

#define DEBUG0(val,s)
#define DEBUG1(val,s,a1)
#define DEBUG2(val,s,a1,a2)
#define DEBUG3(val,s,a1,a2,a3)
#define DEBUG4(val,s,a1,a2,a3,a4)
#define DEBUG5(val,s,a1,a2,a3,a4,a5)

#endif /* DEBUG */