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
16 17 18 19 |
# File 'lib/heapinfo/segment.rb', line 16 def initialize(base, name) @base = base @name = name end |
Instance Attribute Details
#base ⇒ Object (readonly)
Base address of segment
10 11 12 |
# File 'lib/heapinfo/segment.rb', line 10 def base @base end |
#name ⇒ Object (readonly)
Name of segment
12 13 14 |
# File 'lib/heapinfo/segment.rb', line 12 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.
47 48 49 50 51 52 53 54 55 |
# File 'lib/heapinfo/segment.rb', line 47 def self.find(maps, pattern) return Nil.instance if pattern.nil? needs = maps.select { |m| pattern.is_a?(Regexp) ? m[3] =~ pattern : m[3].include?(pattern) } # Use the last heap segment when multiple of them present return new(needs.map(&:first).max, needs[0][3]) if pattern == '[heap]' 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.
34 35 36 |
# File 'lib/heapinfo/segment.rb', line 34 def coerce(other) [other, base] end |