From 084e7e31b257f6ac859769553b4c1c6ca2930152 Mon Sep 17 00:00:00 2001 From: Koichi Sasada Date: Mon, 16 Nov 2020 16:40:04 +0900 Subject: remain enabled and line specified trace points If two or more tracepoints enabled with the same target and with different target lines, the only last line is activated. This patch fixes this issue by remaining existing trace instructions. [Bug #17302] --- test/ruby/test_settracefunc.rb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'test') diff --git a/test/ruby/test_settracefunc.rb b/test/ruby/test_settracefunc.rb index 9579974407..2caf71c000 100644 --- a/test/ruby/test_settracefunc.rb +++ b/test/ruby/test_settracefunc.rb @@ -2175,6 +2175,31 @@ class TestSetTraceFunc < Test::Unit::TestCase assert_equal 'target_line is specified, but line event is not specified', e.message end + def test_tracepoint_enable_with_target_line_two_times + events = [] + line_0 = __LINE__ + code1 = proc{ + events << 1 # tp1 + events << 2 + events << 3 # tp2 + } + + tp1 = TracePoint.new(:line) do |tp| + events << :tp1 + end + tp2 = TracePoint.new(:line) do |tp| + events << :tp2 + end + + tp1.enable(target: code1, target_line: line_0 + 2) do + tp2.enable(target: code1, target_line: line_0 + 4) do + # two hooks + code1.call + end + end + assert_equal [:tp1, 1, 2, :tp2, 3], events + end + def test_script_compiled events = [] tp = TracePoint.new(:script_compiled){|tp| -- cgit v1.2.3