別のキーワード
種類
- インスタンスメソッド (13)
- 特異メソッド (2)
- クラス (1)
クラス
- TracePoint (15)
キーワード
- binding (1)
-
callee
_ id (1) -
defined
_ class (1) -
eval
_ script (1) - event (1)
- inspect (1)
-
instruction
_ sequence (1) - lineno (1)
-
method
_ id (1) - new (1)
- parameters (1)
- path (1)
-
raised
_ exception (1) -
return
_ value (1) - trace (1)
検索結果
先頭5件
-
TracePoint (132205.0)
-
Kernel.#set_trace_func と同様の機能をオブジェクト指向的な API で 提供するクラスです。
Kernel.#set_trace_func と同様の機能をオブジェクト指向的な API で
提供するクラスです。
//emlist[例:例外に関する情報を収集する][ruby]{
trace = TracePoint.new(:raise) do |tp|
p [tp.lineno, tp.event, tp.raised_exception]
end
# => #<TracePoint:0x007f786a452448>
trace.enable
# => false
0 / 0
# => [5, :raise, #<ZeroDivisionError: divided by 0... -
TracePoint
# eval _ script -> String | nil (81682.0) -
script_compiledイベント発生時にコンパイルされたソースコードを返します。 ファイルから読み込んだ場合は、nilを返します。
script_compiledイベント発生時にコンパイルされたソースコードを返します。
ファイルから読み込んだ場合は、nilを返します。
//emlist[例][ruby]{
TracePoint.new(:script_compiled) do |tp|
p tp.eval_script # => "puts 'hello'"
end.enable do
eval("puts 'hello'")
end
//}
@raise RuntimeError :script_compiled イベントのための
イベントフックの外側で実行した場合に... -
TracePoint
# raised _ exception -> Exception (81661.0) -
発生した例外を返します。
発生した例外を返します。
@raise RuntimeError :raise イベントのためのイベントフックの外側で実行し
た場合に発生します。
//emlist[例][ruby]{
trace = TracePoint.new(:raise) do |tp|
tp.raised_exception # => #<ZeroDivisionError: divided by 0>
end
trace.enable
begin
0/0
rescue
end
//} -
TracePoint
# inspect -> String (81397.0) -
self の状態を人間に読みやすい文字列にして返します。
self の状態を人間に読みやすい文字列にして返します。
//emlist[例][ruby]{
def foo(ret)
ret
end
trace = TracePoint.new(:call) do |tp|
p tp.inspect # "#<TracePoint:call `foo'@/path/to/test.rb:1>"
end
trace.enable
foo 1
//} -
TracePoint
# parameters -> [object] (81379.0) -
現在のフックが属するメソッドまたはブロックのパラメータ定義を返します。 フォーマットは Method#parameters と同じです。
現在のフックが属するメソッドまたはブロックのパラメータ定義を返します。
フォーマットは Method#parameters と同じです。
@raise RuntimeError :call、:return、:b_call、:b_return、:c_call、:c_return
イベントのためのイベントフックの外側で実行した場合に発生します。
//emlist[例][ruby]{
def foo(a, b = 2)
end
TracePoint.new(:call) do |tp|
p tp.parameters # => a], [:opt, ... -
TracePoint
# path -> String (81379.0) -
イベントが発生したファイルのパスを返します。
イベントが発生したファイルのパスを返します。
@raise RuntimeError イベントフックの外側で実行した場合に発生します。
//emlist[例][ruby]{
def foo(ret)
ret
end
trace = TracePoint.new(:call) do |tp|
p tp.path # => "/path/to/test.rb"
end
trace.enable
foo 1
//} -
TracePoint
. new(*events) {|obj| . . . } -> TracePoint (73261.0) -
新しい TracePoint オブジェクトを作成して返します。トレースを有効 にするには TracePoint#enable を実行してください。
新しい TracePoint オブジェクトを作成して返します。トレースを有効
にするには TracePoint#enable を実行してください。
//emlist[例:irb で実行した場合][ruby]{
trace = TracePoint.new(:call) do |tp|
p [tp.lineno, tp.defined_class, tp.method_id, tp.event]
end
# => #<TracePoint:0x007f17372cdb20>
trace.enable
# => false
puts "Hello, TracePoint!"
# .... -
TracePoint
. trace(*events) {|obj| . . . } -> TracePoint (73099.0) -
新しい TracePoint オブジェクトを作成して自動的にトレースを開始し ます。TracePoint.new のコンビニエンスメソッドです。
新しい TracePoint オブジェクトを作成して自動的にトレースを開始し
ます。TracePoint.new のコンビニエンスメソッドです。
@param events トレースするイベントを String か Symbol で任
意の数指定します。指定できる値については
TracePoint.new を参照してください。
//emlist[例][ruby]{
trace = TracePoint.trace(:call) { |tp| [tp.lineno, tp.event] }
# => #<TracePoint:0x00... -
TracePoint
# defined _ class -> Class | module (72562.0) -
メソッドを定義したクラスかモジュールを返します。
メソッドを定義したクラスかモジュールを返します。
//emlist[例][ruby]{
class C; def foo; end; end
trace = TracePoint.new(:call) do |tp|
p tp.defined_class # => C
end.enable do
C.new.foo
end
//}
メソッドがモジュールで定義されていた場合も(include に関係なく)モジュー
ルを返します。
//emlist[例][ruby]{
module M; def foo; end; end
class C; include M; end;
trac... -
TracePoint
# callee _ id -> Symbol | nil (72400.0) -
イベントが発生したメソッドの呼ばれた名前を Symbol で返します。 トップレベルであった場合は nil を返します。
イベントが発生したメソッドの呼ばれた名前を Symbol で返します。
トップレベルであった場合は nil を返します。
@raise RuntimeError イベントフックの外側で実行した場合に発生します。
//emlist[][ruby]{
class C
def method_name
end
alias alias_name method_name
end
trace = TracePoint.new(:call) do |tp|
p [tp.method_id, tp.callee_id] # => [:method_name, :alias_name]
e... -
TracePoint
# method _ id -> Symbol | nil (72400.0) -
イベントが発生したメソッドの定義時の名前を Symbol で返します。 トップレベルであった場合は nil を返します。
イベントが発生したメソッドの定義時の名前を Symbol で返します。
トップレベルであった場合は nil を返します。
@raise RuntimeError イベントフックの外側で実行した場合に発生します。
//emlist[][ruby]{
class C
def method_name
end
alias alias_name method_name
end
trace = TracePoint.new(:call) do |tp|
p [tp.method_id, tp.callee_id] # => [:method_name, :alias_name]
e... -
TracePoint
# event -> Symbol (72097.0) -
発生したイベントの種類を Symbol で返します。
発生したイベントの種類を Symbol で返します。
発生するイベントの詳細については、TracePoint.new を参照してくださ
い。
@raise RuntimeError イベントフックの外側で実行した場合に発生します。
//emlist[例][ruby]{
def foo(ret)
ret
end
trace = TracePoint.new(:call, :return) do |tp|
p tp.event
end
trace.enable
foo 1
# => :call
# :return
//} -
TracePoint
# binding -> Binding (72079.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
//} -
TracePoint
# instruction _ sequence -> RubyVM :: InstructionSequence (72079.0) -
script_compiledイベント発生時にコンパイルされた RubyVM::InstructionSequenceインスタンスを返します。
script_compiledイベント発生時にコンパイルされた
RubyVM::InstructionSequenceインスタンスを返します。
//emlist[例][ruby]{
TracePoint.new(:script_compiled) do |tp|
p tp.instruction_sequence # => <RubyVM::InstructionSequence:block in <main>@(eval):1>
end.enable do
eval("puts 'hello'")
end
//}
@raise RuntimeError :script_comp... -
TracePoint
# return _ value -> object (72079.0) -
メソッドやブロックの戻り値を返します。
メソッドやブロックの戻り値を返します。
@raise RuntimeError :return、:c_return、:b_return イベントのためのイベ
ントフックの外側で実行した場合に発生します。
//emlist[例][ruby]{
def foo(ret)
ret
end
trace = TracePoint.new(:return) do |tp|
p tp.return_value # => 1
end
trace.enable
foo 1
//} -
TracePoint
# lineno -> Integer (72061.0) -
発生したイベントの行番号を返します。
発生したイベントの行番号を返します。
@raise RuntimeError イベントフックの外側で実行した場合に発生します。
//emlist[例][ruby]{
def foo(ret)
ret
end
trace = TracePoint.new(:call, :return) do |tp|
tp.lineno
end
trace.enable
foo 1
# => 1
# 3
//}