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

Feature/apmi 2892: ios crash reporting improvements #6

Open
wants to merge 6 commits into
base: main
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
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func initializeCrashReporting() {
defer {
startupSpan.end()
}
let config = PLCrashReporterConfig(signalHandlerType: .BSD, symbolicationStrategy: PLCrashReporterSymbolicationStrategy(rawValue: 0) /* none */)
let config = PLCrashReporterConfig(signalHandlerType: .BSD, symbolicationStrategy: .all /* all */)
let crashReporter_ = PLCrashReporter(configuration: config)
if crashReporter_ == nil {
startupSpan.setAttribute(key: "error.message", value: "Cannot construct PLCrashReporter")
Expand Down Expand Up @@ -102,6 +102,13 @@ func loadPendingCrashReport(_ data: Data!) throws {
span.setAttribute(key: "exception.type", value: report.exceptionInfo.exceptionName)
span.setAttribute(key: "exception.message", value: report.exceptionInfo.exceptionReason)
}
// binary images
let text = NSMutableString()
for case let binaryImage as PLCrashReportBinaryImageInfo in report.images {
text.append(binaryImageToStack(report: report, binaryImage: binaryImage))
text.append("\n")
}
span.setAttribute(key: "binaryImages", value: String(text))
span.end(time: now)
}

Expand Down Expand Up @@ -144,7 +151,46 @@ func formatStackFrame(frame: PLCrashReportStackFrameInfo, frameNum: Int, report:
}
return String(format: "%-4ld%-35@ 0x%016lx %@", frameNum, imageName, frame.instructionPointer, symbolString!)
}

// Add binary image as attribute of crash span
func binaryImageToStack(report: PLCrashReport, binaryImage: PLCrashReportBinaryImageInfo) -> String {
var baseAddress: UInt64 = 0
var imageSize: UInt64 = 0
var imageName = "???"
var imageUUID = "XXX"
var shortname = imageName
let imageInfo = binaryImage
var binaryArchi = "Unknown"
if imageInfo != nil {
imageName = imageInfo.imageName
shortname = URL(fileURLWithPath: imageName).lastPathComponent
baseAddress = imageInfo.imageBaseAddress
imageSize = imageInfo.imageSize
imageUUID = imageInfo.imageUUID
// PLCrashReportSystemInfo PLCrashReportArchitecture
binaryArchi = convertBinaryArchitectueIntoString(archi: report.systemInfo.architecture)
}
return String(format: "0x%lx 0x%lx %@ %@ <%@> %-35@ ", baseAddress, imageSize, shortname, binaryArchi, imageUUID, imageName)
}
func convertBinaryArchitectueIntoString(archi: PLCrashReportArchitecture) -> String {
var architecture = ""
switch archi {
case PLCrashReportArchitectureX86_32:
architecture = "x86-32"
case PLCrashReportArchitectureX86_64:
architecture = "x86-64"
case PLCrashReportArchitectureARMv6:
architecture = "ARMv6"
case PLCrashReportArchitecturePPC:
architecture = "PPC"
case PLCrashReportArchitecturePPC64:
architecture = "PPC64"
case PLCrashReportArchitectureARMv7:
architecture = "ARMv7"
default:
architecture = "Unknown"
}
return architecture
}
/**
Call start() *after* SplunkRum.initialize()
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class CrashTests: XCTestCase {
XCTAssertEqual(crashReport!.attributes["error"]?.description, "true")
XCTAssertEqual(crashReport!.attributes["exception.type"]?.description, "SIGILL")
XCTAssertTrue(crashReport!.attributes["exception.stacktrace"]?.description.contains("UIKitCore") ?? false)

XCTAssertTrue(crashReport!.attributes["binaryImages"]?.description.contains(".dylib") ?? false)
XCTAssertNotNil(startup)
XCTAssertEqual(startup!.attributes["component"]?.description, "appstart")

Expand Down