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_sfor pretty printing.
Constructor Details
#initialize(base, name) ⇒ Segment
Instantiate a HeapInfo::Segment object
14 15 16 17 |
# File 'lib/heapinfo/segment.rb', line 14 def initialize(base, name) @base = base @name = name end |
Instance Attribute Details
#base ⇒ Object (readonly)
Base address of segment
8 9 10 |
# File 'lib/heapinfo/segment.rb', line 8 def base @base end |
#name ⇒ Object (readonly)
Name of segment
10 11 12 |
# File 'lib/heapinfo/segment.rb', line 10 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.
45 46 47 48 49 |
# File 'lib/heapinfo/segment.rb', line 45 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.
32 33 34 |
# File 'lib/heapinfo/segment.rb', line 32 def coerce(other) [other, base] end |