LLDB  mainline
EmulateInstruction.cpp
Go to the documentation of this file.
1 //===-- EmulateInstruction.cpp --------------------------------------------===//
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 
10 
11 #include "lldb/Core/Address.h"
14 #include "lldb/Core/StreamFile.h"
15 #include "lldb/Symbol/UnwindPlan.h"
16 #include "lldb/Target/Process.h"
18 #include "lldb/Target/StackFrame.h"
22 #include "lldb/Utility/Status.h"
23 #include "lldb/Utility/Stream.h"
25 #include "lldb/lldb-forward.h"
27 
28 #include "llvm/ADT/StringRef.h"
29 
30 #include <cstring>
31 #include <memory>
32 
33 #include <cinttypes>
34 #include <cstdio>
35 
36 namespace lldb_private {
37 class Target;
38 }
39 
40 using namespace lldb;
41 using namespace lldb_private;
42 
44 EmulateInstruction::FindPlugin(const ArchSpec &arch,
45  InstructionType supported_inst_type,
46  const char *plugin_name) {
47  EmulateInstructionCreateInstance create_callback = nullptr;
48  if (plugin_name) {
49  create_callback =
50  PluginManager::GetEmulateInstructionCreateCallbackForPluginName(
51  plugin_name);
52  if (create_callback) {
53  EmulateInstruction *emulate_insn_ptr =
54  create_callback(arch, supported_inst_type);
55  if (emulate_insn_ptr)
56  return emulate_insn_ptr;
57  }
58  } else {
59  for (uint32_t idx = 0;
60  (create_callback =
61  PluginManager::GetEmulateInstructionCreateCallbackAtIndex(idx)) !=
62  nullptr;
63  ++idx) {
64  EmulateInstruction *emulate_insn_ptr =
65  create_callback(arch, supported_inst_type);
66  if (emulate_insn_ptr)
67  return emulate_insn_ptr;
68  }
69  }
70  return nullptr;
71 }
72 
73 EmulateInstruction::EmulateInstruction(const ArchSpec &arch) : m_arch(arch) {}
74 
75 llvm::Optional<RegisterValue>
76 EmulateInstruction::ReadRegister(const RegisterInfo &reg_info) {
77  if (m_read_reg_callback == nullptr)
78  return {};
79 
80  RegisterValue reg_value;
81  bool success = m_read_reg_callback(this, m_baton, &reg_info, reg_value);
82  if (success)
83  return reg_value;
84  return {};
85 }
86 
88  uint32_t reg_num,
89  RegisterValue &reg_value) {
90  llvm::Optional<RegisterInfo> reg_info = GetRegisterInfo(reg_kind, reg_num);
91  if (!reg_info)
92  return false;
93 
94  llvm::Optional<RegisterValue> value = ReadRegister(*reg_info);
95  if (value)
96  reg_value = *value;
97  return value.has_value();
98 }
99 
101  uint32_t reg_num,
102  uint64_t fail_value,
103  bool *success_ptr) {
104  RegisterValue reg_value;
105  if (ReadRegister(reg_kind, reg_num, reg_value))
106  return reg_value.GetAsUInt64(fail_value, success_ptr);
107  if (success_ptr)
108  *success_ptr = false;
109  return fail_value;
110 }
111 
112 uint64_t EmulateInstruction::ReadRegisterUnsigned(const RegisterInfo &reg_info,
113  uint64_t fail_value,
114  bool *success_ptr) {
115  llvm::Optional<RegisterValue> reg_value = ReadRegister(reg_info);
116  if (!reg_value) {
117  if (success_ptr)
118  *success_ptr = false;
119  return fail_value;
120  }
121 
122  return reg_value->GetAsUInt64(fail_value, success_ptr);
123 }
124 
126  const RegisterInfo &reg_info,
127  const RegisterValue &reg_value) {
128  if (m_write_reg_callback != nullptr)
129  return m_write_reg_callback(this, m_baton, context, &reg_info, reg_value);
130  return false;
131 }
132 
134  lldb::RegisterKind reg_kind,
135  uint32_t reg_num,
136  const RegisterValue &reg_value) {
137  llvm::Optional<RegisterInfo> reg_info = GetRegisterInfo(reg_kind, reg_num);
138  if (reg_info)
139  return WriteRegister(context, *reg_info, reg_value);
140  return false;
141 }
142 
144  lldb::RegisterKind reg_kind,
145  uint32_t reg_num,
146  uint64_t uint_value) {
147  llvm::Optional<RegisterInfo> reg_info = GetRegisterInfo(reg_kind, reg_num);
148  if (reg_info) {
149  RegisterValue reg_value;
150  if (reg_value.SetUInt(uint_value, reg_info->byte_size))
151  return WriteRegister(context, *reg_info, reg_value);
152  }
153  return false;
154 }
155 
157  const RegisterInfo &reg_info,
158  uint64_t uint_value) {
159  RegisterValue reg_value;
160  if (reg_value.SetUInt(uint_value, reg_info.byte_size))
161  return WriteRegister(context, reg_info, reg_value);
162  return false;
163 }
164 
166  void *dst, size_t dst_len) {
167  if (m_read_mem_callback != nullptr)
168  return m_read_mem_callback(this, m_baton, context, addr, dst, dst_len) ==
169  dst_len;
170  return false;
171 }
172 
174  lldb::addr_t addr,
175  size_t byte_size,
176  uint64_t fail_value,
177  bool *success_ptr) {
178  uint64_t uval64 = 0;
179  bool success = false;
180  if (byte_size <= 8) {
181  uint8_t buf[sizeof(uint64_t)];
182  size_t bytes_read =
183  m_read_mem_callback(this, m_baton, context, addr, buf, byte_size);
184  if (bytes_read == byte_size) {
185  lldb::offset_t offset = 0;
186  DataExtractor data(buf, byte_size, GetByteOrder(), GetAddressByteSize());
187  uval64 = data.GetMaxU64(&offset, byte_size);
188  success = true;
189  }
190  }
191 
192  if (success_ptr)
193  *success_ptr = success;
194 
195  if (!success)
196  uval64 = fail_value;
197  return uval64;
198 }
199 
201  lldb::addr_t addr, uint64_t uval,
202  size_t uval_byte_size) {
204  strm.PutMaxHex64(uval, uval_byte_size);
205 
206  size_t bytes_written = m_write_mem_callback(
207  this, m_baton, context, addr, strm.GetString().data(), uval_byte_size);
208  return (bytes_written == uval_byte_size);
209 }
210 
212  const void *src, size_t src_len) {
213  if (m_write_mem_callback != nullptr)
214  return m_write_mem_callback(this, m_baton, context, addr, src, src_len) ==
215  src_len;
216  return false;
217 }
218 
219 void EmulateInstruction::SetBaton(void *baton) { m_baton = baton; }
220 
222  ReadMemoryCallback read_mem_callback,
223  WriteMemoryCallback write_mem_callback,
224  ReadRegisterCallback read_reg_callback,
225  WriteRegisterCallback write_reg_callback) {
226  m_read_mem_callback = read_mem_callback;
227  m_write_mem_callback = write_mem_callback;
228  m_read_reg_callback = read_reg_callback;
229  m_write_reg_callback = write_reg_callback;
230 }
231 
233  ReadMemoryCallback read_mem_callback) {
234  m_read_mem_callback = read_mem_callback;
235 }
236 
238  WriteMemoryCallback write_mem_callback) {
239  m_write_mem_callback = write_mem_callback;
240 }
241 
243  ReadRegisterCallback read_reg_callback) {
244  m_read_reg_callback = read_reg_callback;
245 }
246 
248  WriteRegisterCallback write_reg_callback) {
249  m_write_reg_callback = write_reg_callback;
250 }
251 
252 //
253 // Read & Write Memory and Registers callback functions.
254 //
255 
257  void *baton, const Context &context,
258  lldb::addr_t addr, void *dst,
259  size_t dst_len) {
260  if (baton == nullptr || dst == nullptr || dst_len == 0)
261  return 0;
262 
263  StackFrame *frame = (StackFrame *)baton;
264 
265  ProcessSP process_sp(frame->CalculateProcess());
266  if (process_sp) {
267  Status error;
268  return process_sp->ReadMemory(addr, dst, dst_len, error);
269  }
270  return 0;
271 }
272 
274  void *baton, const Context &context,
275  lldb::addr_t addr, const void *src,
276  size_t src_len) {
277  if (baton == nullptr || src == nullptr || src_len == 0)
278  return 0;
279 
280  StackFrame *frame = (StackFrame *)baton;
281 
282  ProcessSP process_sp(frame->CalculateProcess());
283  if (process_sp) {
284  Status error;
285  return process_sp->WriteMemory(addr, src, src_len, error);
286  }
287 
288  return 0;
289 }
290 
292  void *baton,
293  const RegisterInfo *reg_info,
294  RegisterValue &reg_value) {
295  if (baton == nullptr)
296  return false;
297 
298  StackFrame *frame = (StackFrame *)baton;
299  return frame->GetRegisterContext()->ReadRegister(reg_info, reg_value);
300 }
301 
303  void *baton, const Context &context,
304  const RegisterInfo *reg_info,
305  const RegisterValue &reg_value) {
306  if (baton == nullptr)
307  return false;
308 
309  StackFrame *frame = (StackFrame *)baton;
310  return frame->GetRegisterContext()->WriteRegister(reg_info, reg_value);
311 }
312 
314  void *baton,
315  const Context &context,
316  lldb::addr_t addr, void *dst,
317  size_t length) {
318  StreamFile strm(stdout, false);
319  strm.Printf(" Read from Memory (address = 0x%" PRIx64 ", length = %" PRIu64
320  ", context = ",
321  addr, (uint64_t)length);
322  context.Dump(strm, instruction);
323  strm.EOL();
324  *((uint64_t *)dst) = 0xdeadbeef;
325  return length;
326 }
327 
329  void *baton,
330  const Context &context,
331  lldb::addr_t addr,
332  const void *dst, size_t length) {
333  StreamFile strm(stdout, false);
334  strm.Printf(" Write to Memory (address = 0x%" PRIx64 ", length = %" PRIu64
335  ", context = ",
336  addr, (uint64_t)length);
337  context.Dump(strm, instruction);
338  strm.EOL();
339  return length;
340 }
341 
343  void *baton,
344  const RegisterInfo *reg_info,
345  RegisterValue &reg_value) {
346  StreamFile strm(stdout, false);
347  strm.Printf(" Read Register (%s)\n", reg_info->name);
348  lldb::RegisterKind reg_kind;
349  uint32_t reg_num;
350  if (GetBestRegisterKindAndNumber(reg_info, reg_kind, reg_num))
351  reg_value.SetUInt64((uint64_t)reg_kind << 24 | reg_num);
352  else
353  reg_value.SetUInt64(0);
354 
355  return true;
356 }
357 
359  void *baton,
360  const Context &context,
361  const RegisterInfo *reg_info,
362  const RegisterValue &reg_value) {
363  StreamFile strm(stdout, false);
364  strm.Printf(" Write to Register (name = %s, value = ", reg_info->name);
365  DumpRegisterValue(reg_value, &strm, reg_info, false, false, eFormatDefault);
366  strm.PutCString(", context = ");
367  context.Dump(strm, instruction);
368  strm.EOL();
369  return true;
370 }
371 
373  EmulateInstruction *instruction) const {
374  switch (type) {
375  case eContextReadOpcode:
376  strm.PutCString("reading opcode");
377  break;
378 
379  case eContextImmediate:
380  strm.PutCString("immediate");
381  break;
382 
384  strm.PutCString("push register");
385  break;
386 
388  strm.PutCString("pop register");
389  break;
390 
392  strm.PutCString("adjust sp");
393  break;
394 
396  strm.PutCString("set frame pointer");
397  break;
398 
400  strm.PutCString("adjusting (writing value back to) a base register");
401  break;
402 
404  strm.PutCString("register + offset");
405  break;
406 
408  strm.PutCString("store register");
409  break;
410 
412  strm.PutCString("load register");
413  break;
414 
416  strm.PutCString("relative branch immediate");
417  break;
418 
420  strm.PutCString("absolute branch register");
421  break;
422 
424  strm.PutCString("supervisor call");
425  break;
426 
428  strm.PutCString("table branch read memory");
429  break;
430 
432  strm.PutCString("write random bits to a register");
433  break;
434 
436  strm.PutCString("write random bits to a memory address");
437  break;
438 
439  case eContextArithmetic:
440  strm.PutCString("arithmetic");
441  break;
442 
444  strm.PutCString("return from exception");
445  break;
446 
447  default:
448  strm.PutCString("unrecognized context.");
449  break;
450  }
451 
452  switch (GetInfoType()) {
454  strm.Printf(" (reg_plus_offset = %s%+" PRId64 ")",
457  break;
458 
460  strm.Printf(" (reg_plus_reg = %s + %s)",
463  break;
464 
466  strm.Printf(" (base_and_imm_offset = %s%+" PRId64 ", data_reg = %s)",
470  break;
471 
473  strm.Printf(" (base_and_reg_offset = %s + %s, data_reg = %s)",
477  break;
478 
480  strm.Printf(" (register to register binary op: %s and %s)",
483  break;
484 
485  case eInfoTypeOffset:
486  strm.Printf(" (signed_offset = %+" PRId64 ")", info.signed_offset);
487  break;
488 
489  case eInfoTypeRegister:
490  strm.Printf(" (reg = %s)", info.reg.name);
491  break;
492 
493  case eInfoTypeImmediate:
494  strm.Printf(" (unsigned_immediate = %" PRIu64 " (0x%16.16" PRIx64 "))",
496  break;
497 
499  strm.Printf(" (signed_immediate = %+" PRId64 " (0x%16.16" PRIx64 "))",
501  break;
502 
503  case eInfoTypeAddress:
504  strm.Printf(" (address = 0x%" PRIx64 ")", info.address);
505  break;
506 
508  strm.Printf(" (isa = %u, unsigned_immediate = %u (0x%8.8x))",
511  break;
512 
514  strm.Printf(" (isa = %u, signed_immediate = %i (0x%8.8x))",
518  break;
519 
520  case eInfoTypeISA:
521  strm.Printf(" (isa = %u)", info.isa);
522  break;
523 
524  case eInfoTypeNoArgs:
525  break;
526  }
527 }
528 
530  const Address &inst_addr,
531  Target *target) {
532  m_opcode = opcode;
534  if (inst_addr.IsValid()) {
535  if (target != nullptr)
536  m_addr = inst_addr.GetLoadAddress(target);
538  m_addr = inst_addr.GetFileAddress();
539  }
540  return true;
541 }
542 
544  const RegisterInfo *reg_info, lldb::RegisterKind &reg_kind,
545  uint32_t &reg_num) {
546  // Generic and DWARF should be the two most popular register kinds when
547  // emulating instructions since they are the most platform agnostic...
548  reg_num = reg_info->kinds[eRegisterKindGeneric];
549  if (reg_num != LLDB_INVALID_REGNUM) {
550  reg_kind = eRegisterKindGeneric;
551  return true;
552  }
553 
554  reg_num = reg_info->kinds[eRegisterKindDWARF];
555  if (reg_num != LLDB_INVALID_REGNUM) {
556  reg_kind = eRegisterKindDWARF;
557  return true;
558  }
559 
560  reg_num = reg_info->kinds[eRegisterKindLLDB];
561  if (reg_num != LLDB_INVALID_REGNUM) {
562  reg_kind = eRegisterKindLLDB;
563  return true;
564  }
565 
566  reg_num = reg_info->kinds[eRegisterKindEHFrame];
567  if (reg_num != LLDB_INVALID_REGNUM) {
568  reg_kind = eRegisterKindEHFrame;
569  return true;
570  }
571 
572  reg_num = reg_info->kinds[eRegisterKindProcessPlugin];
573  if (reg_num != LLDB_INVALID_REGNUM) {
574  reg_kind = eRegisterKindProcessPlugin;
575  return true;
576  }
577  return false;
578 }
579 
580 uint32_t
582  const RegisterInfo &reg_info) {
583  lldb::RegisterKind reg_kind;
584  uint32_t reg_num;
585  if (reg_ctx && GetBestRegisterKindAndNumber(&reg_info, reg_kind, reg_num))
586  return reg_ctx->ConvertRegisterKindToRegisterNumber(reg_kind, reg_num);
587  return LLDB_INVALID_REGNUM;
588 }
589 
591  unwind_plan.Clear();
592  return false;
593 }
lldb_private::Stream::PutMaxHex64
size_t PutMaxHex64(uint64_t uvalue, size_t byte_size, lldb::ByteOrder byte_order=lldb::eByteOrderInvalid)
Definition: Stream.cpp:288
lldb_private::EmulateInstruction::Context::ContextInfo::isa
uint32_t isa
Definition: EmulateInstruction.h:242
lldb_private::EmulateInstruction::Context::ContextInfo::RegisterToRegisterPlusIndirectOffset
struct lldb_private::EmulateInstruction::Context::ContextInfo::RegisterToRegisterPlusIndirectOffset RegisterToRegisterPlusIndirectOffset
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:313
lldb_private::ArchSpec
Definition: ArchSpec.h:32
LLDB_INVALID_REGNUM
#define LLDB_INVALID_REGNUM
Definition: lldb-defines.h:79
lldb_private::Address::IsValid
bool IsValid() const
Check if the object state is valid.
Definition: Address.h:345
lldb_private::EmulateInstruction::Context::ContextInfo::RegisterToRegisterPlusOffset::data_reg
RegisterInfo data_reg
Definition: EmulateInstruction.h:204
lldb_private::EmulateInstruction::m_read_reg_callback
ReadRegisterCallback m_read_reg_callback
Definition: EmulateInstruction.h:502
lldb_private::EmulateInstruction::SetReadRegCallback
void SetReadRegCallback(ReadRegisterCallback read_reg_callback)
Definition: EmulateInstruction.cpp:242
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:302
lldb_private::Opcode
Definition: Opcode.h:29
lldb_private::RegisterValue
Definition: RegisterValue.h:28
lldb_private::EmulateInstruction::eContextRegisterPlusOffset
@ eContextRegisterPlusOffset
Definition: EmulateInstruction.h:133
lldb::eRegisterKindDWARF
@ eRegisterKindDWARF
the register numbers seen DWARF
Definition: lldb-enumerations.h:230
lldb_private::EmulateInstruction::eInfoTypeRegisterPlusIndirectOffset
@ eInfoTypeRegisterPlusIndirectOffset
Definition: EmulateInstruction.h:169
lldb_private::EmulateInstruction::GetAddressByteSize
uint32_t GetAddressByteSize() const
Definition: EmulateInstruction.h:431
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:358
lldb::eRegisterKindGeneric
@ eRegisterKindGeneric
insn ptr reg, stack ptr reg, etc not specific to any particular target
Definition: lldb-enumerations.h:231
lldb_private::EmulateInstruction::eInfoTypeAddress
@ eInfoTypeAddress
Definition: EmulateInstruction.h:177
lldb-private-interfaces.h
lldb_private::EmulateInstruction::Context::ContextInfo::RegisterPlusIndirectOffset
struct lldb_private::EmulateInstruction::Context::ContextInfo::RegisterPlusIndirectOffset RegisterPlusIndirectOffset
lldb_private::EmulateInstruction::eContextAbsoluteBranchRegister
@ eContextAbsoluteBranchRegister
Definition: EmulateInstruction.h:144
lldb_private::EmulateInstruction::Context
Definition: EmulateInstruction.h:184
lldb_private::EmulateInstruction::Context::ContextInfo::RegisterToRegisterPlusIndirectOffset::offset_reg
RegisterInfo offset_reg
Definition: EmulateInstruction.h:211
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:328
lldb_private::EmulateInstruction::eInfoTypeRegister
@ eInfoTypeRegister
Definition: EmulateInstruction.h:174
lldb_private::EmulateInstruction::CreateFunctionEntryUnwind
virtual bool CreateFunctionEntryUnwind(UnwindPlan &unwind_plan)
Definition: EmulateInstruction.cpp:590
lldb_private::EmulateInstruction::eContextTableBranchReadMemory
@ eContextTableBranchReadMemory
Definition: EmulateInstruction.h:152
lldb_private::EmulateInstruction::Context::ContextInfo::RegisterToRegisterPlusOffset
struct lldb_private::EmulateInstruction::Context::ContextInfo::RegisterToRegisterPlusOffset RegisterToRegisterPlusOffset
lldb_private::EmulateInstruction::Context::ContextInfo::RegisterPlusOffset::signed_offset
int64_t signed_offset
Definition: EmulateInstruction.h:195
WriteRegisterCallback
static bool WriteRegisterCallback(EmulateInstruction *instruction, void *baton, const EmulateInstruction::Context &context, const RegisterInfo *reg_info, const RegisterValue &reg_value)
Definition: NativeProcessSoftwareSingleStep.cpp:73
lldb_private::EmulateInstruction::Context::GetInfoType
enum InfoType GetInfoType() const
Definition: EmulateInstruction.h:191
lldb_private::RegisterContext::ConvertRegisterKindToRegisterNumber
virtual uint32_t ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind, uint32_t num)
Convert from a given register numbering scheme to the lldb register numbering scheme.
Definition: RegisterContext.cpp:268
lldb_private::EmulateInstruction::eContextRegisterStore
@ eContextRegisterStore
Definition: EmulateInstruction.h:136
lldb_private::EmulateInstruction::Context::ContextInfo::signed_immediate
int64_t signed_immediate
Definition: EmulateInstruction.h:228
lldb::offset_t
uint64_t offset_t
Definition: lldb-types.h:87
RegisterValue.h
StackFrame.h
lldb_private::EmulateInstruction::ReadRegisterFrame
static bool ReadRegisterFrame(EmulateInstruction *instruction, void *baton, const RegisterInfo *reg_info, RegisterValue &reg_value)
Definition: EmulateInstruction.cpp:291
lldb_private::EmulateInstruction::Context::ContextInfo::ISAAndImmediateSigned::isa
uint32_t isa
Definition: EmulateInstruction.h:238
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:221
lldb_private::EmulateInstruction::GetInternalRegisterNumber
static uint32_t GetInternalRegisterNumber(RegisterContext *reg_ctx, const RegisterInfo &reg_info)
Definition: EmulateInstruction.cpp:581
lldb_private::EmulateInstruction::Context::ContextInfo::ISAAndImmediate::isa
uint32_t isa
Definition: EmulateInstruction.h:233
lldb_private::EmulateInstruction::Context::ContextInfo::RegisterPlusIndirectOffset::base_reg
RegisterInfo base_reg
Definition: EmulateInstruction.h:199
lldb_private::Target
Definition: Target.h:469
lldb_private::EmulateInstruction::Context::ContextInfo::unsigned_immediate
uint64_t unsigned_immediate
Definition: EmulateInstruction.h:227
lldb_private::StreamString::GetString
llvm::StringRef GetString() const
Definition: StreamString.cpp:51
lldb_private::EmulateInstruction::eContextReadOpcode
@ eContextReadOpcode
Definition: EmulateInstruction.h:102
lldb_private::EmulateInstruction::eInfoTypeNoArgs
@ eInfoTypeNoArgs
Definition: EmulateInstruction.h:181
Process.h
lldb_private::EmulateInstruction::Context::ContextInfo::RegisterToRegisterPlusOffset::offset
int64_t offset
Definition: EmulateInstruction.h:206
lldb_private::RegisterValue::GetAsUInt64
uint64_t GetAsUInt64(uint64_t fail_value=UINT64_MAX, bool *success_ptr=nullptr) const
Definition: RegisterValue.cpp:556
lldb_private::EmulateInstruction::ReadRegisterDefault
static bool ReadRegisterDefault(EmulateInstruction *instruction, void *baton, const RegisterInfo *reg_info, RegisterValue &reg_value)
Definition: EmulateInstruction.cpp:342
lldb_private::EmulateInstruction::Context::ContextInfo::reg
RegisterInfo reg
Definition: EmulateInstruction.h:225
lldb_private::EmulateInstruction::eInfoTypeRegisterPlusOffset
@ eInfoTypeRegisterPlusOffset
Definition: EmulateInstruction.h:168
DumpRegisterValue.h
lldb::eRegisterKindEHFrame
@ eRegisterKindEHFrame
the register numbers seen in eh_frame
Definition: lldb-enumerations.h:229
lldb_private::EmulateInstruction::m_baton
void * m_baton
Definition: EmulateInstruction.h:499
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
lldb_private::RegisterValue::SetUInt64
void SetUInt64(uint64_t uint, Type t=eTypeUInt64)
Definition: RegisterValue.h:205
lldb_private::EmulateInstruction::eInfoTypeRegisterToRegisterPlusIndirectOffset
@ eInfoTypeRegisterToRegisterPlusIndirectOffset
Definition: EmulateInstruction.h:171
lldb_private::EmulateInstruction::GetByteOrder
lldb::ByteOrder GetByteOrder() const
Definition: EmulateInstruction.h:433
lldb_private::EmulateInstruction::eContextImmediate
@ eContextImmediate
Definition: EmulateInstruction.h:106
EmulateInstruction.h
lldb_private::EmulateInstruction::eInfoTypeRegisterToRegisterPlusOffset
@ eInfoTypeRegisterToRegisterPlusOffset
Definition: EmulateInstruction.h:170
lldb::eRegisterKindLLDB
@ eRegisterKindLLDB
lldb's internal register numbers
Definition: lldb-enumerations.h:235
lldb_private::EmulateInstruction::eInfoTypeISAAndImmediate
@ eInfoTypeISAAndImmediate
Definition: EmulateInstruction.h:178
lldb_private::DataExtractor
Definition: DataExtractor.h:48
lldb_private::EmulateInstruction::Context::ContextInfo::ISAAndImmediateSigned
struct lldb_private::EmulateInstruction::Context::ContextInfo::ISAAndImmediateSigned ISAAndImmediateSigned
lldb::eRegisterKindProcessPlugin
@ eRegisterKindProcessPlugin
num used by the process plugin - e.g.
Definition: lldb-enumerations.h:233
lldb_private::EmulateInstruction::ReadMemory
size_t ReadMemory(const Context &context, lldb::addr_t addr, void *dst, size_t dst_len)
Definition: EmulateInstruction.cpp:165
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:529
StreamString.h
lldb_private::Address::GetFileAddress
lldb::addr_t GetFileAddress() const
Get the file address.
Definition: Address.cpp:291
lldb_private::StreamString
Definition: StreamString.h:23
lldb_private::EmulateInstruction::m_write_reg_callback
WriteRegisterCallback m_write_reg_callback
Definition: EmulateInstruction.h:503
lldb_private::EmulateInstruction::SetBaton
void SetBaton(void *baton)
Definition: EmulateInstruction.cpp:219
lldb_private::EmulateInstruction::eInfoTypeISAAndImmediateSigned
@ eInfoTypeISAAndImmediateSigned
Definition: EmulateInstruction.h:179
lldb_private::EmulateInstruction::Context::ContextInfo::RegisterPlusIndirectOffset::offset_reg
RegisterInfo offset_reg
Definition: EmulateInstruction.h:200
lldb_private::EmulateInstruction::Context::ContextInfo::RegisterRegisterOperands
struct lldb_private::EmulateInstruction::Context::ContextInfo::RegisterRegisterOperands RegisterRegisterOperands
lldb_private::EmulateInstruction::SetWriteRegCallback
void SetWriteRegCallback(WriteRegisterCallback write_reg_callback)
Definition: EmulateInstruction.cpp:247
lldb_private::EmulateInstruction::eContextReturnFromException
@ eContextReturnFromException
Definition: EmulateInstruction.h:164
Address.h
UnwindPlan.h
lldb_private::RegisterContext
Definition: RegisterContext.h:17
lldb_private::EmulateInstruction::WriteMemoryUnsigned
bool WriteMemoryUnsigned(const Context &context, lldb::addr_t addr, uint64_t uval, size_t uval_byte_size)
Definition: EmulateInstruction.cpp:200
lldb::RegisterKind
RegisterKind
Register numbering types.
Definition: lldb-enumerations.h:228
lldb_private::EmulateInstruction::eContextAdjustStackPointer
@ eContextAdjustStackPointer
Definition: EmulateInstruction.h:117
lldb_private::EmulateInstruction::Context::ContextInfo::RegisterToRegisterPlusIndirectOffset::data_reg
RegisterInfo data_reg
Definition: EmulateInstruction.h:212
lldb_private::EmulateInstruction::GetRegisterInfo
virtual llvm::Optional< RegisterInfo > GetRegisterInfo(lldb::RegisterKind reg_kind, uint32_t reg_num)=0
StreamFile.h
lldb_private::EmulateInstruction::eInfoTypeImmediateSigned
@ eInfoTypeImmediateSigned
Definition: EmulateInstruction.h:176
lldb_private::EmulateInstruction::Context::info
union lldb_private::EmulateInstruction::Context::ContextInfo info
lldb_private::EmulateInstruction::Context::ContextInfo::RegisterPlusOffset::reg
RegisterInfo reg
Definition: EmulateInstruction.h:194
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:273
lldb_private::EmulateInstruction::m_read_mem_callback
ReadMemoryCallback m_read_mem_callback
Definition: EmulateInstruction.h:500
lldb_private::EmulateInstruction::Context::ContextInfo::ISAAndImmediate
struct lldb_private::EmulateInstruction::Context::ContextInfo::ISAAndImmediate ISAAndImmediate
lldb_private::UnwindPlan::Clear
void Clear()
Definition: UnwindPlan.h:508
lldb_private::Status
Definition: Status.h:44
lldb_private::EmulateInstruction::ReadRegister
llvm::Optional< RegisterValue > ReadRegister(const RegisterInfo &reg_info)
Definition: EmulateInstruction.cpp:76
uint32_t
WriteMemoryCallback
static size_t WriteMemoryCallback(EmulateInstruction *instruction, void *baton, const EmulateInstruction::Context &context, lldb::addr_t addr, const void *dst, size_t length)
Definition: NativeProcessSoftwareSingleStep.cpp:83
lldb_private::EmulateInstruction
Definition: EmulateInstruction.h:93
lldb_private::RegisterValue::SetUInt
bool SetUInt(uint64_t uint, uint32_t byte_size)
Definition: RegisterValue.cpp:727
lldb_private::EmulateInstruction::SetWriteMemCallback
void SetWriteMemCallback(WriteMemoryCallback write_mem_callback)
Definition: EmulateInstruction.cpp:237
lldb_private::Address
Definition: Address.h:59
lldb_private::DataExtractor::GetMaxU64
uint64_t GetMaxU64(lldb::offset_t *offset_ptr, size_t byte_size) const
Extract an unsigned integer of size byte_size from *offset_ptr.
Definition: DataExtractor.cpp:524
lldb_private::EmulateInstruction::Context::ContextInfo::signed_offset
int64_t signed_offset
Definition: EmulateInstruction.h:222
lldb_private::Stream::EOL
size_t EOL()
Output and End of Line character to the stream.
Definition: Stream.cpp:128
lldb_private::Address::GetLoadAddress
lldb::addr_t GetLoadAddress(Target *target) const
Get the load address.
Definition: Address.cpp:311
lldb_private::EmulateInstruction::eContextSetFramePointer
@ eContextSetFramePointer
Definition: EmulateInstruction.h:120
lldb_private::EmulateInstruction::WriteMemory
bool WriteMemory(const Context &context, lldb::addr_t addr, const void *src, size_t src_len)
Definition: EmulateInstruction.cpp:211
lldb_private::EmulateInstruction::eInfoTypeOffset
@ eInfoTypeOffset
Definition: EmulateInstruction.h:173
lldb_private::EmulateInstruction::Context::ContextInfo::RegisterRegisterOperands::operand1
RegisterInfo operand1
Definition: EmulateInstruction.h:217
lldb_private::EmulateInstruction::eContextRegisterLoad
@ eContextRegisterLoad
Definition: EmulateInstruction.h:138
lldb_private::EmulateInstruction::Context::ContextInfo::ISAAndImmediate::unsigned_data32
uint32_t unsigned_data32
Definition: EmulateInstruction.h:234
lldb_private::EmulateInstruction::eContextWriteRegisterRandomBits
@ eContextWriteRegisterRandomBits
Definition: EmulateInstruction.h:155
lldb_private::DumpRegisterValue
bool DumpRegisterValue(const RegisterValue &reg_val, Stream *s, const RegisterInfo *reg_info, bool prefix_with_name, bool prefix_with_alt_name, lldb::Format format, uint32_t reg_name_right_align_at=0, ExecutionContextScope *exe_scope=nullptr)
Definition: DumpRegisterValue.cpp:18
PluginManager.h
lldb_private::EmulateInstruction::Context::ContextInfo::address
lldb::addr_t address
Definition: EmulateInstruction.h:230
LLDB_INVALID_ADDRESS
#define LLDB_INVALID_ADDRESS
Definition: lldb-defines.h:74
DataExtractor.h
lldb_private::Stream::Printf
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition: Stream.cpp:107
lldb_private::EmulateInstruction::Context::ContextInfo::RegisterToRegisterPlusIndirectOffset::base_reg
RegisterInfo base_reg
Definition: EmulateInstruction.h:210
lldb-forward.h
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:543
lldb_private::EmulateInstruction::Context::ContextInfo::RegisterPlusOffset
struct lldb_private::EmulateInstruction::Context::ContextInfo::RegisterPlusOffset RegisterPlusOffset
lldb_private::StackFrame::CalculateProcess
lldb::ProcessSP CalculateProcess() override
Definition: StackFrame.cpp:1772
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:256
lldb_private::EmulateInstruction::eInfoTypeISA
@ eInfoTypeISA
Definition: EmulateInstruction.h:180
Status.h
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::StackFrame::GetRegisterContext
lldb::RegisterContextSP GetRegisterContext()
Get the RegisterContext for this frame, if possible.
Definition: StackFrame.cpp:1143
lldb_private::EmulateInstruction::eContextAdjustBaseRegister
@ eContextAdjustBaseRegister
Definition: EmulateInstruction.h:127
lldb_private::EmulateInstruction::m_write_mem_callback
WriteMemoryCallback m_write_mem_callback
Definition: EmulateInstruction.h:501
ReadRegisterCallback
static bool ReadRegisterCallback(EmulateInstruction *instruction, void *baton, const RegisterInfo *reg_info, RegisterValue &reg_value)
Definition: NativeProcessSoftwareSingleStep.cpp:46
ConstString.h
lldb_private::Stream::eBinary
@ eBinary
Get and put data as binary instead of as the default string mode.
Definition: Stream.h:32
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:173
lldb_private::StreamFile
Definition: StreamFile.h:22
Stream.h
lldb_private::Stream::PutCString
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Definition: Stream.cpp:63
lldb_private::EmulateInstruction::Context::ContextInfo::RegisterToRegisterPlusOffset::base_reg
RegisterInfo base_reg
Definition: EmulateInstruction.h:205
lldb_private::EmulateInstruction::Context::ContextInfo::ISAAndImmediateSigned::signed_data32
int32_t signed_data32
Definition: EmulateInstruction.h:239
lldb_private::EmulateInstruction::Context::ContextInfo::RegisterRegisterOperands::operand2
RegisterInfo operand2
Definition: EmulateInstruction.h:219
lldb_private::EmulateInstruction::Context::Dump
void Dump(Stream &s, EmulateInstruction *instruction) const
Definition: EmulateInstruction.cpp:372
lldb_private::EmulateInstruction::eContextPopRegisterOffStack
@ eContextPopRegisterOffStack
Definition: EmulateInstruction.h:114
lldb_private::StackFrame
Definition: StackFrame.h:40
lldb_private::EmulateInstruction::ReadRegisterUnsigned
uint64_t ReadRegisterUnsigned(const RegisterInfo &reg_info, uint64_t fail_value, bool *success_ptr)
Definition: EmulateInstruction.cpp:112
lldb_private::EmulateInstruction::SetReadMemCallback
void SetReadMemCallback(ReadMemoryCallback read_mem_callback)
Definition: EmulateInstruction.cpp:232
lldb_private::EmulateInstruction::eInfoTypeImmediate
@ eInfoTypeImmediate
Definition: EmulateInstruction.h:175
lldb_private::EmulateInstruction::m_addr
lldb::addr_t m_addr
Definition: EmulateInstruction.h:504
lldb_private::UnwindPlan
Definition: UnwindPlan.h:53
lldb
Definition: SBAddress.h:15
lldb_private::EmulateInstruction::eContextPushRegisterOnStack
@ eContextPushRegisterOnStack
Definition: EmulateInstruction.h:110
lldb_private::EmulateInstruction::eContextRelativeBranchImmediate
@ eContextRelativeBranchImmediate
Definition: EmulateInstruction.h:141
lldb_private::EmulateInstruction::WriteRegisterUnsigned
bool WriteRegisterUnsigned(const Context &context, const RegisterInfo &reg_info, uint64_t reg_value)
Definition: EmulateInstruction.cpp:156
RegisterContext.h
ReadMemoryCallback
static size_t ReadMemoryCallback(EmulateInstruction *instruction, void *baton, const EmulateInstruction::Context &context, lldb::addr_t addr, void *dst, size_t length)
Definition: NativeProcessSoftwareSingleStep.cpp:36
lldb_private::EmulateInstruction::WriteRegister
bool WriteRegister(const Context &context, const RegisterInfo &ref_info, const RegisterValue &reg_value)
Definition: EmulateInstruction.cpp:125
lldb::eFormatDefault
@ eFormatDefault
Definition: lldb-enumerations.h:157
lldb_private::EmulateInstruction::eContextArithmetic
@ eContextArithmetic
Definition: EmulateInstruction.h:160
lldb_private::EmulateInstruction::eContextSupervisorCall
@ eContextSupervisorCall
Definition: EmulateInstruction.h:148
lldb_private::EmulateInstruction::m_opcode
Opcode m_opcode
Definition: EmulateInstruction.h:505