204件ヒット
[1-100件を表示]
(0.024秒)
種類
- インスタンスメソッド (103)
- 特異メソッド (48)
- 文書 (29)
- ライブラリ (12)
- モジュール関数 (12)
クラス
- Binding (7)
- ERB (24)
-
IRB
:: Frame (12) -
RubyVM
:: InstructionSequence (12) - Thread (36)
- TracePoint (24)
- Tracer (36)
モジュール
- Kernel (12)
キーワード
-
NEWS for Ruby 3
. 0 . 0 (5) -
add
_ filter (24) -
add
_ trace _ func (12) - backtrace (12)
- new (12)
- of (12)
- result (12)
-
ruby 1
. 6 feature (12) -
ruby 1
. 9 feature (12) - self (12)
-
set
_ trace _ func (24) -
source
_ location (7) -
trace
_ func (24) - tracer (12)
検索結果
先頭5件
-
tracer (26006.0)
-
実行トレース出力をとる機能を提供します。
...ruby -rtracer hoge.rb
もうひとつはソースからrequireする方法です。
require 'tracer'
とした後
Tracer.on
によりトレース出力を有効にします。
Tracer.off
によりトレース出力を無効にします。
また、ブロック付きで Tracer.on......tracer'
class Hoge
def Hoge.fuga(i)
"fuga #{i}"
end
end
Tracer.add_filter {|event, file, line, id, binding, klass|
event =~ /line/ and klass.to_s =~ /hoge/i
}
Tracer.on
for i in 0..3
puts Hoge.fuga(i) if i % 3 == 0
end
Tracer.off
=== SEE ALSO
Kernel.#set_tr... -
TracePoint
# binding -> Binding | nil (21230.0) -
発生したイベントによって生成された Binding オブジェクトを返します。
...された Binding オブジェクトを返します。
C で記述されたメソッドは binding を生成しないため、
:c_call および :c_return イベントに対しては nil を返すことに注意してください。
//emlist[例][ruby]{
def foo(ret)
ret
end
trace = TracePoint.ne......w(:call) do |tp|
p tp.binding.local_variables # => [:ret]
end
trace.enable
foo 1
//}... -
TracePoint
# binding -> Binding (21224.0) -
発生したイベントによって生成された Binding オブジェクトを返します。
...発生したイベントによって生成された Binding オブジェクトを返します。
//emlist[例][ruby]{
def foo(ret)
ret
end
trace = TracePoint.new(:call) do |tp|
p tp.binding.local_variables # => [:ret]
end
trace.enable
foo 1
//}... -
Tracer
# trace _ func(event , file , line , id , binding , klass , *) -> object | nil (9201.0) -
@todo
@todo -
Binding
# source _ location -> [String , Integer] (9106.0) -
self の Ruby のソースファイル名と行番号を返します。
...self の Ruby のソースファイル名と行番号を返します。
d:spec/variables#pseudo の __FILE__ と __LINE__ も参照してください。
//emlist[例][ruby]{
p binding.source_location # => ["test.rb", 1]
//}... -
IRB
:: Frame # trace _ func(event , file , line , id , binding) -> Binding (6302.0) -
ライブラリ内部で使用します。
ライブラリ内部で使用します。 -
Thread
# backtrace -> [String] | nil (6206.0) -
スレッドの現在のバックトレースを返します。
...def m1
sleep 5
end
def m2
m1
end
end
th = Thread.new {C1.new.m2; Thread.stop}
th.backtrace
# => [
# [0] "(irb):3:in `sleep'",
# [1] "(irb):3:in `m1'",
# [2] "(irb):6:in `m2'",
# [3] "(irb):10:in `block in irb_binding'"
# ]
th.kill
th.backtrace # => nil
//}... -
Kernel
. # set _ trace _ func(proc) -> Proc (6172.0) -
Ruby インタプリタのイベントをトレースする Proc オブジェクトとして 指定された proc を登録します。 nil を指定するとトレースがオフになります。
...す。
標準添付の debug、tracer、
profile はこの組み込み関数を利用して実現されています。
=== ブロックパラメータの意味
渡す Proc オブジェクトのパラメータは
//emlist[][ruby]{
proc{|event, file, line, id, binding, klass| "..." }
//}
で、意......び出されたメソッドを表す Symbol オブジェクト。
トップレベルでは nil。
//}
: binding
実行中のプログラムのコンテキストを表す Binding オブジェクト。
: klass
event に応じ、以下のものが渡されます。
第四ブロック引数......。
//emlist[例][ruby]{
set_trace_func lambda {|*arg|
p arg
}
class Foo
end
43.to_s
# ----結果----
# ["c-return", "..", 1, :set_trace_func, #<Binding:0xf6ceb8>, Kernel]
# ["line", "..", 4, nil, #<Binding:0x10cbcd8>, nil]
# ["c-call", "..", 4, :inherited, #<Binding:0x10cba98>, Class]
# ["c-ret... -
Thread
# set _ trace _ func(pr) -> Proc | nil (6172.0) -
スレッドにトレース用ハンドラを設定します。
...th = Thread.new do
class Trace
end
2.to_s
Thread.current.set_trace_func nil
3.to_s
end
th.set_trace_func lambda {|*arg| p arg }
th.join
# => ["line", "example.rb", 2, nil, #<Binding:0x00007fc8de87cb08>, nil]
# => ["c-call", "example.rb", 2, :inherited, #<Binding:0x00007fc8de886770>, Clas......turn", "example.rb", 2, :inherited, #<Binding:0x00007fc8de8844e8>, Class]
# => ["class", "example.rb", 2, nil, #<Binding:0x00007fc8de88e830>, nil]
# => ["end", "example.rb", 3, nil, #<Binding:0x00007fc8de88d6b0>, nil]
# => ["line", "example.rb", 4, nil, #<Binding:0x00007fc8de88c440>, nil]
# => ["c-c......"example.rb", 4, :to_s, #<Binding:0x00007fc8de894a50>, Integer]
# => ["line", "example.rb", 5, nil, #<Binding:0x00007fc8de967b08>, nil]
# => ["c-call", "example.rb", 5, :current, #<Binding:0x00007fc8de967798>, Thread]
# => ["c-return", "example.rb", 5, :current, #<Binding:0x00007fc8de9673b0>, Threa... -
Thread
# add _ trace _ func(pr) -> Proc (6148.0) -
スレッドにトレース用ハンドラを追加します。
...class Trace
end
43.to_s
end
th.add_trace_func lambda {|*arg| p arg }
th.join
# => ["line", "example.rb", 4, nil, #<Binding:0x00007f98e107d0d8>, nil]
# => ["c-call", "example.rb", 4, :inherited, #<Binding:0x00007f98e1087448>, Class]
# => ["c-return", "example.rb", 4, :inherited, #<Binding:0x000......=> ["class", "example.rb", 4, nil, #<Binding:0x00007f98e108f210>, nil]
# => ["end", "example.rb", 5, nil, #<Binding:0x00007f98e108e5e0>, nil]
# => ["line", "example.rb", 6, nil, #<Binding:0x00007f98e108d4b0>, nil]
# => ["c-call", "example.rb", 6, :to_s, #<Binding:0x00007f98e1097aa0>, Integer]
# => [......"c-return", "example.rb", 6, :to_s, #<Binding:0x00007f98e1095cc8>, Integer]
//}
@see Thread#set_trace_func Kernel.#set_trace_func...