summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNguyễn Quang Minh <[email protected]>2020-08-06 09:56:24 +0700
committer<[email protected]>2020-08-06 11:56:24 +0900
commit1819652578e8f9fe3606f7a716ec4e427fc55f0a ()
tree4b1fc8e695a0de3823f0c8542c71e886442404b6
parentbbbec4b87c1e66909f5bee9acd3e460b8c1ad663 (diff)
[Feature #16513] TracePoint#inspect returns "... file:line" (#3391)
* Fix debug documents to match Thread#to_s change (Feature #16412 ticket) * TracePoint#inspect returns "... file:line" (Feature #16513) * Guard older version of Ruby in Tracepoint inspection tests * Focus on current thread only when running TracePoint inspection test
Notes: Merged-By: ko1 <[email protected]>
-rw-r--r--lib/debug.rb8
-rw-r--r--spec/ruby/core/tracepoint/enable_spec.rb14
-rw-r--r--spec/ruby/core/tracepoint/inspect_spec.rb95
-rw-r--r--test/ruby/test_settracefunc.rb4
-rw-r--r--trace_point.rb2
-rw-r--r--vm_trace.c6
6 files changed, 116 insertions, 13 deletions
@@ -1012,8 +1012,8 @@ EOHELP
#
# (rdb:1) DEBUGGER__.thread_list_all
# +1 #<Thread:0x007fb2320c03f0 run> debug_me.rb.rb:3
- # 2 #<Thread:0x007fb23218a538@debug_me.rb.rb:3 sleep>
- # 3 #<Thread:0x007fb23218b0f0@debug_me.rb.rb:3 sleep>
# [1, 2, 3]
#
# Your current thread is indicated by a <b>+</b>
@@ -1022,8 +1022,8 @@ EOHELP
#
# (rdb:1) th l
# +1 #<Thread:0x007f99328c0410 run> debug_me.rb:3
- # 2 #<Thread:0x007f9932938230@debug_me.rb:3 sleep> debug_me.rb:3
- # 3 #<Thread:0x007f9932938e10@debug_me.rb:3 sleep> debug_me.rb:3
#
# See DEBUGGER__ for more usage.
@@ -123,6 +123,18 @@ describe 'TracePoint#enable' do
end
describe "when nested" do
it "enables both TracePoints but only calls the respective callbacks" do
called = false
first = TracePoint.new(:line) do |tp|
@@ -146,7 +158,7 @@ describe 'TracePoint#enable' do
end
all.uniq.should == [second]
- inspects.uniq.should == ["#<TracePoint:line@#{__FILE__}:#{line}>"]
called.should == true
end
end
@@ -2,6 +2,18 @@ require_relative '../../spec_helper'
require_relative 'fixtures/classes'
describe 'TracePoint#inspect' do
it 'returns a string containing a human-readable TracePoint status' do
TracePoint.new(:line) {}.inspect.should == '#<TracePoint:disabled>'
end
@@ -16,7 +28,54 @@ describe 'TracePoint#inspect' do
line = __LINE__
end
- inspect.should == "#<TracePoint:line@#{__FILE__}:#{line}>"
end
it 'returns a String showing the event, path and line for a :class event' do
@@ -31,6 +90,38 @@ describe 'TracePoint#inspect' do
end
end
- inspect.should == "#<TracePoint:class@#{__FILE__}:#{line}>"
end
end
@@ -937,9 +937,9 @@ class TestSetTraceFunc < Test::Unit::TestCase
when :line
assert_match(/ in /, str)
when :call, :c_call
- assert_match(/call \`/, str) # #<TracePoint:c_call `inherited'@../trunk/test.rb:11>
when :return, :c_return
- assert_match(/return \`/, str) # #<TracePoint:return `m'@../trunk/test.rb:3>
when /thread/
assert_match(/\#<Thread:/, str) # #<TracePoint:thread_end of #<Thread:0x87076c0>>
else
@@ -183,7 +183,7 @@ class TracePoint
# t.enable(target: method(:m1))
#
# m1
- # # prints #<TracePoint:[email protected]:4 in `m1'>
# m2
# # prints nothing
#
@@ -1456,7 +1456,7 @@ tracepoint_inspect(rb_execution_context_t *ec, VALUE self)
VALUE sym = rb_tracearg_method_id(trace_arg);
if (NIL_P(sym))
break;
- return rb_sprintf("#<TracePoint:%"PRIsVALUE"@%"PRIsVALUE":%d in `%"PRIsVALUE"'>",
rb_tracearg_event(trace_arg),
rb_tracearg_path(trace_arg),
FIX2INT(rb_tracearg_lineno(trace_arg)),
@@ -1466,7 +1466,7 @@ tracepoint_inspect(rb_execution_context_t *ec, VALUE self)
case RUBY_EVENT_C_CALL:
case RUBY_EVENT_RETURN:
case RUBY_EVENT_C_RETURN:
- return rb_sprintf("#<TracePoint:%"PRIsVALUE" `%"PRIsVALUE"'@%"PRIsVALUE":%d>",
rb_tracearg_event(trace_arg),
rb_tracearg_method_id(trace_arg),
rb_tracearg_path(trace_arg),
@@ -1479,7 +1479,7 @@ tracepoint_inspect(rb_execution_context_t *ec, VALUE self)
default:
break;
}
- return rb_sprintf("#<TracePoint:%"PRIsVALUE"@%"PRIsVALUE":%d>",
rb_tracearg_event(trace_arg),
rb_tracearg_path(trace_arg),
FIX2INT(rb_tracearg_lineno(trace_arg)));