Skip to content

sparc ¤

Classes:

Attributes:

SPARC_LOAD_INSTRUCTIONS module-attribute ¤

SPARC_LOAD_INSTRUCTIONS = {
    SPARC_INS_LDUB: 1,
    SPARC_INS_LDSB: 1,
    SPARC_INS_LDUH: 2,
    SPARC_INS_LDSH: 2,
    SPARC_INS_LD: 4,
    SPARC_INS_LDD: 8,
}

SPARC_STORE_INSTRUCTIONS module-attribute ¤

SPARC_STORE_INSTRUCTIONS = {
    SPARC_INS_STB: 1,
    SPARC_INS_STH: 2,
    SPARC_INS_ST: 4,
    SPARC_INS_STD: 8,
}

SPARC_CONDITIONAL_BRANCHES module-attribute ¤

SPARC_CONDITIONAL_BRANCHES = {
    SPARC_INS_B,
    SPARC_INS_ALIAS_BE,
    SPARC_INS_ALIAS_BNE,
    SPARC_INS_ALIAS_BNEG,
    SPARC_INS_ALIAS_BPOS,
    SPARC_INS_ALIAS_BVS,
    SPARC_INS_ALIAS_BVC,
    SPARC_INS_ALIAS_BCS,
    SPARC_INS_ALIAS_BCC,
    SPARC_INS_ALIAS_BL,
    SPARC_INS_ALIAS_BLE,
    SPARC_INS_ALIAS_BG,
    SPARC_INS_ALIAS_BGE,
    SPARC_INS_ALIAS_BLEU,
    SPARC_INS_ALIAS_BGU,
}

CCR_C_MASK module-attribute ¤

CCR_C_MASK = 1 << 0

CCR_V_MASK module-attribute ¤

CCR_V_MASK = 1 << 1

CCR_Z_MASK module-attribute ¤

CCR_Z_MASK = 1 << 2

CCR_N_MASK module-attribute ¤

CCR_N_MASK = 1 << 3

ICC_CONDITION_RESOLVERS module-attribute ¤

ICC_CONDITION_RESOLVERS: dict[int, Callable[[int], bool]] = {
    SPARC_CC_ICC_NE: lambda ccr: not ccr & CCR_Z_MASK,
    SPARC_CC_ICC_E: lambda ccr: bool(ccr & CCR_Z_MASK),
    SPARC_CC_ICC_G: lambda ccr: not ccr & CCR_N_MASK ^ ccr & CCR_V_MASK
    and not ccr & CCR_Z_MASK,
    SPARC_CC_ICC_LE: lambda ccr: bool(ccr & CCR_N_MASK ^ ccr & CCR_V_MASK)
    or bool(ccr & CCR_Z_MASK),
    SPARC_CC_ICC_GE: lambda ccr: not ccr & CCR_N_MASK ^ ccr & CCR_V_MASK,
    SPARC_CC_ICC_L: lambda ccr: bool(ccr & CCR_N_MASK ^ ccr & CCR_V_MASK),
    SPARC_CC_ICC_GU: lambda ccr: not ccr & CCR_Z_MASK and not ccr & CCR_C_MASK,
    SPARC_CC_ICC_LEU: lambda ccr: bool(ccr & CCR_Z_MASK)
    or bool(ccr & CCR_C_MASK),
    SPARC_CC_ICC_CC: lambda ccr: not ccr & CCR_C_MASK,
    SPARC_CC_ICC_CS: lambda ccr: bool(ccr & CCR_C_MASK),
    SPARC_CC_ICC_POS: lambda ccr: not ccr & CCR_N_MASK,
    SPARC_CC_ICC_NEG: lambda ccr: bool(ccr & CCR_N_MASK),
    SPARC_CC_ICC_VC: lambda ccr: not ccr & CCR_V_MASK,
    SPARC_CC_ICC_VS: lambda ccr: bool(ccr & CCR_V_MASK),
}

SparcDisassemblyAssistant ¤

SparcDisassemblyAssistant(architecture: PWNDBG_SUPPORTED_ARCHITECTURES_TYPE)

Bases: DisassemblyAssistant

Methods:

  • enhance

    Enhance the instruction - resolving branch targets, conditionals, and adding annotations

  • can_reason_about_process_state

    Determine if the program counter of the process equals the address of the instruction being enhanced.

  • dump

    Debug-only method.

Attributes:

architecture instance-attribute ¤

architecture: PWNDBG_SUPPORTED_ARCHITECTURES_TYPE = architecture

manual_register_values instance-attribute ¤

manual_register_values: PseudoEmulatedRegisterFile = PseudoEmulatedRegisterFile(
    current, ptrsize
)

supports_manual_emulation class-attribute instance-attribute ¤

supports_manual_emulation = False

This feature relies on the Capstone .regs_access() features that not all architectures have reliable support for

op_handlers instance-attribute ¤

op_handlers: dict[
    int, Callable[[PwndbgInstruction, EnhancedOperand, Emulator], int | None]
] = {
    CS_OP_IMM: _parse_immediate,
    CS_OP_REG: _parse_register,
    CS_OP_MEM: _parse_memory,
}

op_names instance-attribute ¤

op_names: dict[
    int, Callable[[PwndbgInstruction, EnhancedOperand], str | None]
] = {
    CS_OP_IMM: _immediate_string,
    CS_OP_REG: _register_string,
    CS_OP_MEM: _memory_string,
}

enhance ¤

enhance(instruction: PwndbgInstruction, emu: Emulator = None) -> None

Enhance the instruction - resolving branch targets, conditionals, and adding annotations

This is the only public method that should be called on this object externally.

can_reason_about_process_state ¤

can_reason_about_process_state(instruction: PwndbgInstruction) -> bool

Determine if the program counter of the process equals the address of the instruction being enhanced. If so, it means we can safely reason and read from registers and memory to enhance values that we can add to the annotation string. This becomes relevent when NOT emulating, and is meant to allow more details when the PC is at the instruction being enhanced

dump ¤

dump(instruction: PwndbgInstruction)

Debug-only method.