comparison debug.h @ 1898:3f87f7ff1092

Fix building with DEBUG_TRACE = 0 Also try a less repetitive way of specifying macros
author Matt Johnston <matt@ucc.asn.au>
date Tue, 22 Mar 2022 23:29:38 +0800
parents 180e580778df
children be236878efcf
comparison
equal deleted inserted replaced
1897:fe68c0244b97 1898:3f87f7ff1092
51 51
52 #if DEBUG_TRACE 52 #if DEBUG_TRACE
53 extern int debug_trace; 53 extern int debug_trace;
54 #endif 54 #endif
55 55
56 /* you don't need to touch this block */ 56 /* Enable debug trace levels.
57 /* enable debug trace levels */ 57 We can't use __VA_ARGS_ here because Dropbear supports
58 #if (DEBUG_TRACE==1) 58 old ~C89 compilers */
59 #define DEBUG1(X) dropbear_trace1 X; 59 /* Default is to discard output ... */
60 #define DEBUG1(X)
60 #define DEBUG2(X) 61 #define DEBUG2(X)
61 #define DEBUG3(X) 62 #define DEBUG3(X)
62 #define TRACE(X) 63 #define TRACE(X)
63 #define TRACE2(X) 64 #define TRACE2(X)
64 #elif (DEBUG_TRACE==2) 65 /* ... unless DEBUG_TRACE is high enough */
66 #if (DEBUG_TRACE>=1)
67 #undef DEBUG1
65 #define DEBUG1(X) dropbear_trace1 X; 68 #define DEBUG1(X) dropbear_trace1 X;
69 #endif
70 #if (DEBUG_TRACE>=2)
71 #undef DEBUG2
66 #define DEBUG2(X) dropbear_trace2 X; 72 #define DEBUG2(X) dropbear_trace2 X;
67 #define DEBUG3(X) 73 #endif
68 #define TRACE(X) 74 #if (DEBUG_TRACE>=3)
69 #define TRACE2(X) 75 #undef DEBUG3
70 #elif (DEBUG_TRACE==3)
71 #define DEBUG1(X) dropbear_trace1 X;
72 #define DEBUG2(X) dropbear_trace2 X;
73 #define DEBUG3(X) dropbear_trace3 X; 76 #define DEBUG3(X) dropbear_trace3 X;
74 #define TRACE(X) 77 #endif
75 #define TRACE2(X) 78 #if (DEBUG_TRACE>=4)
76 #elif (DEBUG_TRACE==4) 79 #undef TRACE
77 #define DEBUG1(X) dropbear_trace1 X; 80 #define TRACE(X) dropbear_trace4 X;
78 #define DEBUG2(X) dropbear_trace2 X; 81 #endif
79 #define DEBUG3(X) dropbear_trace3 X; 82 #if (DEBUG_TRACE>=5)
80 #define TRACE(X) dropbear_trace4 X; 83 #undef TRACE2
81 #define TRACE2(X)
82 #elif (DEBUG_TRACE==5)
83 #define DEBUG1(X) dropbear_trace1 X;
84 #define DEBUG2(X) dropbear_trace2 X;
85 #define DEBUG3(X) dropbear_trace3 X;
86 #define TRACE(X) dropbear_trace4 X;
87 #define TRACE2(X) dropbear_trace5 X; 84 #define TRACE2(X) dropbear_trace5 X;
88 #endif 85 #endif
89 86
90 /* To debug with GDB it is easier to run with no forking of child processes. 87 /* To debug with GDB it is easier to run with no forking of child processes.
91 You will need to pass "-F" as well. */ 88 You will need to pass "-F" as well. */