るりまサーチ (Ruby 2.4.0)

最速Rubyリファレンスマニュアル検索!
4件ヒット [1-4件を表示] (0.330秒)
トップページ > ライブラリ:ビルトイン[x] > バージョン:2.4.0[x] > クエリ:_builtin[x] > クエリ:new[x] > クエリ:set_trace_func[x]

別のキーワード

  1. _builtin new
  2. _builtin inspect
  3. _builtin []
  4. _builtin to_s
  5. _builtin each

クラス

キーワード

検索結果

Thread#set_trace_func(pr) -> Proc | nil (78400.0)

スレッドにトレース用ハンドラを設定します。

スレッドにトレース用ハンドラを設定します。

nil を渡すとトレースを解除します。

設定したハンドラを返します。

//emlist[例][ruby]{
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]
#...

TracePoint#defined_class -> Class | module (24133.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 (24109.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...

Thread#add_trace_func(pr) -> Proc (24061.0)

スレッドにトレース用ハンドラを追加します。

スレッドにトレース用ハンドラを追加します。

追加したハンドラを返します。

@param pr トレースハンドラ(Proc オブジェクト)

//emlist[例][ruby]{
th = Thread.new do
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, ...