# Generated by the protocol buffer compiler.  DO NOT EDIT!
# sources: tombstone.proto
# plugin: python-betterproto2
from dataclasses import dataclass

import betterproto2


class Architecture(betterproto2.Enum):
    ARM32 = 0
    ARM64 = 1
    X86 = 2
    X86_64 = 3
    RISCV64 = 4
    NONE = 5


class MemoryErrorTool(betterproto2.Enum):
    GWP_ASAN = 0
    SCUDO = 1


class MemoryErrorType(betterproto2.Enum):
    UNKNOWN = 0
    USE_AFTER_FREE = 1
    DOUBLE_FREE = 2
    INVALID_FREE = 3
    BUFFER_OVERFLOW = 4
    BUFFER_UNDERFLOW = 5


@dataclass(eq=False, repr=False)
class CrashDetail(betterproto2.Message):
    """
    NOTE TO OEMS: If you add custom fields to this proto, do not use numbers in
    the reserved range.
    """

    name: "bytes" = betterproto2.field(1, betterproto2.TYPE_BYTES)
    data: "bytes" = betterproto2.field(2, betterproto2.TYPE_BYTES)


@dataclass(eq=False, repr=False)
class StackHistoryBufferEntry(betterproto2.Message):
    addr: "BacktraceFrame | None" = betterproto2.field(1, betterproto2.TYPE_MESSAGE, optional=True)
    fp: "int" = betterproto2.field(2, betterproto2.TYPE_UINT64)
    tag: "int" = betterproto2.field(3, betterproto2.TYPE_UINT64)


@dataclass(eq=False, repr=False)
class StackHistoryBuffer(betterproto2.Message):
    tid: "int" = betterproto2.field(1, betterproto2.TYPE_UINT64)
    entries: "list[StackHistoryBufferEntry]" = betterproto2.field(2, betterproto2.TYPE_MESSAGE, repeated=True)


@dataclass(eq=False, repr=False)
class Tombstone(betterproto2.Message):
    arch: "Architecture" = betterproto2.field(1, betterproto2.TYPE_ENUM, default_factory=lambda: Architecture(0))
    guest_arch: "Architecture" = betterproto2.field(24, betterproto2.TYPE_ENUM, default_factory=lambda: Architecture(0))
    build_fingerprint: "str" = betterproto2.field(2, betterproto2.TYPE_STRING)
    revision: "str" = betterproto2.field(3, betterproto2.TYPE_STRING)
    timestamp: "str" = betterproto2.field(4, betterproto2.TYPE_STRING)
    pid: "int" = betterproto2.field(5, betterproto2.TYPE_UINT32)
    tid: "int" = betterproto2.field(6, betterproto2.TYPE_UINT32)
    uid: "int" = betterproto2.field(7, betterproto2.TYPE_UINT32)
    selinux_label: "str" = betterproto2.field(8, betterproto2.TYPE_STRING)
    command_line: "list[str]" = betterproto2.field(9, betterproto2.TYPE_STRING, repeated=True)
    # Process uptime in seconds.
    process_uptime: "int" = betterproto2.field(20, betterproto2.TYPE_UINT32)
    signal_info: "Signal | None" = betterproto2.field(10, betterproto2.TYPE_MESSAGE, optional=True)
    abort_message: "str" = betterproto2.field(14, betterproto2.TYPE_STRING)
    crash_details: "list[CrashDetail]" = betterproto2.field(21, betterproto2.TYPE_MESSAGE, repeated=True)
    causes: "list[Cause]" = betterproto2.field(15, betterproto2.TYPE_MESSAGE, repeated=True)
    threads: "dict[int, Thread]" = betterproto2.field(
        16, betterproto2.TYPE_MAP, map_meta=betterproto2.map_meta(betterproto2.TYPE_UINT32, betterproto2.TYPE_MESSAGE)
    )
    guest_threads: "dict[int, Thread]" = betterproto2.field(
        25, betterproto2.TYPE_MAP, map_meta=betterproto2.map_meta(betterproto2.TYPE_UINT32, betterproto2.TYPE_MESSAGE)
    )
    memory_mappings: "list[MemoryMapping]" = betterproto2.field(17, betterproto2.TYPE_MESSAGE, repeated=True)
    log_buffers: "list[LogBuffer]" = betterproto2.field(18, betterproto2.TYPE_MESSAGE, repeated=True)
    open_fds: "list[FD]" = betterproto2.field(19, betterproto2.TYPE_MESSAGE, repeated=True)
    page_size: "int" = betterproto2.field(22, betterproto2.TYPE_UINT32)
    has_been_16kb_mode: "bool" = betterproto2.field(23, betterproto2.TYPE_BOOL)
    stack_history_buffer: "StackHistoryBuffer | None" = betterproto2.field(26, betterproto2.TYPE_MESSAGE, optional=True)


@dataclass(eq=False, repr=False)
class Signal(betterproto2.Message):
    number: "int" = betterproto2.field(1, betterproto2.TYPE_INT32)
    name: "str" = betterproto2.field(2, betterproto2.TYPE_STRING)
    code: "int" = betterproto2.field(3, betterproto2.TYPE_INT32)
    code_name: "str" = betterproto2.field(4, betterproto2.TYPE_STRING)
    has_sender: "bool" = betterproto2.field(5, betterproto2.TYPE_BOOL)
    sender_uid: "int" = betterproto2.field(6, betterproto2.TYPE_INT32)
    sender_pid: "int" = betterproto2.field(7, betterproto2.TYPE_INT32)
    has_fault_address: "bool" = betterproto2.field(8, betterproto2.TYPE_BOOL)
    fault_address: "int" = betterproto2.field(9, betterproto2.TYPE_UINT64)
    # Note, may or may not contain the dump of the actual memory contents.
    # Currently, on arm64, we only include metadata, and not the contents.
    fault_adjacent_metadata: "MemoryDump | None" = betterproto2.field(10, betterproto2.TYPE_MESSAGE, optional=True)


@dataclass(eq=False, repr=False)
class HeapObject(betterproto2.Message):
    address: "int" = betterproto2.field(1, betterproto2.TYPE_UINT64)
    size: "int" = betterproto2.field(2, betterproto2.TYPE_UINT64)
    allocation_tid: "int" = betterproto2.field(3, betterproto2.TYPE_UINT64)
    allocation_backtrace: "list[BacktraceFrame]" = betterproto2.field(4, betterproto2.TYPE_MESSAGE, repeated=True)
    deallocation_tid: "int" = betterproto2.field(5, betterproto2.TYPE_UINT64)
    deallocation_backtrace: "list[BacktraceFrame]" = betterproto2.field(6, betterproto2.TYPE_MESSAGE, repeated=True)


@dataclass(eq=False, repr=False)
class MemoryError(betterproto2.Message):
    tool: "MemoryErrorTool" = betterproto2.field(1, betterproto2.TYPE_ENUM, default_factory=lambda: MemoryErrorTool(0))
    type: "MemoryErrorType" = betterproto2.field(2, betterproto2.TYPE_ENUM, default_factory=lambda: MemoryErrorType(0))
    heap: "HeapObject | None" = betterproto2.field(3, betterproto2.TYPE_MESSAGE, optional=True, group="location")


@dataclass(eq=False, repr=False)
class Cause(betterproto2.Message):
    human_readable: "str" = betterproto2.field(1, betterproto2.TYPE_STRING)
    memory_error: "MemoryError | None" = betterproto2.field(2, betterproto2.TYPE_MESSAGE, optional=True, group="details")


@dataclass(eq=False, repr=False)
class Register(betterproto2.Message):
    name: "str" = betterproto2.field(1, betterproto2.TYPE_STRING)
    u64: "int" = betterproto2.field(2, betterproto2.TYPE_UINT64)


@dataclass(eq=False, repr=False)
class Thread(betterproto2.Message):
    id: "int" = betterproto2.field(1, betterproto2.TYPE_INT32)
    name: "str" = betterproto2.field(2, betterproto2.TYPE_STRING)
    registers: "list[Register]" = betterproto2.field(3, betterproto2.TYPE_MESSAGE, repeated=True)
    backtrace_note: "list[str]" = betterproto2.field(7, betterproto2.TYPE_STRING, repeated=True)
    unreadable_elf_files: "list[str]" = betterproto2.field(9, betterproto2.TYPE_STRING, repeated=True)
    current_backtrace: "list[BacktraceFrame]" = betterproto2.field(4, betterproto2.TYPE_MESSAGE, repeated=True)
    memory_dump: "list[MemoryDump]" = betterproto2.field(5, betterproto2.TYPE_MESSAGE, repeated=True)
    tagged_addr_ctrl: "int" = betterproto2.field(6, betterproto2.TYPE_INT64)
    pac_enabled_keys: "int" = betterproto2.field(8, betterproto2.TYPE_INT64)


@dataclass(eq=False, repr=False)
class BacktraceFrame(betterproto2.Message):
    rel_pc: "int" = betterproto2.field(1, betterproto2.TYPE_UINT64)
    pc: "int" = betterproto2.field(2, betterproto2.TYPE_UINT64)
    sp: "int" = betterproto2.field(3, betterproto2.TYPE_UINT64)
    function_name: "str" = betterproto2.field(4, betterproto2.TYPE_STRING)
    function_offset: "int" = betterproto2.field(5, betterproto2.TYPE_UINT64)
    file_name: "str" = betterproto2.field(6, betterproto2.TYPE_STRING)
    file_map_offset: "int" = betterproto2.field(7, betterproto2.TYPE_UINT64)
    build_id: "str" = betterproto2.field(8, betterproto2.TYPE_STRING)


@dataclass(eq=False, repr=False)
class ArmMTEMetadata(betterproto2.Message):
    # One memory tag per granule (e.g. every 16 bytes) of regular memory.
    memory_tags: "bytes" = betterproto2.field(1, betterproto2.TYPE_BYTES)


@dataclass(eq=False, repr=False)
class MemoryDump(betterproto2.Message):
    register_name: "str" = betterproto2.field(1, betterproto2.TYPE_STRING)
    mapping_name: "str" = betterproto2.field(2, betterproto2.TYPE_STRING)
    begin_address: "int" = betterproto2.field(3, betterproto2.TYPE_UINT64)
    memory: "bytes" = betterproto2.field(4, betterproto2.TYPE_BYTES)
    arm_mte_metadata: "ArmMTEMetadata | None" = betterproto2.field(6, betterproto2.TYPE_MESSAGE, optional=True, group="metadata")


@dataclass(eq=False, repr=False)
class MemoryMapping(betterproto2.Message):
    begin_address: "int" = betterproto2.field(1, betterproto2.TYPE_UINT64)
    end_address: "int" = betterproto2.field(2, betterproto2.TYPE_UINT64)
    offset: "int" = betterproto2.field(3, betterproto2.TYPE_UINT64)
    read: "bool" = betterproto2.field(4, betterproto2.TYPE_BOOL)
    write: "bool" = betterproto2.field(5, betterproto2.TYPE_BOOL)
    execute: "bool" = betterproto2.field(6, betterproto2.TYPE_BOOL)
    mapping_name: "str" = betterproto2.field(7, betterproto2.TYPE_STRING)
    build_id: "str" = betterproto2.field(8, betterproto2.TYPE_STRING)
    load_bias: "int" = betterproto2.field(9, betterproto2.TYPE_UINT64)


@dataclass(eq=False, repr=False)
class FD(betterproto2.Message):
    fd: "int" = betterproto2.field(1, betterproto2.TYPE_INT32)
    path: "str" = betterproto2.field(2, betterproto2.TYPE_STRING)
    owner: "str" = betterproto2.field(3, betterproto2.TYPE_STRING)
    tag: "int" = betterproto2.field(4, betterproto2.TYPE_UINT64)


@dataclass(eq=False, repr=False)
class LogBuffer(betterproto2.Message):
    name: "str" = betterproto2.field(1, betterproto2.TYPE_STRING)
    logs: "list[LogMessage]" = betterproto2.field(2, betterproto2.TYPE_MESSAGE, repeated=True)


@dataclass(eq=False, repr=False)
class LogMessage(betterproto2.Message):
    timestamp: "str" = betterproto2.field(1, betterproto2.TYPE_STRING)
    pid: "int" = betterproto2.field(2, betterproto2.TYPE_UINT32)
    tid: "int" = betterproto2.field(3, betterproto2.TYPE_UINT32)
    priority: "int" = betterproto2.field(4, betterproto2.TYPE_UINT32)
    tag: "str" = betterproto2.field(5, betterproto2.TYPE_STRING)
    message: "str" = betterproto2.field(6, betterproto2.TYPE_STRING)
