21#define DECLARE_REGISTER_INFOS_PPC64LE_STRUCT
44 return "Emulate instructions for the PPC64 architecture.";
63 if (reg_num >= std::size(g_register_infos_ppc64le))
65 return g_register_infos_ppc64le[reg_num];
68std::optional<RegisterInfo>
101 bool success =
false;
150 static const size_t k_num_ppc_opcodes = std::size(g_opcodes);
152 for (
size_t i = 0; i < k_num_ppc_opcodes; ++i) {
153 if ((g_opcodes[i].mask & opcode) == g_opcodes[i].value)
154 return &g_opcodes[i];
160 const uint32_t opcode =
m_opcode.GetOpcode32();
167 const bool auto_advance_pc =
168 evaluate_options & eEmulateInstructionOptionAutoAdvancePC;
170 bool success =
false;
172 uint32_t orig_pc_value = 0;
173 if (auto_advance_pc) {
181 success = (this->*opcode_data->
callback)(opcode);
185 if (auto_advance_pc) {
186 uint32_t new_pc_value =
191 if (new_pc_value == orig_pc_value) {
204 uint32_t rt =
Bits32(opcode, 25, 21);
205 uint32_t spr =
Bits32(opcode, 20, 11);
207 enum { SPR_LR = 0x100 };
224 LLDB_LOG(log,
"EmulateMFSPR: success!");
229 uint32_t rt =
Bits32(opcode, 25, 21);
230 uint32_t
ra =
Bits32(opcode, 20, 16);
231 uint32_t ds =
Bits32(opcode, 15, 2);
233 int32_t ids = llvm::SignExtend32<16>(ds << 2);
241 LLDB_LOG(log,
"EmulateLD: {0:X+8}: ld r{1}, {2}(r{3})",
m_addr, rt, ids,
ra);
243 std::optional<RegisterInfo> r1_info =
254 LLDB_LOG(log,
"EmulateLD: success!");
259 uint32_t rs =
Bits32(opcode, 25, 21);
260 uint32_t
ra =
Bits32(opcode, 20, 16);
261 uint32_t ds =
Bits32(opcode, 15, 2);
262 uint32_t u =
Bits32(opcode, 1, 0);
277 int32_t ids = llvm::SignExtend32<16>(ds << 2);
279 LLDB_LOG(log,
"EmulateSTD: {0:X+8}: std{1} r{2}, {3}(r{4})",
m_addr,
280 u ?
"u" :
"", rs, ids,
ra);
284 uint32_t rs_num = rs;
288 if (!success || lr != rs_val)
294 std::optional<RegisterInfo> rs_info =
322 LLDB_LOG(log,
"EmulateSTD: success!");
327 uint32_t rs =
Bits32(opcode, 25, 21);
328 uint32_t
ra =
Bits32(opcode, 20, 16);
329 uint32_t rb =
Bits32(opcode, 15, 11);
355 LLDB_LOG(log,
"EmulateOR: success!");
360 uint32_t rt =
Bits32(opcode, 25, 21);
361 uint32_t
ra =
Bits32(opcode, 20, 16);
362 uint32_t si =
Bits32(opcode, 15, 0);
370 int32_t si_val = llvm::SignExtend32<16>(si);
372 LLDB_LOG(log,
"EmulateADDI: {0:X+8}: addi r1, r1, {1}",
m_addr, si_val);
375 std::optional<RegisterInfo> r1_info =
391 LLDB_LOG(log,
"EmulateADDI: success!");
static std::optional< RegisterInfo > LLDBTableGetRegisterInfo(uint32_t reg_num)
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
#define LLDB_PLUGIN_DEFINE_ADV(ClassName, PluginName)
An architecture specification class.
llvm::Triple & GetTriple()
Architecture triple accessor.
bool SetTargetTriple(const ArchSpec &arch) override
static EmulateInstruction * CreateInstance(const ArchSpec &arch, InstructionType inst_type)
std::optional< RegisterInfo > GetRegisterInfo(lldb::RegisterKind reg_kind, uint32_t reg_num) override
bool ReadInstruction() override
Opcode * GetOpcodeForInstruction(uint32_t opcode)
static llvm::StringRef GetPluginDescriptionStatic()
bool EvaluateInstruction(uint32_t evaluate_options) override
bool EmulateMFSPR(uint32_t opcode)
bool EmulateLD(uint32_t opcode)
bool CreateFunctionEntryUnwind(UnwindPlan &unwind_plan) override
bool EmulateADDI(uint32_t opcode)
static llvm::StringRef GetPluginNameStatic()
static bool SupportsEmulatingInstructionsOfTypeStatic(InstructionType inst_type)
bool EmulateOR(uint32_t opcode)
bool EmulateSTD(uint32_t opcode)
"lldb/Core/EmulateInstruction.h" A class that allows emulation of CPU opcodes.
@ eContextSetFramePointer
@ eContextWriteRegisterRandomBits
@ eContextAdjustStackPointer
@ eContextRestoreStackPointer
@ eContextPushRegisterOnStack
lldb::ByteOrder GetByteOrder() const
bool WriteRegisterUnsigned(const Context &context, const RegisterInfo ®_info, uint64_t reg_value)
bool WriteMemory(const Context &context, lldb::addr_t addr, const void *src, size_t src_len)
uint64_t ReadMemoryUnsigned(const Context &context, lldb::addr_t addr, size_t byte_size, uint64_t fail_value, bool *success_ptr)
uint64_t ReadRegisterUnsigned(const RegisterInfo ®_info, uint64_t fail_value, bool *success_ptr)
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ABICreateInstance create_callback)
static bool UnregisterPlugin(ABICreateInstance create_callback)
void SetUnwindPlanForSignalTrap(lldb_private::LazyBool is_for_signal_trap)
void SetRegisterKind(lldb::RegisterKind kind)
void SetReturnAddressRegister(uint32_t regnum)
void AppendRow(const RowSP &row_sp)
std::shared_ptr< Row > RowSP
void SetSourcedFromCompiler(lldb_private::LazyBool from_compiler)
void SetSourceName(const char *)
void SetUnwindPlanValidAtAllInstructions(lldb_private::LazyBool valid_at_all_insn)
#define LLDB_REGNUM_GENERIC_RA
#define LLDB_REGNUM_GENERIC_SP
#define LLDB_REGNUM_GENERIC_FLAGS
#define LLDB_INVALID_ADDRESS
#define LLDB_INVALID_REGNUM
#define LLDB_REGNUM_GENERIC_PC
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
InstructionType
Instruction types.
static uint32_t Bits32(const uint32_t bits, const uint32_t msbit, const uint32_t lsbit)
RegisterKind
Register numbering types.
@ eRegisterKindGeneric
insn ptr reg, stack ptr reg, etc not specific to any particular target
@ eRegisterKindLLDB
lldb's internal register numbers
bool(EmulateInstructionPPC64::* callback)(uint32_t opcode)
void SetRegisterToRegisterPlusOffset(RegisterInfo data_reg, RegisterInfo base_reg, int64_t offset)
void SetRegister(RegisterInfo reg)