From 2b007503e098504b579523bf1b1fdf364b5ecd75 Mon Sep 17 00:00:00 2001 From: Shraddha Hattimare Date: Mon, 11 Apr 2022 15:05:40 +0530 Subject: [PATCH 1/6] featue/APMI-2892 - add binary image as attribute of crash span. - change symbolication stretagy to reformate the stackthread. --- .../CrashReporting.swift | 49 ++++++++++++++++++- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/SplunkRumCrashReporting/SplunkRumCrashReporting/CrashReporting.swift b/SplunkRumCrashReporting/SplunkRumCrashReporting/CrashReporting.swift index 92e13c4..fe6dd44 100644 --- a/SplunkRumCrashReporting/SplunkRumCrashReporting/CrashReporting.swift +++ b/SplunkRumCrashReporting/SplunkRumCrashReporting/CrashReporting.swift @@ -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") @@ -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) } @@ -144,7 +151,45 @@ func formatStackFrame(frame: PLCrashReportStackFrameInfo, frameNum: Int, report: } return String(format: "%-4ld%-35@ 0x%016lx %@", frameNum, imageName, frame.instructionPointer, symbolString!) } - +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() */ From f5073ae018db204be54778932e9bb9bf2cc6095e Mon Sep 17 00:00:00 2001 From: Shraddha Hattimare Date: Mon, 11 Apr 2022 15:12:33 +0530 Subject: [PATCH 2/6] Feature/APMI-2892:iOS Crash reporting improvements add binary image as attribute of crash span. change symbolication stretagy to reformate the stackthread. --- .../SplunkRumCrashReporting/CrashReporting.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/SplunkRumCrashReporting/SplunkRumCrashReporting/CrashReporting.swift b/SplunkRumCrashReporting/SplunkRumCrashReporting/CrashReporting.swift index fe6dd44..5f0a46c 100644 --- a/SplunkRumCrashReporting/SplunkRumCrashReporting/CrashReporting.swift +++ b/SplunkRumCrashReporting/SplunkRumCrashReporting/CrashReporting.swift @@ -151,6 +151,7 @@ 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 From 4e4c7fe4785e8469019e62547f4ac94912696e9c Mon Sep 17 00:00:00 2001 From: Shraddha Hattimare Date: Wed, 13 Apr 2022 15:17:58 +0530 Subject: [PATCH 3/6] feature/APMI-2892 changed in crashtest. --- .../SplunkRumCrashReportingTests/CrashTests.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SplunkRumCrashReporting/SplunkRumCrashReportingTests/CrashTests.swift b/SplunkRumCrashReporting/SplunkRumCrashReportingTests/CrashTests.swift index f736cd1..457f0d9 100644 --- a/SplunkRumCrashReporting/SplunkRumCrashReportingTests/CrashTests.swift +++ b/SplunkRumCrashReporting/SplunkRumCrashReportingTests/CrashTests.swift @@ -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") From 18b0205d9475cc2920f31f64c78ac830a824c959 Mon Sep 17 00:00:00 2001 From: Piyush23786 Date: Fri, 29 Jul 2022 11:47:26 +0530 Subject: [PATCH 4/6] APMI-2892 Custom data --- .../SplunkRumCrashReporting/CrashReporting.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SplunkRumCrashReporting/SplunkRumCrashReporting/CrashReporting.swift b/SplunkRumCrashReporting/SplunkRumCrashReporting/CrashReporting.swift index 5f0a46c..2aca341 100644 --- a/SplunkRumCrashReporting/SplunkRumCrashReporting/CrashReporting.swift +++ b/SplunkRumCrashReporting/SplunkRumCrashReporting/CrashReporting.swift @@ -69,7 +69,7 @@ private func buildTracer() -> Tracer { return OpenTelemetry.instance.tracerProvider.get(instrumentationName: "splunk-ios-crashreporting", instrumentationVersion: CrashReportingVersionString) } - +//CustomData func updateCrashReportSessionId() { TheCrashReporter?.customData = SplunkRum.getSessionId().data(using: .utf8) } From 37b255ae28035113b134a29637f2bd6253d6b858 Mon Sep 17 00:00:00 2001 From: Piyush23786 Date: Fri, 29 Jul 2022 11:52:16 +0530 Subject: [PATCH 5/6] APMI2892 Spacing Violation: Opening braces --- .../SplunkRumCrashReporting/CrashReporting.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SplunkRumCrashReporting/SplunkRumCrashReporting/CrashReporting.swift b/SplunkRumCrashReporting/SplunkRumCrashReporting/CrashReporting.swift index 2aca341..5f0a46c 100644 --- a/SplunkRumCrashReporting/SplunkRumCrashReporting/CrashReporting.swift +++ b/SplunkRumCrashReporting/SplunkRumCrashReporting/CrashReporting.swift @@ -69,7 +69,7 @@ private func buildTracer() -> Tracer { return OpenTelemetry.instance.tracerProvider.get(instrumentationName: "splunk-ios-crashreporting", instrumentationVersion: CrashReportingVersionString) } -//CustomData + func updateCrashReportSessionId() { TheCrashReporter?.customData = SplunkRum.getSessionId().data(using: .utf8) } From 489fa6251210744b0d3ab11dab56149a714d8c01 Mon Sep 17 00:00:00 2001 From: Piyush23786 Date: Fri, 29 Jul 2022 11:56:46 +0530 Subject: [PATCH 6/6] APMI2892 Done inspecting 2 files for auto-correction! --- .../SplunkRumCrashReporting/CrashReporting.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SplunkRumCrashReporting/SplunkRumCrashReporting/CrashReporting.swift b/SplunkRumCrashReporting/SplunkRumCrashReporting/CrashReporting.swift index 5f0a46c..893d22b 100644 --- a/SplunkRumCrashReporting/SplunkRumCrashReporting/CrashReporting.swift +++ b/SplunkRumCrashReporting/SplunkRumCrashReporting/CrashReporting.swift @@ -104,7 +104,7 @@ func loadPendingCrashReport(_ data: Data!) throws { } // binary images let text = NSMutableString() - for case let binaryImage as PLCrashReportBinaryImageInfo in report.images { + for case let binaryImage as PLCrashReportBinaryImageInfo in report.images { text.append(binaryImageToStack(report: report, binaryImage: binaryImage)) text.append("\n") } @@ -166,10 +166,10 @@ func binaryImageToStack(report: PLCrashReport, binaryImage: PLCrashReportBinaryI baseAddress = imageInfo.imageBaseAddress imageSize = imageInfo.imageSize imageUUID = imageInfo.imageUUID - //PLCrashReportSystemInfo PLCrashReportArchitecture + // PLCrashReportSystemInfo PLCrashReportArchitecture binaryArchi = convertBinaryArchitectueIntoString(archi: report.systemInfo.architecture) } - return String(format: "0x%lx 0x%lx %@ %@ <%@> %-35@ ",baseAddress,imageSize,shortname,binaryArchi,imageUUID,imageName) + return String(format: "0x%lx 0x%lx %@ %@ <%@> %-35@ ", baseAddress, imageSize, shortname, binaryArchi, imageUUID, imageName) } func convertBinaryArchitectueIntoString(archi: PLCrashReportArchitecture) -> String { var architecture = ""