1 /*
2  * Copyright (C) 2002 Red Hat, Inc.
3  *
4  * This is free software; you can redistribute it and/or modify it under
5  * the terms of the GNU Library General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this program; if not, write to the Free Software
16  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17  */
18 
19 /* The interfaces in this file are subject to change at any time. */
20 
21 #ifndef vte_debug_h_included
22 #define vte_debug_h_included
23 
24 #include <config.h>
25 
26 #include <glib.h>
27 
28 G_BEGIN_DECLS
29 
30 typedef enum {
31 	VTE_DEBUG_MISC		= 1 << 0,
32 	VTE_DEBUG_PARSE		= 1 << 1,
33 	VTE_DEBUG_IO		= 1 << 2,
34 	VTE_DEBUG_UPDATES	= 1 << 3,
35 	VTE_DEBUG_EVENTS	= 1 << 4,
36 	VTE_DEBUG_SIGNALS	= 1 << 5,
37 	VTE_DEBUG_SELECTION	= 1 << 6,
38 	VTE_DEBUG_SUBSTITUTION	= 1 << 7,
39 	VTE_DEBUG_RING		= 1 << 8,
40 	VTE_DEBUG_PTY		= 1 << 9,
41 	VTE_DEBUG_CURSOR	= 1 << 10,
42 	VTE_DEBUG_KEYBOARD	= 1 << 11,
43 	VTE_DEBUG_LIFECYCLE	= 1 << 12,
44 	VTE_DEBUG_TRIE		= 1 << 13,
45 	VTE_DEBUG_WORK		= 1 << 14,
46 	VTE_DEBUG_CELLS		= 1 << 15,
47 	VTE_DEBUG_TIMEOUT	= 1 << 16,
48 	VTE_DEBUG_DRAW		= 1 << 17,
49 	VTE_DEBUG_ALLY		= 1 << 18,
50 	VTE_DEBUG_ADJ		= 1 << 19,
51 	VTE_DEBUG_PANGOCAIRO    = 1 << 20,
52 	VTE_DEBUG_WIDGET_SIZE   = 1 << 21,
53         VTE_DEBUG_BG            = 1 << 22
54 } VteDebugFlags;
55 
56 void _vte_debug_init(void);
57 
58 extern VteDebugFlags _vte_debug_flags;
59 static inline gboolean _vte_debug_on(VteDebugFlags flags) G_GNUC_CONST G_GNUC_UNUSED;
60 
61 static inline gboolean
_vte_debug_on(VteDebugFlags flags)62 _vte_debug_on(VteDebugFlags flags)
63 {
64 	return (_vte_debug_flags & flags) == flags;
65 }
66 
67 #ifdef VTE_DEBUG
68 #define _VTE_DEBUG_IF(flags) if (G_UNLIKELY (_vte_debug_on (flags)))
69 #else
70 #define _VTE_DEBUG_IF(flags) if (0)
71 #endif
72 
73 #if defined(__GNUC__) && G_HAVE_GNUC_VARARGS
74 #define _vte_debug_print(flags, fmt, ...) \
75 	G_STMT_START { _VTE_DEBUG_IF(flags) g_printerr(fmt, ##__VA_ARGS__); } G_STMT_END
76 #else
77 #include <stdarg.h>
78 #include <glib/gstdio.h>
_vte_debug_print(guint flags,const char * fmt,...)79 static void _vte_debug_print(guint flags, const char *fmt, ...)
80 {
81 	_VTE_DEBUG_IF(flags) {
82 		va_list  ap;
83 		va_start (ap, fmt);
84 		g_vfprintf (stderr, fmt, ap);
85 		va_end (ap);
86 	}
87 }
88 #endif
89 
90 G_END_DECLS
91 
92 #endif
93