def __init__(self, *args, **kwargs): StacktraceProcessor.__init__(self, *args, **kwargs) # If true, the project has been opted into using the symbolicator # service for native symbolication, which also means symbolic is not # used at all anymore. # The (iOS) symbolserver is still used regardless of this value. self.use_symbolicator = _is_symbolicator_enabled( self.project, self.data) metrics.incr('native.use_symbolicator', tags={'value': self.use_symbolicator}) self.arch = cpu_name_from_data(self.data) self.signal = signal_from_data(self.data) self.sym = None self.difs_referenced = set() images = get_path(self.data, 'debug_meta', 'images', default=(), filter=self._is_valid_image) if images: self.available = True self.sdk_info = get_sdk_from_event(self.data) self.object_lookup = ObjectLookup(images) self.images = images else: self.available = False
def __init__(self, *args, **kwargs): StacktraceProcessor.__init__(self, *args, **kwargs) # If true, the project has been opted into using the symbolicator # service for native symbolication, which also means symbolic is not # used at all anymore. # The (iOS) symbolserver is still used regardless of this value. self.use_symbolicator = _is_symbolicator_enabled(self.project, self.data) metrics.incr('native.use_symbolicator', tags={'value': self.use_symbolicator}) self.arch = cpu_name_from_data(self.data) self.signal = signal_from_data(self.data) self.sym = None self.difs_referenced = set() images = get_path(self.data, 'debug_meta', 'images', default=(), filter=self._is_valid_image) if images: self.available = True self.sdk_info = get_sdk_from_event(self.data) self.object_lookup = ObjectLookup(images) self.images = images else: self.available = False
def test_cpu_name_from_data_inferred_type(): cpu_name = cpu_name_from_data( {'contexts': { 'some_device': { 'type': 'device', 'arch': 'arm64' } }}) assert cpu_name == 'arm64'
def test_cpu_name_from_data_inferred_type(): cpu_name = cpu_name_from_data({ 'contexts': { 'some_device': { 'type': 'device', 'arch': 'arm64' } } }) assert cpu_name == 'arm64'
def __init__(self, *args, **kwargs): StacktraceProcessor.__init__(self, *args, **kwargs) debug_meta = self.data.get('debug_meta') self.cpu_name = cpu_name_from_data(self.data) self.sym = None if debug_meta: self.available = True self.debug_meta = debug_meta self.sdk_info = get_sdk_from_event(self.data) self.image_lookup = ImageLookup(self.debug_meta['images']) else: self.available = False
def __init__(self, *args, **kwargs): StacktraceProcessor.__init__(self, *args, **kwargs) debug_meta = self.data.get('debug_meta') self.arch = cpu_name_from_data(self.data) self.sym = None self.dsyms_referenced = set() if debug_meta: self.available = True self.debug_meta = debug_meta self.sdk_info = get_sdk_from_event(self.data) self.object_lookup = ObjectLookup( [img for img in self.debug_meta['images'] if img['type'] in self.supported_images] ) else: self.available = False
def test_cpu_name_from_data(): cpu_name = cpu_name_from_data({ 'contexts': { 'device': { 'type': 'device', 'arch': 'arm64' }, 'device2': { 'type': 'device', 'arch': 'arm7' }, } }) assert cpu_name == 'arm64'
def __init__(self, *args, **kwargs): StacktraceProcessor.__init__(self, *args, **kwargs) debug_meta = self.data.get('debug_meta') self.arch = cpu_name_from_data(self.data) self.sym = None self.difs_referenced = set() if debug_meta: self.available = True self.debug_meta = debug_meta self.sdk_info = get_sdk_from_event(self.data) self.object_lookup = ObjectLookup( [img for img in self.debug_meta['images'] if img['type'] in self.supported_images] ) else: self.available = False
def __init__(self, *args, **kwargs): StacktraceProcessor.__init__(self, *args, **kwargs) self.arch = cpu_name_from_data(self.data) self.sym = None self.difs_referenced = set() images = get_path(self.data, 'debug_meta', 'images', default=(), filter=self._is_valid_image) if images: self.available = True self.sdk_info = get_sdk_from_event(self.data) self.object_lookup = ObjectLookup(images) else: self.available = False
def __init__(self, *args, **kwargs): StacktraceProcessor.__init__(self, *args, **kwargs) debug_meta = self.data.get('debug_meta') self.cpu_name = cpu_name_from_data(self.data) self.sym = None self.dsyms_referenced = set() if debug_meta: self.available = True self.debug_meta = debug_meta self.sdk_info = get_sdk_from_event(self.data) self.image_lookup = ImageLookup([ img for img in self.debug_meta['images'] if img['type'] == 'apple' ]) else: self.available = False
def __init__(self, *args, **kwargs): StacktraceProcessor.__init__(self, *args, **kwargs) self.arch = cpu_name_from_data(self.data) self.sym = None self.difs_referenced = set() images = get_path(self.data, 'debug_meta', 'images', default=(), filter=(lambda img: img and img.get('type') in self.supported_images)) if images: self.available = True self.sdk_info = get_sdk_from_event(self.data) self.object_lookup = ObjectLookup(images) else: self.available = False
def preprocess_apple_crash_event(data): """This processes the "legacy" AppleCrashReport.""" crash_report = data['sentry.interfaces.AppleCrashReport'] if os.environ.get('SENTRY_DUMP_APPLE_CRASH_REPORT') == '1': dump_crash_report(crash_report) project = Project.objects.get_from_cache( id=data['project'], ) system = None errors = [] threads = [] crash = crash_report['crash'] crashed_thread = None threads = {} raw_threads = {} for raw_thread in crash['threads']: if raw_thread['crashed'] and raw_thread.get('backtrace'): crashed_thread = raw_thread raw_threads[raw_thread['index']] = raw_thread threads[raw_thread['index']] = { 'id': raw_thread['index'], 'name': raw_thread.get('name'), 'current': raw_thread.get('current_thread', False), 'crashed': raw_thread.get('crashed', False), } sdk_info = get_sdk_from_apple_system_info(system) referenced_images = find_apple_crash_report_referenced_images( crash_report['binary_images'], raw_threads.values()) sym = Symbolizer(project, crash_report['binary_images'], cpu_name=cpu_name_from_data(data), referenced_images=referenced_images) try: if crashed_thread is None: append_error(data, { 'type': EventError.NATIVE_NO_CRASHED_THREAD, }) else: system = crash_report.get('system') try: bt, errors = sym.symbolize_backtrace( crashed_thread['backtrace']['contents'], sdk_info) for error in errors: append_error(data, error) if inject_apple_backtrace(data, bt, crash.get('diagnosis'), crash.get('error'), system, crashed_thread.get('notable_addresses'), crashed_thread['index']): # We recorded an exception, so in this case we can # skip having the stacktrace. threads[crashed_thread['index']]['stacktrace'] = None except Exception: logger.exception('Failed to symbolicate') errors.append({ 'type': EventError.NATIVE_INTERNAL_FAILURE, 'error': 'The symbolicator encountered an internal failure', }) for thread in six.itervalues(threads): # If we were told to skip the stacktrace, skip it indeed if thread.get('stacktrace', Ellipsis) is None: continue raw_thread = raw_threads.get(thread['id']) if raw_thread is None or not raw_thread.get('backtrace'): continue bt, errors = sym.symbolize_backtrace( raw_thread['backtrace']['contents'], sdk_info) for error in errors: append_error(data, error) thread['stacktrace'] = convert_stacktrace( bt, system, raw_thread.get('notable_addresses')) finally: sym.close() if threads: data['threads'] = { 'values': sorted(threads.values(), key=lambda x: x['id']), } if system: inject_apple_device_data(data, system) return data
def preprocess_apple_crash_event(data): """This processes the "legacy" AppleCrashReport.""" crash_report = data['sentry.interfaces.AppleCrashReport'] if os.environ.get('SENTRY_DUMP_APPLE_CRASH_REPORT') == '1': dump_crash_report(crash_report) project = Project.objects.get_from_cache(id=data['project'], ) system = None errors = [] threads = [] crash = crash_report['crash'] crashed_thread = None threads = {} raw_threads = {} for raw_thread in crash['threads']: if raw_thread['crashed'] and raw_thread.get('backtrace'): crashed_thread = raw_thread raw_threads[raw_thread['index']] = raw_thread threads[raw_thread['index']] = { 'id': raw_thread['index'], 'name': raw_thread.get('name'), 'current': raw_thread.get('current_thread', False), 'crashed': raw_thread.get('crashed', False), } sdk_info = get_sdk_from_apple_system_info(system) referenced_images = find_apple_crash_report_referenced_images( crash_report['binary_images'], raw_threads.values()) sym = Symbolizer(project, crash_report['binary_images'], cpu_name=cpu_name_from_data(data), referenced_images=referenced_images) try: if crashed_thread is None: append_error(data, { 'type': EventError.NATIVE_NO_CRASHED_THREAD, }) else: system = crash_report.get('system') try: bt, errors = sym.symbolize_backtrace( crashed_thread['backtrace']['contents'], sdk_info) for error in errors: append_error(data, error) if inject_apple_backtrace( data, bt, crash.get('diagnosis'), crash.get('error'), system, crashed_thread.get('notable_addresses'), crashed_thread['index']): # We recorded an exception, so in this case we can # skip having the stacktrace. threads[crashed_thread['index']]['stacktrace'] = None except Exception: logger.exception('Failed to symbolicate') errors.append({ 'type': EventError.NATIVE_INTERNAL_FAILURE, 'error': 'The symbolicator encountered an internal failure', }) for thread in six.itervalues(threads): # If we were told to skip the stacktrace, skip it indeed if thread.get('stacktrace', Ellipsis) is None: continue raw_thread = raw_threads.get(thread['id']) if raw_thread is None or not raw_thread.get('backtrace'): continue bt, errors = sym.symbolize_backtrace( raw_thread['backtrace']['contents'], sdk_info) for error in errors: append_error(data, error) thread['stacktrace'] = convert_stacktrace( bt, system, raw_thread.get('notable_addresses')) finally: sym.close() if threads: data['threads'] = { 'values': sorted(threads.values(), key=lambda x: x['id']), } if system: inject_apple_device_data(data, system) return data