class Satyr::Report
Report
containing all data relevant to a software problem
Public Class Methods
new(json)
click to toggle source
Parses given JSON string to create new Report
# File lib/satyr.rb, line 89 def initialize(json) error_msg = ::FFI::MemoryPointer.new(:pointer, 1) pointer = Satyr::FFI.sr_report_from_json_text json.to_s, error_msg error_msg = error_msg.read_pointer unless error_msg.null? message = error_msg.read_string Satyr::set_encoding message Satyr::FFI.free error_msg raise SatyrError, "Failed to parse JSON: #{message}" end # from_json_text should never return NULL without setting error_msg, # better err on the safe side though raise SatyrError, "Failed to create stacktrace" if pointer.null? @struct = Satyr::FFI::ReportStruct.new pointer end
Public Instance Methods
stacktrace()
click to toggle source
Returns Stacktrace
of the report
# File lib/satyr.rb, line 108 def stacktrace stacktrace = @struct[:stacktrace] return nil if stacktrace.null? # There's no sr_stacktrace_dup in libsatyr.so.3, we've got to find out # the type ourselves. dup = case @struct[:type] when :core Satyr::FFI.sr_core_stacktrace_dup(stacktrace) when :python Satyr::FFI.sr_python_stacktrace_dup(stacktrace) when :kerneloops Satyr::FFI.sr_koops_stacktrace_dup(stacktrace) when :java Satyr::FFI.sr_java_stacktrace_dup(stacktrace) when :gdb Satyr::FFI.sr_gdb_stacktrace_dup(stacktrace) else raise SatyrError, "Invalid report type" end raise SatyrError, "Failed to obtain stacktrace" if dup.null? Stacktrace.send(:new, dup) end