summaryrefslogtreecommitdiff
path: root/vm_debug.h
diff options
context:
space:
mode:
Diffstat (limited to 'vm_debug.h')
-rw-r--r--vm_debug.h47
1 files changed, 27 insertions, 20 deletions
diff --git a/vm_debug.h b/vm_debug.h
index 2840e70646..d0bc81574a 100644
--- a/vm_debug.h
+++ b/vm_debug.h
@@ -12,7 +12,6 @@
**********************************************************************/
#include "ruby/ruby.h"
-#include "node.h"
RUBY_SYMBOL_EXPORT_BEGIN
@@ -21,25 +20,22 @@ RUBY_SYMBOL_EXPORT_BEGIN
#define dpi(i) ruby_debug_print_id(-1, 0, "", (i))
#define dpn(n) ruby_debug_print_node(-1, 0, "", (n))
+struct RNode;
+
VALUE ruby_debug_print_value(int level, int debug_level, const char *header, VALUE v);
+void ruby_debug_print_v(VALUE v);
ID ruby_debug_print_id(int level, int debug_level, const char *header, ID id);
-NODE *ruby_debug_print_node(int level, int debug_level, const char *header, const NODE *node);
+struct RNode *ruby_debug_print_node(int level, int debug_level, const char *header, const struct RNode *node);
+void ruby_debug_print_n(const struct RNode *node);
int ruby_debug_print_indent(int level, int debug_level, int indent_level);
void ruby_debug_gc_check_func(void);
void ruby_set_debug_option(const char *str);
RUBY_SYMBOL_EXPORT_END
-#if RUBY_DEVEL
#ifndef USE_RUBY_DEBUG_LOG
#define USE_RUBY_DEBUG_LOG 0
#endif
-#else
-// disable on !RUBY_DEVEL
-#ifdef USE_RUBY_DEBUG_LOG
-#undef USE_RUBY_DEBUG_LOG
-#endif
-#endif
/* RUBY_DEBUG_LOG: Logging debug information mechanism
*
@@ -90,28 +86,39 @@ extern enum ruby_debug_log_mode {
RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 4, 5)
void ruby_debug_log(const char *file, int line, const char *func_name, const char *fmt, ...);
void ruby_debug_log_print(unsigned int n);
-bool ruby_debug_log_filter(const char *func_name);
+bool ruby_debug_log_filter(const char *func_name, const char *file_name);
+
+#if RBIMPL_COMPILER_IS(GCC) && defined(__OPTIMIZE__)
+# define ruby_debug_log(...) \
+ RB_GNUC_EXTENSION_BLOCK( \
+ RBIMPL_WARNING_PUSH(); \
+ RBIMPL_WARNING_IGNORED(-Wformat-zero-length); \
+ ruby_debug_log(__VA_ARGS__); \
+ RBIMPL_WARNING_POP())
+#endif
// convenient macro to log even if the USE_RUBY_DEBUG_LOG macro is not specified.
// You can use this macro for temporary usage (you should not commit it).
-#define _RUBY_DEBUG_LOG(fmt, ...) ruby_debug_log(__FILE__, __LINE__, __func__, fmt, __VA_ARGS__)
+#define _RUBY_DEBUG_LOG(...) ruby_debug_log(__FILE__, __LINE__, RUBY_FUNCTION_NAME_STRING, "" __VA_ARGS__)
#if USE_RUBY_DEBUG_LOG
+# define RUBY_DEBUG_LOG_ENABLED(func_name, file_name) \
+ (ruby_debug_log_mode && ruby_debug_log_filter(func_name, file_name))
-#define RUBY_DEBUG_LOG(fmt, ...) do { \
- if (ruby_debug_log_mode && ruby_debug_log_filter(__func__)) \
- ruby_debug_log(__FILE__, __LINE__, __func__, fmt, __VA_ARGS__); \
+#define RUBY_DEBUG_LOG(...) do { \
+ if (RUBY_DEBUG_LOG_ENABLED(RUBY_FUNCTION_NAME_STRING, __FILE__)) \
+ ruby_debug_log(__FILE__, __LINE__, RUBY_FUNCTION_NAME_STRING, "" __VA_ARGS__); \
} while (0)
-#define RUBY_DEBUG_LOG2(file, line, fmt, ...) do { \
- if (ruby_debug_log_mode && ruby_debug_log_filter(__func__)) \
- ruby_debug_log(file, line, __func__, fmt, __VA_ARGS__); \
+#define RUBY_DEBUG_LOG2(file, line, ...) do { \
+ if (RUBY_DEBUG_LOG_ENABLED(RUBY_FUNCTION_NAME_STRING, file)) \
+ ruby_debug_log(file, line, RUBY_FUNCTION_NAME_STRING, "" __VA_ARGS__); \
} while (0)
-#else
+#else // USE_RUBY_DEBUG_LOG
// do nothing
-#define RUBY_DEBUG_LOG(fmt, ...)
-#define RUBY_DEBUG_LOG2(file, line, fmt, ...)
+#define RUBY_DEBUG_LOG(...)
+#define RUBY_DEBUG_LOG2(file, line, ...)
#endif // USE_RUBY_DEBUG_LOG
#endif /* RUBY_DEBUG_H */