Beispiel #1
0
def _symbolicate(
        profile: MutableMapping[str, Any]) -> MutableMapping[str, Any]:
    project = Project.objects.get_from_cache(id=profile["project_id"])
    symbolicator = Symbolicator(project=project,
                                event_id=profile["profile_id"])

    for i in profile["debug_meta"]["images"]:
        i["debug_id"] = i["uuid"]

    modules = profile["debug_meta"]["images"]
    stacktraces = [{
        "registers": {},
        "frames": s["frames"],
    } for s in profile["sampled_profile"]["samples"]]

    response = symbolicator.process_payload(stacktraces=stacktraces,
                                            modules=modules)
    for original, symbolicated in zip(profile["sampled_profile"]["samples"],
                                      response["stacktraces"]):
        for original_frame, symbolicated_frame in zip(original["frames"],
                                                      symbolicated["frames"]):
            original_frame.update(symbolicated_frame)

    # save the symbolicated frames on the profile
    profile["profile"] = profile["sampled_profile"]

    return profile
Beispiel #2
0
def process_applecrashreport(data):
    project = Project.objects.get_from_cache(id=data["project"])

    report = get_event_attachment(data, APPLECRASHREPORT_ATTACHMENT_TYPE)
    if not report:
        logger.error("Missing applecrashreport for event")
        return

    symbolicator = Symbolicator(project=project, event_id=data["event_id"])

    response = symbolicator.process_applecrashreport(report.data)

    if _handle_response_status(data, response):
        _merge_full_response(data, response)

    return data
Beispiel #3
0
def process_minidump(data):
    project = Project.objects.get_from_cache(id=data["project"])

    minidump = get_event_attachment(data, MINIDUMP_ATTACHMENT_TYPE)
    if not minidump:
        logger.error("Missing minidump for minidump event")
        return

    symbolicator = Symbolicator(project=project, event_id=data["event_id"])

    response = symbolicator.process_minidump(minidump.data)

    if _handle_response_status(data, response):
        _merge_full_response(data, response)

    return data
Beispiel #4
0
def process_minidump(data):
    project = Project.objects.get_from_cache(id=data['project'])

    minidump = get_attached_minidump(data)

    if not minidump:
        logger.error("Missing minidump for minidump event")
        return

    symbolicator = Symbolicator(project=project, event_id=data['event_id'])

    response = symbolicator.process_minidump(
        make_buffered_slice_reader(minidump.data, None))

    if _handle_response_status(data, response):
        _merge_minidump_response(data, response)

    return data
Beispiel #5
0
def reprocess_minidump(data):
    project = Project.objects.get_from_cache(id=data['project'])

    minidump = get_attached_minidump(data)

    if not minidump:
        logger.error("Missing minidump for minidump event")
        return

    task_id_cache_key = task_id_cache_key_for_event(data)

    symbolicator = Symbolicator(
        project=project,
        task_id_cache_key=task_id_cache_key
    )

    response = symbolicator.process_minidump(make_buffered_slice_reader(minidump.data, None))

    if handle_symbolicator_response_status(data, response):
        merge_symbolicator_minidump_response(data, response)

    return data
Beispiel #6
0
def process_payload(data):
    project = Project.objects.get_from_cache(id=data["project"])

    symbolicator = Symbolicator(project=project, event_id=data["event_id"])

    stacktrace_infos = [
        stacktrace for stacktrace in find_stacktraces_in_data(data) if any(
            is_native_platform(x) for x in stacktrace.platforms)
    ]

    modules = native_images_from_data(data)

    stacktraces = [{
        "registers":
        sinfo.stacktrace.get("registers") or {},
        "frames":
        get_frames_for_symbolication(
            sinfo.stacktrace.get("frames") or (), data, modules),
    } for sinfo in stacktrace_infos]

    if not any(stacktrace["frames"] for stacktrace in stacktraces):
        return

    signal = signal_from_data(data)

    response = symbolicator.process_payload(stacktraces=stacktraces,
                                            modules=modules,
                                            signal=signal)

    if not _handle_response_status(data, response):
        return data

    assert len(modules) == len(response["modules"]), (modules, response)

    sdk_info = get_sdk_from_event(data)

    for raw_image, complete_image in zip(modules, response["modules"]):
        _merge_image(raw_image, complete_image, sdk_info, data)

    assert len(stacktraces) == len(response["stacktraces"]), (stacktraces,
                                                              response)

    for sinfo, complete_stacktrace in zip(stacktrace_infos,
                                          response["stacktraces"]):
        complete_frames_by_idx = {}
        for complete_frame in complete_stacktrace.get("frames") or ():
            complete_frames_by_idx.setdefault(complete_frame["original_index"],
                                              []).append(complete_frame)

        new_frames = []
        native_frames_idx = 0

        for raw_frame in reversed(sinfo.stacktrace["frames"]):
            if not _handles_frame(data, raw_frame):
                new_frames.append(raw_frame)
                continue

            for complete_frame in complete_frames_by_idx.get(
                    native_frames_idx) or ():
                merged_frame = dict(raw_frame)
                _merge_frame(merged_frame, complete_frame)
                if merged_frame.get("package"):
                    raw_frame["package"] = merged_frame["package"]
                new_frames.append(merged_frame)

            native_frames_idx += 1

        if sinfo.container is not None and native_frames_idx > 0:
            sinfo.container["raw_stacktrace"] = {
                "frames": list(sinfo.stacktrace["frames"]),
                "registers": sinfo.stacktrace.get("registers"),
            }

        new_frames.reverse()
        sinfo.stacktrace["frames"] = new_frames

    return data
Beispiel #7
0
def process_payload(data):
    project = Project.objects.get_from_cache(id=data['project'])

    symbolicator = Symbolicator(project=project, event_id=data['event_id'])

    stacktrace_infos = [
        stacktrace for stacktrace in find_stacktraces_in_data(data) if any(
            is_native_platform(x) for x in stacktrace.platforms)
    ]

    stacktraces = [{
        'registers':
        sinfo.stacktrace.get('registers') or {},
        'frames': [
            f for f in reversed(sinfo.stacktrace.get('frames') or ())
            if _handles_frame(data, f)
        ]
    } for sinfo in stacktrace_infos]

    if not any(stacktrace['frames'] for stacktrace in stacktraces):
        return

    modules = native_images_from_data(data)
    signal = signal_from_data(data)

    response = symbolicator.process_payload(
        stacktraces=stacktraces,
        modules=modules,
        signal=signal,
    )

    if not _handle_response_status(data, response):
        return data

    assert len(modules) == len(response['modules']), (modules, response)

    sdk_info = get_sdk_from_event(data)

    for raw_image, complete_image in zip(modules, response['modules']):
        _merge_image(raw_image, complete_image, sdk_info,
                     lambda e: write_error(e, data))

    assert len(stacktraces) == len(response['stacktraces']), (stacktraces,
                                                              response)

    for sinfo, complete_stacktrace in zip(stacktrace_infos,
                                          response['stacktraces']):
        complete_frames_by_idx = {}
        for complete_frame in complete_stacktrace.get('frames') or ():
            complete_frames_by_idx \
                .setdefault(complete_frame['original_index'], []) \
                .append(complete_frame)

        new_frames = []
        native_frames_idx = 0

        for raw_frame in reversed(sinfo.stacktrace['frames']):
            if not _handles_frame(data, raw_frame):
                new_frames.append(raw_frame)
                continue

            for complete_frame in complete_frames_by_idx.get(
                    native_frames_idx) or ():
                merged_frame = dict(raw_frame)
                _merge_frame(merged_frame, complete_frame)
                if merged_frame.get('package'):
                    raw_frame['package'] = merged_frame['package']
                new_frames.append(merged_frame)

            native_frames_idx += 1

        if sinfo.container is not None and native_frames_idx > 0:
            sinfo.container['raw_stacktrace'] = {
                'frames': list(sinfo.stacktrace['frames']),
                'registers': sinfo.stacktrace.get('registers')
            }

        new_frames.reverse()
        sinfo.stacktrace['frames'] = new_frames

    return data