diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-12-29 16:44:09 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-12-29 16:44:09 +0000 |
commit | 94f4a0e91ee7077bcb4391a6f754c6ec58e78a15 (patch) | |
tree | 6adca3ea735006170cc986a21fbd191132846d47 /vm_trace.c | |
parent | fd7d4a871cd3ae035a4a48eb728f9d3fcb37e669 (diff) | |
download | bundler-94f4a0e91ee7077bcb4391a6f754c6ec58e78a15.tar.gz |
`TracePoint#enable(target_thraed:)` [Feature #15473]
* vm_trace.c (tracepoint_enable_m): `TracePoint#enable` supports
`target_thread:` keyword to filter a target thread.
[Feature #15473]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66640 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_trace.c')
-rw-r--r-- | vm_trace.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/vm_trace.c b/vm_trace.c index 82c5249abc..79b72876c3 100644 --- a/vm_trace.c +++ b/vm_trace.c @@ -1327,6 +1327,7 @@ rb_tracepoint_disable(VALUE tpval) } } tp->tracing = 0; + tp->target_th = NULL; return Qundef; } @@ -1398,11 +1399,22 @@ rb_hook_list_remove_tracepoint(rb_hook_list_t *list, VALUE tpval) * */ static VALUE -tracepoint_enable_m(VALUE tpval, VALUE target, VALUE target_line) +tracepoint_enable_m(VALUE tpval, VALUE target, VALUE target_line, VALUE target_thread) { rb_tp_t *tp = tpptr(tpval); int previous_tracing = tp->tracing; + /* check target_thread */ + if (RTEST(target_thread)) { + if (tp->target_th) { + rb_raise(rb_eArgError, "can not override target_thread filter"); + } + tp->target_th = rb_thread_ptr(target_thread); + } + else { + tp->target_th = NULL; + } + if (NIL_P(target)) { if (!NIL_P(target_line)) { rb_raise(rb_eArgError, "only target_line is specified"); @@ -1801,7 +1813,7 @@ Init_vm_trace(void) */ rb_define_singleton_method(rb_cTracePoint, "trace", tracepoint_trace_s, -1); - rb_define_method(rb_cTracePoint, "__enable", tracepoint_enable_m, 2); + rb_define_method(rb_cTracePoint, "__enable", tracepoint_enable_m, 3); rb_define_method(rb_cTracePoint, "disable", tracepoint_disable_m, 0); rb_define_method(rb_cTracePoint, "enabled?", rb_tracepoint_enabled_p, 0); |