зеркало из https://github.com/github/ruby.git
[DOC] Update `set_trace_func` document
- Clarify the class of event parameters - Represent event names as strings - Update the example to show the above
This commit is contained in:
Родитель
3b7c8e90da
Коммит
ba8a7ab8a8
51
vm_trace.c
51
vm_trace.c
|
@ -521,25 +521,25 @@ static void call_trace_func(rb_event_flag_t, VALUE data, VALUE self, ID id, VALU
|
|||
*
|
||||
* _proc_ takes up to six parameters:
|
||||
*
|
||||
* * an event name
|
||||
* * a filename
|
||||
* * an event name string
|
||||
* * a filename string
|
||||
* * a line number
|
||||
* * an object id
|
||||
* * a binding
|
||||
* * the name of a class
|
||||
* * a method name symbol, or nil
|
||||
* * a binding, or nil
|
||||
* * the class, module, or nil
|
||||
*
|
||||
* _proc_ is invoked whenever an event occurs.
|
||||
*
|
||||
* Events are:
|
||||
*
|
||||
* +c-call+:: call a C-language routine
|
||||
* +c-return+:: return from a C-language routine
|
||||
* +call+:: call a Ruby method
|
||||
* +class+:: start a class or module definition
|
||||
* +end+:: finish a class or module definition
|
||||
* +line+:: execute code on a new line
|
||||
* +raise+:: raise an exception
|
||||
* +return+:: return from a Ruby method
|
||||
* <code>"c-call"</code>:: call a C-language routine
|
||||
* <code>"c-return"</code>:: return from a C-language routine
|
||||
* <code>"call"</code>:: call a Ruby method
|
||||
* <code>"class"</code>:: start a class or module definition
|
||||
* <code>"end"</code>:: finish a class or module definition
|
||||
* <code>"line"</code>:: execute code on a new line
|
||||
* <code>"raise"</code>:: raise an exception
|
||||
* <code>"return"</code>:: return from a Ruby method
|
||||
*
|
||||
* Tracing is disabled within the context of _proc_.
|
||||
*
|
||||
|
@ -550,24 +550,25 @@ static void call_trace_func(rb_event_flag_t, VALUE data, VALUE self, ID id, VALU
|
|||
* end
|
||||
* end
|
||||
*
|
||||
* set_trace_func proc { |event, file, line, id, binding, classname|
|
||||
* printf "%8s %s:%-2d %10s %8s\n", event, file, line, id, classname
|
||||
* set_trace_func proc { |event, file, line, id, binding, class_or_module|
|
||||
* printf "%8s %s:%-2d %16p %14p\n", event, file, line, id, class_or_module
|
||||
* }
|
||||
* t = Test.new
|
||||
* t.test
|
||||
*
|
||||
* Produces:
|
||||
*
|
||||
* line prog.rb:11 false
|
||||
* c-call prog.rb:11 new Class
|
||||
* c-call prog.rb:11 initialize Object
|
||||
* c-return prog.rb:11 initialize Object
|
||||
* c-return prog.rb:11 new Class
|
||||
* line prog.rb:12 false
|
||||
* call prog.rb:2 test Test
|
||||
* line prog.rb:3 test Test
|
||||
* line prog.rb:4 test Test
|
||||
* return prog.rb:4 test Test
|
||||
* c-return prog.rb:8 :set_trace_func Kernel
|
||||
* line prog.rb:11 nil nil
|
||||
* c-call prog.rb:11 :new Class
|
||||
* c-call prog.rb:11 :initialize BasicObject
|
||||
* c-return prog.rb:11 :initialize BasicObject
|
||||
* c-return prog.rb:11 :new Class
|
||||
* line prog.rb:12 nil nil
|
||||
* call prog.rb:2 :test Test
|
||||
* line prog.rb:3 :test Test
|
||||
* line prog.rb:4 :test Test
|
||||
* return prog.rb:5 :test Test
|
||||
*
|
||||
* Note that for +c-call+ and +c-return+ events, the binding returned is the
|
||||
* binding of the nearest Ruby method calling the C method, since C methods
|
||||
|
|
Загрузка…
Ссылка в новой задаче