|
85 | 85 | fflush(stderr); \
|
86 | 86 | abort(); \
|
87 | 87 | } while (0)
|
88 |
| -#define _LIBUNWIND_LOG(msg, ...) fprintf(stderr, "libunwind: " msg "\n", __VA_ARGS__) |
| 88 | + |
| 89 | +#define _LIBUNWIND_LOG(msg, ...) \ |
| 90 | + fprintf(stderr, "libunwind: " msg "\n", __VA_ARGS__) |
89 | 91 |
|
90 | 92 | #if defined(_LIBUNWIND_HAS_NO_THREADS)
|
91 | 93 | // only used with pthread calls, not needed for the single-threaded builds
|
92 | 94 | #define _LIBUNWIND_LOG_NON_ZERO(x)
|
| 95 | +#else |
| 96 | + #if defined(NDEBUG) |
| 97 | + #define _LIBUNWIND_LOG_NON_ZERO(x) x |
| 98 | + #else |
| 99 | + #define _LIBUNWIND_LOG_NON_ZERO(x) \ |
| 100 | + do { \ |
| 101 | + int _err = x; \ |
| 102 | + if (_err != 0) \ |
| 103 | + _LIBUNWIND_LOG("" #x "=%d in %s", _err, __FUNCTION__); \ |
| 104 | + } while (0) |
| 105 | + #endif |
93 | 106 | #endif
|
94 | 107 |
|
95 | 108 | // Macros that define away in non-Debug builds
|
96 | 109 | #ifdef NDEBUG
|
97 | 110 | #define _LIBUNWIND_DEBUG_LOG(msg, ...)
|
98 | 111 | #define _LIBUNWIND_TRACE_API(msg, ...)
|
99 |
| - #define _LIBUNWIND_TRACING_UNWINDING 0 |
| 112 | + #define _LIBUNWIND_TRACING_UNWINDING (0) |
100 | 113 | #define _LIBUNWIND_TRACE_UNWINDING(msg, ...)
|
101 |
| - #ifndef _LIBUNWIND_LOG_NON_ZERO |
102 |
| - #define _LIBUNWIND_LOG_NON_ZERO(x) x |
103 |
| - #endif |
104 | 114 | #else
|
105 | 115 | #ifdef __cplusplus
|
106 | 116 | extern "C" {
|
|
111 | 121 | }
|
112 | 122 | #endif
|
113 | 123 | #define _LIBUNWIND_DEBUG_LOG(msg, ...) _LIBUNWIND_LOG(msg, __VA_ARGS__)
|
114 |
| - #ifndef _LIBUNWIND_LOG_NON_ZERO |
115 |
| - #define _LIBUNWIND_LOG_NON_ZERO(x) \ |
116 |
| - do { \ |
117 |
| - int _err = x; \ |
118 |
| - if ( _err != 0 ) \ |
119 |
| - _LIBUNWIND_LOG("" #x "=%d in %s", _err, __FUNCTION__); \ |
120 |
| - } while (0) |
121 |
| - #endif |
122 |
| - #define _LIBUNWIND_TRACE_API(msg, ...) \ |
123 |
| - do { \ |
124 |
| - if ( logAPIs() ) _LIBUNWIND_LOG(msg, __VA_ARGS__); \ |
125 |
| - } while(0) |
126 |
| - #define _LIBUNWIND_TRACE_UNWINDING(msg, ...) \ |
127 |
| - do { \ |
128 |
| - if ( logUnwinding() ) _LIBUNWIND_LOG(msg, __VA_ARGS__); \ |
129 |
| - } while(0) |
| 124 | + #define _LIBUNWIND_TRACE_API(msg, ...) \ |
| 125 | + do { \ |
| 126 | + if (logAPIs()) \ |
| 127 | + _LIBUNWIND_LOG(msg, __VA_ARGS__); \ |
| 128 | + } while (0) |
130 | 129 | #define _LIBUNWIND_TRACING_UNWINDING logUnwinding()
|
| 130 | + #define _LIBUNWIND_TRACE_UNWINDING(msg, ...) \ |
| 131 | + do { \ |
| 132 | + if (logUnwinding()) \ |
| 133 | + _LIBUNWIND_LOG(msg, __VA_ARGS__); \ |
| 134 | + } while (0) |
131 | 135 | #endif
|
132 | 136 |
|
133 | 137 | #ifdef __cplusplus
|
|
0 commit comments