Debian Codegraph @

runtime/debug.h

raw
1 /* debug.h
2 *
3 * Definitions for the debug module.
4 *
5 * Copyright 2008-2018 Rainer Gerhards and Adiscon GmbH.
6 *
7 * This file is part of the rsyslog runtime library.
8 *
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 * -or-
15 * see COPYING.ASL20 in the source distribution
16 *
17 * Unless required by applicable law or agreed to in writing, software
18 * distributed under the License is distributed on an "AS IS" BASIS,
19 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 * See the License for the specific language governing permissions and
21 * limitations under the License.
22 */
23 #ifndef DEBUG_H_INCLUDED
24 #define DEBUG_H_INCLUDED
25
26 #include <pthread.h>
27 #include "obj-types.h"
28
29 /* some settings for various debug modes */
30 #define DEBUG_OFF 0
31 #define DEBUG_ONDEMAND 1
32 #define DEBUG_FULL 2
33
34 /* external static data elements (some time to be replaced) */
35 extern int Debug; /* debug flag - read-only after startup */
36 extern int debugging_on; /* read-only, except on sig USR1 */
37 extern int stddbg; /* the handle for regular debug output, set to stdout if not forking, -1 otherwise */
38 extern int dbgTimeoutToStderr;
39
40
41 /* prototypes */
42 rsRetVal dbgClassInit(void);
43 rsRetVal dbgClassExit(void);
44 void dbgSetDebugFile(uchar *fn);
45 void dbgSetDebugLevel(int level);
46 void dbgSetThrdName(const uchar *pszName);
47 void dbgOutputTID(char *name);
48 int dbgGetDbglogFd(void);
49
50 /* external data */
51 extern char *pszAltDbgFileName; /* if set, debug output is *also* sent to here */
52 extern int altdbg; /* and the handle for alternate debug output */
53
54 /* macros */
55 #ifdef DEBUGLESS
56 #define DBGL_UNUSED __attribute__((__unused__))
57 static inline void r_dbgoprint(const char DBGL_UNUSED *srcname,
58 obj_t DBGL_UNUSED *pObj,
59 const char DBGL_UNUSED *fmt,
60 ...) {}
61 static inline void r_dbgprintf(const char DBGL_UNUSED *srcname, const char DBGL_UNUSED *fmt, ...) {}
62 #else
63 #define DBGL_UNUSED
64 void r_dbgoprint(const char *srcname, obj_t *pObj, const char *fmt, ...) __attribute__((format(printf, 3, 4)));
65 void r_dbgprintf(const char *srcname, const char *fmt, ...) __attribute__((format(printf, 2, 3)));
66 #endif
67
68 #define DBGPRINTF(...) \
69 if (Debug) { \
70 r_dbgprintf(__FILE__, __VA_ARGS__); \
71 }
72 #define DBGOPRINT(...) \
73 if (Debug) { \
74 r_dbgoprint(__FILE__, __VA_ARGS__); \
75 }
76 #define dbgprintf(...) r_dbgprintf(__FILE__, __VA_ARGS__)
77 #define dbgoprint(...) r_dbgoprint(__FILE__, __VA_ARGS__)
78
79 /* things originally introduced for now removed rtinst */
80 #define d_pthread_mutex_lock(x) pthread_mutex_lock(x)
81 #define d_pthread_mutex_trylock(x) pthread_mutex_trylock(x)
82 #define d_pthread_mutex_unlock(x) pthread_mutex_unlock(x)
83 #define d_pthread_cond_wait(cond, mut) pthread_cond_wait(cond, mut)
84 #define d_pthread_cond_timedwait(cond, mut, to) pthread_cond_timedwait(cond, mut, to)
85
86 #endif /* #ifndef DEBUG_H_INCLUDED */