種類
- インスタンスメソッド (309)
- モジュール関数 (132)
- 特異メソッド (76)
- 定数 (11)
- クラス (11)
クラス
- Exception (33)
- Fiber (5)
- Object (11)
-
RubyVM
:: InstructionSequence (44) - Thread (33)
-
Thread
:: Backtrace :: Location (33) - TracePoint (226)
キーワード
- TracePoint (11)
- WUNTRACED (11)
-
absolute
_ path (11) -
add
_ trace _ func (11) - backtrace (11)
-
backtrace
_ locations (11) - binding (11)
-
callee
_ id (11) - caller (33)
-
caller
_ locations (22) -
compile
_ option (11) -
compile
_ option= (11) -
defined
_ class (11) - disable (22)
- disasm (11)
- disassemble (11)
- enable (22)
- enabled? (11)
-
eval
_ script (6) - event (11)
- fail (11)
- freeze (11)
- inspect (22)
-
instruction
_ sequence (6) - lineno (11)
-
method
_ id (11) - new (11)
- parameters (6)
- path (22)
- raise (27)
-
raised
_ exception (11) -
return
_ value (11) - self (11)
-
set
_ backtrace (11) -
set
_ trace _ func (22) - stat (10)
-
trace
_ var (33) -
untrace
_ var (11)
検索結果
先頭5件
-
TracePoint
. trace(*events) {|obj| . . . } -> TracePoint (24321.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:0x007f786a452448>
trace.enabled? # => true
//}
@raise ThreadError ブロックを指定しなかった場合に発生し... -
TracePoint (12042.0)
-
Kernel.#set_trace_func と同様の機能をオブジェクト指向的な API で 提供するクラスです。
...t_trace_func と同様の機能をオブジェクト指向的な API で
提供するクラスです。
//emlist[例:例外に関する情報を収集する][ruby]{
trace = TracePoint.new(:raise) do |tp|
p [tp.lineno, tp.event, tp.raised_exception]
end
# => #<TracePoint:0x007f786a452448>
trace.e......: divided by 0>]
//}
TracePoint.new または、TracePoint.trace で指定したブロック
は、メソッドの引数(上記の例では :raise)に対応するイベントが発生した時に
呼び出されます。
発生するイベントの詳細については、TracePoint.new を参照......ンダー #12 TracePoint の紹介 (1): https://www.atdot.net/~ko1/diary/201212.html#d12
* Ruby VM アドベントカレンダー #13 TracePoint の紹介 (2): https://www.atdot.net/~ko1/diary/201212.html#d13
* Ruby VM アドベントカレンダー #14 TracePoint の紹介 (3): https://www.atdot.... -
TracePoint
# raised _ exception -> Exception (9214.0) -
発生した例外を返します。
...eError :raise イベントのためのイベントフックの外側で実行し
た場合に発生します。
//emlist[例][ruby]{
trace = TracePoint.new(:raise) do |tp|
tp.raised_exception # => #<ZeroDivisionError: divided by 0>
end
trace.enable
begin
0/0
rescue
end
//}... -
Exception
# backtrace _ locations -> [Thread :: Backtrace :: Location] (9208.0) -
バックトレース情報を返します。Exception#backtraceに似ていますが、 Thread::Backtrace::Location の配列を返す点が異なります。
...バックトレース情報を返します。Exception#backtraceに似ていますが、
Thread::Backtrace::Location の配列を返す点が異なります。
現状では Exception#set_backtrace によって戻り値が変化する事はあり
ません。
//emlist[例: test.rb][ruby]{
require......et_exception
return begin
yield
rescue => e
e
end
end
e = get_exception { check_long_month(2) }
p e.backtrace_locations
# => ["test.rb:4:in `check_long_month'", "test.rb:15:in `block in <main>'", "test.rb:9:in `get_exception'", "test.rb:15:in `<main>'"]
//}
@see Exception#backtrace... -
Process
:: WUNTRACED -> Integer (9130.0) -
Process.#waitpid の第二引数に指定するフラグです。 このフラグが指定された場合、waitpid は停止しているだけで 終了していない子プロセスのプロセス ID も返すようになります。 trace されている子プロセスの ID は返しません。
...
Process.#waitpid の第二引数に指定するフラグです。
このフラグが指定された場合、waitpid は停止しているだけで
終了していない子プロセスのプロセス ID も返すようになります。
trace されている子プロセスの ID は返しません......。
include Process
pid = fork{ Process.kill('SIGSTOP', Process.pid) }
p pid #=> 4336
p waitpid2(pid, WUNTRACED) #=> [4336, #<Process::Status: pid=4336,stopped(SIGSTOP=19)>]
@see waitpid(2)... -
TracePoint
# inspect -> String (9120.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
# path -> String (9120.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
//}... -
Exception
# backtrace -> [String] (9108.0) -
バックトレース情報を返します。
...)
* "#{sourcefile}:#{sourceline}"
(トップレベルの場合)
という形式の String の配列です。
//emlist[例][ruby]{
def methd
raise
end
begin
methd
rescue => e
p e.backtrace
end
#=> ["filename.rb:2:in `methd'", "filename.rb:6"]
//}
@see Exception#backtrace_locations... -
TracePoint
# eval _ script -> String | nil (9108.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 'he......llo'")
end
//}
@raise RuntimeError :script_compiled イベントのための
イベントフックの外側で実行した場合に発生します。... -
TracePoint
# parameters -> [object] (9108.0) -
現在のフックが属するメソッドまたはブロックのパラメータ定義を返します。 フォーマットは Method#parameters と同じです。
...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, :b
end.enable do
foo(1)
end
//}
@see Method#parameters, UnboundMethod#parameters, Proc#parameters...