Exemplo n.º 1
0
def process_minidump(minidump, cfi=None):
    if isinstance(minidump, InMemoryUploadedFile):
        minidump.open()  # seek to start
        return ProcessState.from_minidump_buffer(minidump.read(), cfi)
    elif isinstance(minidump, TemporaryUploadedFile):
        return ProcessState.from_minidump(minidump.temporary_file_path(), cfi)
    else:
        return ProcessState.from_minidump_buffer(minidump, cfi)
Exemplo n.º 2
0
def process_minidump(minidump, cfi=None):
    if isinstance(minidump, InMemoryUploadedFile):
        minidump.open()  # seek to start
        return ProcessState.from_minidump_buffer(minidump.read(), cfi)
    elif isinstance(minidump, TemporaryUploadedFile):
        return ProcessState.from_minidump(minidump.temporary_file_path(), cfi)
    else:
        return ProcessState.from_minidump_buffer(minidump, cfi)
Exemplo n.º 3
0
def merge_minidump_event(data, minidump):
    if isinstance(minidump, InMemoryUploadedFile):
        state = ProcessState.from_minidump_buffer(minidump.read())
    elif isinstance(minidump, TemporaryUploadedFile):
        state = ProcessState.from_minidump(minidump.temporary_file_path())
    else:
        state = ProcessState.from_minidump(minidump)

    data['platform'] = 'native'
    data['level'] = 'fatal' if state.crashed else 'info'
    data['message'] = 'Assertion Error: %s' % state.assertion if state.assertion \
        else 'Fatal Error: %s' % state.crash_reason

    if state.timestamp:
        data['timestamp'] = float(state.timestamp)

    # Extract as much context information as we can.
    info = state.system_info
    context = data.setdefault('contexts', {})
    os = context.setdefault('os', {})
    device = context.setdefault('device', {})
    os['type'] = 'os'  # Required by "get_sdk_from_event"
    os['name'] = MINIDUMP_OS_TYPES.get(info.os_name, info.os_name)
    os['version'] = info.os_version
    os['build'] = info.os_build
    device['arch'] = arch_from_breakpad(info.cpu_family)

    # We can extract stack traces here already but since CFI is not
    # available yet (without debug symbols), the stackwalker will
    # resort to stack scanning which yields low-quality results. If
    # the user provides us with debug symbols, we could reprocess this
    # minidump and add improved stacktraces later.
    data['threads'] = [
        {
            'id': thread.thread_id,
            'crashed': False,
            'stacktrace': {
                'frames': [
                    {
                        'instruction_addr': '0x%x' % frame.return_address,
                        'function': '<unknown>',  # Required by interface
                        'package': frame.module.name if frame.module else None,
                    } for frame in reversed(list(thread.frames()))
                ],
            },
        } for thread in state.threads()
    ]

    # Mark the crashed thread and add its stacktrace to the exception
    crashed_thread = data['threads'][state.requesting_thread]
    crashed_thread['crashed'] = True

    # Extract the crash reason and infos
    data['exception'] = {
        'value': data['message'],
        'thread_id': crashed_thread['id'],
        'type': state.crash_reason,
        # Move stacktrace here from crashed_thread (mutating!)
        'stacktrace': crashed_thread.pop('stacktrace'),
    }

    # Extract referenced (not all loaded) images
    images = [{
        'type': 'symbolic',
        'id': id_from_breakpad(module.id),
        'image_addr': '0x%x' % module.addr,
        'image_size': module.size,
        'name': module.name,
    } for module in state.modules()]
    data.setdefault('debug_meta', {})['images'] = images
Exemplo n.º 4
0
def merge_minidump_event(data, minidump):
    if isinstance(minidump, InMemoryUploadedFile):
        minidump.open()  # seek to start
        state = ProcessState.from_minidump_buffer(minidump.read())
    elif isinstance(minidump, TemporaryUploadedFile):
        state = ProcessState.from_minidump(minidump.temporary_file_path())
    else:
        state = ProcessState.from_minidump(minidump)

    data['platform'] = 'native'
    data['level'] = 'fatal' if state.crashed else 'info'
    data['message'] = 'Assertion Error: %s' % state.assertion if state.assertion \
        else 'Fatal Error: %s' % state.crash_reason

    if state.timestamp:
        data['timestamp'] = float(state.timestamp)

    # Extract as much context information as we can.
    info = state.system_info
    context = data.setdefault('contexts', {})
    os = context.setdefault('os', {})
    device = context.setdefault('device', {})
    os['type'] = 'os'  # Required by "get_sdk_from_event"
    os['name'] = MINIDUMP_OS_TYPES.get(info.os_name, info.os_name)
    os['version'] = info.os_version
    os['build'] = info.os_build
    device['arch'] = arch_from_breakpad(info.cpu_family)

    # We can extract stack traces here already but since CFI is not
    # available yet (without debug symbols), the stackwalker will
    # resort to stack scanning which yields low-quality results. If
    # the user provides us with debug symbols, we could reprocess this
    # minidump and add improved stacktraces later.
    data['threads'] = [{
        'id': thread.thread_id,
        'crashed': False,
        'stacktrace': {
            'frames': [{
                'instruction_addr': '0x%x' % frame.return_address,
                'function': '<unknown>',  # Required by interface
                'package': frame.module.name if frame.module else None,
            } for frame in reversed(list(thread.frames()))],
            'registers': thread.get_frame(0).registers if thread.frame_count else None,
        },
    } for thread in state.threads()]

    # Mark the crashed thread and add its stacktrace to the exception
    crashed_thread = data['threads'][state.requesting_thread]
    crashed_thread['crashed'] = True

    # Extract the crash reason and infos
    data['exception'] = {
        'value': data['message'],
        'thread_id': crashed_thread['id'],
        'type': state.crash_reason,
        # Move stacktrace here from crashed_thread (mutating!)
        'stacktrace': crashed_thread.pop('stacktrace'),
        'mechanism': {
            'type': 'minidump',
            'handled': False,
            # We cannot extract exception codes or signals with the breakpad
            # extractor just yet. Once these capabilities are added to symbolic,
            # these values should go in the mechanism here.
        }
    }

    # Extract referenced (not all loaded) images
    images = [{
        'type': 'symbolic',
        'id': id_from_breakpad(module.id),
        'image_addr': '0x%x' % module.addr,
        'image_size': module.size,
        'name': module.name,
    } for module in state.modules()]
    data.setdefault('debug_meta', {})['images'] = images
Exemplo n.º 5
0
def merge_minidump_event(data, minidump_path):
    state = ProcessState.from_minidump(minidump_path)

    data['level'] = LOG_LEVELS_MAP[
        'fatal'] if state.crashed else LOG_LEVELS_MAP['info']
    data['message'] = 'Assertion Error: %s' % state.assertion if state.assertion \
        else 'Fatal Error: %s' % state.crash_reason

    if state.timestamp:
        data['timestamp'] = float(state.timestamp)

    # Extract as much system information as we can. TODO: We should create
    # a custom context and implement a specific minidump view in the event
    # UI.
    info = state.system_info
    context = data.setdefault('contexts', {})
    os = context.setdefault('os', {})
    device = context.setdefault('device', {})
    os['type'] = 'os'  # Required by "get_sdk_from_event"
    os['name'] = MINIDUMP_OS_TYPES.get(info.os_name, info.os_name)
    device['arch'] = info.cpu_family

    # Breakpad reports the version and build number always in one string,
    # but a version number is guaranteed even on certain linux distros.
    match = VERSION_RE.search(info.os_version)
    if match is not None:
        version, build = match.groups()
        os['version'] = version
        os['build'] = build

    # We can extract stack traces here already but since CFI is not
    # available yet (without debug symbols), the stackwalker will
    # resort to stack scanning which yields low-quality results. If
    # the user provides us with debug symbols, we could reprocess this
    # minidump and add improved stacktraces later.
    threads = [
        {
            'id': thread.thread_id,
            'crashed': False,
            'stacktrace': {
                'frames': [
                    {
                        'instruction_addr': '0x%x' % frame.instruction,
                        'function': '<unknown>',  # Required by interface
                    } for frame in thread.frames()
                ],
            },
        } for thread in state.threads()
    ]
    data.setdefault('threads', {})['values'] = threads

    # Mark the crashed thread and add its stacktrace to the exception
    crashed_thread = threads[state.requesting_thread]
    crashed_thread['crashed'] = True

    # Extract the crash reason and infos
    exception = {
        'value': data['message'],
        'thread_id': crashed_thread['id'],
        'type': state.crash_reason,
        # Move stacktrace here from crashed_thread (mutating!)
        'stacktrace': crashed_thread.pop('stacktrace'),
    }

    data.setdefault('sentry.interfaces.Exception', {}) \
        .setdefault('values', []) \
        .append(exception)

    # Extract referenced (not all loaded) images
    images = [
        {
            'type': 'apple',  # Required by interface
            'uuid': six.text_type(module.uuid),
            'image_addr': '0x%x' % module.addr,
            'image_size': '0x%x' % module.size,
            'name': module.name,
        } for module in state.modules()
    ]
    data.setdefault('debug_meta', {})['images'] = images
Exemplo n.º 6
0
def merge_minidump_event(data, minidump_path):
    state = ProcessState.from_minidump(minidump_path)

    data['level'] = LOG_LEVELS_MAP['fatal'] if state.crashed else LOG_LEVELS_MAP['info']
    data['message'] = 'Assertion Error: %s' % state.assertion if state.assertion \
        else 'Fatal Error: %s' % state.crash_reason

    if state.timestamp:
        data['timestamp'] = float(state.timestamp)

    # Extract as much system information as we can. TODO: We should create
    # a custom context and implement a specific minidump view in the event
    # UI.
    info = state.system_info
    context = data.setdefault('contexts', {})
    os = context.setdefault('os', {})
    device = context.setdefault('device', {})
    os['type'] = 'os'  # Required by "get_sdk_from_event"
    os['name'] = _minidump_os_mapping.get(info.os_name, info.os_name)
    device['arch'] = info.cpu_family

    # Breakpad reports the version and build number always in one string,
    # but a version number is guaranteed even on certain linux distros.
    match = _version_re.search(info.os_version)
    if match is not None:
        version, build = match.groups()
        os['version'] = version
        os['build'] = build

    # We can extract stack traces here already but since CFI is not
    # available yet (without debug symbols), the stackwalker will
    # resort to stack scanning which yields low-quality results. If
    # the user provides us with debug symbols, we will reprocess this
    # minidump and add improved stacktraces later.
    threads = [{
        'id': thread.thread_id,
        'crashed': False,
        'stacktrace': {
            'frames': [{
                'instruction_addr': '0x%x' % frame.instruction,
                'function': '<unknown>',  # Required by interface
            } for frame in thread.frames()],
        },
    } for thread in state.threads()]
    data.setdefault('threads', {})['values'] = threads

    # Mark the crashed thread and add its stacktrace to the exception
    crashed_thread = threads[state.requesting_thread]
    crashed_thread['crashed'] = True

    # Extract the crash reason and infos
    exception = {
        'value': data['message'],
        'thread_id': crashed_thread['id'],
        'type': state.crash_reason,
        # Move stacktrace here from crashed_thread (mutating!)
        'stacktrace': crashed_thread.pop('stacktrace'),
    }

    data.setdefault('sentry.interfaces.Exception', {}) \
        .setdefault('values', []) \
        .append(exception)

    # Extract referenced (not all loaded) images
    images = [{
        'type': 'apple',  # Required by interface
        'uuid': six.text_type(module.uuid),
        'image_addr': '0x%x' % module.addr,
        'image_size': '0x%x' % module.size,
        'name': module.name,
    } for module in state.modules()]
    data.setdefault('debug_meta', {})['images'] = images