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.
92 93 94 95 |
# File 'lib/heapinfo/arena.rb', line 92 def initialize(_size_t, base, *, **) super @fd = fd_of(base) end |
Instance Attribute Details
#fd ⇒ Integer (readonly)
Returns fd.
85 86 87 |
# File 'lib/heapinfo/arena.rb', line 85 def fd @fd end |
#index ⇒ Integer
Returns index.
87 88 89 |
# File 'lib/heapinfo/arena.rb', line 87 def index @index end |
Instance Method Details
#idx_to_size ⇒ Integer
Mapping index of fastbin to chunk size.
99 100 101 |
# File 'lib/heapinfo/arena.rb', line 99 def idx_to_size index * size_t * 2 + size_t * 4 end |
#inspect ⇒ String
Pretty inspect.
113 114 115 116 117 118 119 120 |
# File 'lib/heapinfo/arena.rb', line 113 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 detectednilend with zero address (normal case).
127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/heapinfo/arena.rb', line 127 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 |
#title ⇒ String
For pretty inspect.
105 106 107 108 109 |
# File 'lib/heapinfo/arena.rb', line 105 def title class_name = Helper.color(Helper.class_name(self), sev: :bin) size_str = index.nil? ? nil : "[#{Helper.color(format('%#x', idx_to_size))}]" "#{class_name}#{size_str}: " end |