Project

General

Profile

Actions

Bug #7513

closed

TracePoint#enable/disable should not cause error

Added by ko1 (Koichi Sasada) about 12 years ago. Updated about 12 years ago.

Status:
Closed
Target version:
ruby -v:
ruby 2.0.0dev (2012-12-01 trunk 38127) [i386-mswin32_100]
Backport:
[ruby-core:50561]

Description

=begin
= Abstract

TracePoint#enable/disable should not cause error if it is enabled or disabled.

= Problem

The following code cause error because it calls "enable" on enabled tracepoint.

trace = TracePoint.trace{}
p trace.enabled? #=> true
trace.enable #=> `enable': trace is already enable (RuntimeError)

However, similar feature "GC.enable" and "GC.disable" don't cause error.
They only return previous status.

= Solution

TracePoint#enable and disable should align GC.enable/disable.

trace = TracePoint.trace{} # enable
trace.enable # do nothing, and return true (enabled)
trace.enable{
...
} # after block, trace is still enable

Any comments?

=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0