2009-10-09 Chris Toshok <toshok@ximian.com>
[moon.git] / src / debug.h
blobb16ec82be2f1fb5f68f2a2f9ee2b7e2ac4b99c54
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*
3 * debug.h:
5 * Copyright 2007 Novell, Inc. (http://www.novell.com)
7 * See the LICENSE file included with the distribution for details.
8 *
9 */
11 #ifndef __MOONLIGHT_DEBUG_H__
12 #define __MOONLIGHT_DEBUG_H__
14 #if defined (DEBUG) || LOGGING
16 #include <glib.h>
17 #include <stdio.h>
18 #include <stdlib.h>
19 #include <string.h>
21 #endif /* DEBUG || LOGGING */
23 #include "runtime.h"
26 * Stacktrace (debug) stuff
30 #if DEBUG
32 #define MAX_STACK_FRAMES 10
34 char* get_stack_trace_prefix (const char* prefix, int maxframes = MAX_STACK_FRAMES);
35 void print_stack_trace_prefix (const char* prefix, int maxframes = MAX_STACK_FRAMES);
37 void print_reftrace (const char * type, const char * typname, int refcount, bool keep);
38 void dump_frames (void);
40 G_BEGIN_DECLS
42 char* get_stack_trace (void);
43 void print_stack_trace (void);
44 void enable_vm_stack_trace (void);
45 void hexdump_addr (void *addr, size_t n);
47 G_END_DECLS
49 #else
51 #define print_stack_trace()
52 #define enable_vm_stack_trace()
53 #define print_reftrace (const char * type, const char * typname, int refcount, bool keep)
54 #define dump_frames (void)
56 #endif /* DEBUG */
59 * Logging stuff
62 #if LOGGING
64 #define LOG_ALSA(...) if (G_UNLIKELY (debug_flags & RUNTIME_DEBUG_ALSA)) printf (__VA_ARGS__);
65 #define LOG_ALSA_EX(...) if (G_UNLIKELY (debug_flags_ex & RUNTIME_DEBUG_ALSA_EX)) printf (__VA_ARGS__);
66 #define LOG_AUDIO(...) if (G_UNLIKELY (debug_flags & RUNTIME_DEBUG_AUDIO)) printf (__VA_ARGS__);
67 #define LOG_AUDIO_EX(...) if (G_UNLIKELY (debug_flags_ex & RUNTIME_DEBUG_AUDIO_EX)) printf (__VA_ARGS__);
68 #define LOG_PULSE(...) if (G_UNLIKELY (debug_flags & RUNTIME_DEBUG_PULSE)) printf (__VA_ARGS__);
69 #define LOG_PULSE_EX(...) if (G_UNLIKELY (debug_flags_ex & RUNTIME_DEBUG_PULSE_EX)) printf (__VA_ARGS__);
70 #define LOG_HTTPSTREAMING(...) if (G_UNLIKELY (debug_flags & RUNTIME_DEBUG_HTTPSTREAMING)) printf (__VA_ARGS__);
71 #define LOG_MARKERS(...) if (G_UNLIKELY (debug_flags & RUNTIME_DEBUG_MARKERS)) printf (__VA_ARGS__);
72 #define LOG_MARKERS_EX(...) if (G_UNLIKELY (debug_flags_ex & RUNTIME_DEBUG_MARKERS_EX)) printf (__VA_ARGS__);
73 #define LOG_MMS(...) if (G_UNLIKELY (debug_flags & RUNTIME_DEBUG_MMS)) printf (__VA_ARGS__);
74 #define LOG_MEDIAPLAYER(...) if (G_UNLIKELY (debug_flags & RUNTIME_DEBUG_MEDIAPLAYER)) printf (__VA_ARGS__);
75 #define LOG_MEDIAPLAYER_EX(...) if (G_UNLIKELY (debug_flags_ex & RUNTIME_DEBUG_MEDIAPLAYER_EX)) printf (__VA_ARGS__);
76 #define LOG_PIPELINE(...) if (G_UNLIKELY (debug_flags & RUNTIME_DEBUG_PIPELINE)) printf (__VA_ARGS__);
77 #define LOG_PIPELINE_EX(...) if (G_UNLIKELY (debug_flags_ex & RUNTIME_DEBUG_PIPELINE_EX)) printf (__VA_ARGS__);
78 #define LOG_PIPELINE_ERROR(...) if (G_UNLIKELY (debug_flags & RUNTIME_DEBUG_PIPELINE_ERROR)) printf (__VA_ARGS__);
79 #define LOG_PIPELINE_ERROR_CONDITIONAL(x, ...) if (G_UNLIKELY (x && debug_flags & PIPELINE_ERROR)) printf (__VA_ARGS__);
80 #define LOG_FRAMEREADERLOOP(...) if (G_UNLIKELY (debug_flags & RUNTIME_DEBUG_FRAMEREADERLOOP)) printf (__VA_ARGS__);
81 #define LOG_FFMPEG(...) if (G_UNLIKELY (debug_flags & RUNTIME_DEBUG_FFMPEG)) printf(__VA_ARGS__);
82 #define LOG_UI(...) if (G_UNLIKELY (debug_flags & RUNTIME_DEBUG_UI)) printf (__VA_ARGS__);
83 #define LOG_CODECS(...) if (G_UNLIKELY (debug_flags & RUNTIME_DEBUG_CODECS)) printf (__VA_ARGS__);
84 #define LOG_DP(...) if (G_UNLIKELY (debug_flags & RUNTIME_DEBUG_DP)) printf (__VA_ARGS__);
85 #define LOG_DOWNLOADER(...) if (G_UNLIKELY (debug_flags & RUNTIME_DEBUG_DOWNLOADER)) printf (__VA_ARGS__);
86 #define LOG_FONT(...) if (G_UNLIKELY (debug_flags & RUNTIME_DEBUG_FONT)) fprintf (__VA_ARGS__);
87 #define LOG_LAYOUT(...) if (G_UNLIKELY (debug_flags & RUNTIME_DEBUG_LAYOUT)) printf (__VA_ARGS__);
88 #define LOG_MEDIA(...) if (G_UNLIKELY (debug_flags & RUNTIME_DEBUG_MEDIA)) printf (__VA_ARGS__);
89 #define LOG_MEDIAELEMENT(...) if (G_UNLIKELY (debug_flags & RUNTIME_DEBUG_MEDIAELEMENT)) printf (__VA_ARGS__);
90 #define LOG_MEDIAELEMENT_EX(...) if (G_UNLIKELY (debug_flags_ex & RUNTIME_DEBUG_MEDIAELEMENT_EX)) printf (__VA_ARGS__);
91 #define LOG_MSI(...) if (G_UNLIKELY (debug_flags & RUNTIME_DEBUG_MSI)) printf (__VA_ARGS__);
92 #define LOG_BUFFERING(...) if (G_UNLIKELY (debug_flags & RUNTIME_DEBUG_BUFFERING)) printf (__VA_ARGS__);
93 #define LOG_PIPELINE_ASF(...) if (G_UNLIKELY (debug_flags & RUNTIME_DEBUG_ASF)) printf (__VA_ARGS__);
94 #define LOG_PLAYLIST(...) if (G_UNLIKELY (debug_flags & RUNTIME_DEBUG_PLAYLIST)) printf (__VA_ARGS__);
95 #define LOG_PLAYLIST_WARN(...) if (G_UNLIKELY (debug_flags_ex & RUNTIME_DEBUG_PLAYLIST_EX)) printf (__VA_ARGS__);
96 #define LOG_TEXT(...) if (G_UNLIKELY (debug_flags & RUNTIME_DEBUG_TEXT)) fprintf (__VA_ARGS__);
97 #define LOG_XAML(...) if (G_UNLIKELY (debug_flags & RUNTIME_DEBUG_XAML)) printf (__VA_ARGS__);
98 #define LOG_DEPLOYMENT(...) if (G_UNLIKELY (debug_flags & RUNTIME_DEBUG_DEPLOYMENT)) printf (__VA_ARGS__);
99 #define LOG_MP3(...) if (G_UNLIKELY (debug_flags & RUNTIME_DEBUG_MP3)) printf (__VA_ARGS__);
100 #define LOG_ASF(...) if (G_UNLIKELY (debug_flags & RUNTIME_DEBUG_ASF)) printf (__VA_ARGS__);
101 #define LOG_VALUE(...) if (G_UNLIKELY (debug_flags & RUNTIME_DEBUG_VALUE)) printf (__VA_ARGS__);
103 #else
105 #define LOG_ALSA(...)
106 #define LOG_ALSA_EX(...)
107 #define LOG_AUDIO(...)
108 #define LOG_AUDIO_EX(...)
109 #define LOG_PULSE(...)
110 #define LOG_PULSE_EX(...)
111 #define LOG_HTTPSTREAMING(...)
112 #define LOG_MARKERS(...)
113 #define LOG_MARKERS_EX(...)
114 #define LOG_MMS(...)
115 #define LOG_MEDIAPLAYER(...)
116 #define LOG_MEDIAPLAYER_EX(...)
117 #define LOG_PIPELINE(...)
118 #define LOG_PIPELINE_EX(...)
119 #define LOG_PIPELINE_ERROR(...)
120 #define LOG_PIPELINE_ERROR_CONDITIONAL(x, ...)
121 #define LOG_FRAMEREADERLOOP(...)
122 #define LOG_FFMPEG(...)
123 #define LOG_UI(...)
124 #define LOG_CODECS(...)
125 #define LOG_DP(...)
126 #define LOG_DOWNLOADER(...)
127 #define LOG_FONT(...)
128 #define LOG_LAYOUT(...)
129 #define LOG_MEDIA(...)
130 #define LOG_MEDIAELEMENT(...)
131 #define LOG_MEDIAELEMENT_EX(...)
132 #define LOG_MSI(...)
133 #define LOG_BUFFERING(...)
134 #define LOG_PIPELINE_ASF(...)
135 #define LOG_PLAYLIST(...)
136 #define LOG_PLAYLIST_WARN(...)
137 #define LOG_TEXT(...)
138 #define LOG_XAML(...)
139 #define LOG_DEPLOYMENT(...)
140 #define LOG_MP3(...)
141 #define LOG_ASF(...)
142 #define LOG_VALUE(...)
144 #endif /* LOGGING */
146 #if SANITY && defined (DEBUG)
147 G_BEGIN_DECLS
148 void moonlight_install_signal_handlers ();
149 G_END_DECLS
150 #else
151 #define moonlight_install_signal_handlers()
152 #endif /* SANITY */
154 #endif /* __MOONLIGHT_DEBUG_H */