mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* eval.c (rb_call0): call_cfunc() should be protected.
* test/ruby/test_settracefunc.rb: added test for c-return. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@8165 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
a658ebd5bc
commit
9b03ab6f93
3 changed files with 33 additions and 20 deletions
|
@ -1,3 +1,9 @@
|
|||
Wed Mar 16 23:36:02 2005 Shugo Maeda <shugo@ruby-lang.org>
|
||||
|
||||
* eval.c (rb_call0): call_cfunc() should be protected.
|
||||
|
||||
* test/ruby/test_settracefunc.rb: added test for c-return.
|
||||
|
||||
Wed Mar 16 22:20:25 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
|
||||
|
||||
* object.c (str_to_id): fixed typo.
|
||||
|
|
27
eval.c
27
eval.c
|
@ -5470,7 +5470,6 @@ rb_call0(klass, recv, id, oid, argc, argv, body, nosuper)
|
|||
volatile VALUE result = Qnil;
|
||||
int itr;
|
||||
static int tick;
|
||||
volatile int trace_status = 0; /* 0:none 1:cfunc 2:rfunc */
|
||||
TMP_PROTECT;
|
||||
|
||||
switch (ruby_iter->iter) {
|
||||
|
@ -5508,11 +5507,22 @@ rb_call0(klass, recv, id, oid, argc, argv, body, nosuper)
|
|||
len, rb_class2name(klass), rb_id2name(id));
|
||||
}
|
||||
if (trace_func) {
|
||||
int state;
|
||||
|
||||
call_trace_func("c-call", ruby_current_node, recv, id, klass);
|
||||
trace_status = 1; /* cfunc */
|
||||
}
|
||||
PUSH_TAG(PROT_FUNC);
|
||||
if ((state = EXEC_TAG()) == 0) {
|
||||
result = call_cfunc(body->nd_cfnc, recv, len, argc, argv);
|
||||
}
|
||||
POP_TAG();
|
||||
ruby_current_node = ruby_frame->node;
|
||||
call_trace_func("c-return", ruby_current_node, recv, id, klass);
|
||||
if (state) JUMP_TAG(state);
|
||||
}
|
||||
else {
|
||||
result = call_cfunc(body->nd_cfnc, recv, len, argc, argv);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
/* for attr get/set */
|
||||
|
@ -5542,6 +5552,7 @@ rb_call0(klass, recv, id, oid, argc, argv, body, nosuper)
|
|||
int state;
|
||||
VALUE *local_vars; /* OK */
|
||||
NODE *saved_cref = 0;
|
||||
int trace_return = 0;
|
||||
|
||||
PUSH_SCOPE();
|
||||
|
||||
|
@ -5637,7 +5648,7 @@ rb_call0(klass, recv, id, oid, argc, argv, body, nosuper)
|
|||
|
||||
if (trace_func) {
|
||||
call_trace_func("call", b2, recv, id, klass);
|
||||
trace_status = 2; /* rfunc */
|
||||
trace_return = 1;
|
||||
}
|
||||
result = rb_eval(recv, body);
|
||||
}
|
||||
|
@ -5650,14 +5661,8 @@ rb_call0(klass, recv, id, oid, argc, argv, body, nosuper)
|
|||
POP_CLASS();
|
||||
POP_SCOPE();
|
||||
ruby_cref = saved_cref;
|
||||
switch (trace_status) {
|
||||
case 0: break; /* none */
|
||||
case 1: /* cfunc */
|
||||
call_trace_func("c-return", body, recv, id, klass);
|
||||
break;
|
||||
case 2: /* rfunc */
|
||||
if (trace_return) {
|
||||
call_trace_func("return", body, recv, id, klass);
|
||||
break;
|
||||
}
|
||||
switch (state) {
|
||||
case 0:
|
||||
|
|
|
@ -11,16 +11,18 @@ class TestSetTraceFunc < Test::Unit::TestCase
|
|||
a = 1
|
||||
foo
|
||||
a
|
||||
b = 1 + 2
|
||||
set_trace_func nil
|
||||
|
||||
assert_equal(["line", 11], events.shift) # line "a = 1"
|
||||
assert_equal(["line", 12], events.shift) # line "foo"
|
||||
assert_equal(["call", 4], events.shift) # call foo
|
||||
event, lineno = events.shift # return
|
||||
assert_equal("return", event)
|
||||
assert_not_equal(4, lineno)# it should be 4 but cannot be expected in 1.8
|
||||
assert_equal(["return", 4], events.shift) # return foo
|
||||
assert_equal(["line", 13], events.shift) # line "a"
|
||||
assert_equal(["line", 14], events.shift) # line "set_trace_func nil"
|
||||
assert_equal(["c-call", 14], events.shift) # c-call set_trace_func
|
||||
assert_equal(["line", 14], events.shift) # line "b = 1 + 2"
|
||||
assert_equal(["c-call", 14], events.shift) # c-call Fixnum#+
|
||||
assert_equal(["c-return", 14], events.shift) # c-return Fixnum#+
|
||||
assert_equal(["line", 15], events.shift) # line "set_trace_func nil"
|
||||
assert_equal(["c-call", 15], events.shift) # c-call set_trace_func
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue