//! GhostScope Protocol Library
//!
//! Provides types and functionality for the GhostScope tracing protocol.

// Core modules
pub mod bpf_abi;
mod type_kind;

pub mod format_printer;
pub mod streaming_parser;
pub mod trace_context;
pub mod trace_event;
pub mod type_info;

pub use type_kind::{consts, TypeKind};

pub use trace_event::{
    EndInstructionData, ExprErrorData, InstructionHeader, InstructionType,
    PrintComplexFormatArgPrefix, PrintStringIndexData, PrintVariableIndexData, TraceEventHeader,
    TraceEventMessage, VariableReadErrorPayload, VariableStatus, END_INSTRUCTION_DATA_OFFSET,
    END_INSTRUCTION_EXECUTION_STATUS_OFFSET, END_INSTRUCTION_TOTAL_INSTRUCTIONS_OFFSET,
    EXPR_ERROR_DATA_ERROR_CODE_OFFSET, EXPR_ERROR_DATA_FAILING_ADDR_OFFSET,
    EXPR_ERROR_DATA_FLAGS_OFFSET, EXPR_ERROR_DATA_SIZE, EXPR_ERROR_DATA_STRING_INDEX_OFFSET,
    INSTRUCTION_HEADER_DATA_LENGTH_OFFSET, INSTRUCTION_HEADER_INST_TYPE_OFFSET,
    INSTRUCTION_HEADER_RESERVED_OFFSET, INSTRUCTION_HEADER_SIZE,
    PRINT_COMPLEX_FORMAT_ARG_ACCESS_PATH_LEN_OFFSET, PRINT_COMPLEX_FORMAT_ARG_ACCESS_PATH_OFFSET,
    PRINT_COMPLEX_FORMAT_ARG_DATA_LEN_SIZE, PRINT_COMPLEX_FORMAT_ARG_FIXED_HEADER_LEN,
    PRINT_COMPLEX_FORMAT_ARG_STATUS_OFFSET, PRINT_COMPLEX_FORMAT_ARG_TYPE_INDEX_OFFSET,
    PRINT_COMPLEX_FORMAT_ARG_VAR_NAME_INDEX_OFFSET, PRINT_COMPLEX_FORMAT_DATA_ARG_COUNT_OFFSET,
    TRACE_EVENT_HEADER_MAGIC_OFFSET, TRACE_EVENT_HEADER_SIZE, TRACE_EVENT_MESSAGE_PID_OFFSET,
    TRACE_EVENT_MESSAGE_SIZE, TRACE_EVENT_MESSAGE_TID_OFFSET, TRACE_EVENT_MESSAGE_TIMESTAMP_OFFSET,
    TRACE_EVENT_MESSAGE_TRACE_ID_OFFSET, VARIABLE_READ_ERROR_PAYLOAD_ADDR_OFFSET,
    VARIABLE_READ_ERROR_PAYLOAD_ERRNO_OFFSET, VARIABLE_READ_ERROR_PAYLOAD_LEN,
};

pub use bpf_abi::{
    backtrace_unwind_row_from_words, backtrace_unwind_row_register_word, backtrace_unwind_row_word,
    BacktraceModuleRowRange, BacktraceTailCallState, BacktraceUnwindRow, PidAliasValue,
    ProcModuleKey, ProcModuleOffsetsValue, ProcModuleRangeKey, ProcModuleRangeMeta,
    ProcModuleRangeValue, BACKTRACE_MODULE_ROW_RANGE_ROW_END_OFFSET,
    BACKTRACE_MODULE_ROW_RANGE_ROW_START_OFFSET, BACKTRACE_MODULE_ROW_RANGE_SIZE,
    BACKTRACE_RA_AT_CFA_OFFSET, BACKTRACE_RA_REGISTER, BACKTRACE_RA_SAME_VALUE,
    BACKTRACE_RA_UNDEFINED, BACKTRACE_RA_VAL_CFA_OFFSET, BACKTRACE_RECOVERY_AT_CFA_OFFSET,
    BACKTRACE_RECOVERY_REGISTER, BACKTRACE_RECOVERY_SAME_VALUE, BACKTRACE_RECOVERY_UNDEFINED,
    BACKTRACE_RECOVERY_VAL_CFA_OFFSET, BACKTRACE_TAIL_NO_NEXT_SLOT,
    BACKTRACE_TAIL_STATE_ACTIVE_SLOT_OFFSET, BACKTRACE_TAIL_STATE_CURRENT_IP_OFFSET,
    BACKTRACE_TAIL_STATE_CURRENT_RBP_OFFSET, BACKTRACE_TAIL_STATE_CURRENT_RSP_OFFSET,
    BACKTRACE_TAIL_STATE_ERROR_CODE_OFFSET, BACKTRACE_TAIL_STATE_EVENT_SIZE_OFFSET,
    BACKTRACE_TAIL_STATE_FLAGS_OFFSET, BACKTRACE_TAIL_STATE_FRAME_COUNT_OFFSET,
    BACKTRACE_TAIL_STATE_INST_OFFSET_OFFSET, BACKTRACE_TAIL_STATE_MODULE_BIAS_OFFSET,
    BACKTRACE_TAIL_STATE_MODULE_COOKIE_OFFSET, BACKTRACE_TAIL_STATE_NEXT_SLOT_OFFSET,
    BACKTRACE_TAIL_STATE_OFFSETS_FOUND_OFFSET, BACKTRACE_TAIL_STATE_REQUESTED_DEPTH_OFFSET,
    BACKTRACE_TAIL_STATE_SIZE, BACKTRACE_TAIL_STATE_TAIL_CALLS_OFFSET,
    BACKTRACE_UNWIND_ROW_CFA_OFFSET_OFFSET, BACKTRACE_UNWIND_ROW_CFA_REGISTER_OFFSET,
    BACKTRACE_UNWIND_ROW_PC_END_OFFSET, BACKTRACE_UNWIND_ROW_PC_START_OFFSET,
    BACKTRACE_UNWIND_ROW_RA_KIND_OFFSET, BACKTRACE_UNWIND_ROW_RA_OFFSET_OFFSET,
    BACKTRACE_UNWIND_ROW_RA_REGISTER_OFFSET, BACKTRACE_UNWIND_ROW_RBP_KIND_OFFSET,
    BACKTRACE_UNWIND_ROW_RBP_OFFSET_OFFSET, BACKTRACE_UNWIND_ROW_RBP_REGISTER_OFFSET,
    BACKTRACE_UNWIND_ROW_SIZE, BACKTRACE_UNWIND_WORDS_PER_ROW, BACKTRACE_UNWIND_WORD_CFA_OFFSET,
    BACKTRACE_UNWIND_WORD_PC_END, BACKTRACE_UNWIND_WORD_PC_START, BACKTRACE_UNWIND_WORD_RA_OFFSET,
    BACKTRACE_UNWIND_WORD_RBP_OFFSET, BACKTRACE_UNWIND_WORD_REGISTERS,
    PID_ALIAS_VALUE_PROC_PID_OFFSET, PID_ALIAS_VALUE_SIZE, PROC_MODULE_KEY_COOKIE_HI_OFFSET,
    PROC_MODULE_KEY_COOKIE_LO_OFFSET, PROC_MODULE_KEY_PAD_OFFSET, PROC_MODULE_KEY_PID_OFFSET,
    PROC_MODULE_KEY_SIZE, PROC_MODULE_OFFSETS_VALUE_BASE_OFFSET,
    PROC_MODULE_OFFSETS_VALUE_BSS_OFFSET, PROC_MODULE_OFFSETS_VALUE_DATA_OFFSET,
    PROC_MODULE_OFFSETS_VALUE_RODATA_OFFSET, PROC_MODULE_OFFSETS_VALUE_SIZE,
    PROC_MODULE_OFFSETS_VALUE_SIZE_OFFSET, PROC_MODULE_OFFSETS_VALUE_TEXT_OFFSET,
    PROC_MODULE_RANGE_KEY_INDEX_OFFSET, PROC_MODULE_RANGE_KEY_PAD_OFFSET,
    PROC_MODULE_RANGE_KEY_PID_OFFSET, PROC_MODULE_RANGE_KEY_SIZE,
    PROC_MODULE_RANGE_KEY_SLOT_OFFSET, PROC_MODULE_RANGE_META_ACTIVE_SLOT_OFFSET,
    PROC_MODULE_RANGE_META_COUNT_OFFSET, PROC_MODULE_RANGE_META_SIZE,
    PROC_MODULE_RANGE_VALUE_BASE_OFFSET, PROC_MODULE_RANGE_VALUE_COOKIE_HI_OFFSET,
    PROC_MODULE_RANGE_VALUE_COOKIE_LO_OFFSET, PROC_MODULE_RANGE_VALUE_END_OFFSET,
    PROC_MODULE_RANGE_VALUE_SIZE, PROC_MODULE_RANGE_VALUE_TEXT_OFFSET,
};

pub use trace_context::TraceContext;

pub use format_printer::FormatPrinter;

pub use streaming_parser::{
    EventSource, ParseState, ParsedBacktraceFrame, ParsedInstruction, ParsedTraceEvent,
    StreamingTraceParser,
};

pub use type_info::{EnumVariant, StructMember, TypeCache, TypeInfo, TypeQualifier};

pub use ghostscope_platform as platform;
