Class: HeapInfo::Arena
- Inherits:
-
Object
- Object
- HeapInfo::Arena
- Defined in:
- lib/heapinfo/arena.rb
Overview
Records status of an arena, including bin(s) and top chunk.
Instance Attribute Summary collapse
-
#fastbin ⇒ Array<HeapInfo::Fastbin>
readonly
Fastbins in an array.
-
#last_remainder ⇒ HeapInfo::Chunk
readonly
Current last remainder.
-
#smallbin ⇒ Array<HeapInfo::Smallbin>
readonly
Smallbins in an array.
-
#system_mem ⇒ Integer
readonly
The
system_memin arena. -
#top_chunk ⇒ HeapInfo::Chunk
readonly
Current top chunk.
-
#unsorted_bin ⇒ Array<HeapInfo::UnsortedBin>
readonly
The unsorted bin (array size will always be one).
Instance Method Summary collapse
-
#initialize(base, size_t, dumper) ⇒ Arena
constructor
Instantiate a Arena object.
-
#layouts(*args) ⇒ String
Pretty dump of bins layouts.
-
#reload! ⇒ HeapInfo::Arena
Refresh all attributes.
Constructor Details
#initialize(base, size_t, dumper) ⇒ Arena
Instantiate a HeapInfo::Arena object.
26 27 28 29 30 31 |
# File 'lib/heapinfo/arena.rb', line 26 def initialize(base, size_t, dumper) @base = base @size_t = size_t @dumper = dumper reload! end |
Instance Attribute Details
#fastbin ⇒ Array<HeapInfo::Fastbin> (readonly)
Returns Fastbins in an array.
8 9 10 |
# File 'lib/heapinfo/arena.rb', line 8 def fastbin @fastbin end |
#last_remainder ⇒ HeapInfo::Chunk (readonly)
Returns Current last remainder.
12 13 14 |
# File 'lib/heapinfo/arena.rb', line 12 def last_remainder @last_remainder end |
#smallbin ⇒ Array<HeapInfo::Smallbin> (readonly)
Returns Smallbins in an array.
16 17 18 |
# File 'lib/heapinfo/arena.rb', line 16 def smallbin @smallbin end |
#system_mem ⇒ Integer (readonly)
Returns The system_mem in arena.
18 19 20 |
# File 'lib/heapinfo/arena.rb', line 18 def system_mem @system_mem end |
#top_chunk ⇒ HeapInfo::Chunk (readonly)
Returns Current top chunk.
10 11 12 |
# File 'lib/heapinfo/arena.rb', line 10 def top_chunk @top_chunk end |
#unsorted_bin ⇒ Array<HeapInfo::UnsortedBin> (readonly)
Returns The unsorted bin (array size will always be one).
14 15 16 |
# File 'lib/heapinfo/arena.rb', line 14 def unsorted_bin @unsorted_bin end |
Instance Method Details
#layouts(*args) ⇒ String
Pretty dump of bins layouts.
64 65 66 67 68 69 70 71 72 |
# File 'lib/heapinfo/arena.rb', line 64 def layouts(*args) args.concat(%i[fast unsort small large]) if args.map(&:to_s).include?('all') args = args.map(&:to_s).join('|') res = '' res += fastbin.map(&:inspect).join if args.include?('fast') res += unsorted_bin.inspect if args.include?('unsort') res += smallbin.map(&:inspect).join if args.include?('small') res end |
#reload! ⇒ HeapInfo::Arena
Refresh all attributes. Retrive data using @dumper, load bins, top chunk etc.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/heapinfo/arena.rb', line 36 def reload! top_ptr_offset = @base + 8 + size_t * 10 top_ptr = Helper.unpack(size_t, @dumper.call(top_ptr_offset, size_t)) @fastbin = [] return self if top_ptr.zero? # arena not init yet @top_chunk = Chunk.new(size_t, top_ptr, @dumper) @last_remainder = Chunk.new(size_t, top_ptr_offset + 8, @dumper) # this offset diff after 2.23 @system_mem = Array.new(2) do |off| Helper.unpack(size_t, @dumper.call(top_ptr_offset + 258 * size_t + 16 + off * size_t, size_t)) end.find { |val| val >= 0x21000 && (val & 0xfff).zero? } @fastbin = Array.new(7) do |idx| Fastbin.new(size_t, @base + 8 - size_t * 2 + size_t * idx, @dumper, head: true).tap { |f| f.index = idx } end @unsorted_bin = UnsortedBin.new(size_t, top_ptr_offset, @dumper, head: true) @smallbin = Array.new(62) do |idx| Smallbin.new(size_t, @base + 8 + size_t * (12 + 2 * idx), @dumper, head: true).tap { |s| s.index = idx } end self end |