PyCrashReport

2.0.0 · active · verified Thu Apr 16

PyCrashReport is a pure Python 3 library designed for parsing and analyzing Apple's crash reports, distilling them into a clearer view by focusing on essential debugging data. It supports user-mode and kernel-mode crash reports, providing basic metadata for other types. The library is actively maintained, with frequent minor updates and a recent major version release (v2.0.0).

Common errors

Warnings

Install

Imports

Quickstart

Instantiate the `CrashReport` object with the content of an Apple crash report (typically an .ips file) and access its parsed attributes like incident identifier, process name, OS version, and the crashed thread's backtrace.

import os
from pycrashreport.crash_report import CrashReport

# Simulate a crash report content (replace with actual file reading)
crash_report_content = """
Incident Identifier: 1234ABCD-ABCD-ABCD-ABCD-1234ABCDABCD
CrashReporter Key: 0123456789abcdef0123456789abcdef01234567
Hardware Model: iPhone13,4
Process: MyApp [1234]
Path: /private/var/containers/Bundle/Application/APP_UUID/MyApp.app/MyApp
Identifier: com.example.MyApp
Version: 1.0 (1)
Code Type: ARM-64 (Native)
Parent Process: launchd [1]
Date/Time: 2026-04-16 10:00:00.000 +0000
OS Version: iOS 17.4 (21E236)
Report Version: 104

Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000000
Termination Reason: Namespace SIGNAL, Code 0xb
Terminating Process: exc handler [1234]

Triggered by Thread:  0

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   libsystem_kernel.dylib        0x180000000 0x180000000 + 0x21c4
1   MyApp                         0x100000000 main + 0 (main.m:16)
2   dyld                          0x102000000 start + 0

Binary Images:
0x100000000 - 0x100003fff MyApp arm64e  <UUID> /private/var/containers/Bundle/Application/APP_UUID/MyApp.app/MyApp
0x180000000 - 0x18001ffff libsystem_kernel.dylib arm64e  <UUID> /usr/lib/system/libsystem_kernel.dylib
0x102000000 - 0x102033fff dyld arm64e  <UUID> /usr/lib/dyld
"""

try:
    # It's common to pass the raw content or a file-like object
    # For a real file, you would use: with open('path/to/report.ips', 'r') as f: report = CrashReport(f.read())
    report = CrashReport(crash_report_content)

    print(f"Incident Identifier: {report.incident_identifier}")
    print(f"Process Name: {report.process_name}")
    print(f"Process ID: {report.process_id}")
    print(f"OS Version: {report.os_version}")
    print(f"Exception Type: {report.exception_type}")
    print(f"Crashed Thread: {report.crashed_thread_id}")

    if report.crashed_thread and report.crashed_thread.frames:
        print("\nCrashed Thread Backtrace:")
        for frame in report.crashed_thread.frames:
            print(f"  {frame.image_name} {frame.address} {frame.symbol_name if frame.symbol_name else ''}")

except Exception as e:
    print(f"Error parsing crash report: {e}")

view raw JSON →