зеркало из https://github.com/github/ruby.git
* lib/tracer.rb: no show lines unkonwn line number. [ruby-core:22096],
no trace display c-call and c-return as default. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24226 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
904abb1d9b
Коммит
623cfccb6f
|
@ -1,3 +1,8 @@
|
||||||
|
Tue Jul 21 20:41:20 2009 Keiju Ishitsuka <keiju@emperor2.pendome>
|
||||||
|
|
||||||
|
* lib/tracer.rb: no show lines unkonwn line number. [ruby-core:22096],
|
||||||
|
no trace display c-call and c-return as default.
|
||||||
|
|
||||||
Tue Jul 21 16:24:41 2009 Masaki Suketa <masaki.suketa@nifty.ne.jp>
|
Tue Jul 21 16:24:41 2009 Masaki Suketa <masaki.suketa@nifty.ne.jp>
|
||||||
|
|
||||||
* ext/win32ole/win32ole.c (vtdate2rbtime): VT_DATE variant object
|
* ext/win32ole/win32ole.c (vtdate2rbtime): VT_DATE variant object
|
||||||
|
|
|
@ -1,27 +1,44 @@
|
||||||
#
|
# tracer.rb -
|
||||||
# tracer.rb -
|
# $Release Version: 0.3$
|
||||||
# $Release Version: 0.2$
|
# $Revision: 1.12 $
|
||||||
# $Revision: 1.8 $
|
# by Keiju ISHITSUKA(keiju@ishitsuka.com)
|
||||||
# by Keiju ISHITSUKA(Nippon Rational Inc.)
|
|
||||||
#
|
#
|
||||||
# --
|
# --
|
||||||
#
|
#
|
||||||
|
#
|
||||||
#
|
#
|
||||||
#
|
require "thread"
|
||||||
|
|
||||||
#
|
#
|
||||||
# tracer main class
|
# tracer main class
|
||||||
#
|
#
|
||||||
class Tracer
|
class Tracer
|
||||||
@RCS_ID='-$Id: tracer.rb,v 1.8 1998/05/19 03:42:49 keiju Exp keiju $-'
|
|
||||||
|
|
||||||
@stdout = STDOUT
|
|
||||||
@verbose = false
|
|
||||||
class << self
|
class << self
|
||||||
attr_accessor :verbose
|
attr_accessor :verbose
|
||||||
alias verbose? verbose
|
alias verbose? verbose
|
||||||
|
|
||||||
attr_accessor :stdout
|
attr_accessor :stdout
|
||||||
|
attr_reader :stdout_mutex
|
||||||
|
|
||||||
|
# display process id?
|
||||||
|
attr_accessor :display_process_id
|
||||||
|
alias display_process_id? display_process_id
|
||||||
|
|
||||||
|
# display thread id?
|
||||||
|
attr_accessor :display_thread_id
|
||||||
|
alias display_thread_id? display_thread_id
|
||||||
|
|
||||||
|
# display builtin method call?
|
||||||
|
attr_accessor :display_c_call
|
||||||
|
alias display_c_call? display_c_call
|
||||||
end
|
end
|
||||||
|
Tracer::stdout = STDOUT
|
||||||
|
Tracer::verbose = false
|
||||||
|
Tracer::display_process_id = false
|
||||||
|
Tracer::display_thread_id = true
|
||||||
|
Tracer::display_c_call = false
|
||||||
|
|
||||||
|
@stdout_mutex = Mutex.new
|
||||||
|
|
||||||
EVENT_SYMBOL = {
|
EVENT_SYMBOL = {
|
||||||
"line" => "-",
|
"line" => "-",
|
||||||
|
@ -29,8 +46,10 @@ class Tracer
|
||||||
"return" => "<",
|
"return" => "<",
|
||||||
"class" => "C",
|
"class" => "C",
|
||||||
"end" => "E",
|
"end" => "E",
|
||||||
"c-call" => ">",
|
"raise" => "^",
|
||||||
"c-return" => "<",
|
"c-call" => "}",
|
||||||
|
"c-return" => "{",
|
||||||
|
"unknown" => "?"
|
||||||
}
|
}
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
|
@ -84,7 +103,7 @@ class Tracer
|
||||||
|
|
||||||
unless list = SCRIPT_LINES__[file]
|
unless list = SCRIPT_LINES__[file]
|
||||||
begin
|
begin
|
||||||
f = open(file)
|
f = File::open(file)
|
||||||
begin
|
begin
|
||||||
SCRIPT_LINES__[file] = list = f.readlines
|
SCRIPT_LINES__[file] = list = f.readlines
|
||||||
ensure
|
ensure
|
||||||
|
@ -117,16 +136,27 @@ class Tracer
|
||||||
return unless p.call event, file, line, id, binding, klass
|
return unless p.call event, file, line, id, binding, klass
|
||||||
end
|
end
|
||||||
|
|
||||||
# saved_crit = Thread.critical
|
return unless Tracer::display_c_call? or
|
||||||
# Thread.critical = true
|
event != "c-call" && event != "c-return"
|
||||||
stdout.printf("#%d:%s:%d:%s:%s: %s",
|
|
||||||
get_thread_no,
|
Tracer::stdout_mutex.synchronize do
|
||||||
file,
|
if EVENT_SYMBOL[event]
|
||||||
line,
|
stdout.printf("<%d>", $$) if Tracer::display_process_id?
|
||||||
klass || '',
|
stdout.printf("#%d:", get_thread_no) if Tracer::display_thread_id?
|
||||||
EVENT_SYMBOL[event],
|
if line == 0
|
||||||
get_line(file, line))
|
source = "?\n"
|
||||||
# Thread.critical = saved_crit
|
else
|
||||||
|
source = get_line(file, line)
|
||||||
|
end
|
||||||
|
printf("%s:%d:%s:%s: %s",
|
||||||
|
file,
|
||||||
|
line,
|
||||||
|
klass || '',
|
||||||
|
EVENT_SYMBOL[event],
|
||||||
|
source)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Single = new
|
Single = new
|
||||||
|
@ -149,7 +179,6 @@ class Tracer
|
||||||
def Tracer.add_filter(p = proc)
|
def Tracer.add_filter(p = proc)
|
||||||
Single.add_filter(p)
|
Single.add_filter(p)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
SCRIPT_LINES__ = {} unless defined? SCRIPT_LINES__
|
SCRIPT_LINES__ = {} unless defined? SCRIPT_LINES__
|
||||||
|
@ -161,6 +190,6 @@ if $0 == __FILE__
|
||||||
ARGV.shift
|
ARGV.shift
|
||||||
Tracer.on
|
Tracer.on
|
||||||
require $0
|
require $0
|
||||||
elsif caller.size == 1
|
elsif caller.size <= 1
|
||||||
Tracer.on
|
Tracer.on
|
||||||
end
|
end
|
||||||
|
|
Загрузка…
Ссылка в новой задаче