From 5b40cb6a2cc6085a346f0f34be03b6ffdaeda8ca Mon Sep 17 00:00:00 2001 From: ko1 Date: Tue, 26 Nov 2013 08:41:44 +0000 Subject: * 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 --- ChangeLog | 10 ++++++++++ NEWS | 2 ++ ext/-test-/tracepoint/tracepoint.c | 9 +++++++++ test/-ext-/tracepoint/test_tracepoint.rb | 4 ++++ vm_trace.c | 8 +++++++- 5 files changed, 32 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index e834f8ff92..a5c31582f7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +Tue Nov 26 17:38:16 2013 Koichi Sasada + + * 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 * file.c (rb_readlink): fix buffer overflow on a long symlink. since diff --git a/NEWS b/NEWS index d93a8ff346..1b27c83948 100644 --- a/NEWS +++ b/NEWS @@ -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; -- cgit v1.2.3