diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-04-25 08:17:24 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-04-25 08:17:24 +0000 |
commit | 5ad56e7c0b5a99df526d3bffbb3c6d3461af73be (patch) | |
tree | 775945357a22bac1bdfce41f16b7e1ee23c7a8d0 /vm_backtrace.c | |
parent | 0adeb1c8ab237280896091e9d2034fabf0d050ab (diff) | |
download | ruby-5ad56e7c0b5a99df526d3bffbb3c6d3461af73be.tar.gz |
load.c: backtrace of circular require
* load.c (load_lock): print backtrace of circular require via
`Warning.warn` [ruby-core:80850] [Bug #13505]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58471 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_backtrace.c')
-rw-r--r-- | vm_backtrace.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/vm_backtrace.c b/vm_backtrace.c index 6a5dadf709..a5ab52e349 100644 --- a/vm_backtrace.c +++ b/vm_backtrace.c @@ -772,10 +772,15 @@ rb_backtrace(void) vm_backtrace_print(stderr); } +struct print_to_arg { + VALUE (*iter)(VALUE recv, VALUE str); + VALUE output; +}; + static void oldbt_print_to(void *data, VALUE file, int lineno, VALUE name) { - VALUE output = (VALUE)data; + const struct print_to_arg *arg = data; VALUE str = rb_sprintf("\tfrom %"PRIsVALUE":%d:in ", file, lineno); if (NIL_P(name)) { @@ -784,16 +789,19 @@ oldbt_print_to(void *data, VALUE file, int lineno, VALUE name) else { rb_str_catf(str, " `%"PRIsVALUE"'\n", name); } - rb_io_write(output, str); + (*arg->iter)(arg->output, str); } void -rb_backtrace_print_to(VALUE output) +rb_backtrace_each(VALUE (*iter)(VALUE recv, VALUE str), VALUE output) { struct oldbt_arg arg; + struct print_to_arg parg; + parg.iter = iter; + parg.output = output; arg.func = oldbt_print_to; - arg.data = (void *)output; + arg.data = &parg; backtrace_each(GET_THREAD(), oldbt_init, oldbt_iter_iseq, |