るりまサーチ

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

別のキーワード

  1. _builtin source_location
  2. location path
  3. location to_s
  4. location label
  5. location lineno

検索結果

Kernel.#caller_locations(range) -> [Thread::Backtrace::Location] | nil (6225.0)

現在のフレームを Thread::Backtrace::Location の配列で返します。引 数で指定した値が範囲外の場合は nil を返します。

...現在のフレームを Thread::Backtrace::Location の配列で返します。引
数で指定した値が範囲外の場合は nil を返します。

@param start 開始フレームの位置を数値で指定します。

@param length 取得するフレームの個数を指定します。

@pa...
...uby]{
def test1(start, length)
location
s = caller_locations(start, length)
p locations
p locations.map(&:lineno)
p locations.map(&:path)
end

def test2(start, length)
test1(start, length)
end

def test3(start, length)
test2(start, length)
end

caller_locations # => []
test3(1, nil)
# =>...
...(1, 2)
# => ["/Users/user/test.rb:9:in `test2'", "/Users/user/test.rb:13:in `test3'"]
# => [9, 13]
# => ["/Users/user/test.rb", "/Users/user/test.rb"]
test3(2, 1)
# => ["/Users/user/test.rb:13:in `test3'"]
# => [13]
# => ["/Users/user/test.rb"]
//}

@see Thread::Backtrace::Location, Kernel.#caller...

Kernel.#caller_locations(start = 1, length = nil) -> [Thread::Backtrace::Location] | nil (6225.0)

現在のフレームを Thread::Backtrace::Location の配列で返します。引 数で指定した値が範囲外の場合は nil を返します。

...現在のフレームを Thread::Backtrace::Location の配列で返します。引
数で指定した値が範囲外の場合は nil を返します。

@param start 開始フレームの位置を数値で指定します。

@param length 取得するフレームの個数を指定します。

@pa...
...uby]{
def test1(start, length)
location
s = caller_locations(start, length)
p locations
p locations.map(&:lineno)
p locations.map(&:path)
end

def test2(start, length)
test1(start, length)
end

def test3(start, length)
test2(start, length)
end

caller_locations # => []
test3(1, nil)
# =>...
...(1, 2)
# => ["/Users/user/test.rb:9:in `test2'", "/Users/user/test.rb:13:in `test3'"]
# => [9, 13]
# => ["/Users/user/test.rb", "/Users/user/test.rb"]
test3(2, 1)
# => ["/Users/user/test.rb:13:in `test3'"]
# => [13]
# => ["/Users/user/test.rb"]
//}

@see Thread::Backtrace::Location, Kernel.#caller...

ObjectSpace.#allocation_sourcefile(object) -> String (6101.0)

objectの元となったソースファイル名を返します。

...uire 'objspace'

ObjectSpace::trace_object_allocations_start
obj = Object.new
puts "file:#{ObjectSpace::allocation_sourcefile(obj)}" # => file:test.rb
ObjectSpace::trace_object_allocations_stop
//}

@see ObjectSpace.#trace_object_allocations_start,
ObjectSpace.#trace_object_allocations_stop...

ObjectSpace.#allocation_sourceline(object) -> Integer (6101.0)

objectの元となったソースファイルの行番号を返します。

...y]{
require 'objspace'

ObjectSpace::trace_object_allocations_start
obj = Object.new
puts "line:#{ObjectSpace::allocation_sourceline(obj)}" # => line:4
ObjectSpace::trace_object_allocations_stop
//}

@see ObjectSpace.#trace_object_allocations_start,
ObjectSpace.#trace_object_allocations_stop...

ObjectSpace.#trace_object_allocations { ... } (6101.0)

与えられたブロック内でオブジェクトのトレースを行います。 

...のトレースを行います。 

//emlist[例][ruby]{
require 'objspace'

class C
include ObjectSpace

def foo
trace_object_allocations do
obj = Object.new
p "#{allocation_sourcefile(obj)}:#{allocation_sourceline(obj)}"
end
end
end

C.new.foo #=> "objtrace.rb:8"
//}...

絞り込み条件を変える

ObjectSpace.#trace_object_allocations_start -> nil (6101.0)

オブジェクト割り当てのトレースを開始します。

...オブジェクト割り当てのトレースを開始します。

@see ObjectSpace.#trace_object_allocations_stop...

ObjectSpace.#trace_object_allocations_stop -> nil (6101.0)

オブジェクト割り当てのトレースを終了します。

...オブジェクト割り当てのトレースを終了します。

トレースを終了する為には、ObjectSpace.#trace_object_allocations_startを呼んだ回数分だけこのメソッドを呼ぶ必要があります。

@see ObjectSpace.#trace_object_allocations_start...