ruby-changes:31775
From: ko1 <ko1@a...>
Date: Tue, 26 Nov 2013 17:41:55 +0900 (JST)
Subject: [ruby-changes:31775] ko1:r43854 (trunk): * vm_trace.c: prohibit to specify normal events and internal events
ko1 2013-11-26 17:41:44 +0900 (Tue, 26 Nov 2013) New Revision: 43854 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=43854 Log: * vm_trace.c: prohibit to specify normal events and internal events simultaneously. I will introduce special care for internal events later. * ext/-test-/tracepoint/tracepoint.c: test this behavior. * test/-ext-/tracepoint/test_tracepoint.rb: ditto. Modified files: trunk/ChangeLog trunk/NEWS trunk/ext/-test-/tracepoint/tracepoint.c trunk/test/-ext-/tracepoint/test_tracepoint.rb trunk/vm_trace.c Index: ChangeLog =================================================================== --- ChangeLog (revision 43853) +++ ChangeLog (revision 43854) @@ -1,3 +1,13 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Tue Nov 26 17:38:16 2013 Koichi Sasada <ko1@a...> + + * vm_trace.c: prohibit to specify normal events and internal events + simultaneously. + I will introduce special care for internal events later. + + * ext/-test-/tracepoint/tracepoint.c: test this behavior. + + * test/-ext-/tracepoint/test_tracepoint.rb: ditto. + Tue Nov 26 16:30:31 2013 Nobuyoshi Nakada <nobu@r...> * file.c (rb_readlink): fix buffer overflow on a long symlink. since Index: ext/-test-/tracepoint/tracepoint.c =================================================================== --- ext/-test-/tracepoint/tracepoint.c (revision 43853) +++ ext/-test-/tracepoint/tracepoint.c (revision 43854) @@ -69,9 +69,18 @@ tracepoint_track_objspace_events(VALUE s https://github.com/ruby/ruby/blob/trunk/ext/-test-/tracepoint/tracepoint.c#L69 return result; } +static VALUE +tracepoint_specify_normal_and_internal_events(VALUE self) +{ + VALUE tpval = rb_tracepoint_new(0, RUBY_INTERNAL_EVENT_NEWOBJ | RUBY_EVENT_CALL, 0, 0); + rb_tracepoint_enable(tpval); + return Qnil; /* should not be reached */ +} + void Init_tracepoint(void) { VALUE mBug = rb_define_module("Bug"); rb_define_module_function(mBug, "tracepoint_track_objspace_events", tracepoint_track_objspace_events, 0); + rb_define_module_function(mBug, "tracepoint_specify_normal_and_internal_events", tracepoint_specify_normal_and_internal_events, 0); } Index: NEWS =================================================================== --- NEWS (revision 43853) +++ NEWS (revision 43854) @@ -331,3 +331,5 @@ with all sufficient information, see the https://github.com/ruby/ruby/blob/trunk/NEWS#L331 * RUBY_INTERNAL_EVENT_FREEOBJ * RUBY_INTERNAL_EVENT_GC_START * RUBY_INTERNAL_EVENT_GC_END + * Note that you *can not* specify "internal events" with normal events + (such as RUBY_EVENT_CALL, RUBY_EVENT_RETURN) simultaneously. Index: vm_trace.c =================================================================== --- vm_trace.c (revision 43853) +++ vm_trace.c (revision 43854) @@ -105,7 +105,13 @@ thval2thread_t(VALUE thval) https://github.com/ruby/ruby/blob/trunk/vm_trace.c#L105 static rb_event_hook_t * alloc_event_hook(rb_event_hook_func_t func, rb_event_flag_t events, VALUE data, rb_event_hook_flag_t hook_flags) { - rb_event_hook_t *hook = ALLOC(rb_event_hook_t); + rb_event_hook_t *hook; + + if ((events & RUBY_INTERNAL_EVENT_MASK) && (events & ~RUBY_INTERNAL_EVENT_MASK)) { + rb_raise(rb_eTypeError, "Can not specify normal event and internal event simultaneously."); + } + + hook = ALLOC(rb_event_hook_t); hook->hook_flags = hook_flags; hook->events = events; hook->func = func; Index: test/-ext-/tracepoint/test_tracepoint.rb =================================================================== --- test/-ext-/tracepoint/test_tracepoint.rb (revision 43853) +++ test/-ext-/tracepoint/test_tracepoint.rb (revision 43854) @@ -50,4 +50,8 @@ class TestTracepointObj < Test::Unit::Te https://github.com/ruby/ruby/blob/trunk/test/-ext-/tracepoint/test_tracepoint.rb#L50 assert_operator gc_start_count, :>=, gc_end_count assert_operator stat2[:count] - stat1[:count] - 1, :<=, gc_end_count end + + def test_tracepoint_specify_normal_and_internal_events + assert_raise(TypeError){ Bug.tracepoint_specify_normal_and_internal_events } + end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/