Class: HeapInfo::Segment
- Inherits:
-
Object
- Object
- HeapInfo::Segment
- Defined in:
- lib/heapinfo/segment.rb
Overview
Record the base address and name in maps
Direct Known Subclasses
Instance Attribute Summary collapse
-
#base ⇒ Object
readonly
Base address of segment.
-
#name ⇒ Object
readonly
Name of segment.
Class Method Summary collapse
-
.find(maps, pattern) ⇒ HeapInfo::Segment?
Helper for creating a Segment.
Instance Method Summary collapse
-
#coerce(other) ⇒ (Object, Integer)
To support addr - h.libc.
-
#initialize(base, name) ⇒ Segment
constructor
Instantiate a Segment object.
-
#to_s ⇒ String
Hook
#to_s
for pretty printing.
Constructor Details
#initialize(base, name) ⇒ Segment
Instantiate a HeapInfo::Segment object
11 12 13 14 |
# File 'lib/heapinfo/segment.rb', line 11 def initialize(base, name) @base = base @name = name end |
Instance Attribute Details
#base ⇒ Object (readonly)
Base address of segment
5 6 7 |
# File 'lib/heapinfo/segment.rb', line 5 def base @base end |
#name ⇒ Object (readonly)
Name of segment
7 8 9 |
# File 'lib/heapinfo/segment.rb', line 7 def name @name end |
Class Method Details
.find(maps, pattern) ⇒ HeapInfo::Segment?
Helper for creating a HeapInfo::Segment.
Search the specific pattern
in maps
and return a
HeapInfo::Segment object.
42 43 44 45 46 |
# File 'lib/heapinfo/segment.rb', line 42 def self.find(maps, pattern) return Nil.new if pattern.nil? needs = maps.select { |m| pattern.is_a?(Regexp) ? m[3] =~ pattern : m[3].include?(pattern) } new(needs.map(&:first).min, needs[0][3]) unless needs.empty? end |
Instance Method Details
#coerce(other) ⇒ (Object, Integer)
To support addr - h.libc. Treat all operations are manipulating on
base
.
29 30 31 |
# File 'lib/heapinfo/segment.rb', line 29 def coerce(other) [other, base] end |
#to_s ⇒ String
Hook #to_s
for pretty printing
18 19 20 |
# File 'lib/heapinfo/segment.rb', line 18 def to_s format("%-28s\tbase @ #{Helper.color(format('%#x', base))}\n", Helper.color(name.split('/')[-1])) end |