# $Date: 1998/05/19 03:42:49 $
# by Keiju ISHITSUKA(Nippon Rational Inc.)
@RCS_ID='-$Id: tracer.rb,v 1.8 1998/05/19 03:42:49 keiju Exp keiju $-'
@threads[Thread.main.object_id] = 0
@threads[Thread.current.object_id] = 0
set_trace_func method(:trace_func).to_proc
stdout.print "Trace on\n" if Tracer.verbose?
stdout.print "Trace off\n" if Tracer.verbose?
def set_get_line_procs(file, p = proc)
@get_line_procs[file] = p
if p = @get_line_procs[file]
unless list = SCRIPT_LINES__[file]
SCRIPT_LINES__[file] = list = f.readlines
SCRIPT_LINES__[file] = list = []
if no = @threads[Thread.current.object_id]
@threads[Thread.current.object_id] = @threads.size
def trace_func(event, file, line, id, binding, klass, *)
return if file == __FILE__
return unless p.call event, file, line, id, binding, klass
saved_crit = Thread.critical
stdout.printf("#%d:%s:%d:%s:%s: %s",
Thread.critical = saved_crit
def Tracer.set_get_line_procs(file_name, p = proc)
Single.set_get_line_procs(file_name, p)
def Tracer.add_filter(p = proc)
SCRIPT_LINES__ = {} unless defined? SCRIPT_LINES__
elsif caller(0).size == 1