LLDB mainline
Classes | Functions
x86 Namespace Reference

Classes

struct  InstructionOpcodeAndModrm
 These are the three values deciding instruction control flow kind. More...
 

Functions

lldb::InstructionControlFlowKind MapOpcodeIntoControlFlowKind (InstructionOpcodeAndModrm opcode_and_modrm)
 Determine the InstructionControlFlowKind based on opcode and modrm bytes.
 
std::optional< InstructionOpcodeAndModrmInstructionLengthDecode (const uint8_t *inst_bytes, int bytes_len, bool is_exec_mode_64b)
 Decode an instruction into opcode, modrm and opcode_len.
 
lldb::InstructionControlFlowKind GetControlFlowKind (bool is_exec_mode_64b, Opcode m_opcode)
 

Function Documentation

◆ GetControlFlowKind()

lldb::InstructionControlFlowKind x86::GetControlFlowKind ( bool  is_exec_mode_64b,
Opcode  m_opcode 
)

◆ InstructionLengthDecode()

std::optional< InstructionOpcodeAndModrm > x86::InstructionLengthDecode ( const uint8_t *  inst_bytes,
int  bytes_len,
bool  is_exec_mode_64b 
)

Decode an instruction into opcode, modrm and opcode_len.

Refer to http://ref.x86asm.net/coder.html for the instruction bytes layout. Opcodes in x86 are generally the first byte of instruction, though two-byte instructions and prefixes exist. ModR/M is the byte following the opcode and adds additional information for how the instruction is executed.

Parameters
[in]inst_bytesRaw bytes of the instruction
[in]bytes_lenThe length of the inst_bytes array.
[in]is_exec_mode_64bIf true, the execution mode is 64 bit.
Returns
Returns decoded instruction as struct InstructionOpcodeAndModrm, holding primary_opcode, opcode_len and modrm byte. Refer to the struct definition for more details. Otherwise if the given instruction is invalid, returns std::nullopt.

Definition at line 263 of file DisassemblerLLVMC.cpp.

References x86::InstructionOpcodeAndModrm::modrm, x86::InstructionOpcodeAndModrm::opcode_len, and x86::InstructionOpcodeAndModrm::primary_opcode.

Referenced by GetControlFlowKind().

◆ MapOpcodeIntoControlFlowKind()

lldb::InstructionControlFlowKind x86::MapOpcodeIntoControlFlowKind ( InstructionOpcodeAndModrm  opcode_and_modrm)

Determine the InstructionControlFlowKind based on opcode and modrm bytes.

Refer to http://ref.x86asm.net/coder.html for the full list of opcode and instruction set.

Parameters
[in]opcode_and_modrmContains primary_opcode byte, its length, and ModR/M byte. Refer to the struct InstructionOpcodeAndModrm for details.
Returns
The control flow kind of the instruction or eInstructionControlFlowKindOther if the instruction doesn't affect the control flow of the program.

Definition at line 130 of file DisassemblerLLVMC.cpp.

References lldb::eInstructionControlFlowKindCall, lldb::eInstructionControlFlowKindCondJump, lldb::eInstructionControlFlowKindFarCall, lldb::eInstructionControlFlowKindFarJump, lldb::eInstructionControlFlowKindFarReturn, lldb::eInstructionControlFlowKindJump, lldb::eInstructionControlFlowKindOther, lldb::eInstructionControlFlowKindReturn, x86::InstructionOpcodeAndModrm::modrm, x86::InstructionOpcodeAndModrm::opcode_len, and x86::InstructionOpcodeAndModrm::primary_opcode.

Referenced by GetControlFlowKind().