Get class location from class object

后端 未结 7 2151
北恋
北恋 2020-12-13 23:29

I have a bunch of code to look at, and now it is debugging time. Since I have never been a fan of Ruby\'s debugger I am looking for a way of going through code and reading i

7条回答
  •  再見小時候
    2020-12-14 00:27

    Frankly, given your described code organization, I think ruby-debug is the easy route to discovering the destination of your call-site: just set breakpoint and step in. If you're really allergic to the debugger, you could instrument the call site with Kernel#set_trace_func.

    $max_trace = 10
    set_trace_func proc { |event, file, line, id, binding, classname|
      printf "%8s %s:%-2d %10s %8s\n", event, file, line, id, classname
      $max_trace -= 1 
      set_trace_func(nil) unless $max_trace > 0
    }
    

提交回复
热议问题