2020-04-10 08:11:40 +03:00
|
|
|
#ifndef RUBY_DEBUG_H
|
|
|
|
#define RUBY_DEBUG_H
|
2006-12-31 18:02:22 +03:00
|
|
|
/**********************************************************************
|
|
|
|
|
2012-11-20 16:57:49 +04:00
|
|
|
vm_debug.h - YARV Debug function interface
|
2006-12-31 18:02:22 +03: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-14 01:13:04 +03:00
|
|
|
Copyright (C) 2004-2007 Koichi Sasada
|
2006-12-31 18:02:22 +03:00
|
|
|
|
|
|
|
**********************************************************************/
|
|
|
|
|
2007-06-10 07: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 23:52:31 +04:00
|
|
|
#include "node.h"
|
2006-12-31 18:02:22 +03:00
|
|
|
|
2013-04-05 14:29:38 +04:00
|
|
|
RUBY_SYMBOL_EXPORT_BEGIN
|
2010-07-22 01:38:25 +04:00
|
|
|
|
2011-01-17 16:54:54 +03: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 21:19:22 +04:00
|
|
|
|
2007-06-29 12: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 09:34:04 +04:00
|
|
|
int ruby_debug_print_indent(int level, int debug_level, int indent_level);
|
2007-03-19 06:58:57 +03:00
|
|
|
void ruby_debug_gc_check_func(void);
|
2008-09-23 12:03:41 +04:00
|
|
|
void ruby_set_debug_option(const char *str);
|
|
|
|
|
2013-04-05 14:29:38 +04:00
|
|
|
RUBY_SYMBOL_EXPORT_END
|
2010-07-22 01: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 10:55:54 +03: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 12:14:53 +03: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 10:55:54 +03:00
|
|
|
* If "(3) __func__ in C (message title)" contains the specified string, the
|
2020-07-09 12:14:53 +03: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 10:55:54 +03: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;
|
|
|
|
|
2021-09-09 08:05:11 +03:00
|
|
|
RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 4, 5)
|
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 10:55:54 +03:00
|
|
|
void ruby_debug_log(const char *file, int line, const char *func_name, const char *fmt, ...);
|
|
|
|
void ruby_debug_log_print(unsigned int n);
|
2020-08-01 22:24:47 +03:00
|
|
|
bool ruby_debug_log_filter(const char *func_name);
|
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 10:55:54 +03:00
|
|
|
|
|
|
|
// 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).
|
2021-10-03 10:22:53 +03:00
|
|
|
#define _RUBY_DEBUG_LOG(...) ruby_debug_log(__FILE__, __LINE__, RUBY_FUNCTION_NAME_STRING, "" __VA_ARGS__)
|
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 10:55:54 +03:00
|
|
|
|
|
|
|
#if USE_RUBY_DEBUG_LOG
|
2021-10-03 10:22:53 +03:00
|
|
|
# define RUBY_DEBUG_LOG_ENABLED(func_name) \
|
|
|
|
(ruby_debug_log_mode && ruby_debug_log_filter(func_name))
|
2020-08-01 22:24:47 +03:00
|
|
|
|
2021-09-28 12:00:03 +03:00
|
|
|
#define RUBY_DEBUG_LOG(...) do { \
|
2021-10-03 10:22:53 +03:00
|
|
|
if (RUBY_DEBUG_LOG_ENABLED(RUBY_FUNCTION_NAME_STRING)) \
|
|
|
|
ruby_debug_log(__FILE__, __LINE__, RUBY_FUNCTION_NAME_STRING, "" __VA_ARGS__); \
|
2020-08-01 22:24:47 +03:00
|
|
|
} while (0)
|
|
|
|
|
2021-09-28 12:00:03 +03:00
|
|
|
#define RUBY_DEBUG_LOG2(file, line, ...) do { \
|
2021-10-03 10:22:53 +03:00
|
|
|
if (RUBY_DEBUG_LOG_ENABLED(RUBY_FUNCTION_NAME_STRING)) \
|
|
|
|
ruby_debug_log(file, line, RUBY_FUNCTION_NAME_STRING, "" __VA_ARGS__); \
|
2020-08-01 22:24:47 +03:00
|
|
|
} while (0)
|
|
|
|
|
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 10:55:54 +03:00
|
|
|
#else
|
|
|
|
// do nothing
|
2021-09-28 12:00:03 +03:00
|
|
|
#define RUBY_DEBUG_LOG(...)
|
|
|
|
#define RUBY_DEBUG_LOG2(file, line, ...)
|
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 10:55:54 +03:00
|
|
|
#endif // USE_RUBY_DEBUG_LOG
|
|
|
|
|
2007-06-29 12:10:16 +04:00
|
|
|
#endif /* RUBY_DEBUG_H */
|