From: Kent Sibilev Date: 2006-07-30T01:44:30+09:00 Subject: Re: Trace API bug Anyone? On 7/21/06, Kent Sibilev wrote: > Does this patch make any sense? > > Index: eval.c > =================================================================== > RCS file: /src/ruby/eval.c,v > retrieving revision 1.616.2.182 > diff -u -r1.616.2.182 eval.c > --- eval.c 20 Jul 2006 07:04:14 -0000 1.616.2.182 > +++ eval.c 21 Jul 2006 05:02:24 -0000 > @@ -5837,8 +5837,14 @@ > break; > > case NODE_BMETHOD: > - ruby_frame->flags |= FRAME_DMETH; > - result = proc_invoke(body->nd_cval, rb_ary_new4(argc, argv), > recv, klass); > + { > + struct BLOCK *data; > + ruby_frame->flags |= FRAME_DMETH; > + Data_Get_Struct(body->nd_cval, struct BLOCK, data); > + EXEC_EVENT_HOOK(RUBY_EVENT_CALL, data->body, recv, id, klass); > + result = proc_invoke(body->nd_cval, rb_ary_new4(argc, > argv), recv, klass); > + EXEC_EVENT_HOOK(RUBY_EVENT_RETURN, body, recv, id, klass); > + } > break; > > case NODE_SCOPE: > > > > On 7/20/06, Kent Sibilev wrote: > > Hi Everyone, > > > > I've noticed a small bug while playing with my ruby-debug extension. I > > think the current Ruby interpreter misses a 'call' event when calling > > a method defined with Module#define_method. Below is the small script > > that proves it: > > > > $ cat -n t.rb > > 1 class A > > 2 def m1 > > 3 "m1 called\n" > > 4 end > > 5 define_method("m2") do > > 6 "m2 called\n" > > 7 end > > 8 end > > 9 > > 10 a = A.new > > 11 set_trace_func proc {|event, file, line, *args| puts "#{event}:#{line}"} > > 12 > > 13 a.m1 > > 14 a.m2 > > 15 > > $ ruby t.rb > > line:13 > > call:2 > > line:3 > > return:4 > > line:14 > > line:6 > > > > Notice how the invocation of A#m2 doesn't emit any 'call' or 'c-call' events. > > > > -- > > Kent > > --- > > http://www.datanoise.com > > > > > > > -- > Kent > --- > http://www.datanoise.com > > -- Kent --- http://www.datanoise.com