Class: Satyr::Report
- Inherits:
-
Object
- Object
- Satyr::Report
- Defined in:
- lib/satyr.rb
Overview
Report containing all data relevant to a software problem
Instance Method Summary collapse
-
#initialize(json) ⇒ Report
constructor
Parses given JSON string to create new Report.
-
#stacktrace ⇒ Object
Returns Stacktrace of the report.
Constructor Details
#initialize(json) ⇒ Report
Parses given JSON string to create new Report
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# 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? = error_msg.read_string Satyr::set_encoding Satyr::FFI.free error_msg raise SatyrError, "Failed to parse JSON: #{}" 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 |
Instance Method Details
#stacktrace ⇒ Object
Returns Stacktrace of the report
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# 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 |