143件ヒット
[1-100件を表示]
(0.080秒)
種類
- モジュール関数 (44)
- インスタンスメソッド (44)
- 特異メソッド (33)
- 関数 (22)
クラス
-
IRB
:: Frame (11) - Thread (11)
- TracePoint (11)
- Tracer (44)
モジュール
- Kernel (44)
キーワード
-
add
_ filter (22) -
call
_ trace _ func (11) - caller (33)
-
defined
_ class (11) -
set
_ trace _ func (33)
検索結果
先頭5件
- IRB
:: Frame # trace _ func(event , file , line , id , binding) -> Binding - Tracer
# trace _ func(event , file , line , id , binding , klass , *) -> object | nil - Tracer
. trace _ func(*vars) -> object | nil - static void call
_ trace _ func(char *event , NODE *pos , VALUE self , ID id , VALUE klass) - Kernel
. # set _ trace _ func(proc) -> Proc
-
IRB
:: Frame # trace _ func(event , file , line , id , binding) -> Binding (18201.0) -
ライブラリ内部で使用します。
ライブラリ内部で使用します。 -
Tracer
# trace _ func(event , file , line , id , binding , klass , *) -> object | nil (18201.0) -
@todo
@todo -
Tracer
. trace _ func(*vars) -> object | nil (18201.0) -
debug ライブラリの内部で使用します。
debug ライブラリの内部で使用します。 -
static void call
_ trace _ func(char *event , NODE *pos , VALUE self , ID id , VALUE klass) (12216.0) -
評価器の動作をフックする手続き trace_func を評価します。
...評価器の動作をフックする手続き trace_func を評価します。... -
Kernel
. # set _ trace _ func(proc) -> Proc (9113.0) -
Ruby インタプリタのイベントをトレースする Proc オブジェクトとして 指定された proc を登録します。 nil を指定するとトレースがオフになります。
...Ruby インタプリタのイベントをトレースする Proc オブジェクトとして
指定された proc を登録します。 nil を指定するとトレースがオフになります。
Ruby インタプリタがプログラムを実行する過程で、メソッドの呼び出しや......準添付の debug、tracer、
profile はこの組み込み関数を利用して実現されています。
=== ブロックパラメータの意味
渡す Proc オブジェクトのパラメータは
//emlist[][ruby]{
proc{|event, file, line, id, binding, klass| "..." }
//}
で、意味は以下......Class オブジェクト。トップレベルでは nil。
//}
@param proc トレース用 Proc オブジェクトを指定します。nil を指定した場合、トレースをオフにします。
@return proc を返します。
//emlist[例][ruby]{
set_trace_func lambda {|*arg|
p arg
}
clas... -
static VALUE set
_ trace _ func(VALUE obj , VALUE trace) (6416.0) -
Kernel#set_trace_func の実体。 評価器に対するフック手続きを登録します。
...Kernel#set_trace_func の実体。
評価器に対するフック手続きを登録します。... -
Thread
# set _ trace _ func(pr) -> Proc | nil (6231.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,......e87cb08>, nil]
# => ["c-call", "example.rb", 2, :inherited, #<Binding:0x00007fc8de886770>, Class]
# => ["c-return", "example.rb", 2, :inherited, #<Binding:0x00007fc8de8844e8>, Class]
# => ["class", "example.rb", 2, nil, #<Binding:0x00007fc8de88e830>, nil]
# => ["end", "example.rb", 3, nil, #<Binding......c8de88d6b0>, nil]
# => ["line", "example.rb", 4, nil, #<Binding:0x00007fc8de88c440>, nil]
# => ["c-call", "example.rb", 4, :to_s, #<Binding:0x00007fc8de896f30>, Integer]
# => ["c-return", "example.rb", 4, :to_s, #<Binding:0x00007fc8de894a50>, Integer]
# => ["line", "example.rb", 5, nil, #<Binding:0x... -
TracePoint
# defined _ class -> Class | module (6212.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......foo; end; end
class C; include M; end;
trace = TracePoint.new(:call) do |tp|
p tp.defined_class # => M
end.enable do
C.new.foo
end
//}
[注意] 特異メソッドを実行した場合は TracePoint#defined_class は特異クラ
スを返します。また、Kernel.#set_trace_func の 6 番目......クラスではなく元のクラスを返します。
//emlist[例][ruby]{
class C; def self.foo; end; end
trace = TracePoint.new(:call) do |tp|
p tp.defined_class # => #<Class:C>
end.enable do
C.foo
end
//}
Kernel.#set_trace_func と TracePoint の上記の差分に注意して
ください... -
Kernel
. # caller(range) -> [String] | nil (6106.0) -
start 段上の呼び出し元の情報を $@ の形式のバックトレース(文字列の配列)として返します。
...ます。caller の戻り値を $@ に代入することで
例外の発生位置を設定できます。
引数で指定した値が範囲外の場合は nil を返します。
@param start long の範囲を超えない正の整数でスタックレベルを指定します。
@param length 取得......囲を示す Range オブジェクトを指定します。
@see Kernel.#set_trace_func,Kernel.#raise,
Kernel.#caller_locations
//emlist[例][ruby]{
def foo
p caller(0)
p caller(1)
p caller(2)
p caller(3)
p caller(4)
end
def bar
foo
end
bar
#=> ["-:2:in `foo'", "-:10:in `bar'",......[]
# nil
//}
以下の関数は、caller の要素から [ファイル名, 行番号, メソッド名]
を取り出して返します。
//emlist[例][ruby]{
def parse_caller(at)
if /^(.+?):(\d+)(?::in `(.*)')?/ =~ at
file = $1
line = $2.to_i
method = $3
[file, line, method]... -
Kernel
. # caller(start = 1) -> [String] | nil (6106.0) -
start 段上の呼び出し元の情報を $@ の形式のバックトレース(文字列の配列)として返します。
...ます。caller の戻り値を $@ に代入することで
例外の発生位置を設定できます。
引数で指定した値が範囲外の場合は nil を返します。
@param start long の範囲を超えない正の整数でスタックレベルを指定します。
@param length 取得......囲を示す Range オブジェクトを指定します。
@see Kernel.#set_trace_func,Kernel.#raise,
Kernel.#caller_locations
//emlist[例][ruby]{
def foo
p caller(0)
p caller(1)
p caller(2)
p caller(3)
p caller(4)
end
def bar
foo
end
bar
#=> ["-:2:in `foo'", "-:10:in `bar'",......[]
# nil
//}
以下の関数は、caller の要素から [ファイル名, 行番号, メソッド名]
を取り出して返します。
//emlist[例][ruby]{
def parse_caller(at)
if /^(.+?):(\d+)(?::in `(.*)')?/ =~ at
file = $1
line = $2.to_i
method = $3
[file, line, method]...