Class: Squash::Symbolicator::Symbols
- Inherits:
-
Object
- Object
- Squash::Symbolicator::Symbols
- Includes:
- Enumerable, SerialBox
- Defined in:
- lib/squash/symbolicator/symbols.rb
Overview
An aggregation of the ‘Symbolicator::Symbol`s of a binary. This class is enumerable.
Instance Method Summary collapse
-
#[](*args) ⇒ Object
Delegated to ‘Array`.
-
#add(start_address, end_address, file, line, symbol) ⇒ Object
Adds a symbol definition to the aggregation.
-
#clear(*args) ⇒ Object
Delegated to ‘Array`.
-
#each(*args) ⇒ Object
Delegated to ‘Array`.
-
#for(address) ⇒ Symbol?
Returns the ‘Symbolicator::Symbol` containing a given program counter address.
-
#initialize ⇒ Symbols
constructor
Creates a new empty aggregation.
- #inspect ⇒ Object
-
#size(*args) ⇒ Object
Delegated to ‘Array`.
Constructor Details
#initialize ⇒ Symbols
Creates a new empty aggregation.
51 52 53 |
# File 'lib/squash/symbolicator/symbols.rb', line 51 def initialize @symbols = Array.new end |
Instance Method Details
#[](*args) ⇒ Object
Delegated to ‘Array`.
92 |
# File 'lib/squash/symbolicator/symbols.rb', line 92 def [](*args) @symbols[*args] end |
#add(start_address, end_address, file, line, symbol) ⇒ Object
Adds a symbol definition to the aggregation.
66 67 68 69 70 71 72 73 74 75 |
# File 'lib/squash/symbolicator/symbols.rb', line 66 def add(start_address, end_address, file, line, symbol) index = @symbols.find_index { |sym| sym.start_address > start_address || (sym.start_address == start_address && sym.end_address >= end_address) } new_sym = Squash::Symbolicator::Symbol.new(start_address, end_address, file, line, symbol) if index @symbols.insert index, new_sym else @symbols << new_sym end end |
#clear(*args) ⇒ Object
Delegated to ‘Array`.
94 |
# File 'lib/squash/symbolicator/symbols.rb', line 94 def clear(*args) @symbols.clear(*args) end |
#each(*args) ⇒ Object
Delegated to ‘Array`.
90 |
# File 'lib/squash/symbolicator/symbols.rb', line 90 def each(*args) @symbols.each(*args) end |
#for(address) ⇒ Symbol?
Returns the ‘Symbolicator::Symbol` containing a given program counter address. If there are symbols with overlapping address ranges, the one with the smallest range is returned.
85 86 87 |
# File 'lib/squash/symbolicator/symbols.rb', line 85 def for(address) @symbols.detect { |sym| sym.start_address <= address && sym.end_address >= address } end |
#inspect ⇒ Object
99 |
# File 'lib/squash/symbolicator/symbols.rb', line 99 def inspect() "#<#{self.class} [#{size} symbols]>" end |
#size(*args) ⇒ Object
Delegated to ‘Array`.
96 |
# File 'lib/squash/symbolicator/symbols.rb', line 96 def size(*args) @symbols.size(*args) end |