class Tracer

tracer main class

Constants

EVENT_SYMBOL

Symbol table used for displaying trace information

Single

Reference to singleton instance of Tracer

display_c_call
display_process_id
display_thread_id
stdout
verbose

Attributes

display_c_call[RW]

display C-routine calls in trace output (defaults to false)

display_c_call?[RW]

display C-routine calls in trace output (defaults to false)

display_process_id[RW]

display process id in trace output (defaults to false)

display_process_id?[RW]

display process id in trace output (defaults to false)

display_thread_id[RW]

display thread id in trace output (defaults to true)

display_thread_id?[RW]

display thread id in trace output (defaults to true)

stdout[RW]

output stream used to output trace (defaults to STDOUT)

stdout_mutex[R]

mutex lock used by tracer for displaying trace output

verbose[RW]

display additional debug information (defaults to false)

verbose?[RW]

display additional debug information (defaults to false)

Public Class Methods

add_filter(p = proc) click to toggle source

Used to filter unwanted trace output

Example which only outputs lines of code executed within the Kernel class:

Tracer.add_filter do |event, file, line, id, binding, klass, *rest|
  "Kernel" == klass.to_s
end
# File rake/lib/tracer.rb, line 275
def Tracer.add_filter(p = proc)
  Single.add_filter(p)
end
off() click to toggle source

Disable tracing

# File rake/lib/tracer.rb, line 248
def Tracer.off
  Single.off
end
on() { || ... } click to toggle source

Start tracing

Example

Tracer.on
# code to trace here
Tracer.off

You can also pass a block:

Tracer.on {
  # trace everything in this block
}
# File rake/lib/tracer.rb, line 237
def Tracer.on
  if block_given?
    Single.on{yield}
  else
    Single.on
  end
end
set_get_line_procs(file_name, p = proc) click to toggle source

Register an event handler p which is called everytime a line in file_name is executed.

Example:

Tracer.set_get_line_procs("example.rb", lambda { |line|
  puts "line number executed is #{line}"
})
# File rake/lib/tracer.rb, line 262
def Tracer.set_get_line_procs(file_name, p = proc)
  Single.set_get_line_procs(file_name, p)
end
trace_func(*vars) click to toggle source
# File rake/lib/debug.rb, line 16
def Tracer.trace_func(*vars)
  Single.trace_func(*vars)
end