Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/AnonR/anonr.TX.../opt/alt/ruby18/lib64/ruby/1.8
File: tracer.rb
#
[0] Fix | Delete
# tracer.rb -
[1] Fix | Delete
# $Release Version: 0.2$
[2] Fix | Delete
# $Revision: 1.8 $
[3] Fix | Delete
# $Date: 1998/05/19 03:42:49 $
[4] Fix | Delete
# by Keiju ISHITSUKA(Nippon Rational Inc.)
[5] Fix | Delete
#
[6] Fix | Delete
# --
[7] Fix | Delete
#
[8] Fix | Delete
#
[9] Fix | Delete
#
[10] Fix | Delete
[11] Fix | Delete
#
[12] Fix | Delete
# tracer main class
[13] Fix | Delete
#
[14] Fix | Delete
class Tracer
[15] Fix | Delete
@RCS_ID='-$Id: tracer.rb,v 1.8 1998/05/19 03:42:49 keiju Exp keiju $-'
[16] Fix | Delete
[17] Fix | Delete
@stdout = STDOUT
[18] Fix | Delete
@verbose = false
[19] Fix | Delete
class << self
[20] Fix | Delete
attr :verbose, true
[21] Fix | Delete
alias verbose? verbose
[22] Fix | Delete
attr :stdout, true
[23] Fix | Delete
end
[24] Fix | Delete
[25] Fix | Delete
EVENT_SYMBOL = {
[26] Fix | Delete
"line" => "-",
[27] Fix | Delete
"call" => ">",
[28] Fix | Delete
"return" => "<",
[29] Fix | Delete
"class" => "C",
[30] Fix | Delete
"end" => "E",
[31] Fix | Delete
"c-call" => ">",
[32] Fix | Delete
"c-return" => "<",
[33] Fix | Delete
}
[34] Fix | Delete
[35] Fix | Delete
def initialize
[36] Fix | Delete
@threads = Hash.new
[37] Fix | Delete
if defined? Thread.main
[38] Fix | Delete
@threads[Thread.main.object_id] = 0
[39] Fix | Delete
else
[40] Fix | Delete
@threads[Thread.current.object_id] = 0
[41] Fix | Delete
end
[42] Fix | Delete
[43] Fix | Delete
@get_line_procs = {}
[44] Fix | Delete
[45] Fix | Delete
@filters = []
[46] Fix | Delete
end
[47] Fix | Delete
[48] Fix | Delete
def stdout
[49] Fix | Delete
Tracer.stdout
[50] Fix | Delete
end
[51] Fix | Delete
[52] Fix | Delete
def on
[53] Fix | Delete
if block_given?
[54] Fix | Delete
on
[55] Fix | Delete
begin
[56] Fix | Delete
yield
[57] Fix | Delete
ensure
[58] Fix | Delete
off
[59] Fix | Delete
end
[60] Fix | Delete
else
[61] Fix | Delete
set_trace_func method(:trace_func).to_proc
[62] Fix | Delete
stdout.print "Trace on\n" if Tracer.verbose?
[63] Fix | Delete
end
[64] Fix | Delete
end
[65] Fix | Delete
[66] Fix | Delete
def off
[67] Fix | Delete
set_trace_func nil
[68] Fix | Delete
stdout.print "Trace off\n" if Tracer.verbose?
[69] Fix | Delete
end
[70] Fix | Delete
[71] Fix | Delete
def add_filter(p = proc)
[72] Fix | Delete
@filters.push p
[73] Fix | Delete
end
[74] Fix | Delete
[75] Fix | Delete
def set_get_line_procs(file, p = proc)
[76] Fix | Delete
@get_line_procs[file] = p
[77] Fix | Delete
end
[78] Fix | Delete
[79] Fix | Delete
def get_line(file, line)
[80] Fix | Delete
if p = @get_line_procs[file]
[81] Fix | Delete
return p.call(line)
[82] Fix | Delete
end
[83] Fix | Delete
[84] Fix | Delete
unless list = SCRIPT_LINES__[file]
[85] Fix | Delete
begin
[86] Fix | Delete
f = open(file)
[87] Fix | Delete
begin
[88] Fix | Delete
SCRIPT_LINES__[file] = list = f.readlines
[89] Fix | Delete
ensure
[90] Fix | Delete
f.close
[91] Fix | Delete
end
[92] Fix | Delete
rescue
[93] Fix | Delete
SCRIPT_LINES__[file] = list = []
[94] Fix | Delete
end
[95] Fix | Delete
end
[96] Fix | Delete
[97] Fix | Delete
if l = list[line - 1]
[98] Fix | Delete
l
[99] Fix | Delete
else
[100] Fix | Delete
"-\n"
[101] Fix | Delete
end
[102] Fix | Delete
end
[103] Fix | Delete
[104] Fix | Delete
def get_thread_no
[105] Fix | Delete
if no = @threads[Thread.current.object_id]
[106] Fix | Delete
no
[107] Fix | Delete
else
[108] Fix | Delete
@threads[Thread.current.object_id] = @threads.size
[109] Fix | Delete
end
[110] Fix | Delete
end
[111] Fix | Delete
[112] Fix | Delete
def trace_func(event, file, line, id, binding, klass, *)
[113] Fix | Delete
return if file == __FILE__
[114] Fix | Delete
[115] Fix | Delete
for p in @filters
[116] Fix | Delete
return unless p.call event, file, line, id, binding, klass
[117] Fix | Delete
end
[118] Fix | Delete
[119] Fix | Delete
saved_crit = Thread.critical
[120] Fix | Delete
Thread.critical = true
[121] Fix | Delete
stdout.printf("#%d:%s:%d:%s:%s: %s",
[122] Fix | Delete
get_thread_no,
[123] Fix | Delete
file,
[124] Fix | Delete
line,
[125] Fix | Delete
klass || '',
[126] Fix | Delete
EVENT_SYMBOL[event],
[127] Fix | Delete
get_line(file, line))
[128] Fix | Delete
Thread.critical = saved_crit
[129] Fix | Delete
end
[130] Fix | Delete
[131] Fix | Delete
Single = new
[132] Fix | Delete
def Tracer.on
[133] Fix | Delete
if block_given?
[134] Fix | Delete
Single.on{yield}
[135] Fix | Delete
else
[136] Fix | Delete
Single.on
[137] Fix | Delete
end
[138] Fix | Delete
end
[139] Fix | Delete
[140] Fix | Delete
def Tracer.off
[141] Fix | Delete
Single.off
[142] Fix | Delete
end
[143] Fix | Delete
[144] Fix | Delete
def Tracer.set_get_line_procs(file_name, p = proc)
[145] Fix | Delete
Single.set_get_line_procs(file_name, p)
[146] Fix | Delete
end
[147] Fix | Delete
[148] Fix | Delete
def Tracer.add_filter(p = proc)
[149] Fix | Delete
Single.add_filter(p)
[150] Fix | Delete
end
[151] Fix | Delete
[152] Fix | Delete
end
[153] Fix | Delete
[154] Fix | Delete
SCRIPT_LINES__ = {} unless defined? SCRIPT_LINES__
[155] Fix | Delete
[156] Fix | Delete
if $0 == __FILE__
[157] Fix | Delete
# direct call
[158] Fix | Delete
[159] Fix | Delete
$0 = ARGV[0]
[160] Fix | Delete
ARGV.shift
[161] Fix | Delete
Tracer.on
[162] Fix | Delete
require $0
[163] Fix | Delete
elsif caller(0).size == 1
[164] Fix | Delete
Tracer.on
[165] Fix | Delete
end
[166] Fix | Delete
[167] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function