2020-04-10 01:11:40 -04:00
|
|
|
#ifndef RUBY_DEBUG_H
|
|
|
|
#define RUBY_DEBUG_H
|
2006-12-31 10:02:22 -05:00
|
|
|
/**********************************************************************
|
|
|
|
|
2012-11-20 07:57:49 -05:00
|
|
|
vm_debug.h - YARV Debug function interface
|
2006-12-31 10:02:22 -05:00
|
|
|
|
|
|
|
$Author$
|
|
|
|
created at: 04/08/25 02:33:49 JST
|
|
|
|
|
* blockinlining.c, compile.c, compile.h, debug.c, debug.h,
id.c, insnhelper.h, insns.def, thread.c, thread_pthread.ci,
thread_pthread.h, thread_win32.ci, thread_win32.h, vm.h,
vm_dump.c, vm_evalbody.ci, vm_opts.h: fix comments and
copyright year.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13920 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-13 17:13:04 -05:00
|
|
|
Copyright (C) 2004-2007 Koichi Sasada
|
2006-12-31 10:02:22 -05:00
|
|
|
|
|
|
|
**********************************************************************/
|
|
|
|
|
2007-06-09 23:06:15 -04:00
|
|
|
#include "ruby/ruby.h"
|
* include/ruby/node.h, node.h: move node.h from include path.
This change stop to install node.h beacuase of saving ABI
(node.h will be changed. Extensions should not depends on
this file).
* blockinlining.c, class.c, compile.c, debug.h, enum.c,
gc.c, iseq.c, parse.y, ruby.c, signal.c, variable.c,
vm.c, vm_core.h, vm_dump.c: ditto.
* ext/ripper/depend: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19500 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-23 15:52:31 -04:00
|
|
|
#include "node.h"
|
2006-12-31 10:02:22 -05:00
|
|
|
|
2013-04-05 06:29:38 -04:00
|
|
|
RUBY_SYMBOL_EXPORT_BEGIN
|
2010-07-21 17:38:25 -04:00
|
|
|
|
2011-01-17 08:54:54 -05:00
|
|
|
#define dpv(h,v) ruby_debug_print_value(-1, 0, (h), (v))
|
|
|
|
#define dp(v) ruby_debug_print_value(-1, 0, "", (v))
|
|
|
|
#define dpi(i) ruby_debug_print_id(-1, 0, "", (i))
|
|
|
|
#define dpn(n) ruby_debug_print_node(-1, 0, "", (n))
|
2007-06-24 13:19:22 -04:00
|
|
|
|
2007-06-29 04:10:16 -04:00
|
|
|
VALUE ruby_debug_print_value(int level, int debug_level, const char *header, 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);
|
2008-04-14 01:34:04 -04:00
|
|
|
int ruby_debug_print_indent(int level, int debug_level, int indent_level);
|
2007-03-18 23:58:57 -04:00
|
|
|
void ruby_debug_gc_check_func(void);
|
2008-09-23 04:03:41 -04:00
|
|
|
void ruby_set_debug_option(const char *str);
|
|
|
|
|
2013-04-05 06:29:38 -04:00
|
|
|
RUBY_SYMBOL_EXPORT_END
|
2010-07-21 17:38:25 -04:00
|
|
|
|
RUBY_DEBUG_LOG: Logging debug information mechanism (#3279)
* RUBY_DEBUG_LOG: Logging debug information mechanism
This feature provides a mechanism to store logging information
to a file, stderr or memory space with simple macros.
The following information will be stored.
* (1) __FILE__, __LINE__ in C
* (2) __FILE__, __LINE__ in Ruby
* (3) __func__ in C (message title)
* (4) given string with sprintf format
* (5) Thread number (if multiple threads are running)
This feature is enabled only USE_RUBY_DEBUG_LOG is enabled.
Release version should not enable it.
Running with the `RUBY_DEBUG_LOG` environment variable enables
this feature.
# logging into a file
RUBY_DEBUG_LOG=/path/to/file STDERR
# logging into STDERR
RUBY_DEBUG_LOG=stderr
# logging into memory space (check with a debugger)
# It will help if the timing is important.
RUBY_DEBUG_LOG=mem
RUBY_DEBUG_LOG_FILTER environment variable can specify the fileter string.
If "(3) __func__ in C (message title)" contains the specified string, the
infomation will be stored (example: RUBY_DEBUG_LOG_FILTER=str will enable
only on str related information).
In a MRI source code, you can use the following macros:
* RUBY_DEBUG_LOG(fmt, ...): Above (1) to (4) will be logged.
* RUBY_DEBUG_LOG2(file, line, fmt, ...):
Same as RUBY_DEBUG_LOG(), but (1) will be replaced with given file, line.
2020-07-03 03:55:54 -04:00
|
|
|
#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
|
|
|
|
*
|
|
|
|
* This feature provides a mechanism to store logging information
|
|
|
|
* to a file, stderr or memory space with simple macros.
|
|
|
|
*
|
|
|
|
* The following information will be stored.
|
|
|
|
* * (1) __FILE__, __LINE__ in C
|
|
|
|
* * (2) __FILE__, __LINE__ in Ruby
|
|
|
|
* * (3) __func__ in C (message title)
|
|
|
|
* * (4) given string with sprintf format
|
|
|
|
* * (5) Thread number (if multiple threads are running)
|
|
|
|
*
|
|
|
|
* This feature is enabled only USE_RUBY_DEBUG_LOG is enabled.
|
|
|
|
* Release version should not enable it.
|
|
|
|
*
|
|
|
|
* Running with the `RUBY_DEBUG_LOG` environment variable enables
|
|
|
|
* this feature.
|
|
|
|
*
|
|
|
|
* # logging into a file
|
|
|
|
* RUBY_DEBUG_LOG=/path/to/file STDERR
|
|
|
|
*
|
|
|
|
* # logging into STDERR
|
|
|
|
* RUBY_DEBUG_LOG=stderr
|
|
|
|
*
|
|
|
|
* # logging into memory space (check with a debugger)
|
|
|
|
* # It will help if the timing is important.
|
|
|
|
* RUBY_DEBUG_LOG=mem
|
|
|
|
*
|
2020-07-09 05:14:53 -04:00
|
|
|
* RUBY_DEBUG_LOG_FILTER environment variable can specify the filter string.
|
RUBY_DEBUG_LOG: Logging debug information mechanism (#3279)
* RUBY_DEBUG_LOG: Logging debug information mechanism
This feature provides a mechanism to store logging information
to a file, stderr or memory space with simple macros.
The following information will be stored.
* (1) __FILE__, __LINE__ in C
* (2) __FILE__, __LINE__ in Ruby
* (3) __func__ in C (message title)
* (4) given string with sprintf format
* (5) Thread number (if multiple threads are running)
This feature is enabled only USE_RUBY_DEBUG_LOG is enabled.
Release version should not enable it.
Running with the `RUBY_DEBUG_LOG` environment variable enables
this feature.
# logging into a file
RUBY_DEBUG_LOG=/path/to/file STDERR
# logging into STDERR
RUBY_DEBUG_LOG=stderr
# logging into memory space (check with a debugger)
# It will help if the timing is important.
RUBY_DEBUG_LOG=mem
RUBY_DEBUG_LOG_FILTER environment variable can specify the fileter string.
If "(3) __func__ in C (message title)" contains the specified string, the
infomation will be stored (example: RUBY_DEBUG_LOG_FILTER=str will enable
only on str related information).
In a MRI source code, you can use the following macros:
* RUBY_DEBUG_LOG(fmt, ...): Above (1) to (4) will be logged.
* RUBY_DEBUG_LOG2(file, line, fmt, ...):
Same as RUBY_DEBUG_LOG(), but (1) will be replaced with given file, line.
2020-07-03 03:55:54 -04:00
|
|
|
* If "(3) __func__ in C (message title)" contains the specified string, the
|
2020-07-09 05:14:53 -04:00
|
|
|
* information will be stored (example: RUBY_DEBUG_LOG_FILTER=str will enable
|
RUBY_DEBUG_LOG: Logging debug information mechanism (#3279)
* RUBY_DEBUG_LOG: Logging debug information mechanism
This feature provides a mechanism to store logging information
to a file, stderr or memory space with simple macros.
The following information will be stored.
* (1) __FILE__, __LINE__ in C
* (2) __FILE__, __LINE__ in Ruby
* (3) __func__ in C (message title)
* (4) given string with sprintf format
* (5) Thread number (if multiple threads are running)
This feature is enabled only USE_RUBY_DEBUG_LOG is enabled.
Release version should not enable it.
Running with the `RUBY_DEBUG_LOG` environment variable enables
this feature.
# logging into a file
RUBY_DEBUG_LOG=/path/to/file STDERR
# logging into STDERR
RUBY_DEBUG_LOG=stderr
# logging into memory space (check with a debugger)
# It will help if the timing is important.
RUBY_DEBUG_LOG=mem
RUBY_DEBUG_LOG_FILTER environment variable can specify the fileter string.
If "(3) __func__ in C (message title)" contains the specified string, the
infomation will be stored (example: RUBY_DEBUG_LOG_FILTER=str will enable
only on str related information).
In a MRI source code, you can use the following macros:
* RUBY_DEBUG_LOG(fmt, ...): Above (1) to (4) will be logged.
* RUBY_DEBUG_LOG2(file, line, fmt, ...):
Same as RUBY_DEBUG_LOG(), but (1) will be replaced with given file, line.
2020-07-03 03:55:54 -04:00
|
|
|
* only on str related information).
|
|
|
|
*
|
|
|
|
* In a MRI source code, you can use the following macros:
|
|
|
|
* * RUBY_DEBUG_LOG(fmt, ...): Above (1) to (4) will be logged.
|
|
|
|
* * RUBY_DEBUG_LOG2(file, line, fmt, ...):
|
|
|
|
* Same as RUBY_DEBUG_LOG(), but (1) will be replaced with given file, line.
|
|
|
|
*/
|
|
|
|
|
|
|
|
extern enum ruby_debug_log_mode {
|
|
|
|
ruby_debug_log_disabled = 0x00,
|
|
|
|
ruby_debug_log_memory = 0x01,
|
|
|
|
ruby_debug_log_stderr = 0x02,
|
|
|
|
ruby_debug_log_file = 0x04,
|
|
|
|
} ruby_debug_log_mode;
|
|
|
|
|
|
|
|
void ruby_debug_log(const char *file, int line, const char *func_name, const char *fmt, ...);
|
|
|
|
void ruby_debug_log_print(unsigned int n);
|
|
|
|
|
|
|
|
// 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__)
|
|
|
|
|
|
|
|
#if USE_RUBY_DEBUG_LOG
|
|
|
|
#define RUBY_DEBUG_LOG(fmt, ...) do { if (ruby_debug_log_mode) ruby_debug_log(__FILE__, __LINE__, __func__, fmt, __VA_ARGS__); } while (0)
|
|
|
|
#define RUBY_DEBUG_LOG2(file, line, fmt, ...) do { if (ruby_debug_log_mode) ruby_debug_log(file, line, __func__, fmt, __VA_ARGS__); } while (0)
|
|
|
|
#else
|
|
|
|
// do nothing
|
|
|
|
#define RUBY_DEBUG_LOG(fmt, ...)
|
|
|
|
#define RUBY_DEBUG_LOG2(file, line, fmt, ...)
|
|
|
|
#endif // USE_RUBY_DEBUG_LOG
|
|
|
|
|
2007-06-29 04:10:16 -04:00
|
|
|
#endif /* RUBY_DEBUG_H */
|