Class: Crashreport

Inherits:
Object
  • Object
show all
Defined in:
lib/symsym.rb

Overview

A class representing a crashreport

This must be initialized with the crashreport as plain text, a path where to look for .dSYM bundlles can be given. The report can be de-symbolized with symbolicate!

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(r, dsymfile = nil) ⇒ Crashreport

Creates a new Crashreport object

r is the crash report as string. dsymfile is a path where this object will look for a matching .dSYM bundle



75
76
77
78
79
80
81
82
# File 'lib/symsym.rb', line 75

def initialize(r, dsymfile=nil)
  @report = r
  @dsymfile = dsymfile
  @identifier         = @report[/Identifier:\s*(.*)/, 1]
  @shortversion       = @report[/Version:\s*(.*) \((.*)\)/, 1]
  @version            = @report[/Version:\s*(.*) \((.*)\)/, 2]
  findDysmFile(dsymfile)
end

Instance Attribute Details

#identifierObject (readonly)

Returns the value of attribute identifier.



63
64
65
# File 'lib/symsym.rb', line 63

def identifier
  @identifier
end

#reportObject (readonly)

Returns the value of attribute report.



63
64
65
# File 'lib/symsym.rb', line 63

def report
  @report
end

#shortversionObject (readonly)

Returns the value of attribute shortversion.



63
64
65
# File 'lib/symsym.rb', line 63

def shortversion
  @shortversion
end

#versionObject (readonly)

Returns the value of attribute version.



63
64
65
# File 'lib/symsym.rb', line 63

def version
  @version
end

Class Method Details

.address_from_report_line(s) ⇒ Object

Extracts the address from a crashreport-line



66
67
68
69
70
# File 'lib/symsym.rb', line 66

def self.address_from_report_line(s)
  a = s[/(0x[0-9a-f]+)/, 1]
  return a.hex if a
  nil
end

Instance Method Details

#addressesObject

returns an array of all adresses found in the crashreport



100
101
102
103
104
105
106
107
108
# File 'lib/symsym.rb', line 100

def addresses
  return @addresses if @addresses
  @addresses = []
  @report.lines.each do |l|
    a = Crashreport.address_from_report_line(l)
    @addresses << a if a
  end
  @addresses
end

#findDysmFile(searchpath) ⇒ Object

Find dSYM Bundle

Look for a matching dSYM bundle. Use the current directory when nil



87
88
89
90
91
92
93
94
95
96
97
# File 'lib/symsym.rb', line 87

def findDysmFile(searchpath)
  Find.find(searchpath || '.') do |f|
    if f =~ /.dSYM/
      dsymfile = DsymFile.new(f)
      if dsymfile.matches_report? self
        @dsymfile = dsymfile
        return
      end
    end
  end
end

#symbolicate!Object

de-symbolizes the crashreport

The get the report with .report aftwards



113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/symsym.rb', line 113

def symbolicate!
  return if @isSymbolicated
  buildgdbcommandfile
  gdbout = rungdb
  @symbols = []
  gdbout.lines.each do |l|
    @symbols << Symbolized.new(l)
  end
  
  addresses.each do |a|
    @symbols.each do |s|
      if s.startaddress  && a >= s.startaddress && a <= s.endaddress
        report.gsub!(/(0x.*#{a.to_s(16)}) (.*)/, "#{$1} #{s.symbol} (#{s.filename}:#{s.line})")
      end # address matches
    end # @symbols.each
  end# addresses.each
  @isSymbolicated = true
end