Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Squash ios crash log symbolication #91

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions app/models/occurrence.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.

begin
if(SquashIosCrashLogSymbolication.osx?)
@@SquashIosCrashLogSymbolicationAvailable = true;
else
@@SquashIosCrashLogSymbolicationAvailable = false;
end
rescue LoadError
@@SquashIosCrashLogSymbolicationAvailable = false;
end

# An individual occurrence of a {Bug}, or put another way, a single instance of
# an exception occurring and being recorded. Occurrences record all relevant
# information about the exception itself and the state of the program when the
Expand Down Expand Up @@ -383,6 +393,7 @@ class Occurrence < ActiveRecord::Base
# Universal
message: {presence: true, length: {maximum: 1000}},
backtraces: {type: Array, presence: true},
crash_log: {type: String, allow_nil: true},
ivars: {type: Hash, allow_nil: true},
user_data: {type: Hash, allow_nil: true},
parent_exceptions: {type: Array, allow_nil: true},
Expand Down Expand Up @@ -566,6 +577,12 @@ def additional?
user_data.present? || extra_data.present? || ivars.present?
end

# @return [true, false] Whether or not this Occurrence has a crash log attached

def crash_log?
crash_log.present?
end

# @return [true, false] Whether or not this exception occurred as part of an
# XMLHttpRequest (Ajax) request.

Expand Down Expand Up @@ -691,6 +708,29 @@ def symbolicate(symb=nil)
end
end
self.backtraces = bt # refresh the actual JSON

if (user_data.present? && @@SquashIosCrashLogSymbolicationAvailable )
begin
Rails.logger.debug "-- SquashIosCrashLogSymbolication.symbolicate_crash called... --"

self.crash_log = SquashIosCrashLogSymbolication.symbolicate_crash(user_data, SquashIosCrashLogSymbolication.env)

# if we have a symbolicated crash_log, remove the encoded plcrashlog
if(self.crash_log && self.crash_log.present?)
self.user_data = nil
Rails.logger.debug "-- SquashIosCrashLogSymbolication.symbolicate_crash complete. crash_log contains crash_log, user_data set to nil --"
end
rescue Object => err
# don't get into an infinite loop of notifying Squash
Rails.logger.error "-- ERROR IN symbolicate #{err.object_id} --"
Rails.logger.error "SquashIosCrashLogSymbolication.symbolicate(user_data, #{SquashIosCrashLogSymbolication.env})\n"
Rails.logger.error err
Rails.logger.error err.backtrace.join("\n")
Rails.logger.error @attrs.inspect
Rails.logger.error "-- END ERROR #{err.object_id} --"
raise if Rails.env.test?
end
end
end

# Like {#symbolicate}, but saves the record.
Expand Down
38 changes: 38 additions & 0 deletions app/views/additions/crashlog_rendering.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# encoding: utf-8

# Copyright 2013 Cerner Corp.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Adds methods to a view class that allow it to render Crash Logs in a standard
# style.

module CrashlogRendering
protected

# Renders a Crash Log.
#
# @param [String] crash_log The Crash Log to render, in the format
# used by {Occurrence}.

def render_crash_log(crash_log)

h4 "Crash Log"
div(id:'crash_log') do
text raw ("<pre>#{crash_log}</pre>")
end
end


end

9 changes: 8 additions & 1 deletion app/views/occurrences/show.html.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ module Occurrences
# @private
class Show < Views::Layouts::Application
include BacktraceRendering
include CrashlogRendering

needs :project, :environment, :bug, :occurrence

Expand Down Expand Up @@ -116,7 +117,13 @@ def tab_content
end

def backtrace_tab
render_backtraces @occurrence.backtraces, 'root'
if @occurrence.crash_log?
# do not convert \n to <br/> and \n\n to <p> using simple_format()
# instead use <pre></pre> tags in render_crash_log
render_crash_log @occurrence.crash_log
else
render_backtraces @occurrence.backtraces, 'root'
end
end

def parents_tab
Expand Down
35 changes: 35 additions & 0 deletions config/symbolication_paths.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
# for each environment, provide paths used by the symbolication process
development:

# PATH to PLCrashReporter's plcrashutil
plcrashutil: /usr/local/bin/plcrashutil

# PATH TO Xcode's symbolicatecrash script
symbolicationcrash: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/PrivateFrameworks/DTDeviceKit.framework/Versions/A/Resources/symbolicatecrash

# PATH TO Application symbols - Apple's spotlight will try to locate the Application symbols but give it a hint
symbolpath: /Library/

test:

# PATH to PLCrashReporter's plcrashutil
plcrashutil: /usr/local/bin/plcrashutil

# PATH TO Xcode's symbolicatecrash script
symbolicationcrash: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/PrivateFrameworks/DTDeviceKit.framework/Versions/A/Resources/symbolicatecrash

# PATH TO Application symbols - Apple's spotlight will try to locate the Application symbols but give it a hint
symbolpath: /Library/

production:

# PATH to PLCrashReporter's plcrashutil
plcrashutil: /usr/local/bin/plcrashutil

# PATH TO Xcode's symbolicatecrash script
symbolicationcrash: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/PrivateFrameworks/DTDeviceKit.framework/Versions/A/Resources/symbolicatecrash

# PATH TO Application symbols - Apple's spotlight will try to locate the Application symbols but give it a hint
symbolpath: /Library/

14 changes: 14 additions & 0 deletions doc/README_FOR_APP.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Additional configuration options can be found in the following locations:
* `config/application.rb`
* `config/environments/*.rb`
* `config/environments/*/*.yml`
* `config/symbolication_paths.yml`

If you don't see what you're looking for in any of those files, you'll probably
have to change the code to make it work. Don't be afraid -- the code is
Expand All @@ -58,6 +59,19 @@ Squash requires the following:
* The Bundler gem
* Git 1.7 or newer

To realize full stack symbolication for iOS/OS X crashes, the following
are additional requirements (either on the computer running Squash or
on the computer where script/squash_symbolicate_ios_crash will be run):

* OS X
* Xcode
* plcrashutil (part of PLCrashReporter)
* iOS/OS X application .dSYM files

In the latter form, the script/squash_symbolicate_ios_crash, config/databas.yml,
config/symbolication_paths.yml, and the lib/squash_ios_crash_log_symbolication.rb
files and folder structure are required.

### Notes on some of the gem and library choices

**Why do you specifically require PostgreSQL?** Squash uses a lot of
Expand Down
Loading