LLDB  mainline
EmulateInstruction.h
Go to the documentation of this file.
1 //===-- EmulateInstruction.h ------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLDB_CORE_EMULATEINSTRUCTION_H
10 #define LLDB_CORE_EMULATEINSTRUCTION_H
11 
12 #include <string>
13 
14 #include "lldb/Core/Address.h"
15 #include "lldb/Core/Opcode.h"
17 #include "lldb/Utility/ArchSpec.h"
18 #include "lldb/lldb-defines.h"
19 #include "lldb/lldb-enumerations.h"
22 #include "lldb/lldb-types.h"
23 
24 #include <cstddef>
25 #include <cstdint>
26 
27 namespace lldb_private {
28 class OptionValueDictionary;
29 class RegisterContext;
30 class RegisterValue;
31 class Stream;
32 class Target;
33 class UnwindPlan;
34 
35 /// \class EmulateInstruction EmulateInstruction.h
36 /// "lldb/Core/EmulateInstruction.h"
37 /// A class that allows emulation of CPU opcodes.
38 ///
39 /// This class is a plug-in interface that is accessed through the standard
40 /// static FindPlugin function call in the EmulateInstruction class. The
41 /// FindPlugin takes a target triple and returns a new object if there is a
42 /// plug-in that supports the architecture and OS. Four callbacks and a baton
43 /// are provided. The four callbacks are read register, write register, read
44 /// memory and write memory.
45 ///
46 /// This class is currently designed for these main use cases: - Auto
47 /// generation of Call Frame Information (CFI) from assembly code - Predicting
48 /// single step breakpoint locations - Emulating instructions for breakpoint
49 /// traps
50 ///
51 /// Objects can be asked to read an instruction which will cause a call to the
52 /// read register callback to get the PC, followed by a read memory call to
53 /// read the opcode. If ReadInstruction () returns true, then a call to
54 /// EmulateInstruction::EvaluateInstruction () can be made. At this point the
55 /// EmulateInstruction subclass will use all of the callbacks to emulate an
56 /// instruction.
57 ///
58 /// Clients that provide the callbacks can either do the read/write
59 /// registers/memory to actually emulate the instruction on a real or virtual
60 /// CPU, or watch for the EmulateInstruction::Context which is context for the
61 /// read/write register/memory which explains why the callback is being
62 /// called. Examples of a context are: "pushing register 3 onto the stack at
63 /// offset -12", or "adjusting stack pointer by -16". This extra context
64 /// allows the generation of
65 /// CFI information from assembly code without having to actually do
66 /// the read/write register/memory.
67 ///
68 /// Clients must be prepared that not all instructions for an Instruction Set
69 /// Architecture (ISA) will be emulated.
70 ///
71 /// Subclasses at the very least should implement the instructions that save
72 /// and restore registers onto the stack and adjustment to the stack pointer.
73 /// By just implementing a few instructions for an ISA that are the typical
74 /// prologue opcodes, you can then generate CFI using a class that will soon
75 /// be available.
76 ///
77 /// Implementing all of the instructions that affect the PC can then allow
78 /// single step prediction support.
79 ///
80 /// Implementing all of the instructions allows for emulation of opcodes for
81 /// breakpoint traps and will pave the way for "thread centric" debugging. The
82 /// current debugging model is "process centric" where all threads must be
83 /// stopped when any thread is stopped; when hitting software breakpoints we
84 /// must disable the breakpoint by restoring the original breakpoint opcode,
85 /// single stepping and restoring the breakpoint trap. If all threads were
86 /// allowed to run then other threads could miss the breakpoint.
87 ///
88 /// This class centralizes the code that usually is done in separate code
89 /// paths in a debugger (single step prediction, finding save restore
90 /// locations of registers for unwinding stack frame variables) and emulating
91 /// the instruction is just a bonus.
92 
94 public:
95  static EmulateInstruction *FindPlugin(const ArchSpec &arch,
96  InstructionType supported_inst_type,
97  const char *plugin_name);
98 
99  enum ContextType {
101  // Read an instruction opcode from memory
103 
104  // Usually used for writing a register value whose source value is an
105  // immediate
107 
108  // Exclusively used when saving a register to the stack as part of the
109  // prologue
111 
112  // Exclusively used when restoring a register off the stack as part of the
113  // epilogue
115 
116  // Add or subtract a value from the stack
118 
119  // Adjust the frame pointer for the current frame
121 
122  // Typically in an epilogue sequence. Copy the frame pointer back into the
123  // stack pointer, use SP for CFA calculations again.
125 
126  // Add or subtract a value from a base address register (other than SP)
128 
129  // Add or subtract a value from the PC or store a value to the PC.
131 
132  // Used in WriteRegister callbacks to indicate where the
134 
135  // Used in WriteMemory callback to indicate where the data came from
137 
139 
140  // Used when performing a PC-relative branch where the
142 
143  // Used when performing an absolute branch where the
145 
146  // Used when performing a supervisor call to an operating system to provide
147  // a service:
149 
150  // Used when performing a MemU operation to read the PC-relative offset
151  // from an address.
153 
154  // Used when random bits are written into a register
156 
157  // Used when random bits are written to memory
159 
161 
163 
165  };
166 
167  enum InfoType {
182  } InfoType;
183 
184  struct Context {
187  union {
188  struct RegisterPlusOffset {
189  RegisterInfo reg; // base register
190  int64_t signed_offset; // signed offset added to base register
192 
194  RegisterInfo base_reg; // base register number
195  RegisterInfo offset_reg; // offset register kind
197 
199  RegisterInfo data_reg; // source/target register for data
200  RegisterInfo base_reg; // base register for address calculation
201  int64_t offset; // offset for address calculation
203 
205  RegisterInfo base_reg; // base register for address calculation
206  RegisterInfo offset_reg; // offset register for address calculation
207  RegisterInfo data_reg; // source/target register for data
209 
210  struct RegisterRegisterOperands {
211  RegisterInfo
212  operand1; // register containing first operand for binary op
213  RegisterInfo
214  operand2; // register containing second operand for binary op
216 
217  int64_t signed_offset; // signed offset by which to adjust self (for
218  // registers only)
219 
220  RegisterInfo reg; // plain register
221 
222  uint64_t unsigned_immediate; // unsigned immediate value
223  int64_t signed_immediate; // signed immediate value
224 
225  lldb::addr_t address; // direct address
226 
227  struct ISAAndImmediate {
229  uint32_t unsigned_data32; // immediate data
230  } ISAAndImmediate;
231 
232  struct ISAAndImmediateSigned {
233  uint32_t isa;
234  int32_t signed_data32; // signed immediate data
236 
237  uint32_t isa;
238  } info;
239 
240  Context() = default;
241 
242  void SetRegisterPlusOffset(RegisterInfo base_reg, int64_t signed_offset) {
244  info.RegisterPlusOffset.reg = base_reg;
245  info.RegisterPlusOffset.signed_offset = signed_offset;
246  }
247 
249  RegisterInfo offset_reg) {
251  info.RegisterPlusIndirectOffset.base_reg = base_reg;
252  info.RegisterPlusIndirectOffset.offset_reg = offset_reg;
253  }
254 
256  RegisterInfo base_reg,
257  int64_t offset) {
259  info.RegisterToRegisterPlusOffset.data_reg = data_reg;
260  info.RegisterToRegisterPlusOffset.base_reg = base_reg;
261  info.RegisterToRegisterPlusOffset.offset = offset;
262  }
263 
265  RegisterInfo offset_reg,
266  RegisterInfo data_reg) {
268  info.RegisterToRegisterPlusIndirectOffset.base_reg = base_reg;
269  info.RegisterToRegisterPlusIndirectOffset.offset_reg = offset_reg;
270  info.RegisterToRegisterPlusIndirectOffset.data_reg = data_reg;
271  }
272 
273  void SetRegisterRegisterOperands(RegisterInfo op1_reg,
274  RegisterInfo op2_reg) {
276  info.RegisterRegisterOperands.operand1 = op1_reg;
277  info.RegisterRegisterOperands.operand2 = op2_reg;
278  }
279 
280  void SetOffset(int64_t signed_offset) {
282  info.signed_offset = signed_offset;
283  }
284 
285  void SetRegister(RegisterInfo reg) {
287  info.reg = reg;
288  }
289 
290  void SetImmediate(uint64_t immediate) {
292  info.unsigned_immediate = immediate;
293  }
294 
297  info.signed_immediate = signed_immediate;
298  }
299 
302  info.address = address;
303  }
306  info.ISAAndImmediate.isa = isa;
307  info.ISAAndImmediate.unsigned_data32 = data;
308  }
309 
310  void SetISAAndImmediateSigned(uint32_t isa, int32_t data) {
312  info.ISAAndImmediateSigned.isa = isa;
313  info.ISAAndImmediateSigned.signed_data32 = data;
314  }
315 
318  info.isa = isa;
319  }
320 
322 
323  void Dump(Stream &s, EmulateInstruction *instruction) const;
324  };
325 
326  typedef size_t (*ReadMemoryCallback)(EmulateInstruction *instruction,
327  void *baton, const Context &context,
328  lldb::addr_t addr, void *dst,
329  size_t length);
330 
331  typedef size_t (*WriteMemoryCallback)(EmulateInstruction *instruction,
332  void *baton, const Context &context,
333  lldb::addr_t addr, const void *dst,
334  size_t length);
335 
336  typedef bool (*ReadRegisterCallback)(EmulateInstruction *instruction,
337  void *baton,
338  const RegisterInfo *reg_info,
339  RegisterValue &reg_value);
340 
341  typedef bool (*WriteRegisterCallback)(EmulateInstruction *instruction,
342  void *baton, const Context &context,
343  const RegisterInfo *reg_info,
344  const RegisterValue &reg_value);
345 
346  // Type to represent the condition of an instruction. The UINT32 value is
347  // reserved for the unconditional case and all other value can be used in an
348  // architecture dependent way.
351 
352  EmulateInstruction(const ArchSpec &arch);
353 
354  ~EmulateInstruction() override = default;
355 
356  // Mandatory overrides
357  virtual bool
359 
360  virtual bool SetTargetTriple(const ArchSpec &arch) = 0;
361 
362  virtual bool ReadInstruction() = 0;
363 
364  virtual bool EvaluateInstruction(uint32_t evaluate_options) = 0;
365 
367  return UnconditionalCondition;
368  }
369 
370  virtual bool TestEmulation(Stream *out_stream, ArchSpec &arch,
371  OptionValueDictionary *test_data) = 0;
372 
373  virtual bool GetRegisterInfo(lldb::RegisterKind reg_kind, uint32_t reg_num,
374  RegisterInfo &reg_info) = 0;
375 
376  // Optional overrides
377  virtual bool SetInstruction(const Opcode &insn_opcode,
378  const Address &inst_addr, Target *target);
379 
380  virtual bool CreateFunctionEntryUnwind(UnwindPlan &unwind_plan);
381 
382  static const char *TranslateRegister(lldb::RegisterKind reg_kind,
383  uint32_t reg_num, std::string &reg_name);
384 
385  // RegisterInfo variants
386  bool ReadRegister(const RegisterInfo *reg_info, RegisterValue &reg_value);
387 
388  uint64_t ReadRegisterUnsigned(const RegisterInfo *reg_info,
389  uint64_t fail_value, bool *success_ptr);
390 
391  bool WriteRegister(const Context &context, const RegisterInfo *ref_info,
392  const RegisterValue &reg_value);
393 
394  bool WriteRegisterUnsigned(const Context &context,
395  const RegisterInfo *reg_info, uint64_t reg_value);
396 
397  // Register kind and number variants
398  bool ReadRegister(lldb::RegisterKind reg_kind, uint32_t reg_num,
399  RegisterValue &reg_value);
400 
401  bool WriteRegister(const Context &context, lldb::RegisterKind reg_kind,
402  uint32_t reg_num, const RegisterValue &reg_value);
403 
404  uint64_t ReadRegisterUnsigned(lldb::RegisterKind reg_kind, uint32_t reg_num,
405  uint64_t fail_value, bool *success_ptr);
406 
407  bool WriteRegisterUnsigned(const Context &context,
408  lldb::RegisterKind reg_kind, uint32_t reg_num,
409  uint64_t reg_value);
410 
411  size_t ReadMemory(const Context &context, lldb::addr_t addr, void *dst,
412  size_t dst_len);
413 
414  uint64_t ReadMemoryUnsigned(const Context &context, lldb::addr_t addr,
415  size_t byte_size, uint64_t fail_value,
416  bool *success_ptr);
417 
418  bool WriteMemory(const Context &context, lldb::addr_t addr, const void *src,
419  size_t src_len);
420 
421  bool WriteMemoryUnsigned(const Context &context, lldb::addr_t addr,
422  uint64_t uval, size_t uval_byte_size);
423 
425 
427 
428  const Opcode &GetOpcode() const { return m_opcode; }
429 
430  lldb::addr_t GetAddress() const { return m_addr; }
431 
432  const ArchSpec &GetArchitecture() const { return m_arch; }
433 
434  static size_t ReadMemoryFrame(EmulateInstruction *instruction, void *baton,
435  const Context &context, lldb::addr_t addr,
436  void *dst, size_t length);
437 
438  static size_t WriteMemoryFrame(EmulateInstruction *instruction, void *baton,
439  const Context &context, lldb::addr_t addr,
440  const void *dst, size_t length);
441 
442  static bool ReadRegisterFrame(EmulateInstruction *instruction, void *baton,
443  const RegisterInfo *reg_info,
444  RegisterValue &reg_value);
445 
446  static bool WriteRegisterFrame(EmulateInstruction *instruction, void *baton,
447  const Context &context,
448  const RegisterInfo *reg_info,
449  const RegisterValue &reg_value);
450 
451  static size_t ReadMemoryDefault(EmulateInstruction *instruction, void *baton,
452  const Context &context, lldb::addr_t addr,
453  void *dst, size_t length);
454 
455  static size_t WriteMemoryDefault(EmulateInstruction *instruction, void *baton,
456  const Context &context, lldb::addr_t addr,
457  const void *dst, size_t length);
458 
459  static bool ReadRegisterDefault(EmulateInstruction *instruction, void *baton,
460  const RegisterInfo *reg_info,
461  RegisterValue &reg_value);
462 
463  static bool WriteRegisterDefault(EmulateInstruction *instruction, void *baton,
464  const Context &context,
465  const RegisterInfo *reg_info,
466  const RegisterValue &reg_value);
467 
468  void SetBaton(void *baton);
469 
470  void SetCallbacks(ReadMemoryCallback read_mem_callback,
471  WriteMemoryCallback write_mem_callback,
472  ReadRegisterCallback read_reg_callback,
473  WriteRegisterCallback write_reg_callback);
474 
475  void SetReadMemCallback(ReadMemoryCallback read_mem_callback);
476 
477  void SetWriteMemCallback(WriteMemoryCallback write_mem_callback);
478 
479  void SetReadRegCallback(ReadRegisterCallback read_reg_callback);
480 
481  void SetWriteRegCallback(WriteRegisterCallback write_reg_callback);
482 
483  static bool GetBestRegisterKindAndNumber(const RegisterInfo *reg_info,
484  lldb::RegisterKind &reg_kind,
485  uint32_t &reg_num);
486 
488  const RegisterInfo &reg_info);
489 
490 protected:
492  void *m_baton = nullptr;
499 
500 private:
501  // For EmulateInstruction only
502  EmulateInstruction(const EmulateInstruction &) = delete;
503  const EmulateInstruction &operator=(const EmulateInstruction &) = delete;
504 };
505 
506 } // namespace lldb_private
507 
508 #endif // LLDB_CORE_EMULATEINSTRUCTION_H
lldb_private::EmulateInstruction::ContextType
ContextType
Definition: EmulateInstruction.h:99
lldb_private::EmulateInstruction::ReadMemoryDefault
static size_t ReadMemoryDefault(EmulateInstruction *instruction, void *baton, const Context &context, lldb::addr_t addr, void *dst, size_t length)
Definition: EmulateInstruction.cpp:304
lldb_private::ArchSpec::GetByteOrder
lldb::ByteOrder GetByteOrder() const
Returns the byte order for the architecture specification.
Definition: ArchSpec.cpp:730
lldb-private-types.h
lldb_private::EmulateInstruction::ReadMemoryCallback
size_t(* ReadMemoryCallback)(EmulateInstruction *instruction, void *baton, const Context &context, lldb::addr_t addr, void *dst, size_t length)
Definition: EmulateInstruction.h:326
lldb_private::EmulateInstruction::WriteRegisterCallback
bool(* WriteRegisterCallback)(EmulateInstruction *instruction, void *baton, const Context &context, const RegisterInfo *reg_info, const RegisterValue &reg_value)
Definition: EmulateInstruction.h:341
lldb_private::ArchSpec
Definition: ArchSpec.h:33
lldb_private::EmulateInstruction::Context::signed_immediate
int64_t signed_immediate
Definition: EmulateInstruction.h:223
lldb_private::EmulateInstruction::SetTargetTriple
virtual bool SetTargetTriple(const ArchSpec &arch)=0
lldb_private::EmulateInstruction::Context::address
lldb::addr_t address
Definition: EmulateInstruction.h:225
lldb_private::EmulateInstruction::GetOpcode
const Opcode & GetOpcode() const
Definition: EmulateInstruction.h:428
lldb_private::EmulateInstruction::m_read_reg_callback
ReadRegisterCallback m_read_reg_callback
Definition: EmulateInstruction.h:495
lldb_private::EmulateInstruction::SetReadRegCallback
void SetReadRegCallback(ReadRegisterCallback read_reg_callback)
Definition: EmulateInstruction.cpp:233
lldb_private::EmulateInstruction::Context::info
union lldb_private::EmulateInstruction::Context::@7 info
lldb_private::EmulateInstruction::Context::RegisterToRegisterPlusIndirectOffset
struct lldb_private::EmulateInstruction::Context::@7::RegisterToRegisterPlusIndirectOffset RegisterToRegisterPlusIndirectOffset
lldb_private::EmulateInstruction::WriteRegisterFrame
static bool WriteRegisterFrame(EmulateInstruction *instruction, void *baton, const Context &context, const RegisterInfo *reg_info, const RegisterValue &reg_value)
Definition: EmulateInstruction.cpp:293
lldb_private::Opcode
Definition: Opcode.h:29
lldb_private::RegisterValue
Definition: RegisterValue.h:28
lldb_private::EmulateInstruction::eContextRegisterPlusOffset
@ eContextRegisterPlusOffset
Definition: EmulateInstruction.h:133
lldb_private::EmulateInstruction::eInfoTypeRegisterPlusIndirectOffset
@ eInfoTypeRegisterPlusIndirectOffset
Definition: EmulateInstruction.h:169
Opcode.h
lldb_private::EmulateInstruction::GetAddressByteSize
uint32_t GetAddressByteSize() const
Definition: EmulateInstruction.h:424
lldb_private::EmulateInstruction::WriteRegisterDefault
static bool WriteRegisterDefault(EmulateInstruction *instruction, void *baton, const Context &context, const RegisterInfo *reg_info, const RegisterValue &reg_value)
Definition: EmulateInstruction.cpp:349
lldb_private::EmulateInstruction::GetInstructionCondition
virtual InstructionCondition GetInstructionCondition()
Definition: EmulateInstruction.h:366
lldb_private::EmulateInstruction::SupportsEmulatingInstructionsOfType
virtual bool SupportsEmulatingInstructionsOfType(InstructionType inst_type)=0
lldb_private::EmulateInstruction::eInfoTypeAddress
@ eInfoTypeAddress
Definition: EmulateInstruction.h:177
lldb_private::EmulateInstruction::Context::signed_data32
int32_t signed_data32
Definition: EmulateInstruction.h:234
lldb_private::EmulateInstruction::Context::RegisterPlusIndirectOffset
struct lldb_private::EmulateInstruction::Context::@7::RegisterPlusIndirectOffset RegisterPlusIndirectOffset
lldb_private::PluginInterface
Definition: PluginInterface.h:16
lldb_private::EmulateInstruction::Context::base_reg
RegisterInfo base_reg
Definition: EmulateInstruction.h:194
lldb_private::EmulateInstruction::Context::ISAAndImmediate
struct lldb_private::EmulateInstruction::Context::@7::ISAAndImmediate ISAAndImmediate
lldb-defines.h
lldb_private::EmulateInstruction::Context::data_reg
RegisterInfo data_reg
Definition: EmulateInstruction.h:199
lldb_private::EmulateInstruction::eContextAbsoluteBranchRegister
@ eContextAbsoluteBranchRegister
Definition: EmulateInstruction.h:144
lldb_private::EmulateInstruction::Context
Definition: EmulateInstruction.h:184
lldb_private::EmulateInstruction::WriteMemoryDefault
static size_t WriteMemoryDefault(EmulateInstruction *instruction, void *baton, const Context &context, lldb::addr_t addr, const void *dst, size_t length)
Definition: EmulateInstruction.cpp:319
lldb_private::EmulateInstruction::eInfoTypeRegister
@ eInfoTypeRegister
Definition: EmulateInstruction.h:174
lldb_private::EmulateInstruction::CreateFunctionEntryUnwind
virtual bool CreateFunctionEntryUnwind(UnwindPlan &unwind_plan)
Definition: EmulateInstruction.cpp:581
lldb_private::EmulateInstruction::eContextTableBranchReadMemory
@ eContextTableBranchReadMemory
Definition: EmulateInstruction.h:152
lldb_private::EmulateInstruction::TranslateRegister
static const char * TranslateRegister(lldb::RegisterKind reg_kind, uint32_t reg_num, std::string &reg_name)
lldb_private::EmulateInstruction::eContextRegisterStore
@ eContextRegisterStore
Definition: EmulateInstruction.h:136
lldb_private::EmulateInstruction::m_arch
ArchSpec m_arch
Definition: EmulateInstruction.h:491
lldb_private::EmulateInstruction::ReadRegisterFrame
static bool ReadRegisterFrame(EmulateInstruction *instruction, void *baton, const RegisterInfo *reg_info, RegisterValue &reg_value)
Definition: EmulateInstruction.cpp:282
lldb_private::EmulateInstruction::eContextWriteMemoryRandomBits
@ eContextWriteMemoryRandomBits
Definition: EmulateInstruction.h:158
lldb_private::Stream
Definition: Stream.h:28
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
lldb_private::EmulateInstruction::SetCallbacks
void SetCallbacks(ReadMemoryCallback read_mem_callback, WriteMemoryCallback write_mem_callback, ReadRegisterCallback read_reg_callback, WriteRegisterCallback write_reg_callback)
Definition: EmulateInstruction.cpp:212
lldb_private::EmulateInstruction::GetInternalRegisterNumber
static uint32_t GetInternalRegisterNumber(RegisterContext *reg_ctx, const RegisterInfo &reg_info)
Definition: EmulateInstruction.cpp:572
lldb-private-enumerations.h
lldb_private::Target
Definition: Target.h:451
lldb_private::EmulateInstruction::eContextReadOpcode
@ eContextReadOpcode
Definition: EmulateInstruction.h:102
lldb_private::EmulateInstruction::eInfoTypeNoArgs
@ eInfoTypeNoArgs
Definition: EmulateInstruction.h:181
lldb_private::EmulateInstruction::Context::SetOffset
void SetOffset(int64_t signed_offset)
Definition: EmulateInstruction.h:280
lldb_private::EmulateInstruction::ReadRegisterDefault
static bool ReadRegisterDefault(EmulateInstruction *instruction, void *baton, const RegisterInfo *reg_info, RegisterValue &reg_value)
Definition: EmulateInstruction.cpp:333
lldb_private::EmulateInstruction::eInfoTypeRegisterPlusOffset
@ eInfoTypeRegisterPlusOffset
Definition: EmulateInstruction.h:168
lldb_private::EmulateInstruction::m_baton
void * m_baton
Definition: EmulateInstruction.h:492
lldb_private::EmulateInstruction::Context::SetISAAndImmediateSigned
void SetISAAndImmediateSigned(uint32_t isa, int32_t data)
Definition: EmulateInstruction.h:310
lldb_private::EmulateInstruction::eInfoTypeRegisterToRegisterPlusIndirectOffset
@ eInfoTypeRegisterToRegisterPlusIndirectOffset
Definition: EmulateInstruction.h:171
lldb_private::EmulateInstruction::GetByteOrder
lldb::ByteOrder GetByteOrder() const
Definition: EmulateInstruction.h:426
lldb_private::EmulateInstruction::Context::SetRegister
void SetRegister(RegisterInfo reg)
Definition: EmulateInstruction.h:285
lldb_private::EmulateInstruction::ReadRegisterUnsigned
uint64_t ReadRegisterUnsigned(const RegisterInfo *reg_info, uint64_t fail_value, bool *success_ptr)
Definition: EmulateInstruction.cpp:103
lldb_private::EmulateInstruction::eContextImmediate
@ eContextImmediate
Definition: EmulateInstruction.h:106
lldb_private::EmulateInstruction::GetArchitecture
const ArchSpec & GetArchitecture() const
Definition: EmulateInstruction.h:432
lldb_private::EmulateInstruction::eInfoTypeRegisterToRegisterPlusOffset
@ eInfoTypeRegisterToRegisterPlusOffset
Definition: EmulateInstruction.h:170
lldb_private::EmulateInstruction::eInfoTypeISAAndImmediate
@ eInfoTypeISAAndImmediate
Definition: EmulateInstruction.h:178
lldb_private::EmulateInstruction::InstructionCondition
uint32_t InstructionCondition
Definition: EmulateInstruction.h:349
lldb_private::EmulateInstruction::UnconditionalCondition
static const InstructionCondition UnconditionalCondition
Definition: EmulateInstruction.h:350
lldb_private::EmulateInstruction::ReadMemory
size_t ReadMemory(const Context &context, lldb::addr_t addr, void *dst, size_t dst_len)
Definition: EmulateInstruction.cpp:156
lldb_private::EmulateInstruction::Context::type
ContextType type
Definition: EmulateInstruction.h:185
lldb_private::EmulateInstruction::SetInstruction
virtual bool SetInstruction(const Opcode &insn_opcode, const Address &inst_addr, Target *target)
Definition: EmulateInstruction.cpp:520
lldb_private::EmulateInstruction::eContextInvalid
@ eContextInvalid
Definition: EmulateInstruction.h:100
lldb_private::EmulateInstruction::Context::SetRegisterToRegisterPlusIndirectOffset
void SetRegisterToRegisterPlusIndirectOffset(RegisterInfo base_reg, RegisterInfo offset_reg, RegisterInfo data_reg)
Definition: EmulateInstruction.h:264
lldb_private::EmulateInstruction::Context::SetRegisterPlusOffset
void SetRegisterPlusOffset(RegisterInfo base_reg, int64_t signed_offset)
Definition: EmulateInstruction.h:242
lldb_private::EmulateInstruction::m_write_reg_callback
WriteRegisterCallback m_write_reg_callback
Definition: EmulateInstruction.h:496
lldb_private::EmulateInstruction::Context::reg
RegisterInfo reg
Definition: EmulateInstruction.h:189
lldb-enumerations.h
lldb_private::EmulateInstruction::Context::SetISAAndImmediate
void SetISAAndImmediate(uint32_t isa, uint32_t data)
Definition: EmulateInstruction.h:304
lldb_private::EmulateInstruction::Context::SetRegisterToRegisterPlusOffset
void SetRegisterToRegisterPlusOffset(RegisterInfo data_reg, RegisterInfo base_reg, int64_t offset)
Definition: EmulateInstruction.h:255
lldb_private::EmulateInstruction::ReadInstruction
virtual bool ReadInstruction()=0
lldb_private::EmulateInstruction::Context::signed_offset
int64_t signed_offset
Definition: EmulateInstruction.h:190
PluginInterface.h
lldb_private::EmulateInstruction::SetBaton
void SetBaton(void *baton)
Definition: EmulateInstruction.cpp:210
lldb_private::EmulateInstruction::eInfoTypeISAAndImmediateSigned
@ eInfoTypeISAAndImmediateSigned
Definition: EmulateInstruction.h:179
lldb_private::EmulateInstruction::Context::offset
int64_t offset
Definition: EmulateInstruction.h:201
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:40
lldb_private::EmulateInstruction::SetWriteRegCallback
void SetWriteRegCallback(WriteRegisterCallback write_reg_callback)
Definition: EmulateInstruction.cpp:238
lldb_private::EmulateInstruction::WriteMemoryCallback
size_t(* WriteMemoryCallback)(EmulateInstruction *instruction, void *baton, const Context &context, lldb::addr_t addr, const void *dst, size_t length)
Definition: EmulateInstruction.h:331
lldb_private::EmulateInstruction::Context::unsigned_immediate
uint64_t unsigned_immediate
Definition: EmulateInstruction.h:222
lldb_private::EmulateInstruction::eContextReturnFromException
@ eContextReturnFromException
Definition: EmulateInstruction.h:164
Address.h
lldb_private::EmulateInstruction::InfoType
InfoType
Definition: EmulateInstruction.h:167
lldb_private::RegisterContext
Definition: RegisterContext.h:17
lldb_private::ArchSpec::GetAddressByteSize
uint32_t GetAddressByteSize() const
Returns the size in bytes of an address of the current architecture.
Definition: ArchSpec.cpp:683
lldb_private::EmulateInstruction::Context::operand2
RegisterInfo operand2
Definition: EmulateInstruction.h:214
lldb_private::EmulateInstruction::WriteMemoryUnsigned
bool WriteMemoryUnsigned(const Context &context, lldb::addr_t addr, uint64_t uval, size_t uval_byte_size)
Definition: EmulateInstruction.cpp:191
lldb::RegisterKind
RegisterKind
Register numbering types.
Definition: lldb-enumerations.h:227
lldb_private::EmulateInstruction::eContextAdjustStackPointer
@ eContextAdjustStackPointer
Definition: EmulateInstruction.h:117
lldb-types.h
lldb_private::EmulateInstruction::Context::ISAAndImmediateSigned
struct lldb_private::EmulateInstruction::Context::@7::ISAAndImmediateSigned ISAAndImmediateSigned
lldb_private::EmulateInstruction::eInfoTypeImmediateSigned
@ eInfoTypeImmediateSigned
Definition: EmulateInstruction.h:176
lldb_private::EmulateInstruction::WriteMemoryFrame
static size_t WriteMemoryFrame(EmulateInstruction *instruction, void *baton, const Context &context, lldb::addr_t addr, const void *dst, size_t length)
Definition: EmulateInstruction.cpp:264
lldb_private::EmulateInstruction::m_read_mem_callback
ReadMemoryCallback m_read_mem_callback
Definition: EmulateInstruction.h:493
lldb_private::EmulateInstruction::operator=
const EmulateInstruction & operator=(const EmulateInstruction &)=delete
lldb_private::EmulateInstruction::TestEmulation
virtual bool TestEmulation(Stream *out_stream, ArchSpec &arch, OptionValueDictionary *test_data)=0
lldb_private::EmulateInstruction::Context::SetNoArgs
void SetNoArgs()
Definition: EmulateInstruction.h:321
lldb_private::EmulateInstruction::Context::SetRegisterPlusIndirectOffset
void SetRegisterPlusIndirectOffset(RegisterInfo base_reg, RegisterInfo offset_reg)
Definition: EmulateInstruction.h:248
uint32_t
lldb_private::EmulateInstruction
Definition: EmulateInstruction.h:93
lldb_private::EmulateInstruction::SetWriteMemCallback
void SetWriteMemCallback(WriteMemoryCallback write_mem_callback)
Definition: EmulateInstruction.cpp:228
lldb_private::EmulateInstruction::WriteRegister
bool WriteRegister(const Context &context, const RegisterInfo *ref_info, const RegisterValue &reg_value)
Definition: EmulateInstruction.cpp:114
lldb_private::Address
Definition: Address.h:59
lldb_private::EmulateInstruction::~EmulateInstruction
~EmulateInstruction() override=default
lldb_private::EmulateInstruction::Context::unsigned_data32
uint32_t unsigned_data32
Definition: EmulateInstruction.h:229
lldb_private::EmulateInstruction::Context::Context
Context()=default
lldb_private::EmulateInstruction::Context::RegisterToRegisterPlusOffset
struct lldb_private::EmulateInstruction::Context::@7::RegisterToRegisterPlusOffset RegisterToRegisterPlusOffset
lldb_private::EmulateInstruction::Context::operand1
RegisterInfo operand1
Definition: EmulateInstruction.h:212
lldb_private::EmulateInstruction::eContextSetFramePointer
@ eContextSetFramePointer
Definition: EmulateInstruction.h:120
lldb_private::EmulateInstruction::eContextRestoreStackPointer
@ eContextRestoreStackPointer
Definition: EmulateInstruction.h:124
ArchSpec.h
UINT32_MAX
#define UINT32_MAX
Definition: lldb-defines.h:31
lldb_private::EmulateInstruction::WriteMemory
bool WriteMemory(const Context &context, lldb::addr_t addr, const void *src, size_t src_len)
Definition: EmulateInstruction.cpp:202
lldb_private::EmulateInstruction::eInfoTypeOffset
@ eInfoTypeOffset
Definition: EmulateInstruction.h:173
lldb_private::EmulateInstruction::GetAddress
lldb::addr_t GetAddress() const
Definition: EmulateInstruction.h:430
lldb_private::EmulateInstruction::eContextRegisterLoad
@ eContextRegisterLoad
Definition: EmulateInstruction.h:138
lldb_private::EmulateInstruction::FindPlugin
static EmulateInstruction * FindPlugin(const ArchSpec &arch, InstructionType supported_inst_type, const char *plugin_name)
Definition: EmulateInstruction.cpp:44
lldb_private::EmulateInstruction::eContextWriteRegisterRandomBits
@ eContextWriteRegisterRandomBits
Definition: EmulateInstruction.h:155
LLDB_INVALID_ADDRESS
#define LLDB_INVALID_ADDRESS
Definition: lldb-defines.h:86
lldb_private::EmulateInstruction::Context::SetISA
void SetISA(uint32_t isa)
Definition: EmulateInstruction.h:316
lldb_private::EmulateInstruction::Context::RegisterRegisterOperands
struct lldb_private::EmulateInstruction::Context::@7::RegisterRegisterOperands RegisterRegisterOperands
lldb_private::InstructionType
InstructionType
Instruction types.
Definition: lldb-private-enumerations.h:118
lldb_private::EmulateInstruction::eInfoTypeRegisterRegisterOperands
@ eInfoTypeRegisterRegisterOperands
Definition: EmulateInstruction.h:172
lldb_private::EmulateInstruction::GetBestRegisterKindAndNumber
static bool GetBestRegisterKindAndNumber(const RegisterInfo *reg_info, lldb::RegisterKind &reg_kind, uint32_t &reg_num)
Definition: EmulateInstruction.cpp:534
lldb_private::EmulateInstruction::ReadMemoryFrame
static size_t ReadMemoryFrame(EmulateInstruction *instruction, void *baton, const Context &context, lldb::addr_t addr, void *dst, size_t length)
Definition: EmulateInstruction.cpp:247
lldb_private::EmulateInstruction::Context::offset_reg
RegisterInfo offset_reg
Definition: EmulateInstruction.h:195
lldb_private::EmulateInstruction::eInfoTypeISA
@ eInfoTypeISA
Definition: EmulateInstruction.h:180
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::EmulateInstruction::Context::SetAddress
void SetAddress(lldb::addr_t address)
Definition: EmulateInstruction.h:300
lldb_private::EmulateInstruction::WriteRegisterUnsigned
bool WriteRegisterUnsigned(const Context &context, const RegisterInfo *reg_info, uint64_t reg_value)
Definition: EmulateInstruction.cpp:145
lldb_private::EmulateInstruction::eContextAdjustBaseRegister
@ eContextAdjustBaseRegister
Definition: EmulateInstruction.h:127
lldb_private::EmulateInstruction::m_write_mem_callback
WriteMemoryCallback m_write_mem_callback
Definition: EmulateInstruction.h:494
lldb_private::EmulateInstruction::Context::SetRegisterRegisterOperands
void SetRegisterRegisterOperands(RegisterInfo op1_reg, RegisterInfo op2_reg)
Definition: EmulateInstruction.h:273
lldb_private::OptionValueDictionary
Definition: OptionValueDictionary.h:18
lldb_private::EmulateInstruction::EmulateInstruction
EmulateInstruction(const ArchSpec &arch)
Definition: EmulateInstruction.cpp:73
lldb_private::EmulateInstruction::ReadMemoryUnsigned
uint64_t ReadMemoryUnsigned(const Context &context, lldb::addr_t addr, size_t byte_size, uint64_t fail_value, bool *success_ptr)
Definition: EmulateInstruction.cpp:164
lldb_private::EmulateInstruction::EvaluateInstruction
virtual bool EvaluateInstruction(uint32_t evaluate_options)=0
lldb_private::EmulateInstruction::eContextAdjustPC
@ eContextAdjustPC
Definition: EmulateInstruction.h:130
lldb_private::EmulateInstruction::Context::isa
uint32_t isa
Definition: EmulateInstruction.h:228
lldb_private::EmulateInstruction::Context::Dump
void Dump(Stream &s, EmulateInstruction *instruction) const
Definition: EmulateInstruction.cpp:363
lldb_private::EmulateInstruction::eContextPopRegisterOffStack
@ eContextPopRegisterOffStack
Definition: EmulateInstruction.h:114
lldb_private::EmulateInstruction::ReadRegister
bool ReadRegister(const RegisterInfo *reg_info, RegisterValue &reg_value)
Definition: EmulateInstruction.cpp:75
lldb_private::EmulateInstruction::Context::SetImmediateSigned
void SetImmediateSigned(int64_t signed_immediate)
Definition: EmulateInstruction.h:295
lldb_private::EmulateInstruction::SetReadMemCallback
void SetReadMemCallback(ReadMemoryCallback read_mem_callback)
Definition: EmulateInstruction.cpp:223
lldb_private::EmulateInstruction::eInfoTypeImmediate
@ eInfoTypeImmediate
Definition: EmulateInstruction.h:175
lldb_private::EmulateInstruction::m_addr
lldb::addr_t m_addr
Definition: EmulateInstruction.h:497
lldb_private::UnwindPlan
Definition: UnwindPlan.h:53
lldb_private::EmulateInstruction::Context::RegisterPlusOffset
struct lldb_private::EmulateInstruction::Context::@7::RegisterPlusOffset RegisterPlusOffset
lldb_private::EmulateInstruction::eContextPushRegisterOnStack
@ eContextPushRegisterOnStack
Definition: EmulateInstruction.h:110
lldb_private::EmulateInstruction::eContextRelativeBranchImmediate
@ eContextRelativeBranchImmediate
Definition: EmulateInstruction.h:141
lldb_private::EmulateInstruction::GetRegisterInfo
virtual bool GetRegisterInfo(lldb::RegisterKind reg_kind, uint32_t reg_num, RegisterInfo &reg_info)=0
lldb_private::EmulateInstruction::Context::SetImmediate
void SetImmediate(uint64_t immediate)
Definition: EmulateInstruction.h:290
lldb_private::EmulateInstruction::eContextArithmetic
@ eContextArithmetic
Definition: EmulateInstruction.h:160
lldb_private::EmulateInstruction::ReadRegisterCallback
bool(* ReadRegisterCallback)(EmulateInstruction *instruction, void *baton, const RegisterInfo *reg_info, RegisterValue &reg_value)
Definition: EmulateInstruction.h:336
lldb_private::EmulateInstruction::eContextAdvancePC
@ eContextAdvancePC
Definition: EmulateInstruction.h:162
lldb_private::EmulateInstruction::eContextSupervisorCall
@ eContextSupervisorCall
Definition: EmulateInstruction.h:148
lldb::ByteOrder
ByteOrder
Byte ordering definitions.
Definition: lldb-enumerations.h:138
lldb_private::EmulateInstruction::m_opcode
Opcode m_opcode
Definition: EmulateInstruction.h:498
lldb_private::EmulateInstruction::Context::info_type
enum InfoType info_type
Definition: EmulateInstruction.h:186