るりまサーチ

最速Rubyリファレンスマニュアル検索!
539件ヒット [1-100件を表示] (0.060秒)

別のキーワード

  1. openssl p
  2. openssl p=
  3. fileutils mkdir_p
  4. dsa p
  5. matrix p

検索結果

<< 1 2 3 ... > >>

TracePoint.trace(*events) {|obj| ... } -> TracePoint (24321.0)

新しい TracePoint オブジェクトを作成して自動的にトレースを開始し ます。TracePoint.new のコンビニエンスメソッドです。

...新しい TracePoint オブジェクトを作成して自動的にトレースを開始し
ます。TracePoint.new のコンビニエンスメソッドです。

@param events トレースするイベントを String か Symbol で任
意の数指定します。指定できる値に...
...ついては
Trace
Point.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>]
//}

Trace
Point.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 は返しません。

...
P
rocess.#waitpid の第二引数に指定するフラグです。
このフラグが指定された場合、waitpid は停止しているだけで
終了していない子プロセスのプロセス ID も返すようになります。
trace
されている子プロセスの ID は返しません...
...

include Process
p
id = 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]{
Trace
Point.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
Trace
Point.new(:call) do |tp...
...|
p
tp.parameters # => a], [:opt, :b
end.enable do
foo(1)
end
//}

@see Method#parameters, UnboundMethod#parameters, Proc#parameters...

絞り込み条件を変える

<< 1 2 3 ... > >>