Class: Dwarftree::DebugInfoParser
- Inherits:
-
Object
- Object
- Dwarftree::DebugInfoParser
- Defined in:
- lib/dwarftree/debug_info_parser.rb
Constant Summary collapse
- CommandError =
Class.new(StandardError)
- ParserError =
Class.new(StandardError)
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(offset_ranges, flat:) ⇒ DebugInfoParser
constructor
A new instance of DebugInfoParser.
- #parse(debug_info) ⇒ Array<Dwarftree::DIE::CompileUnit>
Constructor Details
#initialize(offset_ranges, flat:) ⇒ DebugInfoParser
Returns a new instance of DebugInfoParser.
36 37 38 39 40 |
# File 'lib/dwarftree/debug_info_parser.rb', line 36 def initialize(offset_ranges, flat:) @offset_die = {} # { 12345 => #<Dwarftree::DIE:* ...> } @offset_ranges = offset_ranges # { 12345 => [(12345..67890), ...] } @flat = flat end |
Class Method Details
.parse(object, flat:) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/dwarftree/debug_info_parser.rb', line 21 def self.parse(object, flat:) begin offset_ranges = Dwarftree::DebugRangesParser.parse(object) rescue Dwarftree::DebugRangesParser::CommandError => e raise CommandError.new(e.) end cmd = ['objdump', '--dwarf=info', object] debug_info = IO.popen(cmd, &:read) unless $?.success? raise CommandError.new("Failed to run: #{cmd.join(' ')}") end new(offset_ranges, flat: flat).parse(debug_info) end |
Instance Method Details
#parse(debug_info) ⇒ Array<Dwarftree::DIE::CompileUnit>
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/dwarftree/debug_info_parser.rb', line 44 def parse(debug_info) nodes = [] each_compilation_unit(debug_info) do |compilation_unit| dies = parse_compilation_unit(compilation_unit) if @flat nodes += dies else nodes << build_tree(dies) end end nodes end |