Class: HeapInfo::Fastbin
Overview
Class for record fastbin type chunk.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#fd ⇒ Integer
readonly
Fd.
-
#index ⇒ Integer
Index.
Attributes inherited from Chunk
#base, #data, #prev_size, #size_t
Instance Method Summary collapse
-
#idx_to_size ⇒ Integer
Mapping index of fastbin to chunk size.
-
#initialize(_size_t, base) ⇒ Fastbin
constructor
Instantiate a Fastbin object.
-
#inspect ⇒ String
Pretty inspect.
-
#list ⇒ Array<Integer, Symbol, nil>
Single link list of
fdchain. -
#title ⇒ String
For pretty inspect.
Methods inherited from Chunk
#bintype, #flags, #mmapped?, #non_main_arena?, #prev_inuse?, #size, #to_s
Constructor Details
#initialize(_size_t, base) ⇒ Fastbin
Instantiate a HeapInfo::Fastbin object.
89 90 91 92 |
# File 'lib/heapinfo/arena.rb', line 89 def initialize(_size_t, base, *) super @fd = fd_of(base) end |
Instance Attribute Details
#fd ⇒ Integer (readonly)
Returns fd.
82 83 84 |
# File 'lib/heapinfo/arena.rb', line 82 def fd @fd end |
#index ⇒ Integer
Returns index.
84 85 86 |
# File 'lib/heapinfo/arena.rb', line 84 def index @index end |
Instance Method Details
#idx_to_size ⇒ Integer
Mapping index of fastbin to chunk size.
96 97 98 |
# File 'lib/heapinfo/arena.rb', line 96 def idx_to_size index * size_t * 2 + size_t * 4 end |
#inspect ⇒ String
Pretty inspect.
110 111 112 113 114 115 116 |
# File 'lib/heapinfo/arena.rb', line 110 def inspect title + list.map do |ptr| next "(#{ptr})\n" if ptr.is_a?(Symbol) next " => (nil)\n" if ptr.nil? format(' => %s', Helper.color(format('%#x', ptr))) end.join end |
#list ⇒ Array<Integer, Symbol, nil>
Returns single link list of fd chain. Last element will be:
-
:loopif loop detectded -
:invalidinvalid address detected -
nilend with zero address (normal case).
123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/heapinfo/arena.rb', line 123 def list dup = {} ptr = @fd ret = [] while ptr != 0 ret << ptr return ret << :loop if dup[ptr] dup[ptr] = true ptr = fd_of(ptr) return ret << :invalid if ptr.nil? end ret << nil end |