def test__convert_debug_meta_to_binary_image_row(): acr = AppleCrashReport(context={'device': {'arch': 'x86', 'family': 'iPhone', 'freeMemory': 169684992, 'memorySize': 17179869184, 'model': 'iPhone9,1', 'simulator': True, 'storageSize': 249695305728, 'type': 'device', 'usableMemory': 14919622656 }, 'os': {'build': '16C67', 'bundleID': 'com.rokkincat.SentryExample', 'bundleVersion': '2', 'kernel_version': 'Darwin Kernel Version 16.3.0: Thu Nov 17 20:23:58 PST 2016; root:xnu-3789.31.2~1/RELEASE_X86_64', 'name': 'iOS', 'type': 'os', 'version': '10.2' } }) binary_image = acr._convert_debug_meta_to_binary_image_row(debug_image={ 'cpu_subtype': 3, 'cpu_type': 16777223, 'image_addr': '0xd69a000', 'image_size': 495616, 'image_vmaddr': '0x0', 'name': '/Users/haza/Library/Developer/CoreSimulator/Devices/DDB32F4C-97CF-4E2B-BD10-EB940553F223/data/Containers/Bundle/Application/8F8140DF-B25B-4088-B5FB-57F474A49CD6/SwiftExample.app/Frameworks/SentrySwift.framework/SentrySwift', 'type': 'apple', 'uuid': 'B427AE1D-BF36-3B50-936F-D78A7D1C8340' }) assert binary_image == '0xd69a000 - 0xd712fff SentrySwift x86 <b427ae1dbf363b50936fd78a7d1c8340> /Users/haza/Library/Developer/CoreSimulator/Devices/DDB32F4C-97CF-4E2B-BD10-EB940553F223/data/Containers/Bundle/Application/8F8140DF-B25B-4088-B5FB-57F474A49CD6/SwiftExample.app/Frameworks/SentrySwift.framework/SentrySwift'
def test__get_exception_info(): acr = AppleCrashReport(exceptions=[{ "value": "Attempted to dereference garbage pointer 0x10.", "mechanism": { "type": "mach", "data": { "relevant_address": "0x10" }, "meta": { "signal": { "number": 10, "code": 0, "name": "SIGBUS", "code_name": "BUS_NOOP" }, "mach_exception": { "exception": 1, "name": "EXC_BAD_ACCESS", "subcode": 8, "code": 16 } } }, "type": "EXC_BAD_ACCESS", "thread_id": 0 }]) exception_info = acr._get_exception_info() assert exception_info == 'Exception Type: EXC_BAD_ACCESS (SIGBUS)\n\
def test__convert_frame_to_apple_string(): acr = AppleCrashReport() frame = acr._convert_frame_to_apple_string(frame={'abs_path': None, 'colno': 0, 'function': 'SentryClient.crash() -> ()', 'image_addr': '0xabd7000', 'in_app': False, 'instruction_addr': '0xac24ab6', 'lineno': 0, 'package': '/Users/haza/Library/Developer/CoreSimulator/Devices/DDB32F4C-97CF-4E2B-BD10-EB940553F223/data/Containers/Bundle/Application/4C903BE8-ED5E-414A-AC42-2D4ACCACE781/SwiftExample.app/Frameworks/SentrySwift.framework/SentrySwift', 'symbol': '_TFC11SentrySwift12SentryClient5crashfT_T_', 'symbol_addr': '0xac24a10' }) assert frame == '0 SentrySwift 0xac24ab6 0xabd7000 + 166' acr2 = AppleCrashReport(symbolicated=True) frame_symbolicated = acr2._convert_frame_to_apple_string(frame={'abs_path': None, 'colno': 0, 'function': 'SentryClient.crash() -> ()', 'image_addr': '0xabd7000', 'in_app': False, 'instruction_addr': '0xac24ab6', 'lineno': 0, 'package': '/Users/haza/Library/Developer/CoreSimulator/Devices/DDB32F4C-97CF-4E2B-BD10-EB940553F223/data/Containers/Bundle/Application/4C903BE8-ED5E-414A-AC42-2D4ACCACE781/SwiftExample.app/Frameworks/SentrySwift.framework/SentrySwift', 'symbol': '_TFC11SentrySwift12SentryClient5crashfT_T_', 'symbol_addr': '0xac24a10' }, number=1) assert frame_symbolicated == '1 SentrySwift 0xac24ab6 SentryClient.crash() -> ()'
def test__get_exception_info_legacy_mechanism(): acr = AppleCrashReport( exceptions=[ { "value": "Attempted to dereference garbage pointer 0x10.", "mechanism": { "posix_signal": { "name": "SIGBUS", "code_name": "BUS_NOOP", "signal": 10, "code": 0 }, "relevant_address": "0x10", "mach_exception": { "exception": 1, "exception_name": "EXC_BAD_ACCESS", "subcode": 8, "code": 16 } }, "type": "EXC_BAD_ACCESS", "thread_id": 0 } ] ) exception_info = acr._get_exception_info() assert exception_info == 'Exception Type: EXC_BAD_ACCESS (SIGBUS)\n\
def test__convert_debug_meta_to_binary_image_row(): acr = AppleCrashReport(context={'device': {'arch': 'x86', 'family': 'iPhone', 'freeMemory': 169684992, 'memorySize': 17179869184, 'model': 'iPhone9,1', 'simulator': True, 'storageSize': 249695305728, 'type': 'device', 'usableMemory': 14919622656 }, 'os': {'build': '16C67', 'bundleID': 'com.rokkincat.SentryExample', 'bundleVersion': '2', 'kernel_version': 'Darwin Kernel Version 16.3.0: Thu Nov 17 20:23:58 PST 2016; root:xnu-3789.31.2~1/RELEASE_X86_64', 'name': 'iOS', 'type': 'os', 'version': '10.2' } }) binary_image = acr._convert_debug_meta_to_binary_image_row(debug_image={ 'cpu_subtype': 3, 'cpu_type': 16777223, 'image_addr': '0xd69a000', 'image_size': 495616, 'image_vmaddr': '0x0', 'name': '/Users/haza/Library/Developer/CoreSimulator/Devices/DDB32F4C-97CF-4E2B-BD10-EB940553F223/data/Containers/Bundle/Application/8F8140DF-B25B-4088-B5FB-57F474A49CD6/SwiftExample.app/Frameworks/SentrySwift.framework/SentrySwift', 'type': 'apple', 'uuid': 'B427AE1D-BF36-3B50-936F-D78A7D1C8340' }) assert binary_image == '0xd69a000 - 0xd712fff SentrySwift x86 <b427ae1dbf363b50936fd78a7d1c8340> /Users/haza/Library/Developer/CoreSimulator/Devices/DDB32F4C-97CF-4E2B-BD10-EB940553F223/data/Containers/Bundle/Application/8F8140DF-B25B-4088-B5FB-57F474A49CD6/SwiftExample.app/Frameworks/SentrySwift.framework/SentrySwift'
def test_get_threads_apple_string_symbolicated(): acr = AppleCrashReport(symbolicated=True, threads=[ {'crashed': True, 'current': True, 'id': 1, 'name': None, 'stacktrace': {'frames': [ {'abs_path': '/Users/haza/Projects/sentry-swift/Sources/ios/SentrySwizzle.swift', 'colno': 0, 'filename': 'SentrySwizzle.swift', 'function': '@objc UIApplication.sentryClient_sendAction(Selector, to : AnyObject?, from : AnyObject?, for : UIEvent?) -> Bool', 'image_addr': '0x2c8000', 'in_app': False, 'instruction_addr': '0x31caa4', 'lineno': 0, 'object_addr': '0x2c8000', 'package': '/private/var/containers/Bundle/Application/06EA18D0-49C5-452C-B431-92B1098FB4AD/SwiftExample.app/Frameworks/SentrySwift.framework/SentrySwift', 'symbol': '_TToFE11SentrySwiftCSo13UIApplication23sentryClient_sendActionfTV10ObjectiveC8Selector2toGSqPs9AnyObject__4fromGSqPS3___3forGSqCSo7UIEvent__Sb', 'symbol_addr': '0x31ca38'}, {'abs_path': '/Users/haza/Projects/sentry-swift/Sources/ios/SentrySwizzle.swift', 'colno': 84, 'filename': 'SentrySwizzle.swift', 'function': 'UIApplication.sentryClient_sendAction(Selector, to : AnyObject?, from : AnyObject?, for : UIEvent?) -> Bool', 'image_addr': '0x2c8000', 'in_app': False, 'instruction_addr': '0x31c3e8', 'lineno': 92, 'object_addr': '0x2c8000', 'package': '/private/var/containers/Bundle/Application/06EA18D0-49C5-452C-B431-92B1098FB4AD/SwiftExample.app/Frameworks/SentrySwift.framework/SentrySwift', 'symbol': '_TFE11SentrySwiftCSo13UIApplication23sentryClient_sendActionfTV10ObjectiveC8Selector2toGSqPs9AnyObject__4fromGSqPS3___3forGSqCSo7UIEvent__Sb', 'symbol_addr': '0x31b9f8'}] }}, {'crashed': False, 'current': False, 'id': 2, 'name': 'com.apple.test', 'stacktrace': {'frames': [ {'abs_path': '/Users/haza/Projects/sentry-swift/Examples/SwiftExample/SwiftExample/ViewController.swift', 'colno': 0, 'filename': 'ViewController.swift', 'function': '@objc ViewController.onClickFatalError(AnyObject) -> ()', 'image_addr': '0xf0000', 'in_app': True, 'instruction_addr': '0xf6cd4', 'lineno': 0, 'object_addr': '0xf0000', 'package': '/var/containers/Bundle/Application/06EA18D0-49C5-452C-B431-92B1098FB4AD/SwiftExample.app/SwiftExample', 'symbol': '_TToFC12SwiftExample14ViewController17onClickFatalErrorfPs9AnyObject_T_', 'symbol_addr': '0xf6c98'}, {'colno': 36, 'image_addr': '0xf0000', 'in_app': True, 'instruction_addr': '0xf6c78', 'lineno': 110, 'object_addr': '0xf0000', 'symbol_addr': '0xf6c04'}] }}, ]) threads = acr.get_threads_apple_string() assert threads.rstrip() == '''\
def test__get_exception_info_legacy_mechanism(): acr = AppleCrashReport(exceptions=[{ "value": "Attempted to dereference garbage pointer 0x10.", "mechanism": { "posix_signal": { "name": "SIGBUS", "code_name": "BUS_NOOP", "signal": 10, "code": 0, }, "relevant_address": "0x10", "mach_exception": { "exception": 1, "exception_name": "EXC_BAD_ACCESS", "subcode": 8, "code": 16, }, }, "type": "EXC_BAD_ACCESS", "thread_id": 0, }]) exception_info = acr._get_exception_info() assert (exception_info == "Exception Type: EXC_BAD_ACCESS (SIGBUS)\n\ Exception Codes: BUS_NOOP at 0x10\n\ Crashed Thread: 0\n\n\ Application Specific Information:\n\ Attempted to dereference garbage pointer 0x10.")
def test__get_exception_info_partial(): acr = AppleCrashReport(exceptions=[{ "value": "Attempted to dereference garbage pointer 0x10.", "type": "EXC_BAD_ACCESS", "thread_id": 0 }]) exception_info = acr._get_exception_info() assert exception_info == '\
def test_get_binary_images_apple_string(): acr = AppleCrashReport( debug_images=[{ 'cpu_subtype': 3, 'cpu_type': 16777223, 'image_addr': '0x141c5000', 'image_size': 20480, 'image_vmaddr': '0x0', 'name': '/Users/haza/Library/Developer/CoreSimulator/Devices/DDB32F4C-97CF-4E2B-BD10-EB940553F223/data/Containers/Bundle/Application/8C286977-D498-44FF-B7BE-42BFE3DE38BD/SwiftExample.app/Frameworks/libswiftContacts.dylib', 'type': 'apple', 'uuid': '4B5A054F-B7A1-3AD0-81E1-513B4DBE2A33' }, { 'cpu_subtype': 3, 'cpu_type': 16777223, 'image_addr': '0x1400c000', 'image_size': 266240, 'image_vmaddr': '0x0', 'name': '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/ContentIndex.framework/ContentIndex', 'type': 'apple', 'uuid': '766DFB14-72EE-32D2-8961-687D32548F2B' }, { 'cpu_subtype': 3, 'cpu_type': 16777223, 'image_addr': '0x1406f000', 'image_size': 913408, 'image_vmaddr': '0x0', 'name': '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/CorePDF.framework/CorePDF', 'type': 'apple', 'uuid': 'BE602DC1-D3A0-3389-B8F4-922C37DEA3DC' }], context={ 'device': { 'arch': 'x86', 'family': 'iPhone', 'freeMemory': 169684992, 'memorySize': 17179869184, 'model': 'iPhone9,1', 'simulator': True, 'storageSize': 249695305728, 'type': 'device', 'usableMemory': 14919622656 }, 'os': { 'build': '16C67', 'bundleID': 'com.rokkincat.SentryExample', 'bundleVersion': '2', 'kernel_version': 'Darwin Kernel Version 16.3.0: Thu Nov 17 20:23:58 PST 2016; root:xnu-3789.31.2~1/RELEASE_X86_64', 'name': 'iOS', 'type': 'os', 'version': '10.2' } }) binary_images = acr.get_binary_images_apple_string() assert binary_images == 'Binary Images:\n\
def test_binary_images_without_code_file(): acr = AppleCrashReport( debug_images=[ { "image_addr": "0x141c5000", "image_size": 20480, "image_vmaddr": "0x0", "type": "native", "debug_id": "4B5A054F-B7A1-3AD0-81E1-513B4DBE2A33", }, { "image_addr": "0x1400c000", "image_size": 266240, "image_vmaddr": "0x0", "type": "native", "debug_id": "766DFB14-72EE-32D2-8961-687D32548F2B", }, { "image_addr": "0x1406f000", "image_size": 913408, # image_vmaddr defaults to 0x0 "type": "native", "debug_id": "BE602DC1-D3A0-3389-B8F4-922C37DEA3DC", }, ], context={ "device": { "arch": "x86", "family": "iPhone", "freeMemory": 169684992, "memorySize": 17179869184, "model": "iPhone9,1", "simulator": True, "storageSize": 249695305728, "type": "device", "usableMemory": 14919622656, }, "os": { "build": "16C67", "bundleID": "com.rokkincat.SentryExample", "bundleVersion": "2", "kernel_version": "Darwin Kernel Version 16.3.0: Thu Nov 17 20:23:58 PST 2016; root:xnu-3789.31.2~1/RELEASE_X86_64", "name": "iOS", "type": "os", "version": "10.2", }, }, ) binary_images = acr.get_binary_images_apple_string() assert (binary_images == "Binary Images:\n\ 0x1400c000 - 0x1404cfff {0} x86 <766dfb1472ee32d28961687d32548f2b> {0}\n\ 0x1406f000 - 0x1414dfff {0} x86 <be602dc1d3a03389b8f4922c37dea3dc> {0}\n\ 0x141c5000 - 0x141c9fff {0} x86 <4b5a054fb7a13ad081e1513b4dbe2a33> {0}". format(NATIVE_UNKNOWN_STRING))
def test__get_exception_info_partial(): acr = AppleCrashReport(exceptions=[{ "value": "Attempted to dereference garbage pointer 0x10.", "type": "EXC_BAD_ACCESS", "thread_id": 0, }]) exception_info = acr._get_exception_info() assert (exception_info == "\ Crashed Thread: 0\n\n\ Application Specific Information:\n\ Attempted to dereference garbage pointer 0x10.")
def test__get_exception_info_partial(): acr = AppleCrashReport( exceptions=[ { "value": "Attempted to dereference garbage pointer 0x10.", "type": "EXC_BAD_ACCESS", "thread_id": 0 } ] ) exception_info = acr._get_exception_info() assert exception_info == '\
def test__get_exception_info_partial(): acr = AppleCrashReport(exception=[{ "value": "Attempted to dereference garbage pointer 0x10.", "mechanism": { "posix_signal": None, "mach_exception": None, }, "type": "EXC_BAD_ACCESS", "thread_id": 0 }]) exception_info = acr._get_exception_info() assert exception_info == '\
def test__get_exception_info_partial(): acr = AppleCrashReport(exception=[{ "value": "Attempted to dereference garbage pointer 0x10.", "mechanism": { "posix_signal": None, "mach_exception": None, }, "type": "EXC_BAD_ACCESS", "thread_id": 0 }]) exception_info = acr._get_exception_info() assert exception_info == '\
def test_get_binary_images_apple_string(): acr = AppleCrashReport(debug_images=[ {'cpu_subtype': 3, 'cpu_type': 16777223, 'image_addr': '0x141c5000', 'image_size': 20480, 'image_vmaddr': '0x0', 'name': '/Users/haza/Library/Developer/CoreSimulator/Devices/DDB32F4C-97CF-4E2B-BD10-EB940553F223/data/Containers/Bundle/Application/8C286977-D498-44FF-B7BE-42BFE3DE38BD/SwiftExample.app/Frameworks/libswiftContacts.dylib', 'type': 'apple', 'uuid': '4B5A054F-B7A1-3AD0-81E1-513B4DBE2A33'}, {'cpu_subtype': 3, 'cpu_type': 16777223, 'image_addr': '0x1400c000', 'image_size': 266240, 'image_vmaddr': '0x0', 'name': '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/ContentIndex.framework/ContentIndex', 'type': 'apple', 'uuid': '766DFB14-72EE-32D2-8961-687D32548F2B'}, {'cpu_subtype': 3, 'cpu_type': 16777223, 'image_addr': '0x1406f000', 'image_size': 913408, 'image_vmaddr': '0x0', 'name': '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/CorePDF.framework/CorePDF', 'type': 'apple', 'uuid': 'BE602DC1-D3A0-3389-B8F4-922C37DEA3DC'} ], context={ 'device': { 'arch': 'x86', 'family': 'iPhone', 'freeMemory': 169684992, 'memorySize': 17179869184, 'model': 'iPhone9,1', 'simulator': True, 'storageSize': 249695305728, 'type': 'device', 'usableMemory': 14919622656 }, 'os': { 'build': '16C67', 'bundleID': 'com.rokkincat.SentryExample', 'bundleVersion': '2', 'kernel_version': 'Darwin Kernel Version 16.3.0: Thu Nov 17 20:23:58 PST 2016; root:xnu-3789.31.2~1/RELEASE_X86_64', 'name': 'iOS', 'type': 'os', 'version': '10.2' } }) binary_images = acr.get_binary_images_apple_string() assert binary_images == 'Binary Images:\n\
def get(self, request, event_id): """ Retrieve an Apple Crash Report from and event ````````````````````````````````````````````` This endpoint returns the an apple crash report for a specific event. The event ID is the event as it appears in the Sentry database and not the event ID that is reported by the client upon submission. This works only if the event.platform == cocoa """ try: event = Event.objects.get(id=event_id) except Event.DoesNotExist: raise ResourceDoesNotExist self.check_object_permissions(request, event.group) Event.objects.bind_nodes([event], 'data') if event.platform not in ('cocoa', 'native'): return HttpResponse( { 'message': 'Only cocoa events can return an apple crash report', }, status=403) symbolicated = (request.GET.get('minified') not in ('1', 'true')) apple_crash_report_string = six.text_type( AppleCrashReport( threads=get_path(event.data, 'threads', 'values', filter=True), context=event.data.get('contexts'), debug_images=get_path(event.data, 'debug_meta', 'images', filter=True), exceptions=get_path(event.data, 'exception', 'values', filter=True), symbolicated=symbolicated, )) response = HttpResponse(apple_crash_report_string, content_type='text/plain') if request.GET.get('download') is not None: filename = u"{}{}.crash".format( event.event_id, symbolicated and '-symbolicated' or '') response = StreamingHttpResponse( apple_crash_report_string, content_type='text/plain', ) response['Content-Length'] = len(apple_crash_report_string) response[ 'Content-Disposition'] = 'attachment; filename="%s"' % filename return response
def _get_crash_report(event: Event) -> str: # Copied from sentry/api/endpoints/event_apple_crash_report.py return str( AppleCrashReport( threads=get_path(event.data, "threads", "values", filter=True), context=event.data.get("contexts"), debug_images=get_path(event.data, "debug_meta", "images", filter=True), exceptions=get_path(event.data, "exception", "values", filter=True), symbolicated=True, ) )
def test__convert_debug_meta_to_binary_image_row(): acr = AppleCrashReport( context={ "device": { "arch": "x86", "family": "iPhone", "freeMemory": 169684992, "memorySize": 17179869184, "model": "iPhone9,1", "simulator": True, "storageSize": 249695305728, "type": "device", "usableMemory": 14919622656, }, "os": { "build": "16C67", "bundleID": "com.rokkincat.SentryExample", "bundleVersion": "2", "kernel_version": "Darwin Kernel Version 16.3.0: Thu Nov 17 20:23:58 PST 2016; root:xnu-3789.31.2~1/RELEASE_X86_64", "name": "iOS", "type": "os", "version": "10.2", }, }) binary_image = acr._convert_debug_meta_to_binary_image_row( debug_image={ "cpu_subtype": 3, "cpu_type": 16777223, "image_addr": "0xd69a000", "image_size": 495616, "image_vmaddr": "0x0", "code_file": "/Users/haza/Library/Developer/CoreSimulator/Devices/DDB32F4C-97CF-4E2B-BD10-EB940553F223/data/Containers/Bundle/Application/8F8140DF-B25B-4088-B5FB-57F474A49CD6/SwiftExample.app/Frameworks/SentrySwift.framework/SentrySwift", "type": "apple", "debug_id": "B427AE1D-BF36-3B50-936F-D78A7D1C8340", }) assert ( binary_image == "0xd69a000 - 0xd712fff SentrySwift x86 <b427ae1dbf363b50936fd78a7d1c8340> /Users/haza/Library/Developer/CoreSimulator/Devices/DDB32F4C-97CF-4E2B-BD10-EB940553F223/data/Containers/Bundle/Application/8F8140DF-B25B-4088-B5FB-57F474A49CD6/SwiftExample.app/Frameworks/SentrySwift.framework/SentrySwift" )
def test__convert_frame_to_apple_string(): acr = AppleCrashReport() frame = acr._convert_frame_to_apple_string(frame={'abs_path': None, 'colno': 0, 'function': 'SentryClient.crash() -> ()', 'image_addr': '0xabd7000', 'in_app': False, 'instruction_addr': '0xac24ab6', 'lineno': 0, 'package': '/Users/haza/Library/Developer/CoreSimulator/Devices/DDB32F4C-97CF-4E2B-BD10-EB940553F223/data/Containers/Bundle/Application/4C903BE8-ED5E-414A-AC42-2D4ACCACE781/SwiftExample.app/Frameworks/SentrySwift.framework/SentrySwift', 'symbol': '_TFC11SentrySwift12SentryClient5crashfT_T_', 'symbol_addr': '0xac24a10' }) assert frame == '0 SentrySwift 0xac24ab6 0xabd7000 + 166' acr2 = AppleCrashReport(symbolicated=True) frame_symbolicated = acr2._convert_frame_to_apple_string(frame={'abs_path': None, 'colno': 0, 'function': 'SentryClient.crash() -> ()', 'image_addr': '0xabd7000', 'in_app': False, 'instruction_addr': '0xac24ab6', 'lineno': 0, 'package': '/Users/haza/Library/Developer/CoreSimulator/Devices/DDB32F4C-97CF-4E2B-BD10-EB940553F223/data/Containers/Bundle/Application/4C903BE8-ED5E-414A-AC42-2D4ACCACE781/SwiftExample.app/Frameworks/SentrySwift.framework/SentrySwift', 'symbol': '_TFC11SentrySwift12SentryClient5crashfT_T_', 'symbol_addr': '0xac24a10' }, number=1) assert frame_symbolicated == '1 SentrySwift 0xac24ab6 SentryClient.crash() -> ()'
def get(self, request, project, event_id): """ Retrieve an Apple Crash Report from an event ````````````````````````````````````````````` This endpoint returns the an apple crash report for a specific event. This works only if the event.platform == cocoa """ event = eventstore.get_event_by_id(project.id, event_id) if event is None: raise ResourceDoesNotExist Event.objects.bind_nodes([event], "data") if event.platform not in ("cocoa", "native"): return HttpResponse( { "message": "Only cocoa events can return an apple crash report" }, status=403) symbolicated = request.GET.get("minified") not in ("1", "true") apple_crash_report_string = six.text_type( AppleCrashReport( threads=get_path(event.data, "threads", "values", filter=True), context=event.data.get("contexts"), debug_images=get_path(event.data, "debug_meta", "images", filter=True), exceptions=get_path(event.data, "exception", "values", filter=True), symbolicated=symbolicated, )) response = HttpResponse(apple_crash_report_string, content_type="text/plain") if request.GET.get("download") is not None: filename = u"{}{}.crash".format( event.event_id, symbolicated and "-symbolicated" or "") response = StreamingHttpResponse(apple_crash_report_string, content_type="text/plain") response["Content-Length"] = len(apple_crash_report_string) response[ "Content-Disposition"] = 'attachment; filename="%s"' % filename return response
def test__convert_frame_to_apple_string(): acr = AppleCrashReport() frame = acr._convert_frame_to_apple_string( frame={ "abs_path": None, "colno": 0, "function": "SentryClient.crash() -> ()", "image_addr": "0xabd7000", "in_app": False, "instruction_addr": "0xac24ab6", "lineno": 0, "package": "/Users/haza/Library/Developer/CoreSimulator/Devices/DDB32F4C-97CF-4E2B-BD10-EB940553F223/data/Containers/Bundle/Application/4C903BE8-ED5E-414A-AC42-2D4ACCACE781/SwiftExample.app/Frameworks/SentrySwift.framework/SentrySwift", "symbol": "_TFC11SentrySwift12SentryClient5crashfT_T_", "symbol_addr": "0xac24a10", }) assert frame == "0 SentrySwift 0xac24ab6 0xabd7000 + 166" acr2 = AppleCrashReport(symbolicated=True) frame_symbolicated = acr2._convert_frame_to_apple_string( frame={ "abs_path": None, "colno": 0, "function": "SentryClient.crash() -> ()", "image_addr": "0xabd7000", "in_app": False, "instruction_addr": "0xac24ab6", "lineno": 0, "package": "/Users/haza/Library/Developer/CoreSimulator/Devices/DDB32F4C-97CF-4E2B-BD10-EB940553F223/data/Containers/Bundle/Application/4C903BE8-ED5E-414A-AC42-2D4ACCACE781/SwiftExample.app/Frameworks/SentrySwift.framework/SentrySwift", "symbol": "_TFC11SentrySwift12SentryClient5crashfT_T_", "symbol_addr": "0xac24a10", }, number=1, ) assert ( frame_symbolicated == "1 SentrySwift 0xac24ab6 SentryClient.crash() -> ()" )
def test_get_thread_apple_string(): acr = AppleCrashReport() thread = acr.get_thread_apple_string({ 'crashed': True, 'current': False, 'id': 1, 'name': None, 'stacktrace': { 'frames': [{ 'abs_path': '/Users/haza/Projects/sentry-swift/Sources/ios/SentrySwizzle.swift', 'colno': 0, 'filename': 'SentrySwizzle.swift', 'function': '@objc UIApplication.sentryClient_sendAction(Selector, to : AnyObject?, from : AnyObject?, for : UIEvent?) -> Bool', 'image_addr': '0x2c8000', 'in_app': False, 'instruction_addr': '0x31caa4', 'lineno': 0, 'object_addr': '0x2c8000', 'package': '/private/var/containers/Bundle/Application/06EA18D0-49C5-452C-B431-92B1098FB4AD/SwiftExample.app/Frameworks/SentrySwift.framework/SentrySwift', 'symbol': '_TToFE11SentrySwiftCSo13UIApplication23sentryClient_sendActionfTV10ObjectiveC8Selector2toGSqPs9AnyObject__4fromGSqPS3___3forGSqCSo7UIEvent__Sb', 'symbol_addr': '0x31ca38' }, { 'abs_path': '/Users/haza/Projects/sentry-swift/Sources/ios/SentrySwizzle.swift', 'colno': 84, 'filename': 'SentrySwizzle.swift', 'function': 'UIApplication.sentryClient_sendAction(Selector, to : AnyObject?, from : AnyObject?, for : UIEvent?) -> Bool', 'image_addr': '0x2c8000', 'in_app': False, 'instruction_addr': '0x31c3e8', 'lineno': 92, 'object_addr': '0x2c8000', 'package': '/private/var/containers/Bundle/Application/06EA18D0-49C5-452C-B431-92B1098FB4AD/SwiftExample.app/Frameworks/SentrySwift.framework/SentrySwift', 'symbol': '_TFE11SentrySwiftCSo13UIApplication23sentryClient_sendActionfTV10ObjectiveC8Selector2toGSqPs9AnyObject__4fromGSqPS3___3forGSqCSo7UIEvent__Sb', 'symbol_addr': '0x31b9f8' }, { 'function': '<redacted>', 'image_addr': '0x8751b000', 'in_app': False, 'instruction_addr': '0x8755fd30', 'package': '/System/Library/Frameworks/UIKit.framework/UIKit', 'symbol_addr': '0x8755fcd0' }, { 'abs_path': '/Users/haza/Projects/sentry-swift/Examples/SwiftExample/SwiftExample/ViewController.swift', 'colno': 0, 'filename': 'ViewController.swift', 'function': '@objc ViewController.onClickFatalError(AnyObject) -> ()', 'image_addr': '0xf0000', 'in_app': True, 'instruction_addr': '0xf6cd4', 'lineno': 0, 'object_addr': '0xf0000', 'package': '/var/containers/Bundle/Application/06EA18D0-49C5-452C-B431-92B1098FB4AD/SwiftExample.app/SwiftExample', 'symbol': '_TToFC12SwiftExample14ViewController17onClickFatalErrorfPs9AnyObject_T_', 'symbol_addr': '0xf6c98' }, { 'abs_path': '/Users/haza/Projects/sentry-swift/Examples/SwiftExample/SwiftExample/ViewController.swift', 'colno': 36, 'filename': 'ViewController.swift', 'function': 'ViewController.onClickFatalError(AnyObject) -> ()', 'image_addr': '0xf0000', 'in_app': True, 'instruction_addr': '0xf6c78', 'lineno': 110, 'object_addr': '0xf0000', 'package': '/var/containers/Bundle/Application/06EA18D0-49C5-452C-B431-92B1098FB4AD/SwiftExample.app/SwiftExample', 'symbol': '_TFC12SwiftExample14ViewController17onClickFatalErrorfPs9AnyObject_T_', 'symbol_addr': '0xf6c04' }, { 'abs_path': '/Users/haza/Projects/sentry-swift/Sources/Sentry.swift', 'colno': 0, 'filename': 'Sentry.swift', 'function': '@objc SentryClient.crash() -> ()', 'image_addr': '0x2c8000', 'in_app': False, 'instruction_addr': '0x312308', 'lineno': 0, 'object_addr': '0x2c8000', 'package': '/private/var/containers/Bundle/Application/06EA18D0-49C5-452C-B431-92B1098FB4AD/SwiftExample.app/Frameworks/SentrySwift.framework/SentrySwift', 'symbol': '_TToFC11SentrySwift12SentryClient5crashfT_T_', 'symbol_addr': '0x312280' }, { 'function': 'specialized _assertionFailed(StaticString, String, StaticString, UInt) -> ()', 'image_addr': '0x3f8000', 'in_app': False, 'instruction_addr': '0x556cc4', 'package': '/private/var/containers/Bundle/Application/06EA18D0-49C5-452C-B431-92B1098FB4AD/SwiftExample.app/Frameworks/libswiftCore.dylib', 'symbol_addr': '0x556c24' }, { 'function': 'specialized _assertionFailed(StaticString, String, StaticString, UInt) -> ()', 'image_addr': '0x3f8000', 'in_app': False, 'instruction_addr': '0x556cc4', 'package': '/private/var/containers/Bundle/Application/06EA18D0-49C5-452C-B431-92B1098FB4AD/SwiftExample.app/Frameworks/libswiftCore.dylib', 'symbol_addr': '0x556c24' }] } }) # TODO(hazat): the address here in a real crash is 0x0000000100556cc4 but we just get 0x556cc4 assert thread == 'Thread 1 name: \n\
def test_get_threads_apple_string(): acr = AppleCrashReport(threads=[ { 'crashed': True, 'current': True, 'id': 1, 'name': None, 'stacktrace': { 'frames': [{ 'abs_path': '/Users/haza/Projects/sentry-swift/Sources/ios/SentrySwizzle.swift', 'colno': 0, 'filename': 'SentrySwizzle.swift', 'function': '@objc UIApplication.sentryClient_sendAction(Selector, to : AnyObject?, from : AnyObject?, for : UIEvent?) -> Bool', 'image_addr': '0x2c8000', 'in_app': False, 'instruction_addr': '0x31caa4', 'lineno': 0, 'object_addr': '0x2c8000', 'package': '/private/var/containers/Bundle/Application/06EA18D0-49C5-452C-B431-92B1098FB4AD/SwiftExample.app/Frameworks/SentrySwift.framework/SentrySwift', 'symbol': '_TToFE11SentrySwiftCSo13UIApplication23sentryClient_sendActionfTV10ObjectiveC8Selector2toGSqPs9AnyObject__4fromGSqPS3___3forGSqCSo7UIEvent__Sb', 'symbol_addr': '0x31ca38' }, { 'abs_path': '/Users/haza/Projects/sentry-swift/Sources/ios/SentrySwizzle.swift', 'colno': 84, 'filename': 'SentrySwizzle.swift', 'function': 'UIApplication.sentryClient_sendAction(Selector, to : AnyObject?, from : AnyObject?, for : UIEvent?) -> Bool', 'image_addr': '0x2c8000', 'in_app': False, 'instruction_addr': '0x31c3e8', 'lineno': 92, 'object_addr': '0x2c8000', 'package': '/private/var/containers/Bundle/Application/06EA18D0-49C5-452C-B431-92B1098FB4AD/SwiftExample.app/Frameworks/SentrySwift.framework/SentrySwift', 'symbol': '_TFE11SentrySwiftCSo13UIApplication23sentryClient_sendActionfTV10ObjectiveC8Selector2toGSqPs9AnyObject__4fromGSqPS3___3forGSqCSo7UIEvent__Sb', 'symbol_addr': '0x31b9f8' }] } }, { 'crashed': False, 'current': False, 'id': 2, 'name': 'com.apple.test', 'stacktrace': { 'frames': [{ 'abs_path': '/Users/haza/Projects/sentry-swift/Examples/SwiftExample/SwiftExample/ViewController.swift', 'colno': 0, 'filename': 'ViewController.swift', 'function': '@objc ViewController.onClickFatalError(AnyObject) -> ()', 'image_addr': '0xf0000', 'in_app': True, 'instruction_addr': '0xf6cd4', 'lineno': 0, 'object_addr': '0xf0000', 'package': '/var/containers/Bundle/Application/06EA18D0-49C5-452C-B431-92B1098FB4AD/SwiftExample.app/SwiftExample', 'symbol': '_TToFC12SwiftExample14ViewController17onClickFatalErrorfPs9AnyObject_T_', 'symbol_addr': '0xf6c98' }, { 'abs_path': '/Users/haza/Projects/sentry-swift/Examples/SwiftExample/SwiftExample/ViewController.swift', 'colno': 36, 'filename': 'ViewController.swift', 'function': 'ViewController.onClickFatalError(AnyObject) -> ()', 'image_addr': '0xf0000', 'in_app': True, 'instruction_addr': '0xf6c78', 'lineno': 110, 'object_addr': '0xf0000', 'package': '/var/containers/Bundle/Application/06EA18D0-49C5-452C-B431-92B1098FB4AD/SwiftExample.app/SwiftExample', 'symbol': '_TFC12SwiftExample14ViewController17onClickFatalErrorfPs9AnyObject_T_', 'symbol_addr': '0xf6c04' }] } }, ]) threads = acr.get_threads_apple_string() assert threads == 'Thread 1 name: \n\
def test_get_thread_apple_string(): acr = AppleCrashReport() thread = acr.get_thread_apple_string({ "crashed": True, "current": False, "id": 1, "name": None, "stacktrace": { "frames": [ { "abs_path": "/Users/haza/Projects/sentry-swift/Sources/ios/SentrySwizzle.swift", "colno": 0, "filename": "SentrySwizzle.swift", "function": "@objc UIApplication.sentryClient_sendAction(Selector, to : AnyObject?, from : AnyObject?, for : UIEvent?) -> Bool", "image_addr": "0x2c8000", "in_app": False, "instruction_addr": "0x31caa4", "lineno": 0, "object_addr": "0x2c8000", "package": "/private/var/containers/Bundle/Application/06EA18D0-49C5-452C-B431-92B1098FB4AD/SwiftExample.app/Frameworks/SentrySwift.framework/SentrySwift", "symbol": "_TToFE11SentrySwiftCSo13UIApplication23sentryClient_sendActionfTV10ObjectiveC8Selector2toGSqPs9AnyObject__4fromGSqPS3___3forGSqCSo7UIEvent__Sb", "symbol_addr": "0x31ca38", }, { "abs_path": "/Users/haza/Projects/sentry-swift/Sources/ios/SentrySwizzle.swift", "colno": 84, "filename": "SentrySwizzle.swift", "function": "UIApplication.sentryClient_sendAction(Selector, to : AnyObject?, from : AnyObject?, for : UIEvent?) -> Bool", "image_addr": "0x2c8000", "in_app": False, "instruction_addr": "0x31c3e8", "lineno": 92, "object_addr": "0x2c8000", "package": "/private/var/containers/Bundle/Application/06EA18D0-49C5-452C-B431-92B1098FB4AD/SwiftExample.app/Frameworks/SentrySwift.framework/SentrySwift", "symbol": "_TFE11SentrySwiftCSo13UIApplication23sentryClient_sendActionfTV10ObjectiveC8Selector2toGSqPs9AnyObject__4fromGSqPS3___3forGSqCSo7UIEvent__Sb", "symbol_addr": "0x31b9f8", }, { "function": "<redacted>", "image_addr": "0x8751b000", "in_app": False, "instruction_addr": "0x8755fd30", "package": "/System/Library/Frameworks/UIKit.framework/UIKit", "symbol_addr": "0x8755fcd0", }, { "abs_path": "/Users/haza/Projects/sentry-swift/Examples/SwiftExample/SwiftExample/ViewController.swift", "colno": 0, "filename": "ViewController.swift", "function": "@objc ViewController.onClickFatalError(AnyObject) -> ()", "image_addr": "0xf0000", "in_app": True, "instruction_addr": "0xf6cd4", "lineno": 0, "object_addr": "0xf0000", "package": "/var/containers/Bundle/Application/06EA18D0-49C5-452C-B431-92B1098FB4AD/SwiftExample.app/SwiftExample", "symbol": "_TToFC12SwiftExample14ViewController17onClickFatalErrorfPs9AnyObject_T_", "symbol_addr": "0xf6c98", }, { "abs_path": "/Users/haza/Projects/sentry-swift/Examples/SwiftExample/SwiftExample/ViewController.swift", "colno": 36, "filename": "ViewController.swift", "function": "ViewController.onClickFatalError(AnyObject) -> ()", "image_addr": "0xf0000", "in_app": True, "instruction_addr": "0xf6c78", "lineno": 110, "object_addr": "0xf0000", "package": "/var/containers/Bundle/Application/06EA18D0-49C5-452C-B431-92B1098FB4AD/SwiftExample.app/SwiftExample", "symbol": "_TFC12SwiftExample14ViewController17onClickFatalErrorfPs9AnyObject_T_", "symbol_addr": "0xf6c04", }, { "abs_path": "/Users/haza/Projects/sentry-swift/Sources/Sentry.swift", "colno": 0, "filename": "Sentry.swift", "function": "@objc SentryClient.crash() -> ()", "image_addr": "0x2c8000", "in_app": False, "instruction_addr": "0x312308", "lineno": 0, "object_addr": "0x2c8000", "package": "/private/var/containers/Bundle/Application/06EA18D0-49C5-452C-B431-92B1098FB4AD/SwiftExample.app/Frameworks/SentrySwift.framework/SentrySwift", "symbol": "_TToFC11SentrySwift12SentryClient5crashfT_T_", "symbol_addr": "0x312280", }, { "function": "specialized _assertionFailed(StaticString, String, StaticString, UInt) -> ()", "image_addr": "0x3f8000", "in_app": False, "instruction_addr": "0x556cc4", "package": "/private/var/containers/Bundle/Application/06EA18D0-49C5-452C-B431-92B1098FB4AD/SwiftExample.app/Frameworks/libswiftCore.dylib", "symbol_addr": "0x556c24", }, { "function": "specialized _assertionFailed(StaticString, String, StaticString, UInt) -> ()", "image_addr": "0x3f8000", "in_app": False, "instruction_addr": "0x556cc4", "package": "/private/var/containers/Bundle/Application/06EA18D0-49C5-452C-B431-92B1098FB4AD/SwiftExample.app/Frameworks/libswiftCore.dylib", "symbol_addr": "0x556c24", }, ] }, }) # TODO(hazat): the address here in a real crash is 0x0000000100556cc4 but we just get 0x556cc4 assert (thread == "Thread 1 Crashed:\n\ 0 libswiftCore.dylib 0x556cc4 0x3f8000 + 160\n\ 1 libswiftCore.dylib 0x556cc4 0x3f8000 + 160\n\ 2 SentrySwift 0x312308 0x2c8000 + 136\n\ 3 SwiftExample 0xf6c78 0xf0000 + 116\n\ 4 SwiftExample 0xf6cd4 0xf0000 + 60\n\ 5 UIKit 0x8755fd30 0x8751b000 + 96\n\ 6 SentrySwift 0x31c3e8 0x2c8000 + 2544\n\ 7 SentrySwift 0x31caa4 0x2c8000 + 108")
def test_get_binary_images_apple_string(): acr = AppleCrashReport( debug_images=[ { "image_addr": "0x141c5000", "image_size": 20480, "image_vmaddr": "0x0", "code_file": "/Users/haza/Library/Developer/CoreSimulator/Devices/DDB32F4C-97CF-4E2B-BD10-EB940553F223/data/Containers/Bundle/Application/8C286977-D498-44FF-B7BE-42BFE3DE38BD/SwiftExample.app/Frameworks/libswiftContacts.dylib", "type": "native", "debug_id": "4B5A054F-B7A1-3AD0-81E1-513B4DBE2A33", }, { "image_addr": "0x1400c000", "image_size": 266240, "image_vmaddr": "0x0", "code_file": "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/ContentIndex.framework/ContentIndex", "type": "native", "debug_id": "766DFB14-72EE-32D2-8961-687D32548F2B", }, { "image_addr": "0x1406f000", "image_size": 913408, # image_vmaddr defaults to 0x0 "code_file": "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/CorePDF.framework/CorePDF", "type": "native", "debug_id": "BE602DC1-D3A0-3389-B8F4-922C37DEA3DC", }, ], context={ "device": { "arch": "x86", "family": "iPhone", "freeMemory": 169684992, "memorySize": 17179869184, "model": "iPhone9,1", "simulator": True, "storageSize": 249695305728, "type": "device", "usableMemory": 14919622656, }, "os": { "build": "16C67", "bundleID": "com.rokkincat.SentryExample", "bundleVersion": "2", "kernel_version": "Darwin Kernel Version 16.3.0: Thu Nov 17 20:23:58 PST 2016; root:xnu-3789.31.2~1/RELEASE_X86_64", "name": "iOS", "type": "os", "version": "10.2", }, }, ) binary_images = acr.get_binary_images_apple_string() assert (binary_images == "Binary Images:\n\ 0x1400c000 - 0x1404cfff ContentIndex x86 <766dfb1472ee32d28961687d32548f2b> /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/ContentIndex.framework/ContentIndex\n\ 0x1406f000 - 0x1414dfff CorePDF x86 <be602dc1d3a03389b8f4922c37dea3dc> /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/CorePDF.framework/CorePDF\n\ 0x141c5000 - 0x141c9fff libswiftContacts.dylib x86 <4b5a054fb7a13ad081e1513b4dbe2a33> /Users/haza/Library/Developer/CoreSimulator/Devices/DDB32F4C-97CF-4E2B-BD10-EB940553F223/data/Containers/Bundle/Application/8C286977-D498-44FF-B7BE-42BFE3DE38BD/SwiftExample.app/Frameworks/libswiftContacts.dylib" )
def test_get_threads_apple_string(): acr = AppleCrashReport(threads=[ { "crashed": True, "current": True, "id": 1, "name": None, "stacktrace": { "frames": [ { "abs_path": "/Users/haza/Projects/sentry-swift/Sources/ios/SentrySwizzle.swift", "colno": 0, "filename": "SentrySwizzle.swift", "function": "@objc UIApplication.sentryClient_sendAction(Selector, to : AnyObject?, from : AnyObject?, for : UIEvent?) -> Bool", "image_addr": "0x2c8000", "in_app": False, "instruction_addr": "0x31caa4", "lineno": 0, "object_addr": "0x2c8000", "package": "/private/var/containers/Bundle/Application/06EA18D0-49C5-452C-B431-92B1098FB4AD/SwiftExample.app/Frameworks/SentrySwift.framework/SentrySwift", "symbol": "_TToFE11SentrySwiftCSo13UIApplication23sentryClient_sendActionfTV10ObjectiveC8Selector2toGSqPs9AnyObject__4fromGSqPS3___3forGSqCSo7UIEvent__Sb", "symbol_addr": "0x31ca38", }, { "abs_path": "/Users/haza/Projects/sentry-swift/Sources/ios/SentrySwizzle.swift", "colno": 84, "filename": "SentrySwizzle.swift", "function": "UIApplication.sentryClient_sendAction(Selector, to : AnyObject?, from : AnyObject?, for : UIEvent?) -> Bool", "image_addr": "0x2c8000", "in_app": False, "instruction_addr": "0x31c3e8", "lineno": 92, "object_addr": "0x2c8000", "package": "/private/var/containers/Bundle/Application/06EA18D0-49C5-452C-B431-92B1098FB4AD/SwiftExample.app/Frameworks/SentrySwift.framework/SentrySwift", "symbol": "_TFE11SentrySwiftCSo13UIApplication23sentryClient_sendActionfTV10ObjectiveC8Selector2toGSqPs9AnyObject__4fromGSqPS3___3forGSqCSo7UIEvent__Sb", "symbol_addr": "0x31b9f8", }, ] }, }, { "crashed": False, "current": False, "id": 2, "name": "com.apple.test", "stacktrace": { "frames": [ { "abs_path": "/Users/haza/Projects/sentry-swift/Examples/SwiftExample/SwiftExample/ViewController.swift", "colno": 0, "filename": "ViewController.swift", "function": "@objc ViewController.onClickFatalError(AnyObject) -> ()", "image_addr": "0xf0000", "in_app": True, "instruction_addr": "0xf6cd4", "lineno": 0, "object_addr": "0xf0000", "package": "/var/containers/Bundle/Application/06EA18D0-49C5-452C-B431-92B1098FB4AD/SwiftExample.app/SwiftExample", "symbol": "_TToFC12SwiftExample14ViewController17onClickFatalErrorfPs9AnyObject_T_", "symbol_addr": "0xf6c98", }, { "abs_path": "/Users/haza/Projects/sentry-swift/Examples/SwiftExample/SwiftExample/ViewController.swift", "colno": 36, "filename": "ViewController.swift", "function": "ViewController.onClickFatalError(AnyObject) -> ()", "image_addr": "0xf0000", "in_app": True, "instruction_addr": "0xf6c78", "lineno": 110, "object_addr": "0xf0000", "package": "/var/containers/Bundle/Application/06EA18D0-49C5-452C-B431-92B1098FB4AD/SwiftExample.app/SwiftExample", "symbol": "_TFC12SwiftExample14ViewController17onClickFatalErrorfPs9AnyObject_T_", "symbol_addr": "0xf6c04", }, ] }, }, ]) threads = acr.get_threads_apple_string() assert (threads == "Thread 1 Crashed:\n\ 0 SentrySwift 0x31c3e8 0x2c8000 + 2544\n\ 1 SentrySwift 0x31caa4 0x2c8000 + 108\n\n\ Thread 2 name: com.apple.test\n\ 0 SwiftExample 0xf6c78 0xf0000 + 116\n\ 1 SwiftExample 0xf6cd4 0xf0000 + 60")
def test_get_thread_apple_string(): acr = AppleCrashReport() thread = acr.get_thread_apple_string({ 'crashed': True, 'current': False, 'id': 1, 'name': None, 'stacktrace': {'frames': [ {'abs_path': '/Users/haza/Projects/sentry-swift/Sources/ios/SentrySwizzle.swift', 'colno': 0, 'filename': 'SentrySwizzle.swift', 'function': '@objc UIApplication.sentryClient_sendAction(Selector, to : AnyObject?, from : AnyObject?, for : UIEvent?) -> Bool', 'image_addr': '0x2c8000', 'in_app': False, 'instruction_addr': '0x31caa4', 'lineno': 0, 'object_addr': '0x2c8000', 'package': '/private/var/containers/Bundle/Application/06EA18D0-49C5-452C-B431-92B1098FB4AD/SwiftExample.app/Frameworks/SentrySwift.framework/SentrySwift', 'symbol': '_TToFE11SentrySwiftCSo13UIApplication23sentryClient_sendActionfTV10ObjectiveC8Selector2toGSqPs9AnyObject__4fromGSqPS3___3forGSqCSo7UIEvent__Sb', 'symbol_addr': '0x31ca38'}, {'abs_path': '/Users/haza/Projects/sentry-swift/Sources/ios/SentrySwizzle.swift', 'colno': 84, 'filename': 'SentrySwizzle.swift', 'function': 'UIApplication.sentryClient_sendAction(Selector, to : AnyObject?, from : AnyObject?, for : UIEvent?) -> Bool', 'image_addr': '0x2c8000', 'in_app': False, 'instruction_addr': '0x31c3e8', 'lineno': 92, 'object_addr': '0x2c8000', 'package': '/private/var/containers/Bundle/Application/06EA18D0-49C5-452C-B431-92B1098FB4AD/SwiftExample.app/Frameworks/SentrySwift.framework/SentrySwift', 'symbol': '_TFE11SentrySwiftCSo13UIApplication23sentryClient_sendActionfTV10ObjectiveC8Selector2toGSqPs9AnyObject__4fromGSqPS3___3forGSqCSo7UIEvent__Sb', 'symbol_addr': '0x31b9f8'}, {'function': '<redacted>', 'image_addr': '0x8751b000', 'in_app': False, 'instruction_addr': '0x8755fd30', 'package': '/System/Library/Frameworks/UIKit.framework/UIKit', 'symbol_addr': '0x8755fcd0'}, {'abs_path': '/Users/haza/Projects/sentry-swift/Examples/SwiftExample/SwiftExample/ViewController.swift', 'colno': 0, 'filename': 'ViewController.swift', 'function': '@objc ViewController.onClickFatalError(AnyObject) -> ()', 'image_addr': '0xf0000', 'in_app': True, 'instruction_addr': '0xf6cd4', 'lineno': 0, 'object_addr': '0xf0000', 'package': '/var/containers/Bundle/Application/06EA18D0-49C5-452C-B431-92B1098FB4AD/SwiftExample.app/SwiftExample', 'symbol': '_TToFC12SwiftExample14ViewController17onClickFatalErrorfPs9AnyObject_T_', 'symbol_addr': '0xf6c98'}, {'abs_path': '/Users/haza/Projects/sentry-swift/Examples/SwiftExample/SwiftExample/ViewController.swift', 'colno': 36, 'filename': 'ViewController.swift', 'function': 'ViewController.onClickFatalError(AnyObject) -> ()', 'image_addr': '0xf0000', 'in_app': True, 'instruction_addr': '0xf6c78', 'lineno': 110, 'object_addr': '0xf0000', 'package': '/var/containers/Bundle/Application/06EA18D0-49C5-452C-B431-92B1098FB4AD/SwiftExample.app/SwiftExample', 'symbol': '_TFC12SwiftExample14ViewController17onClickFatalErrorfPs9AnyObject_T_', 'symbol_addr': '0xf6c04'}, {'abs_path': '/Users/haza/Projects/sentry-swift/Sources/Sentry.swift', 'colno': 0, 'filename': 'Sentry.swift', 'function': '@objc SentryClient.crash() -> ()', 'image_addr': '0x2c8000', 'in_app': False, 'instruction_addr': '0x312308', 'lineno': 0, 'object_addr': '0x2c8000', 'package': '/private/var/containers/Bundle/Application/06EA18D0-49C5-452C-B431-92B1098FB4AD/SwiftExample.app/Frameworks/SentrySwift.framework/SentrySwift', 'symbol': '_TToFC11SentrySwift12SentryClient5crashfT_T_', 'symbol_addr': '0x312280'}, {'function': 'specialized _assertionFailed(StaticString, String, StaticString, UInt) -> ()', 'image_addr': '0x3f8000', 'in_app': False, 'instruction_addr': '0x556cc4', 'package': '/private/var/containers/Bundle/Application/06EA18D0-49C5-452C-B431-92B1098FB4AD/SwiftExample.app/Frameworks/libswiftCore.dylib', 'symbol_addr': '0x556c24'}, {'function': 'specialized _assertionFailed(StaticString, String, StaticString, UInt) -> ()', 'image_addr': '0x3f8000', 'in_app': False, 'instruction_addr': '0x556cc4', 'package': '/private/var/containers/Bundle/Application/06EA18D0-49C5-452C-B431-92B1098FB4AD/SwiftExample.app/Frameworks/libswiftCore.dylib', 'symbol_addr': '0x556c24'} ]} }) # TODO(hazat): the address here in a real crash is 0x0000000100556cc4 but we just get 0x556cc4 assert thread == 'Thread 1 name: \n\