313件ヒット
[1-100件を表示]
(0.172秒)
ライブラリ
- ビルトイン (197)
-
minitest
/ unit (1) - objspace (55)
-
rdoc
/ context (11)
クラス
- Binding (6)
- Exception (11)
- Method (21)
-
MiniTest
:: Unit (1) - Module (5)
- Proc (11)
-
RDoc
:: Context (11) - Thread (22)
-
Thread
:: Backtrace :: Location (77) - UnboundMethod (11)
モジュール
- Kernel (22)
- ObjectSpace (55)
キーワード
-
NEWS for Ruby 2
. 0 . 0 (11) -
NEWS for Ruby 2
. 7 . 0 (5) -
absolute
_ path (11) -
allocation
_ sourcefile (11) -
allocation
_ sourceline (11) -
backtrace
_ locations (33) -
base
_ label (11) -
caller
_ locations (22) -
const
_ source _ location (5) - inspect (16)
- label (11)
- lineno (11)
- location (1)
-
mark
_ locations _ array (11) - path (11)
-
rb
_ gc _ mark _ locations (11) -
record
_ location (11) -
rubygems
/ security (11) -
source
_ location (39) -
to
_ s (16) -
trace
_ object _ allocations (11) -
trace
_ object _ allocations _ start (11) -
trace
_ object _ allocations _ stop (11)
検索結果
先頭5件
- Thread
:: Backtrace :: Location - Exception
# backtrace _ locations -> [Thread :: Backtrace :: Location] - static void mark
_ locations _ array(register VALUE *x , register long n) - Thread
# backtrace _ locations(range) -> [Thread :: Backtrace :: Location] | nil - Thread
# backtrace _ locations(start = 0 , length = nil) -> [Thread :: Backtrace :: Location] | nil
-
Thread
:: Backtrace :: Location (30018.0) -
Ruby のフレームを表すクラスです。
...caller_locations から生成されます。
//emlist[例1][ruby]{
# caller_locations.rb
def a(skip)
caller_locations(skip)
end
def b(skip)
a(skip)
end
def c(skip)
b(skip)
end
c(0..2).map do |call|
puts call.to_s
end
//}
例1の実行結果:
caller_locations.rb:2:in `a'
caller_locati......in `b'
caller_locations.rb:8:in `c'
//emlist[例2][ruby]{
# foo.rb
class Foo
attr_accessor :locations
def initialize(skip)
@locations = caller_locations(skip)
end
end
Foo.new(0..2).locations.map do |call|
puts call.to_s
end
//}
例2の実行結果:
init.rb:4:in `initialize'
ini......t.rb:8:in `new'
init.rb:8:in `<main>'
=== 参考
* Ruby VM アドベントカレンダー #4 vm_backtrace.c: https://www.atdot.net/~ko1/diary/201212.html#d4... -
Exception
# backtrace _ locations -> [Thread :: Backtrace :: Location] (27817.0) -
バックトレース情報を返します。Exception#backtraceに似ていますが、 Thread::Backtrace::Location の配列を返す点が異なります。
...ption#backtraceに似ていますが、
Thread::Backtrace::Location の配列を返す点が異なります。
現状では Exception#set_backtrace によって戻り値が変化する事はあり
ません。
//emlist[例: test.rb][ruby]{
require "date"
def check_long_month(month)
return if Dat......1).day == 31
raise "#{month} is not long month"
end
def get_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... -
static void mark
_ locations _ array(register VALUE *x , register long n) (24400.0) -
-
Thread
# backtrace _ locations(range) -> [Thread :: Backtrace :: Location] | nil (21824.0) -
スレッドの現在のバックトレースを Thread::Backtrace::Location の配 列で返します。
...クトレースを Thread::Backtrace::Location の配
列で返します。
引数で指定した値が範囲外の場合、スレッドがすでに終了している場合は nil
を返します。
@param start 開始フレームの位置を数値で指定します。
@param length 取得する......@param range 取得したいフレームの範囲を示す Range オブジェクトを指定します。
Kernel.#caller_locations と似ていますが、本メソッドは self に限定
した情報を返します。
//emlist[例][ruby]{
thread = Thread.new { sleep 1 }
thread.run
thread.backtrac......e_locations # => ["/path/to/test.rb:1:in `sleep'", "/path/to/test.rb:1:in `block in <main>'"]
//}
@see Thread::Backtrace::Location... -
Thread
# backtrace _ locations(start = 0 , length = nil) -> [Thread :: Backtrace :: Location] | nil (21824.0) -
スレッドの現在のバックトレースを Thread::Backtrace::Location の配 列で返します。
...クトレースを Thread::Backtrace::Location の配
列で返します。
引数で指定した値が範囲外の場合、スレッドがすでに終了している場合は nil
を返します。
@param start 開始フレームの位置を数値で指定します。
@param length 取得する......@param range 取得したいフレームの範囲を示す Range オブジェクトを指定します。
Kernel.#caller_locations と似ていますが、本メソッドは self に限定
した情報を返します。
//emlist[例][ruby]{
thread = Thread.new { sleep 1 }
thread.run
thread.backtrac......e_locations # => ["/path/to/test.rb:1:in `sleep'", "/path/to/test.rb:1:in `block in <main>'"]
//}
@see Thread::Backtrace::Location... -
Binding
# source _ location -> [String , Integer] (21307.0) -
self の Ruby のソースファイル名と行番号を返します。
...self の Ruby のソースファイル名と行番号を返します。
d:spec/variables#pseudo の __FILE__ と __LINE__ も参照してください。
//emlist[例][ruby]{
p binding.source_location # => ["test.rb", 1]
//}... -
ObjectSpace
. # trace _ object _ allocations { . . . } (21300.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 (21300.0) -
オブジェクト割り当てのトレースを開始します。
...オブジェクト割り当てのトレースを開始します。
@see ObjectSpace.#trace_object_allocations_stop... -
ObjectSpace
. # trace _ object _ allocations _ stop -> nil (21300.0) -
オブジェクト割り当てのトレースを終了します。
...オブジェクト割り当てのトレースを終了します。
トレースを終了する為には、ObjectSpace.#trace_object_allocations_startを呼んだ回数分だけこのメソッドを呼ぶ必要があります。
@see ObjectSpace.#trace_object_allocations_start... -
Kernel
. # caller _ locations(range) -> [Thread :: Backtrace :: Location] | nil (18524.0) -
現在のフレームを Thread::Backtrace::Location の配列で返します。引 数で指定した値が範囲外の場合は nil を返します。
...ムを Thread::Backtrace::Location の配列で返します。引
数で指定した値が範囲外の場合は nil を返します。
@param start 開始フレームの位置を数値で指定します。
@param length 取得するフレームの個数を指定します。
@param range 取得......ange オブジェクトを指定します。
//emlist[例][ruby]{
def test1(start, length)
locations = 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(sta......end
caller_locations # => []
test3(1, nil)
# => ["/Users/user/test.rb:9:in `test2'", "/Users/user/test.rb:13:in `test3'", "/Users/user/test.rb:17:in `<main>'"]
# => [9, 13, 17]
# => ["/Users/user/test.rb", "/Users/user/test.rb", "/Users/user/test.rb"]
test3(1, 2)
# => ["/Users/user/test.rb:9:in `te...