diff options
Diffstat (limited to 'vm_trace.c')
-rw-r--r-- | vm_trace.c | 44 |
1 files changed, 39 insertions, 5 deletions
diff --git a/vm_trace.c b/vm_trace.c index 3d305c68ef..e70d4aad04 100644 --- a/vm_trace.c +++ b/vm_trace.c @@ -868,7 +868,7 @@ tracepoint_attr_self(VALUE tpval) } /* - * Return value from +:return+ and +c_return+ event + * Return value from +:return+, +c_return+, and +b_return+ event */ static VALUE tracepoint_attr_return_value(VALUE tpval) @@ -950,8 +950,8 @@ rb_tracepoint_disable(VALUE tpval) /* * call-seq: - * trace.enable -> trace - * trace.enable { |obj| block } -> obj + * trace.enable -> trace + * trace.enable { block } -> obj * * Activates the trace * @@ -962,6 +962,23 @@ rb_tracepoint_disable(VALUE tpval) * trace.enabled? #=> true * trace.enable #=> RuntimeError * + * If a block is given, the trace will only be enabled within the scope of the + * block. Note: You cannot access event hooks within the block. + * + * trace.enabled? + * #=> false + * + * trace.enable do + * trace.enabled? + * # only enabled for this block + * end + * + * trace.enabled? + * #=> false + * + * trace.enable { p tp.lineno } + * #=> RuntimeError: access from outside + * */ static VALUE tracepoint_enable_m(VALUE tpval) @@ -983,8 +1000,8 @@ tracepoint_enable_m(VALUE tpval) /* * call-seq: - * trace.disable -> trace - * trace.disable { |obj| block } -> obj + * trace.disable -> trace + * trace.disable { block } -> obj * * Deactivates the trace * @@ -995,6 +1012,23 @@ tracepoint_enable_m(VALUE tpval) * trace.enabled? #=> false * trace.disable #=> RuntimeError * + * If a block is given, the trace will only be disable within the scope of the + * block. Note: You cannot access event hooks within the block. + * + * trace.enabled? + * #=> true + * + * trace.disable do + * trace.enabled? + * # only disabled for this block + * end + * + * trace.enabled? + * #=> true + * + * trace.enable { p trace.lineno } + * #=> RuntimeError: access from outside + * */ static VALUE tracepoint_disable_m(VALUE tpval) |