From: "ko1 (Koichi Sasada)" Date: 2022-04-27T06:52:16+00:00 Subject: [ruby-core:108411] [Ruby master Bug#18740] Use of rightward assignment changes line number needed for line-targeted TracePoint Issue #18740 has been updated by ko1 (Koichi Sasada). FYI: Using debug.gem ``` [master]$ rdbg target.rb [1, 10] in target.rb => 1| def foo 2| File.read(__FILE__) 3| .split("\n") 4| .map(&:strip) 5| .reject(&:empty?) 6| .first(10) => lines 7| 8| puts lines 9| end 10| =>#0
at target.rb:1 (rdbg) b 2 # break command #0 BP - Line /mnt/c/ko1/src/rb/ruby-debug/target.rb:6 (call) (rdbg) c # continue command [1, 10] in target.rb 1| def foo 2| File.read(__FILE__) 3| .split("\n") 4| .map(&:strip) 5| .reject(&:empty?) => 6| .first(10) => lines 7| 8| puts lines 9| end 10| =>#0 Object#foo at target.rb:6 #1
at target.rb:11 Stop by #0 BP - Line /mnt/c/ko1/src/rb/ruby-debug/target.rb:6 (call) (rdbg) ``` ---------------------------------------- Bug #18740: Use of rightward assignment changes line number needed for line-targeted TracePoint https://bugs.ruby-lang.org/issues/18740#change-97446 * Author: hurricup (Alexandr Evstigneev) * Status: Open * Priority: Normal * Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN ---------------------------------------- Affected ruby 3.1.1 Sample illustrating the problem (`test.rb`): ``` def foo File.read("test.rb") .split("\n") .map(&:strip) .reject(&:empty?) .first(10) => lines puts lines end TracePoint.new(:line){ puts 'Hi' }.enable(target: RubyVM::InstructionSequence.of(method :foo), target_line: 2) foo ``` produces ``` :212:in `enable': can not enable any hooks (ArgumentError) ``` iseq for method: ``` == disasm: # (catch: FALSE) local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1]) [ 1] lines@0 0000 putnil ( 6)[LiCa] 0001 putnil 0002 putobject false 0004 putnil 0005 putnil 0006 opt_getinlinecache 15, ( 2) 0009 putobject true 0011 getconstant :File 0013 opt_setinlinecache 0015 putstring "test.rb" 0017 opt_send_without_block 0019 putstring "\n" ( 3) 0021 opt_send_without_block 0023 putobject :strip ( 4) 0025 send , nil 0028 putobject :empty? ( 5) 0030 send , nil 0033 putobject 10 ( 6) 0035 opt_send_without_block 0037 dup 0038 setlocal_WC_0 lines@0 0040 jump 88 0042 putspecialobject 1 ( 2) 0044 topn 4 0046 branchif 64 0048 putobject NoMatchingPatternError 0050 putspecialobject 1 0052 putobject "%p: %s" 0054 topn 4 0056 topn 7 0058 opt_send_without_block 0060 opt_send_without_block 0062 jump 84 0064 putobject NoMatchingPatternKeyError 0066 putspecialobject 1 0068 putobject "%p: %s" 0070 topn 4 0072 topn 7 0074 opt_send_without_block 0076 topn 7 0078 topn 9 0080 opt_send_without_block 0082 opt_send_without_block 0084 adjuststack 7 0086 jump 90 0088 adjuststack 6 ( 6) 0090 putself ( 8)[Li] 0091 getlocal_WC_0 lines@0 0093 opt_send_without_block 0095 leave ( 9)[Re] ``` Works like a charm without `=> lines` -- https://bugs.ruby-lang.org/ Unsubscribe: