43 #ifndef SBDEBUGUTILS_H_
44 #define SBDEBUGUTILS_H_
50 #define SB_UNUSED_IN_RELEASE(decl) decl
52 #define SB_UNUSED_IN_RELEASE(decl) decl __attribute__((unused))
55 #define SB_UNUSED_IN_RELEASE(decl) decl
61 #pragma warning(disable: 4101)
67 static PRLogModuleInfo* gPRLogModule = nsnull;
69 #define SB_PRLOG_SETUP(aModuleName) \
72 gPRLogModule = PR_NewLogModule(#aModuleName); \
75 #define TRACE(fmt, ...) \
77 if (PR_LOG_TEST(gPRLogModule, PR_LOG_DEBUG)) { \
78 PR_LogPrint("%s: " fmt, __FUNCTION__, ##__VA_ARGS__); \
82 #define LOG(fmt, ...) \
84 if (PR_LOG_TEST(gPRLogModule, PR_LOG_WARN)) { \
85 PR_LogPrint("%s: " fmt, __FUNCTION__, ##__VA_ARGS__); \
89 struct _sbTraceFunctionClass {
90 _sbTraceFunctionClass(
const char*
function) {
93 ~_sbTraceFunctionClass() {
94 if (PR_LOG_TEST(gPRLogModule, PR_LOG_DEBUG)) {
95 PR_LogPrint(
"%s() <--", mFunction);
98 const char* mFunction;
101 #if defined(__GNUC__)
102 #define __FUNCTION__ __PRETTY_FUNCTION__
105 #define TRACE_FUNCTION_VAR_NAME2(x) SB_TRACE_FUNCTION_VAR_ ## x
106 #define TRACE_FUNCTION_VAR_NAME(x) TRACE_FUNCTION_VAR_NAME2(x)
107 #define TRACE_FUNCTION(fmt, ...) \
108 if (PR_LOG_TEST(gPRLogModule, PR_LOG_DEBUG)) { \
109 PR_LogPrint("%s(" fmt ") -->", __FUNCTION__, ##__VA_ARGS__); \
111 _sbTraceFunctionClass TRACE_FUNCTION_VAR_NAME(__LINE__)(__FUNCTION__)
115 #define SB_PRLOG_SETUP(x) PR_BEGIN_MACRO PR_END_MACRO
116 #define TRACE(...) PR_BEGIN_MACRO PR_END_MACRO
117 #define LOG(...) PR_BEGIN_MACRO PR_END_MACRO
118 #define TRACE_FUNCTION(...) PR_BEGIN_MACRO PR_END_MACRO