From: "hurricup (Alexandr Evstigneev)" Date: 2022-04-27T06:24:20+00:00 Subject: [ruby-core:108409] [Ruby master Bug#18740] Use of rightward assignment changes line number needed for line-targeted TracePoint Issue #18740 has been updated by hurricup (Alexandr Evstigneev). jeremyevans0 (Jeremy Evans) wrote in #note-1: > You can set a tracepoint, rightward assignment just moves the line you need to target. In your example, you have to use `target_line: 6` instead of `target_line: 2`. I'm not sure if this is considered a bug or not. Yes, I can see that. But his is not intuitive for the debugger user and too big difference for the case without `=> lines`, where you can use line 2. This is not a bug (like segfault or smth) but more like usability issue. Feels like you should be able to debug full expression, not only assigning part. ---------------------------------------- Bug #18740: Use of rightward assignment changes line number needed for line-targeted TracePoint https://bugs.ruby-lang.org/issues/18740#change-97444 * 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: