コード例 #1
0
ファイル: plugin.py プロジェクト: xvdy/sentry
def preprocess_apple_crash_event(data):
    crash_report = data.get('sentry.interfaces.AppleCrashReport')
    if crash_report is None:
        return

    project = Project.objects.get_from_cache(id=data['project'], )

    crash = crash_report['crash']
    crashed_thread = None
    for thread in crash['threads']:
        if thread['crashed']:
            crashed_thread = thread
    if crashed_thread is None:
        return

    system = crash_report.get('system')
    sym = Symbolizer(project,
                     crash_report['binary_images'],
                     threads=[crashed_thread])
    with sym:
        bt = sym.symbolize_backtrace(crashed_thread['backtrace']['contents'],
                                     system)
        inject_apple_backtrace(data, bt, crash.get('diagnosis'),
                               crash.get('error'), system)

    return data
コード例 #2
0
ファイル: plugin.py プロジェクト: Akashguharoy/sentry
def preprocess_apple_crash_event(data):
    crash_report = data.get('sentry.interfaces.AppleCrashReport')
    if crash_report is None:
        return

    project = Project.objects.get_from_cache(
        id=data['project'],
    )

    system = None
    errors = []
    crash = crash_report['crash']
    crashed_thread = None
    for thread in crash['threads']:
        if thread['crashed']:
            crashed_thread = thread
    if crashed_thread is None:
        append_error(data, {
            'type': EventError.NATIVE_NO_CRASHED_THREAD,
        })

    else:
        system = crash_report.get('system')
        try:
            sym = Symbolizer(project, crash_report['binary_images'],
                             threads=[crashed_thread])
            with sym:
                bt, errors = sym.symbolize_backtrace(
                    crashed_thread['backtrace']['contents'], system)
                inject_apple_backtrace(data, bt, crash.get('diagnosis'),
                                       crash.get('error'), system,
                                       crashed_thread.get('notable_addresses'))
        except Exception as e:
            logger.exception('Failed to symbolicate')
            append_error(data, {
                'type': EventError.NATIVE_INTERNAL_FAILURE,
                'error': '%s: %s' % (e.__class__.__name__, str(e)),
            })

    for error in errors:
        append_error(data, error)

    if system:
        inject_apple_device_data(data, system)

    return data
コード例 #3
0
ファイル: plugin.py プロジェクト: syd520/sentry
def preprocess_apple_crash_event(data):
    crash_report = data.get('sentry.interfaces.AppleCrashReport')
    if crash_report is None:
        return

    project = Project.objects.get_from_cache(id=data['project'], )

    system = None
    errors = []
    crash = crash_report['crash']
    crashed_thread = None
    for thread in crash['threads']:
        if thread['crashed']:
            crashed_thread = thread
    if crashed_thread is None:
        append_error(data, {
            'type': EventError.NATIVE_NO_CRASHED_THREAD,
        })

    else:
        system = crash_report.get('system')
        try:
            sym = Symbolizer(project,
                             crash_report['binary_images'],
                             threads=[crashed_thread])
            with sym:
                bt, errors = sym.symbolize_backtrace(
                    crashed_thread['backtrace']['contents'], system)
                inject_apple_backtrace(data, bt, crash.get('diagnosis'),
                                       crash.get('error'), system,
                                       crashed_thread.get('notable_addresses'))
        except Exception as e:
            logger.exception('Failed to symbolicate')
            append_error(
                data, {
                    'type': EventError.NATIVE_INTERNAL_FAILURE,
                    'error': '%s: %s' % (e.__class__.__name__, str(e)),
                })

    for error in errors:
        append_error(data, error)

    if system:
        inject_apple_device_data(data, system)

    return data
コード例 #4
0
ファイル: plugin.py プロジェクト: zenefits/sentry
def preprocess_apple_crash_event(data):
    crash_report = data.get("sentry.interfaces.AppleCrashReport")
    if crash_report is None:
        return

    project = Project.objects.get_from_cache(id=data["project"])

    crash = crash_report["crash"]
    crashed_thread = None
    for thread in crash["threads"]:
        if thread["crashed"]:
            crashed_thread = thread
    if crashed_thread is None:
        return

    system = crash_report.get("system")
    sym = Symbolizer(project, crash_report["binary_images"], threads=[crashed_thread])
    with sym:
        bt = sym.symbolize_backtrace(crashed_thread["backtrace"]["contents"], system)
        inject_apple_backtrace(data, bt, crash.get("diagnosis"), crash.get("error"), system)

    return data
コード例 #5
0
ファイル: plugin.py プロジェクト: gilsonbp/sentry
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'],
                     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