15#include <unordered_map>
27 std::unordered_map<uint32_t, RegisterValue> m_register_values;
31 : m_process(process), m_reg_context(reg_context) {}
39 EmulatorBaton *emulator_baton =
static_cast<EmulatorBaton *
>(baton);
42 emulator_baton->m_process.ReadMemory(addr, dst, length, bytes_read);
49 EmulatorBaton *emulator_baton =
static_cast<EmulatorBaton *
>(baton);
51 auto it = emulator_baton->m_register_values.find(
53 if (it != emulator_baton->m_register_values.end()) {
54 reg_value = it->second;
62 emulator_baton->m_reg_context.GetRegisterInfo(
66 emulator_baton->m_reg_context.ReadRegister(full_reg_info, reg_value);
77 EmulatorBaton *emulator_baton =
static_cast<EmulatorBaton *
>(baton);
100 if (next_flags & 0x20)
121 if (
error.GetError() == EIO ||
error.GetError() == EFAULT)
136 std::unique_ptr<EmulateInstruction> emulator_up(
140 if (emulator_up ==
nullptr)
141 return Status(
"Instruction emulator not found!");
143 EmulatorBaton baton(process, register_context);
144 emulator_up->SetBaton(&baton);
150 if (!emulator_up->ReadInstruction()) {
152 auto instr_size = emulator_up->GetLastInstrSize();
154 return Status(
"Read instruction failed!");
155 bool success =
false;
160 return Status(
"Reading pc failed!");
168 bool emulation_result =
169 emulator_up->EvaluateInstruction(eEmulateInstructionOptionAutoAdvancePC);
178 auto flags_it = reg_info_flags ==
nullptr
179 ? baton.m_register_values.end()
180 : baton.m_register_values.find(
185 if (emulation_result) {
186 assert(pc_it != baton.m_register_values.end() &&
187 "Emulation was successfull but PC wasn't updated");
188 next_pc = pc_it->second.GetAsUInt64();
190 if (flags_it != baton.m_register_values.end())
191 next_flags = flags_it->second.GetAsUInt64();
193 next_flags =
ReadFlags(register_context);
194 }
else if (pc_it == baton.m_register_values.end()) {
199 next_pc = register_context.
GetPC() + emulator_up->GetOpcode().GetByteSize();
200 next_flags =
ReadFlags(register_context);
205 return Status(
"Instruction emulation failed unexpectedly.");
static llvm::raw_ostream & error(Stream &strm)
static bool ReadRegisterCallback(EmulateInstruction *instruction, void *baton, const RegisterInfo *reg_info, RegisterValue ®_value)
static int GetSoftwareBreakpointSize(const ArchSpec &arch, lldb::addr_t next_flags)
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 Status SetSoftwareBreakpointOnPC(const ArchSpec &arch, lldb::addr_t pc, lldb::addr_t next_flags, NativeProcessProtocol &process)
static bool WriteRegisterCallback(EmulateInstruction *instruction, void *baton, const EmulateInstruction::Context &context, const RegisterInfo *reg_info, const RegisterValue ®_value)
static lldb::addr_t ReadFlags(NativeRegisterContext ®siter_context)
An architecture specification class.
llvm::Triple & GetTriple()
Architecture triple accessor.
bool IsMIPS() const
if MIPS architecture return true.
llvm::Triple::ArchType GetMachine() const
Returns a machine family for the current architecture.
"lldb/Core/EmulateInstruction.h" A class that allows emulation of CPU opcodes.
static EmulateInstruction * FindPlugin(const ArchSpec &arch, InstructionType supported_inst_type, const char *plugin_name)
virtual Status SetBreakpoint(lldb::addr_t addr, uint32_t size, bool hardware)=0
virtual const ArchSpec & GetArchitecture() const =0
Status SetupSoftwareSingleStepping(NativeThreadProtocol &thread)
std::map< lldb::tid_t, lldb::addr_t > m_threads_stepping_with_breakpoint
lldb::addr_t ReadRegisterAsUnsigned(uint32_t reg, lldb::addr_t fail_value)
const RegisterInfo * GetRegisterInfo(uint32_t reg_kind, uint32_t reg_num)
lldb::addr_t GetPC(lldb::addr_t fail_value=LLDB_INVALID_ADDRESS)
NativeProcessProtocol & GetProcess()
virtual NativeRegisterContext & GetRegisterContext()=0
lldb::tid_t GetID() const
#define LLDB_REGNUM_GENERIC_FLAGS
#define LLDB_INVALID_ADDRESS
#define LLDB_REGNUM_GENERIC_PC
A class that represents a running process on the host machine.
@ eInstructionTypePCModifying
@ eRegisterKindGeneric
insn ptr reg, stack ptr reg, etc not specific to any particular target
@ eRegisterKindDWARF
the register numbers seen DWARF
Every register is described in detail including its name, alternate name (optional),...
uint32_t kinds[lldb::kNumRegisterKinds]
Holds all of the various register numbers for all register kinds.