2006-12-31 10:02:22 -05:00
|
|
|
/**********************************************************************
|
|
|
|
|
|
|
|
debug.c -
|
|
|
|
|
|
|
|
$Author$
|
|
|
|
created at: 04/08/25 02:31:54 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
|
|
|
|
|
|
|
**********************************************************************/
|
|
|
|
|
2020-05-08 05:31:09 -04:00
|
|
|
#include "ruby/internal/config.h"
|
2019-12-04 03:16:30 -05:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "eval_intern.h"
|
|
|
|
#include "id.h"
|
|
|
|
#include "internal/signal.h"
|
|
|
|
#include "internal/util.h"
|
2007-10-16 05:21:11 -04:00
|
|
|
#include "ruby/encoding.h"
|
2018-01-09 01:24:10 -05:00
|
|
|
#include "ruby/io.h"
|
2019-12-04 03:16:30 -05:00
|
|
|
#include "ruby/ruby.h"
|
2008-02-23 16:13:05 -05:00
|
|
|
#include "ruby/util.h"
|
2017-10-24 20:33:29 -04:00
|
|
|
#include "symbol.h"
|
2019-12-04 03:16:30 -05:00
|
|
|
#include "vm_core.h"
|
|
|
|
#include "vm_debug.h"
|
VALUE size packed callinfo (ci).
Now, rb_call_info contains how to call the method with tuple of
(mid, orig_argc, flags, kwarg). Most of cases, kwarg == NULL and
mid+argc+flags only requires 64bits. So this patch packed
rb_call_info to VALUE (1 word) on such cases. If we can not
represent it in VALUE, then use imemo_callinfo which contains
conventional callinfo (rb_callinfo, renamed from rb_call_info).
iseq->body->ci_kw_size is removed because all of callinfo is VALUE
size (packed ci or a pointer to imemo_callinfo).
To access ci information, we need to use these functions:
vm_ci_mid(ci), _flag(ci), _argc(ci), _kwarg(ci).
struct rb_call_info_kw_arg is renamed to rb_callinfo_kwarg.
rb_funcallv_with_cc() and rb_method_basic_definition_p_with_cc()
is temporary removed because cd->ci should be marked.
2020-01-07 18:20:36 -05:00
|
|
|
#include "vm_callinfo.h"
|
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
|
|
|
#include "ruby/thread_native.h"
|
2006-12-31 10:02:22 -05:00
|
|
|
|
2019-12-03 00:42:53 -05:00
|
|
|
/* This is the only place struct RIMemo is actually used */
|
|
|
|
struct RIMemo {
|
|
|
|
VALUE flags;
|
|
|
|
VALUE v0;
|
|
|
|
VALUE v1;
|
|
|
|
VALUE v2;
|
|
|
|
VALUE v3;
|
|
|
|
};
|
|
|
|
|
2007-10-16 05:21:11 -04:00
|
|
|
/* for gdb */
|
2009-08-05 05:46:07 -04:00
|
|
|
const union {
|
2007-10-16 05:21:11 -04:00
|
|
|
enum ruby_special_consts special_consts;
|
|
|
|
enum ruby_value_type value_type;
|
2008-05-08 02:56:59 -04:00
|
|
|
enum ruby_tag_type tag_type;
|
2007-10-16 05:21:11 -04:00
|
|
|
enum node_type node_type;
|
2009-05-21 09:17:54 -04:00
|
|
|
enum ruby_method_ids method_ids;
|
2013-09-20 00:53:08 -04:00
|
|
|
enum ruby_id_types id_types;
|
2015-09-12 22:03:31 -04:00
|
|
|
enum ruby_fl_type fl_types;
|
2020-04-18 03:35:20 -04:00
|
|
|
enum ruby_fl_ushift fl_ushift;
|
2015-09-12 22:03:31 -04:00
|
|
|
enum ruby_encoding_consts encoding_consts;
|
|
|
|
enum ruby_coderange_type enc_coderange_types;
|
|
|
|
enum ruby_econv_flag_type econv_flag_types;
|
2020-04-25 04:52:27 -04:00
|
|
|
rb_econv_result_t econv_result;
|
2017-06-01 00:43:03 -04:00
|
|
|
enum ruby_robject_flags robject_flags;
|
2020-04-25 04:52:27 -04:00
|
|
|
enum ruby_robject_consts robject_consts;
|
2017-06-01 00:43:03 -04:00
|
|
|
enum ruby_rmodule_flags rmodule_flags;
|
|
|
|
enum ruby_rstring_flags rstring_flags;
|
2020-04-25 04:52:27 -04:00
|
|
|
enum ruby_rstring_consts rstring_consts;
|
2017-06-01 00:43:03 -04:00
|
|
|
enum ruby_rarray_flags rarray_flags;
|
2020-04-25 04:52:27 -04:00
|
|
|
enum ruby_rarray_consts rarray_consts;
|
2007-10-16 05:21:11 -04:00
|
|
|
enum {
|
2017-07-05 02:32:54 -04:00
|
|
|
RUBY_FMODE_READABLE = FMODE_READABLE,
|
|
|
|
RUBY_FMODE_WRITABLE = FMODE_WRITABLE,
|
|
|
|
RUBY_FMODE_READWRITE = FMODE_READWRITE,
|
|
|
|
RUBY_FMODE_BINMODE = FMODE_BINMODE,
|
|
|
|
RUBY_FMODE_SYNC = FMODE_SYNC,
|
|
|
|
RUBY_FMODE_TTY = FMODE_TTY,
|
|
|
|
RUBY_FMODE_DUPLEX = FMODE_DUPLEX,
|
|
|
|
RUBY_FMODE_APPEND = FMODE_APPEND,
|
|
|
|
RUBY_FMODE_CREATE = FMODE_CREATE,
|
|
|
|
RUBY_FMODE_NOREVLOOKUP = 0x00000100,
|
|
|
|
RUBY_FMODE_TRUNC = FMODE_TRUNC,
|
|
|
|
RUBY_FMODE_TEXTMODE = FMODE_TEXTMODE,
|
|
|
|
RUBY_FMODE_PREP = 0x00010000,
|
|
|
|
RUBY_FMODE_SETENC_BY_BOM = FMODE_SETENC_BY_BOM,
|
|
|
|
RUBY_FMODE_UNIX = 0x00200000,
|
|
|
|
RUBY_FMODE_INET = 0x00400000,
|
|
|
|
RUBY_FMODE_INET6 = 0x00800000,
|
|
|
|
|
2007-10-16 05:29:32 -04:00
|
|
|
RUBY_NODE_TYPESHIFT = NODE_TYPESHIFT,
|
|
|
|
RUBY_NODE_TYPEMASK = NODE_TYPEMASK,
|
|
|
|
RUBY_NODE_LSHIFT = NODE_LSHIFT,
|
2008-07-01 04:27:58 -04:00
|
|
|
RUBY_NODE_FL_NEWLINE = NODE_FL_NEWLINE
|
2007-10-16 05:21:11 -04:00
|
|
|
} various;
|
2017-11-22 22:14:12 -05:00
|
|
|
union {
|
|
|
|
enum imemo_type types;
|
|
|
|
enum {RUBY_IMEMO_MASK = IMEMO_MASK} mask;
|
|
|
|
struct RIMemo *ptr;
|
|
|
|
} imemo;
|
2017-10-24 20:33:29 -04:00
|
|
|
struct RSymbol *symbol_ptr;
|
2017-11-02 03:52:48 -04:00
|
|
|
enum vm_call_flag_bits vm_call_flags;
|
2009-08-05 05:46:07 -04:00
|
|
|
} ruby_dummy_gdb_enums;
|
2007-10-16 05:21:11 -04:00
|
|
|
|
2010-05-05 00:31:48 -04:00
|
|
|
const SIGNED_VALUE RUBY_NODE_LMASK = NODE_LMASK;
|
2007-10-16 05:21:11 -04:00
|
|
|
|
2008-04-14 01:34:04 -04:00
|
|
|
int
|
2007-06-24 13:19:22 -04:00
|
|
|
ruby_debug_print_indent(int level, int debug_level, int indent_level)
|
2006-12-31 10:02:22 -05:00
|
|
|
{
|
|
|
|
if (level < debug_level) {
|
2008-02-23 14:03:32 -05:00
|
|
|
fprintf(stderr, "%*s", indent_level, "");
|
2006-12-31 10:02:22 -05:00
|
|
|
fflush(stderr);
|
2009-09-14 03:39:16 -04:00
|
|
|
return TRUE;
|
2006-12-31 10:02:22 -05:00
|
|
|
}
|
2009-09-14 03:39:16 -04:00
|
|
|
return FALSE;
|
2008-04-14 01:34:04 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ruby_debug_printf(const char *format, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
va_start(ap, format);
|
|
|
|
vfprintf(stderr, format, ap);
|
|
|
|
va_end(ap);
|
2006-12-31 10:02:22 -05:00
|
|
|
}
|
|
|
|
|
2016-07-25 04:00:46 -04:00
|
|
|
#include "gc.h"
|
|
|
|
|
2006-12-31 10:02:22 -05:00
|
|
|
VALUE
|
2007-06-29 03:57:24 -04:00
|
|
|
ruby_debug_print_value(int level, int debug_level, const char *header, VALUE obj)
|
2006-12-31 10:02:22 -05:00
|
|
|
{
|
|
|
|
if (level < debug_level) {
|
2016-07-25 04:00:46 -04:00
|
|
|
char buff[0x100];
|
|
|
|
rb_raw_obj_info(buff, 0x100, obj);
|
|
|
|
|
|
|
|
fprintf(stderr, "DBG> %s: %s\n", header, buff);
|
2006-12-31 10:02:22 -05:00
|
|
|
fflush(stderr);
|
|
|
|
}
|
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2007-06-24 13:19:22 -04:00
|
|
|
ruby_debug_print_v(VALUE v)
|
2006-12-31 10:02:22 -05:00
|
|
|
{
|
2007-06-24 13:19:22 -04:00
|
|
|
ruby_debug_print_value(0, 1, "", v);
|
2006-12-31 10:02:22 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
ID
|
2007-06-29 03:57:24 -04:00
|
|
|
ruby_debug_print_id(int level, int debug_level, const char *header, ID id)
|
2006-12-31 10:02:22 -05:00
|
|
|
{
|
|
|
|
if (level < debug_level) {
|
2015-05-23 12:36:26 -04:00
|
|
|
fprintf(stderr, "DBG> %s: %s\n", header, rb_id2name(id));
|
2006-12-31 10:02:22 -05:00
|
|
|
fflush(stderr);
|
|
|
|
}
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
* compile.c, parse.y, eval.c, intern.h, iseq.c, lex.c, node.h,
proc.c, vm.c, vm_macro.def, vm_macro.def, yarvcore.c, yarvcore.h,
debug.c, debug.h: merge half-baked-1.9 changes. The biggest change
is to change node structure around NODE_SCOPE, NODE_ARGS. Every
scope (method/class/block) has own NODE_SCOPE node and NODE_ARGS
represents more details of arguments information. I'll write a
document about detail of node structure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-03-21 07:15:15 -04:00
|
|
|
NODE *
|
2007-06-29 03:57:24 -04:00
|
|
|
ruby_debug_print_node(int level, int debug_level, const char *header, const NODE *node)
|
* compile.c, parse.y, eval.c, intern.h, iseq.c, lex.c, node.h,
proc.c, vm.c, vm_macro.def, vm_macro.def, yarvcore.c, yarvcore.h,
debug.c, debug.h: merge half-baked-1.9 changes. The biggest change
is to change node structure around NODE_SCOPE, NODE_ARGS. Every
scope (method/class/block) has own NODE_SCOPE node and NODE_ARGS
represents more details of arguments information. I'll write a
document about detail of node structure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-03-21 07:15:15 -04:00
|
|
|
{
|
|
|
|
if (level < debug_level) {
|
2009-09-14 03:39:16 -04:00
|
|
|
fprintf(stderr, "DBG> %s: %s (%u)\n", header,
|
2007-05-17 00:00:36 -04:00
|
|
|
ruby_node_name(nd_type(node)), nd_line(node));
|
* compile.c, parse.y, eval.c, intern.h, iseq.c, lex.c, node.h,
proc.c, vm.c, vm_macro.def, vm_macro.def, yarvcore.c, yarvcore.h,
debug.c, debug.h: merge half-baked-1.9 changes. The biggest change
is to change node structure around NODE_SCOPE, NODE_ARGS. Every
scope (method/class/block) has own NODE_SCOPE node and NODE_ARGS
represents more details of arguments information. I'll write a
document about detail of node structure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-03-21 07:15:15 -04:00
|
|
|
}
|
2007-06-29 03:57:24 -04:00
|
|
|
return (NODE *)node;
|
* compile.c, parse.y, eval.c, intern.h, iseq.c, lex.c, node.h,
proc.c, vm.c, vm_macro.def, vm_macro.def, yarvcore.c, yarvcore.h,
debug.c, debug.h: merge half-baked-1.9 changes. The biggest change
is to change node structure around NODE_SCOPE, NODE_ARGS. Every
scope (method/class/block) has own NODE_SCOPE node and NODE_ARGS
represents more details of arguments information. I'll write a
document about detail of node structure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-03-21 07:15:15 -04:00
|
|
|
}
|
|
|
|
|
2006-12-31 10:02:22 -05:00
|
|
|
void
|
* this commit is a result of refactoring. only renaming functions,
moving definitions place, add/remove prototypes, deleting
unused variables and removing yarv.h.
This commit doesn't change any behavior of ruby/vm.
* yarv.h, common.mk: remove yarv.h (contents are moved to yarvcore.h).
* error.c, eval_intern.h: include yarvcore.h instead yarv.h
* rename some functions:
* debug.[ch]: debug_*() -> ruby_debug_*()
* iseq.c: iseq_*() -> rb_iseq_*(), ruby_iseq_disasm()
* iseq.c: node_name() -> ruby_node_name()
* vm.c: yarv_check_redefinition_opt_method() ->
rb_vm_check_redefinition_opt_method()
* some refactoring with checking -Wall.
* array.c: remove rb_ary_ptr() (unused) and remove unused
local variables.
* object.c: add a prototype of rb_mod_module_exec().
* eval_intern.h (ruby_cref): set it inline.
* eval_load.c (rb_load), yarvcore.c: yarv_load() -> rb_load_internal().
* parse.y: add a prototype of rb_parse_in_eval() (in eval.c).
* process.c: add a prototype of rb_thread_stop_timer_thread() (in thread.c).
* thread.c: remove raw_gets() function (unused) and fix some format
mismatch (format mismatchs have remained yet. this is todo).
* thread.c (rb_thread_wait_fd_rw): fix typo on label name.
* thread_pthread.ci: comment out codes with USE_THREAD_CACHE.
* vm.c (rb_svar, rb_backref_get, rb_backref_get,
rb_lastline_get, rb_lastline_set) : moved from yarvcore.c.
* vm.c (yarv_init_redefined_flag): add a prototype and rename
yarv_opt_method_table to vm_opt_method_table.
* vm.c (rb_thread_eval): moved from yarvcore.c.
* yarvcore.c: remove unused global variables and fix to use nsdr().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11652 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 20:25:05 -05:00
|
|
|
ruby_debug_breakpoint(void)
|
2006-12-31 10:02:22 -05:00
|
|
|
{
|
|
|
|
/* */
|
|
|
|
}
|
2007-06-29 03:57:24 -04:00
|
|
|
|
2017-03-30 20:35:02 -04:00
|
|
|
#if defined _WIN32
|
|
|
|
# if RUBY_MSVCRT_VERSION >= 80
|
|
|
|
extern int ruby_w32_rtc_error;
|
|
|
|
# endif
|
2017-05-15 20:15:54 -04:00
|
|
|
#endif
|
|
|
|
#if defined _WIN32 || defined __CYGWIN__
|
|
|
|
#include <windows.h>
|
2017-06-05 23:45:02 -04:00
|
|
|
UINT ruby_w32_codepage[2];
|
2017-03-30 20:35:02 -04:00
|
|
|
#endif
|
2017-06-19 10:36:18 -04:00
|
|
|
extern int ruby_rgengc_debug;
|
2019-12-05 00:39:03 -05:00
|
|
|
extern int ruby_on_ci;
|
2017-03-30 20:35:02 -04:00
|
|
|
|
2017-06-20 22:44:23 -04:00
|
|
|
int
|
|
|
|
ruby_env_debug_option(const char *str, int len, void *arg)
|
2007-06-29 03:57:24 -04:00
|
|
|
{
|
2017-06-19 10:36:18 -04:00
|
|
|
int ov;
|
|
|
|
size_t retlen;
|
|
|
|
unsigned long n;
|
2014-11-18 09:58:03 -05:00
|
|
|
#define SET_WHEN(name, var, val) do { \
|
2007-06-29 03:57:24 -04:00
|
|
|
if (len == sizeof(name) - 1 && \
|
2010-12-07 07:16:10 -05:00
|
|
|
strncmp(str, (name), len) == 0) { \
|
2014-11-18 09:58:03 -05:00
|
|
|
(var) = (val); \
|
2017-06-20 22:44:23 -04:00
|
|
|
return 1; \
|
2008-02-23 16:13:05 -05:00
|
|
|
} \
|
|
|
|
} while (0)
|
2017-06-19 10:36:18 -04:00
|
|
|
#define NAME_MATCH_VALUE(name) \
|
|
|
|
((size_t)len >= sizeof(name)-1 && \
|
|
|
|
strncmp(str, (name), sizeof(name)-1) == 0 && \
|
|
|
|
((len == sizeof(name)-1 && !(len = 0)) || \
|
|
|
|
(str[sizeof(name)-1] == '=' && \
|
|
|
|
(str += sizeof(name), len -= sizeof(name), 1))))
|
|
|
|
#define SET_UINT(val) do { \
|
|
|
|
n = ruby_scan_digits(str, len, 10, &retlen, &ov); \
|
|
|
|
if (!ov && retlen) { \
|
|
|
|
val = (unsigned int)n; \
|
|
|
|
} \
|
|
|
|
str += retlen; \
|
|
|
|
len -= retlen; \
|
|
|
|
} while (0)
|
|
|
|
#define SET_UINT_LIST(name, vals, num) do { \
|
|
|
|
int i; \
|
|
|
|
for (i = 0; i < (num); ++i) { \
|
|
|
|
SET_UINT((vals)[i]); \
|
|
|
|
if (!len || *str != ':') break; \
|
|
|
|
++str; \
|
|
|
|
--len; \
|
|
|
|
} \
|
|
|
|
if (len > 0) { \
|
|
|
|
fprintf(stderr, "ignored "name" option: `%.*s'\n", len, str); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
#define SET_WHEN_UINT(name, vals, num, req) \
|
|
|
|
if (NAME_MATCH_VALUE(name)) SET_UINT_LIST(name, vals, num);
|
2017-03-30 20:35:02 -04:00
|
|
|
|
2014-11-18 09:58:03 -05:00
|
|
|
SET_WHEN("gc_stress", *ruby_initial_gc_stress_ptr, Qtrue);
|
|
|
|
SET_WHEN("core", ruby_enable_coredump, 1);
|
2019-12-05 00:39:03 -05:00
|
|
|
SET_WHEN("ci", ruby_on_ci, 1);
|
2017-06-19 10:36:18 -04:00
|
|
|
if (NAME_MATCH_VALUE("rgengc")) {
|
|
|
|
if (!len) ruby_rgengc_debug = 1;
|
|
|
|
else SET_UINT_LIST("rgengc", &ruby_rgengc_debug, 1);
|
2017-06-20 22:44:23 -04:00
|
|
|
return 1;
|
2017-06-19 10:36:18 -04:00
|
|
|
}
|
2017-03-30 20:35:02 -04:00
|
|
|
#if defined _WIN32
|
|
|
|
# if RUBY_MSVCRT_VERSION >= 80
|
2014-11-18 09:58:03 -05:00
|
|
|
SET_WHEN("rtc_error", ruby_w32_rtc_error, 1);
|
2017-03-30 20:35:02 -04:00
|
|
|
# endif
|
2017-05-15 20:15:54 -04:00
|
|
|
#endif
|
|
|
|
#if defined _WIN32 || defined __CYGWIN__
|
2017-06-05 23:45:02 -04:00
|
|
|
if (NAME_MATCH_VALUE("codepage")) {
|
2017-06-19 10:36:18 -04:00
|
|
|
if (!len) fprintf(stderr, "missing codepage argument");
|
|
|
|
else SET_UINT_LIST("codepage", ruby_w32_codepage, numberof(ruby_w32_codepage));
|
2017-06-20 22:44:23 -04:00
|
|
|
return 1;
|
2017-03-30 20:35:02 -04:00
|
|
|
}
|
2009-02-16 02:46:24 -05:00
|
|
|
#endif
|
2017-06-20 22:44:23 -04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
set_debug_option(const char *str, int len, void *arg)
|
|
|
|
{
|
|
|
|
if (!ruby_env_debug_option(str, len, arg)) {
|
|
|
|
fprintf(stderr, "unexpected debug option: %.*s\n", len, str);
|
|
|
|
}
|
2008-02-23 16:13:05 -05: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
|
|
|
STATIC_ASSERT(USE_RUBY_DEBUG_LOG, USE_RUBY_DEBUG_LOG ? RUBY_DEVEL : 1);
|
|
|
|
|
|
|
|
#if RUBY_DEVEL
|
|
|
|
static void setup_debug_log(void);
|
|
|
|
#else
|
|
|
|
#define setup_debug_log()
|
|
|
|
#endif
|
|
|
|
|
2008-02-23 16:13:05 -05:00
|
|
|
void
|
|
|
|
ruby_set_debug_option(const char *str)
|
|
|
|
{
|
|
|
|
ruby_each_words(str, set_debug_option, 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 03:55:54 -04:00
|
|
|
setup_debug_log();
|
|
|
|
}
|
|
|
|
|
|
|
|
#if RUBY_DEVEL
|
|
|
|
|
|
|
|
// RUBY_DEBUG_LOG features
|
|
|
|
// See vm_debug.h comments for details.
|
|
|
|
|
|
|
|
#define MAX_DEBUG_LOG 0x1000
|
|
|
|
#define MAX_DEBUG_LOG_MESSAGE_LEN 0x0200
|
2020-08-01 15:24:47 -04:00
|
|
|
#define MAX_DEBUG_LOG_FILTER 0x0010
|
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
|
|
|
|
|
|
|
enum ruby_debug_log_mode ruby_debug_log_mode;
|
|
|
|
|
|
|
|
static struct {
|
|
|
|
char *mem;
|
|
|
|
unsigned int cnt;
|
2020-08-01 15:24:47 -04:00
|
|
|
char filters[MAX_DEBUG_LOG_FILTER][MAX_DEBUG_LOG_FILTER];
|
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
|
|
|
unsigned int filters_num;
|
|
|
|
rb_nativethread_lock_t lock;
|
|
|
|
FILE *output;
|
|
|
|
} debug_log;
|
|
|
|
|
|
|
|
static char *
|
|
|
|
RUBY_DEBUG_LOG_MEM_ENTRY(unsigned int index)
|
|
|
|
{
|
|
|
|
return &debug_log.mem[MAX_DEBUG_LOG_MESSAGE_LEN * index];
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
setup_debug_log(void)
|
|
|
|
{
|
|
|
|
// check RUBY_DEBUG_LOG
|
|
|
|
const char *log_config = getenv("RUBY_DEBUG_LOG");
|
|
|
|
if (log_config) {
|
|
|
|
fprintf(stderr, "RUBY_DEBUG_LOG=%s\n", log_config);
|
2020-08-01 15:51:15 -04:00
|
|
|
|
|
|
|
if (strcmp(log_config, "mem") == 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 03:55:54 -04:00
|
|
|
debug_log.mem = (char *)malloc(MAX_DEBUG_LOG * MAX_DEBUG_LOG_MESSAGE_LEN);
|
|
|
|
if (debug_log.mem == NULL) {
|
|
|
|
fprintf(stderr, "setup_debug_log failed (can't allocate memory)\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
ruby_debug_log_mode |= ruby_debug_log_memory;
|
|
|
|
}
|
|
|
|
else if (strcmp(log_config, "stderr") == 0) {
|
|
|
|
ruby_debug_log_mode |= ruby_debug_log_stderr;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ruby_debug_log_mode |= ruby_debug_log_file;
|
|
|
|
if ((debug_log.output = fopen(log_config, "w")) == NULL) {
|
|
|
|
fprintf(stderr, "can not open %s for RUBY_DEBUG_LOG\n", log_config);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
setvbuf(debug_log.output, NULL, _IONBF, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
rb_nativethread_lock_initialize(&debug_log.lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
// check RUBY_DEBUG_LOG_FILTER
|
|
|
|
const char *filter_config = getenv("RUBY_DEBUG_LOG_FILTER");
|
2020-08-01 15:24:47 -04:00
|
|
|
if (filter_config && strlen(filter_config) > 0) {
|
|
|
|
unsigned int i;
|
|
|
|
for (i=0; i<MAX_DEBUG_LOG_FILTER; i++) {
|
|
|
|
const char *p;
|
|
|
|
if ((p = strchr(filter_config, ',')) == NULL) {
|
|
|
|
if (strlen(filter_config) >= MAX_DEBUG_LOG_FILTER) {
|
|
|
|
fprintf(stderr, "too long: %s (max:%d)\n", filter_config, MAX_DEBUG_LOG_FILTER);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
strncpy(debug_log.filters[i], filter_config, MAX_DEBUG_LOG_FILTER - 1);
|
|
|
|
i++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
size_t n = p - filter_config;
|
|
|
|
if (n >= MAX_DEBUG_LOG_FILTER) {
|
|
|
|
fprintf(stderr, "too long: %s (max:%d)\n", filter_config, MAX_DEBUG_LOG_FILTER);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
strncpy(debug_log.filters[i], filter_config, n);
|
|
|
|
filter_config = p+1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
debug_log.filters_num = i;
|
|
|
|
for (i=0; i<debug_log.filters_num; i++) {
|
|
|
|
fprintf(stderr, "RUBY_DEBUG_LOG_FILTER[%d]=%s\n", i, debug_log.filters[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
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
|
|
|
|
2020-08-01 15:24:47 -04:00
|
|
|
bool
|
|
|
|
ruby_debug_log_filter(const char *func_name)
|
|
|
|
{
|
|
|
|
if (debug_log.filters_num > 0) {
|
|
|
|
for (unsigned int i = 0; i<debug_log.filters_num; i++) {
|
|
|
|
if (strstr(func_name, debug_log.filters[i]) != NULL) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return true;
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char *
|
|
|
|
pretty_filename(const char *path)
|
|
|
|
{
|
|
|
|
// basename is one idea.
|
|
|
|
const char *s;
|
|
|
|
while ((s = strchr(path, '/')) != NULL) {
|
|
|
|
path = s+1;
|
|
|
|
}
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ruby_debug_log(const char *file, int line, const char *func_name, const char *fmt, ...)
|
|
|
|
{
|
|
|
|
char buff[MAX_DEBUG_LOG_MESSAGE_LEN] = {0};
|
|
|
|
int len = 0;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
// message title
|
|
|
|
if (func_name && len < MAX_DEBUG_LOG_MESSAGE_LEN) {
|
|
|
|
r = snprintf(buff + len, MAX_DEBUG_LOG_MESSAGE_LEN, "%s\t", func_name);
|
|
|
|
if (r < 0) rb_bug("ruby_debug_log returns %d\n", r);
|
|
|
|
len += r;
|
|
|
|
}
|
|
|
|
|
|
|
|
// message
|
|
|
|
if (fmt && len < MAX_DEBUG_LOG_MESSAGE_LEN) {
|
|
|
|
va_list args;
|
|
|
|
va_start(args, fmt);
|
|
|
|
r = vsnprintf(buff + len, MAX_DEBUG_LOG_MESSAGE_LEN - len, fmt, args);
|
|
|
|
va_end(args);
|
|
|
|
if (r < 0) rb_bug("ruby_debug_log vsnprintf() returns %d", r);
|
|
|
|
len += r;
|
|
|
|
}
|
|
|
|
|
|
|
|
// optional information
|
|
|
|
|
|
|
|
// C location
|
|
|
|
if (file && len < MAX_DEBUG_LOG_MESSAGE_LEN) {
|
|
|
|
r = snprintf(buff + len, MAX_DEBUG_LOG_MESSAGE_LEN, "\t%s:%d", pretty_filename(file), line);
|
|
|
|
if (r < 0) rb_bug("ruby_debug_log returns %d\n", r);
|
|
|
|
len += r;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Ruby location
|
|
|
|
int ruby_line;
|
|
|
|
const char *ruby_file = rb_source_location_cstr(&ruby_line);
|
|
|
|
if (len < MAX_DEBUG_LOG_MESSAGE_LEN) {
|
|
|
|
if (ruby_file) {
|
|
|
|
r = snprintf(buff + len, MAX_DEBUG_LOG_MESSAGE_LEN - len, "\t%s:%d", pretty_filename(ruby_file), ruby_line);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
r = snprintf(buff + len, MAX_DEBUG_LOG_MESSAGE_LEN - len, "\t");
|
|
|
|
}
|
|
|
|
if (r < 0) rb_bug("ruby_debug_log returns %d\n", r);
|
|
|
|
len += r;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if 0 // not yet
|
|
|
|
// ractor information
|
|
|
|
if (GET_VM()->ractor.cnt > 1) {
|
|
|
|
rb_ractor_t *cr = GET_RACTOR();
|
|
|
|
if (r && len < MAX_DEBUG_LOG_MESSAGE_LEN) {
|
|
|
|
r = snprintf(buff + len, MAX_DEBUG_LOG_MESSAGE_LEN - len, "\tr:#%u/%u",
|
|
|
|
(unsigned int)rb_ractor_id(cr), GET_VM()->ractor.cnt);
|
|
|
|
if (r < 0) rb_bug("ruby_debug_log returns %d\n", r);
|
|
|
|
len += r;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// thread information
|
|
|
|
if (!rb_thread_alone()) {
|
|
|
|
const rb_thread_t *th = GET_THREAD();
|
|
|
|
if (r && len < MAX_DEBUG_LOG_MESSAGE_LEN) {
|
|
|
|
r = snprintf(buff + len, MAX_DEBUG_LOG_MESSAGE_LEN - len, "\tth:%p", (void *)th);
|
|
|
|
if (r < 0) rb_bug("ruby_debug_log returns %d\n", r);
|
|
|
|
len += r;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rb_nativethread_lock_lock(&debug_log.lock);
|
|
|
|
{
|
|
|
|
unsigned int cnt = debug_log.cnt++;
|
|
|
|
|
|
|
|
if (ruby_debug_log_mode & ruby_debug_log_memory) {
|
|
|
|
unsigned int index = cnt % MAX_DEBUG_LOG;
|
|
|
|
char *dst = RUBY_DEBUG_LOG_MEM_ENTRY(index);
|
|
|
|
strncpy(dst, buff, MAX_DEBUG_LOG_MESSAGE_LEN);
|
|
|
|
}
|
|
|
|
if (ruby_debug_log_mode & ruby_debug_log_stderr) {
|
|
|
|
fprintf(stderr, "%4u: %s\n", cnt, buff);
|
|
|
|
}
|
|
|
|
if (ruby_debug_log_mode & ruby_debug_log_file) {
|
|
|
|
fprintf(debug_log.output, "%u\t%s\n", cnt, buff);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
rb_nativethread_lock_unlock(&debug_log.lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
// for debugger
|
|
|
|
static void
|
|
|
|
debug_log_dump(FILE *out, unsigned int n)
|
|
|
|
{
|
|
|
|
if (ruby_debug_log_mode & ruby_debug_log_memory) {
|
|
|
|
unsigned int size = debug_log.cnt > MAX_DEBUG_LOG ? MAX_DEBUG_LOG : debug_log.cnt;
|
|
|
|
unsigned int current_index = debug_log.cnt % MAX_DEBUG_LOG;
|
|
|
|
if (n == 0) n = size;
|
|
|
|
if (n > size) n = size;
|
|
|
|
|
|
|
|
for (unsigned int i=0; i<n; i++) {
|
|
|
|
int index = current_index - size + i;
|
|
|
|
if (index < 0) index += MAX_DEBUG_LOG;
|
|
|
|
VM_ASSERT(index <= MAX_DEBUG_LOG);
|
|
|
|
const char *mesg = RUBY_DEBUG_LOG_MEM_ENTRY(index);;
|
|
|
|
fprintf(out, "%4u: %s\n", debug_log.cnt - size + i, mesg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
fprintf(stderr, "RUBY_DEBUG_LOG=mem is not specified.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// for debuggers
|
|
|
|
|
|
|
|
void
|
|
|
|
ruby_debug_log_print(unsigned int n)
|
|
|
|
{
|
|
|
|
debug_log_dump(stderr, n);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ruby_debug_log_dump(const char *fname, unsigned int n)
|
|
|
|
{
|
|
|
|
FILE *fp = fopen(fname, "w");
|
|
|
|
if (fp == NULL) {
|
|
|
|
fprintf(stderr, "can't open %s. give up.\n", fname);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
debug_log_dump(fp, n);
|
|
|
|
fclose(fp);
|
|
|
|
}
|
2007-06-29 03:57:24 -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
|
|
|
#endif // #if RUBY_DEVEL
|