9#ifndef LLDB_CORE_EMULATEINSTRUCTION_H
10#define LLDB_CORE_EMULATEINSTRUCTION_H
25#include "llvm/Support/Error.h"
44 std::unique_ptr<EmulateInstruction> emulator_up)
49 virtual llvm::Expected<unsigned>
132 const char *plugin_name);
279 static_assert(std::is_trivial<ContextInfo>::value,
280 "ContextInfo must be trivial.");
286 info.RegisterPlusOffset.reg = base_reg;
287 info.RegisterPlusOffset.signed_offset = signed_offset;
293 info.RegisterPlusIndirectOffset.base_reg = base_reg;
294 info.RegisterPlusIndirectOffset.offset_reg = offset_reg;
301 info.RegisterToRegisterPlusOffset.data_reg = data_reg;
302 info.RegisterToRegisterPlusOffset.base_reg = base_reg;
303 info.RegisterToRegisterPlusOffset.offset = offset;
310 info.RegisterToRegisterPlusIndirectOffset.base_reg = base_reg;
311 info.RegisterToRegisterPlusIndirectOffset.offset_reg = offset_reg;
312 info.RegisterToRegisterPlusIndirectOffset.data_reg = data_reg;
318 info.RegisterRegisterOperands.operand1 = op1_reg;
319 info.RegisterRegisterOperands.operand2 = op2_reg;
324 info.signed_offset = signed_offset;
334 info.unsigned_immediate = immediate;
339 info.signed_immediate = signed_immediate;
344 info.address = address;
348 info.ISAAndImmediate.isa = isa;
349 info.ISAAndImmediate.unsigned_data32 = data;
354 info.ISAAndImmediateSigned.isa = isa;
355 info.ISAAndImmediateSigned.signed_data32 = data;
369 void *baton,
const Context &context,
374 void *baton,
const Context &context,
384 void *baton,
const Context &context,
417 virtual std::optional<RegisterInfo>
427 uint32_t reg_num, std::string ®_name);
433 uint64_t fail_value,
bool *success_ptr);
449 uint64_t fail_value,
bool *success_ptr);
459 size_t byte_size, uint64_t fail_value,
466 uint64_t uval,
size_t uval_byte_size);
480 void *dst,
size_t length);
484 const void *dst,
size_t length);
491 const Context &context,
497 void *dst,
size_t length);
501 const void *dst,
size_t length);
508 const Context &context,
534 static std::unique_ptr<SingleStepBreakpointLocationsPredictor>
536 std::unique_ptr<EmulateInstruction> emulator_up);
539 std::optional<lldb::addr_t>
ReadPC();
544 std::function<std::unique_ptr<SingleStepBreakpointLocationsPredictor>(
545 std::unique_ptr<EmulateInstruction>)>;
559 if (!
m_arch.IsMIPS() && !
m_arch.GetTriple().isPPC64() &&
560 !
m_arch.GetTriple().isLoongArch()) {
562 return [](std::unique_ptr<EmulateInstruction> emulator_up) {
566 return [](std::unique_ptr<EmulateInstruction> emulator_up) {
567 return std::make_unique<SingleStepBreakpointLocationsPredictor>(
568 std::move(emulator_up));
static llvm::raw_ostream & error(Stream &strm)
static bool ReadRegisterCallback(EmulateInstruction *instruction, void *baton, const RegisterInfo *reg_info, RegisterValue ®_value)
static size_t WriteMemoryCallback(EmulateInstruction *instruction, void *baton, const EmulateInstruction::Context &context, lldb::addr_t addr, const void *dst, size_t length)
static size_t ReadMemoryCallback(EmulateInstruction *instruction, void *baton, const EmulateInstruction::Context &context, lldb::addr_t addr, void *dst, size_t length)
static bool WriteRegisterCallback(EmulateInstruction *instruction, void *baton, const EmulateInstruction::Context &context, const RegisterInfo *reg_info, const RegisterValue ®_value)
A section + offset based address class.
An architecture specification class.
"lldb/Core/EmulateInstruction.h" A class that allows emulation of CPU opcodes.
static bool GetBestRegisterKindAndNumber(const RegisterInfo *reg_info, lldb::RegisterKind ®_kind, uint32_t ®_num)
static bool WriteRegisterDefault(EmulateInstruction *instruction, void *baton, const Context &context, const RegisterInfo *reg_info, const RegisterValue ®_value)
static size_t WriteMemoryFrame(EmulateInstruction *instruction, void *baton, const Context &context, lldb::addr_t addr, const void *dst, size_t length)
const EmulateInstruction & operator=(const EmulateInstruction &)=delete
@ eContextRelativeBranchImmediate
@ eContextSetFramePointer
@ eContextAdjustBaseRegister
@ eContextWriteMemoryRandomBits
@ eContextTableBranchReadMemory
@ eContextWriteRegisterRandomBits
@ eContextAdjustStackPointer
@ eContextRestoreStackPointer
@ eContextReturnFromException
@ eContextPushRegisterOnStack
@ eContextPopRegisterOffStack
@ eContextAbsoluteBranchRegister
@ eContextRegisterPlusOffset
@ eInfoTypeRegisterPlusOffset
@ eInfoTypeRegisterRegisterOperands
@ eInfoTypeImmediateSigned
@ eInfoTypeISAAndImmediate
@ eInfoTypeRegisterToRegisterPlusOffset
@ eInfoTypeRegisterToRegisterPlusIndirectOffset
@ eInfoTypeRegisterPlusIndirectOffset
@ eInfoTypeISAAndImmediateSigned
WriteMemoryCallback m_write_mem_callback
lldb::ByteOrder GetByteOrder() const
void SetWriteRegCallback(WriteRegisterCallback write_reg_callback)
virtual bool TestEmulation(Stream &out_stream, ArchSpec &arch, OptionValueDictionary *test_data)=0
bool(* WriteRegisterCallback)(EmulateInstruction *instruction, void *baton, const Context &context, const RegisterInfo *reg_info, const RegisterValue ®_value)
lldb::addr_t GetAddress() const
void SetCallbacks(ReadMemoryCallback read_mem_callback, WriteMemoryCallback write_mem_callback, ReadRegisterCallback read_reg_callback, WriteRegisterCallback write_reg_callback)
static bool ReadRegisterDefault(EmulateInstruction *instruction, void *baton, const RegisterInfo *reg_info, RegisterValue ®_value)
std::optional< lldb::addr_t > ReadPC()
virtual bool CreateFunctionEntryUnwind(UnwindPlan &unwind_plan)
const ArchSpec & GetArchitecture() const
EmulateInstruction(const EmulateInstruction &)=delete
bool WriteMemoryUnsigned(const Context &context, lldb::addr_t addr, uint64_t uval, size_t uval_byte_size)
~EmulateInstruction() override=default
virtual bool SupportsEmulatingInstructionsOfType(InstructionType inst_type)=0
const Opcode & GetOpcode() const
virtual InstructionCondition GetInstructionCondition()
virtual bool EvaluateInstruction(uint32_t evaluate_options)=0
static uint32_t GetInternalRegisterNumber(RegisterContext *reg_ctx, const RegisterInfo ®_info)
void SetReadRegCallback(ReadRegisterCallback read_reg_callback)
std::function< std::unique_ptr< SingleStepBreakpointLocationsPredictor >( std::unique_ptr< EmulateInstruction >)> BreakpointLocationsPredictorCreator
static const InstructionCondition UnconditionalCondition
size_t ReadMemory(const Context &context, lldb::addr_t addr, void *dst, size_t dst_len)
std::optional< RegisterValue > ReadRegister(const RegisterInfo ®_info)
ReadRegisterCallback m_read_reg_callback
size_t(* WriteMemoryCallback)(EmulateInstruction *instruction, void *baton, const Context &context, lldb::addr_t addr, const void *dst, size_t length)
static size_t ReadMemoryFrame(EmulateInstruction *instruction, void *baton, const Context &context, lldb::addr_t addr, void *dst, size_t length)
bool WriteRegister(const Context &context, const RegisterInfo &ref_info, const RegisterValue ®_value)
bool WriteRegisterUnsigned(const Context &context, const RegisterInfo ®_info, uint64_t reg_value)
virtual bool SetTargetTriple(const ArchSpec &arch)=0
bool WriteMemory(const Context &context, lldb::addr_t addr, const void *src, size_t src_len)
virtual std::optional< uint32_t > GetLastInstrSize()
bool WritePC(lldb::addr_t addr)
uint64_t ReadMemoryUnsigned(const Context &context, lldb::addr_t addr, size_t byte_size, uint64_t fail_value, bool *success_ptr)
WriteRegisterCallback m_write_reg_callback
static std::unique_ptr< SingleStepBreakpointLocationsPredictor > CreateBreakpointLocationPredictor(std::unique_ptr< EmulateInstruction > emulator_up)
EmulateInstruction(const ArchSpec &arch)
static size_t WriteMemoryDefault(EmulateInstruction *instruction, void *baton, const Context &context, lldb::addr_t addr, const void *dst, size_t length)
size_t(* ReadMemoryCallback)(EmulateInstruction *instruction, void *baton, const Context &context, lldb::addr_t addr, void *dst, size_t length)
void SetReadMemCallback(ReadMemoryCallback read_mem_callback)
static bool WriteRegisterFrame(EmulateInstruction *instruction, void *baton, const Context &context, const RegisterInfo *reg_info, const RegisterValue ®_value)
uint32_t GetAddressByteSize() const
static const char * TranslateRegister(lldb::RegisterKind reg_kind, uint32_t reg_num, std::string ®_name)
ReadMemoryCallback m_read_mem_callback
static bool ReadRegisterFrame(EmulateInstruction *instruction, void *baton, const RegisterInfo *reg_info, RegisterValue ®_value)
bool(* ReadRegisterCallback)(EmulateInstruction *instruction, void *baton, const RegisterInfo *reg_info, RegisterValue ®_value)
virtual std::optional< RegisterInfo > GetRegisterInfo(lldb::RegisterKind reg_kind, uint32_t reg_num)=0
void SetBaton(void *baton)
static size_t ReadMemoryDefault(EmulateInstruction *instruction, void *baton, const Context &context, lldb::addr_t addr, void *dst, size_t length)
virtual bool SetInstruction(const Opcode &insn_opcode, const Address &inst_addr, Target *target)
static EmulateInstruction * FindPlugin(const ArchSpec &arch, InstructionType supported_inst_type, const char *plugin_name)
virtual BreakpointLocationsPredictorCreator GetSingleStepBreakpointLocationsPredictorCreator()
virtual bool ReadInstruction()=0
uint64_t ReadRegisterUnsigned(const RegisterInfo ®_info, uint64_t fail_value, bool *success_ptr)
uint32_t InstructionCondition
void SetWriteMemCallback(WriteMemoryCallback write_mem_callback)
PluginInterface()=default
virtual llvm::Expected< unsigned > GetBreakpointSize(lldb::addr_t bp_addr)
std::unique_ptr< EmulateInstruction > m_emulator_up
lldb::addr_t GetNextInstructionAddress(Status &error)
SingleStepBreakpointLocationsPredictor(std::unique_ptr< EmulateInstruction > emulator_up)
virtual BreakpointLocations GetBreakpointLocations(Status &status)
virtual ~SingleStepBreakpointLocationsPredictor()=default
lldb::addr_t GetBreakpointLocationAddress(lldb::addr_t entry_pc, Status &error)
A stream class that can stream formatted output to a file.
#define LLDB_INVALID_ADDRESS
A class that represents a running process on the host machine.
InstructionType
Instruction types.
std::vector< lldb::addr_t > BreakpointLocations
ByteOrder
Byte ordering definitions.
RegisterKind
Register numbering types.
void SetISA(uint32_t isa)
void SetRegisterRegisterOperands(RegisterInfo op1_reg, RegisterInfo op2_reg)
void Dump(Stream &s, EmulateInstruction *instruction) const
void SetISAAndImmediate(uint32_t isa, uint32_t data)
void SetImmediate(uint64_t immediate)
void SetISAAndImmediateSigned(uint32_t isa, int32_t data)
void SetRegisterPlusOffset(RegisterInfo base_reg, int64_t signed_offset)
union lldb_private::EmulateInstruction::Context::ContextInfo info
enum InfoType GetInfoType() const
void SetImmediateSigned(int64_t signed_immediate)
void SetRegisterToRegisterPlusIndirectOffset(RegisterInfo base_reg, RegisterInfo offset_reg, RegisterInfo data_reg)
void SetOffset(int64_t signed_offset)
void SetRegisterToRegisterPlusOffset(RegisterInfo data_reg, RegisterInfo base_reg, int64_t offset)
void SetAddress(lldb::addr_t address)
void SetRegister(RegisterInfo reg)
void SetRegisterPlusIndirectOffset(RegisterInfo base_reg, RegisterInfo offset_reg)
Every register is described in detail including its name, alternate name (optional),...
struct lldb_private::EmulateInstruction::Context::ContextInfo::ISAAndImmediateSigned ISAAndImmediateSigned
struct lldb_private::EmulateInstruction::Context::ContextInfo::RegisterRegisterOperands RegisterRegisterOperands
struct lldb_private::EmulateInstruction::Context::ContextInfo::RegisterPlusOffset RegisterPlusOffset
struct lldb_private::EmulateInstruction::Context::ContextInfo::RegisterPlusIndirectOffset RegisterPlusIndirectOffset
uint64_t unsigned_immediate
struct lldb_private::EmulateInstruction::Context::ContextInfo::RegisterToRegisterPlusIndirectOffset RegisterToRegisterPlusIndirectOffset
struct lldb_private::EmulateInstruction::Context::ContextInfo::RegisterToRegisterPlusOffset RegisterToRegisterPlusOffset
struct lldb_private::EmulateInstruction::Context::ContextInfo::ISAAndImmediate ISAAndImmediate