diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-11-26 08:41:44 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-11-26 08:41:44 +0000 |
commit | 5b40cb6a2cc6085a346f0f34be03b6ffdaeda8ca (patch) | |
tree | 67211fab4ded1d08a0aa737446a5f20428b599a2 | |
parent | 079009fb93678e902777669c663ed6f651a05c85 (diff) |
* 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.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43854 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | ext/-test-/tracepoint/tracepoint.c | 9 | ||||
-rw-r--r-- | test/-ext-/tracepoint/test_tracepoint.rb | 4 | ||||
-rw-r--r-- | vm_trace.c | 8 |
5 files changed, 32 insertions, 1 deletions
@@ -1,3 +1,13 @@ +Tue Nov 26 17:38:16 2013 Koichi Sasada <ko1@atdot.net> + + * 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@ruby-lang.org> * file.c (rb_readlink): fix buffer overflow on a long symlink. since @@ -331,3 +331,5 @@ with all sufficient information, see the ChangeLog file. * 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. diff --git a/ext/-test-/tracepoint/tracepoint.c b/ext/-test-/tracepoint/tracepoint.c index a974c2c611..ebe2996622 100644 --- a/ext/-test-/tracepoint/tracepoint.c +++ b/ext/-test-/tracepoint/tracepoint.c @@ -69,9 +69,18 @@ tracepoint_track_objspace_events(VALUE self) 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); } diff --git a/test/-ext-/tracepoint/test_tracepoint.rb b/test/-ext-/tracepoint/test_tracepoint.rb index 967c65f368..27fcceceb5 100644 --- a/test/-ext-/tracepoint/test_tracepoint.rb +++ b/test/-ext-/tracepoint/test_tracepoint.rb @@ -50,4 +50,8 @@ class TestTracepointObj < Test::Unit::TestCase 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 diff --git a/vm_trace.c b/vm_trace.c index 5930274be8..369bd7c4f1 100644 --- a/vm_trace.c +++ b/vm_trace.c @@ -105,7 +105,13 @@ thval2thread_t(VALUE thval) 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; |