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 bool EmulateInstruction::ReadRegister(const RegisterInfo *reg_info,
76  RegisterValue &reg_value) {
77  if (m_read_reg_callback != nullptr)
78  return m_read_reg_callback(this, m_baton, reg_info, reg_value);
79  return false;
80 }
81 
83  uint32_t reg_num,
84  RegisterValue &reg_value) {
85  RegisterInfo reg_info;
86  if (GetRegisterInfo(reg_kind, reg_num, reg_info))
87  return ReadRegister(&reg_info, reg_value);
88  return false;
89 }
90 
92  uint32_t reg_num,
93  uint64_t fail_value,
94  bool *success_ptr) {
95  RegisterValue reg_value;
96  if (ReadRegister(reg_kind, reg_num, reg_value))
97  return reg_value.GetAsUInt64(fail_value, success_ptr);
98  if (success_ptr)
99  *success_ptr = false;
100  return fail_value;
101 }
102 
103 uint64_t EmulateInstruction::ReadRegisterUnsigned(const RegisterInfo *reg_info,
104  uint64_t fail_value,
105  bool *success_ptr) {
106  RegisterValue reg_value;
107  if (ReadRegister(reg_info, reg_value))
108  return reg_value.GetAsUInt64(fail_value, success_ptr);
109  if (success_ptr)
110  *success_ptr = false;
111  return fail_value;
112 }
113 
115  const RegisterInfo *reg_info,
116  const RegisterValue &reg_value) {
117  if (m_write_reg_callback != nullptr)
118  return m_write_reg_callback(this, m_baton, context, reg_info, reg_value);
119  return false;
120 }
121 
123  lldb::RegisterKind reg_kind,
124  uint32_t reg_num,
125  const RegisterValue &reg_value) {
126  RegisterInfo reg_info;
127  if (GetRegisterInfo(reg_kind, reg_num, reg_info))
128  return WriteRegister(context, &reg_info, reg_value);
129  return false;
130 }
131 
133  lldb::RegisterKind reg_kind,
134  uint32_t reg_num,
135  uint64_t uint_value) {
136  RegisterInfo reg_info;
137  if (GetRegisterInfo(reg_kind, reg_num, reg_info)) {
138  RegisterValue reg_value;
139  if (reg_value.SetUInt(uint_value, reg_info.byte_size))
140  return WriteRegister(context, &reg_info, reg_value);
141  }
142  return false;
143 }
144 
146  const RegisterInfo *reg_info,
147  uint64_t uint_value) {
148  if (reg_info != nullptr) {
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  void *dst, size_t dst_len) {
158  if (m_read_mem_callback != nullptr)
159  return m_read_mem_callback(this, m_baton, context, addr, dst, dst_len) ==
160  dst_len;
161  return false;
162 }
163 
165  lldb::addr_t addr,
166  size_t byte_size,
167  uint64_t fail_value,
168  bool *success_ptr) {
169  uint64_t uval64 = 0;
170  bool success = false;
171  if (byte_size <= 8) {
172  uint8_t buf[sizeof(uint64_t)];
173  size_t bytes_read =
174  m_read_mem_callback(this, m_baton, context, addr, buf, byte_size);
175  if (bytes_read == byte_size) {
176  lldb::offset_t offset = 0;
177  DataExtractor data(buf, byte_size, GetByteOrder(), GetAddressByteSize());
178  uval64 = data.GetMaxU64(&offset, byte_size);
179  success = true;
180  }
181  }
182 
183  if (success_ptr)
184  *success_ptr = success;
185 
186  if (!success)
187  uval64 = fail_value;
188  return uval64;
189 }
190 
192  lldb::addr_t addr, uint64_t uval,
193  size_t uval_byte_size) {
195  strm.PutMaxHex64(uval, uval_byte_size);
196 
197  size_t bytes_written = m_write_mem_callback(
198  this, m_baton, context, addr, strm.GetString().data(), uval_byte_size);
199  return (bytes_written == uval_byte_size);
200 }
201 
203  const void *src, size_t src_len) {
204  if (m_write_mem_callback != nullptr)
205  return m_write_mem_callback(this, m_baton, context, addr, src, src_len) ==
206  src_len;
207  return false;
208 }
209 
210 void EmulateInstruction::SetBaton(void *baton) { m_baton = baton; }
211 
213  ReadMemoryCallback read_mem_callback,
214  WriteMemoryCallback write_mem_callback,
215  ReadRegisterCallback read_reg_callback,
216  WriteRegisterCallback write_reg_callback) {
217  m_read_mem_callback = read_mem_callback;
218  m_write_mem_callback = write_mem_callback;
219  m_read_reg_callback = read_reg_callback;
220  m_write_reg_callback = write_reg_callback;
221 }
222 
224  ReadMemoryCallback read_mem_callback) {
225  m_read_mem_callback = read_mem_callback;
226 }
227 
229  WriteMemoryCallback write_mem_callback) {
230  m_write_mem_callback = write_mem_callback;
231 }
232 
234  ReadRegisterCallback read_reg_callback) {
235  m_read_reg_callback = read_reg_callback;
236 }
237 
239  WriteRegisterCallback write_reg_callback) {
240  m_write_reg_callback = write_reg_callback;
241 }
242 
243 //
244 // Read & Write Memory and Registers callback functions.
245 //
246 
248  void *baton, const Context &context,
249  lldb::addr_t addr, void *dst,
250  size_t dst_len) {
251  if (baton == nullptr || dst == nullptr || dst_len == 0)
252  return 0;
253 
254  StackFrame *frame = (StackFrame *)baton;
255 
256  ProcessSP process_sp(frame->CalculateProcess());
257  if (process_sp) {
258  Status error;
259  return process_sp->ReadMemory(addr, dst, dst_len, error);
260  }
261  return 0;
262 }
263 
265  void *baton, const Context &context,
266  lldb::addr_t addr, const void *src,
267  size_t src_len) {
268  if (baton == nullptr || src == nullptr || src_len == 0)
269  return 0;
270 
271  StackFrame *frame = (StackFrame *)baton;
272 
273  ProcessSP process_sp(frame->CalculateProcess());
274  if (process_sp) {
275  Status error;
276  return process_sp->WriteMemory(addr, src, src_len, error);
277  }
278 
279  return 0;
280 }
281 
283  void *baton,
284  const RegisterInfo *reg_info,
285  RegisterValue &reg_value) {
286  if (baton == nullptr)
287  return false;
288 
289  StackFrame *frame = (StackFrame *)baton;
290  return frame->GetRegisterContext()->ReadRegister(reg_info, reg_value);
291 }
292 
294  void *baton, const Context &context,
295  const RegisterInfo *reg_info,
296  const RegisterValue &reg_value) {
297  if (baton == nullptr)
298  return false;
299 
300  StackFrame *frame = (StackFrame *)baton;
301  return frame->GetRegisterContext()->WriteRegister(reg_info, reg_value);
302 }
303 
305  void *baton,
306  const Context &context,
307  lldb::addr_t addr, void *dst,
308  size_t length) {
309  StreamFile strm(stdout, false);
310  strm.Printf(" Read from Memory (address = 0x%" PRIx64 ", length = %" PRIu64
311  ", context = ",
312  addr, (uint64_t)length);
313  context.Dump(strm, instruction);
314  strm.EOL();
315  *((uint64_t *)dst) = 0xdeadbeef;
316  return length;
317 }
318 
320  void *baton,
321  const Context &context,
322  lldb::addr_t addr,
323  const void *dst, size_t length) {
324  StreamFile strm(stdout, false);
325  strm.Printf(" Write to Memory (address = 0x%" PRIx64 ", length = %" PRIu64
326  ", context = ",
327  addr, (uint64_t)length);
328  context.Dump(strm, instruction);
329  strm.EOL();
330  return length;
331 }
332 
334  void *baton,
335  const RegisterInfo *reg_info,
336  RegisterValue &reg_value) {
337  StreamFile strm(stdout, false);
338  strm.Printf(" Read Register (%s)\n", reg_info->name);
339  lldb::RegisterKind reg_kind;
340  uint32_t reg_num;
341  if (GetBestRegisterKindAndNumber(reg_info, reg_kind, reg_num))
342  reg_value.SetUInt64((uint64_t)reg_kind << 24 | reg_num);
343  else
344  reg_value.SetUInt64(0);
345 
346  return true;
347 }
348 
350  void *baton,
351  const Context &context,
352  const RegisterInfo *reg_info,
353  const RegisterValue &reg_value) {
354  StreamFile strm(stdout, false);
355  strm.Printf(" Write to Register (name = %s, value = ", reg_info->name);
356  DumpRegisterValue(reg_value, &strm, reg_info, false, false, eFormatDefault);
357  strm.PutCString(", context = ");
358  context.Dump(strm, instruction);
359  strm.EOL();
360  return true;
361 }
362 
364  EmulateInstruction *instruction) const {
365  switch (type) {
366  case eContextReadOpcode:
367  strm.PutCString("reading opcode");
368  break;
369 
370  case eContextImmediate:
371  strm.PutCString("immediate");
372  break;
373 
375  strm.PutCString("push register");
376  break;
377 
379  strm.PutCString("pop register");
380  break;
381 
383  strm.PutCString("adjust sp");
384  break;
385 
387  strm.PutCString("set frame pointer");
388  break;
389 
391  strm.PutCString("adjusting (writing value back to) a base register");
392  break;
393 
395  strm.PutCString("register + offset");
396  break;
397 
399  strm.PutCString("store register");
400  break;
401 
403  strm.PutCString("load register");
404  break;
405 
407  strm.PutCString("relative branch immediate");
408  break;
409 
411  strm.PutCString("absolute branch register");
412  break;
413 
415  strm.PutCString("supervisor call");
416  break;
417 
419  strm.PutCString("table branch read memory");
420  break;
421 
423  strm.PutCString("write random bits to a register");
424  break;
425 
427  strm.PutCString("write random bits to a memory address");
428  break;
429 
430  case eContextArithmetic:
431  strm.PutCString("arithmetic");
432  break;
433 
435  strm.PutCString("return from exception");
436  break;
437 
438  default:
439  strm.PutCString("unrecognized context.");
440  break;
441  }
442 
443  switch (info_type) {
445  strm.Printf(" (reg_plus_offset = %s%+" PRId64 ")",
446  info.RegisterPlusOffset.reg.name,
447  info.RegisterPlusOffset.signed_offset);
448  break;
449 
451  strm.Printf(" (reg_plus_reg = %s + %s)",
452  info.RegisterPlusIndirectOffset.base_reg.name,
453  info.RegisterPlusIndirectOffset.offset_reg.name);
454  break;
455 
457  strm.Printf(" (base_and_imm_offset = %s%+" PRId64 ", data_reg = %s)",
458  info.RegisterToRegisterPlusOffset.base_reg.name,
459  info.RegisterToRegisterPlusOffset.offset,
460  info.RegisterToRegisterPlusOffset.data_reg.name);
461  break;
462 
464  strm.Printf(" (base_and_reg_offset = %s + %s, data_reg = %s)",
465  info.RegisterToRegisterPlusIndirectOffset.base_reg.name,
466  info.RegisterToRegisterPlusIndirectOffset.offset_reg.name,
467  info.RegisterToRegisterPlusIndirectOffset.data_reg.name);
468  break;
469 
471  strm.Printf(" (register to register binary op: %s and %s)",
472  info.RegisterRegisterOperands.operand1.name,
473  info.RegisterRegisterOperands.operand2.name);
474  break;
475 
476  case eInfoTypeOffset:
477  strm.Printf(" (signed_offset = %+" PRId64 ")", info.signed_offset);
478  break;
479 
480  case eInfoTypeRegister:
481  strm.Printf(" (reg = %s)", info.reg.name);
482  break;
483 
484  case eInfoTypeImmediate:
485  strm.Printf(" (unsigned_immediate = %" PRIu64 " (0x%16.16" PRIx64 "))",
486  info.unsigned_immediate, info.unsigned_immediate);
487  break;
488 
490  strm.Printf(" (signed_immediate = %+" PRId64 " (0x%16.16" PRIx64 "))",
491  info.signed_immediate, info.signed_immediate);
492  break;
493 
494  case eInfoTypeAddress:
495  strm.Printf(" (address = 0x%" PRIx64 ")", info.address);
496  break;
497 
499  strm.Printf(" (isa = %u, unsigned_immediate = %u (0x%8.8x))",
500  info.ISAAndImmediate.isa, info.ISAAndImmediate.unsigned_data32,
501  info.ISAAndImmediate.unsigned_data32);
502  break;
503 
505  strm.Printf(" (isa = %u, signed_immediate = %i (0x%8.8x))",
506  info.ISAAndImmediateSigned.isa,
507  info.ISAAndImmediateSigned.signed_data32,
508  info.ISAAndImmediateSigned.signed_data32);
509  break;
510 
511  case eInfoTypeISA:
512  strm.Printf(" (isa = %u)", info.isa);
513  break;
514 
515  case eInfoTypeNoArgs:
516  break;
517  }
518 }
519 
521  const Address &inst_addr,
522  Target *target) {
523  m_opcode = opcode;
525  if (inst_addr.IsValid()) {
526  if (target != nullptr)
527  m_addr = inst_addr.GetLoadAddress(target);
529  m_addr = inst_addr.GetFileAddress();
530  }
531  return true;
532 }
533 
535  const RegisterInfo *reg_info, lldb::RegisterKind &reg_kind,
536  uint32_t &reg_num) {
537  // Generic and DWARF should be the two most popular register kinds when
538  // emulating instructions since they are the most platform agnostic...
539  reg_num = reg_info->kinds[eRegisterKindGeneric];
540  if (reg_num != LLDB_INVALID_REGNUM) {
541  reg_kind = eRegisterKindGeneric;
542  return true;
543  }
544 
545  reg_num = reg_info->kinds[eRegisterKindDWARF];
546  if (reg_num != LLDB_INVALID_REGNUM) {
547  reg_kind = eRegisterKindDWARF;
548  return true;
549  }
550 
551  reg_num = reg_info->kinds[eRegisterKindLLDB];
552  if (reg_num != LLDB_INVALID_REGNUM) {
553  reg_kind = eRegisterKindLLDB;
554  return true;
555  }
556 
557  reg_num = reg_info->kinds[eRegisterKindEHFrame];
558  if (reg_num != LLDB_INVALID_REGNUM) {
559  reg_kind = eRegisterKindEHFrame;
560  return true;
561  }
562 
563  reg_num = reg_info->kinds[eRegisterKindProcessPlugin];
564  if (reg_num != LLDB_INVALID_REGNUM) {
565  reg_kind = eRegisterKindProcessPlugin;
566  return true;
567  }
568  return false;
569 }
570 
571 uint32_t
573  const RegisterInfo &reg_info) {
574  lldb::RegisterKind reg_kind;
575  uint32_t reg_num;
576  if (reg_ctx && GetBestRegisterKindAndNumber(&reg_info, reg_kind, reg_num))
577  return reg_ctx->ConvertRegisterKindToRegisterNumber(reg_kind, reg_num);
578  return LLDB_INVALID_REGNUM;
579 }
580 
582  unwind_plan.Clear();
583  return false;
584 }
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::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
Definition: ArchSpec.h:33
LLDB_INVALID_REGNUM
#define LLDB_INVALID_REGNUM
Definition: lldb-defines.h:91
lldb_private::Address::IsValid
bool IsValid() const
Check if the object state is valid.
Definition: Address.h:336
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::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::eRegisterKindDWARF
@ eRegisterKindDWARF
the register numbers seen DWARF
Definition: lldb-enumerations.h:229
lldb_private::EmulateInstruction::eInfoTypeRegisterPlusIndirectOffset
@ eInfoTypeRegisterPlusIndirectOffset
Definition: EmulateInstruction.h:169
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::eRegisterKindGeneric
@ eRegisterKindGeneric
insn ptr reg, stack ptr reg, etc not specific to any particular target
Definition: lldb-enumerations.h:230
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::eInfoTypeAddress
@ eInfoTypeAddress
Definition: EmulateInstruction.h:177
lldb-private-interfaces.h
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
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::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::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: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::Target
Definition: Target.h:451
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::RegisterValue::GetAsUInt64
uint64_t GetAsUInt64(uint64_t fail_value=UINT64_MAX, bool *success_ptr=nullptr) const
Definition: RegisterValue.cpp:563
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
DumpRegisterValue.h
lldb::eRegisterKindEHFrame
@ eRegisterKindEHFrame
the register numbers seen in eh_frame
Definition: lldb-enumerations.h:228
lldb_private::EmulateInstruction::m_baton
void * m_baton
Definition: EmulateInstruction.h:492
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:426
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
EmulateInstruction.h
lldb_private::EmulateInstruction::eInfoTypeRegisterToRegisterPlusOffset
@ eInfoTypeRegisterToRegisterPlusOffset
Definition: EmulateInstruction.h:170
lldb::eRegisterKindLLDB
@ eRegisterKindLLDB
lldb's internal register numbers
Definition: lldb-enumerations.h:234
lldb_private::EmulateInstruction::eInfoTypeISAAndImmediate
@ eInfoTypeISAAndImmediate
Definition: EmulateInstruction.h:178
lldb_private::DataExtractor
Definition: DataExtractor.h:48
lldb::eRegisterKindProcessPlugin
@ eRegisterKindProcessPlugin
num used by the process plugin - e.g.
Definition: lldb-enumerations.h:232
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
StreamString.h
lldb_private::Address::GetFileAddress
lldb::addr_t GetFileAddress() const
Get the file address.
Definition: Address.cpp:290
lldb_private::StreamString
Definition: StreamString.h:23
lldb_private::EmulateInstruction::m_write_reg_callback
WriteRegisterCallback m_write_reg_callback
Definition: EmulateInstruction.h:496
lldb_private::EmulateInstruction::SetBaton
void SetBaton(void *baton)
Definition: EmulateInstruction.cpp:210
lldb_private::EmulateInstruction::eInfoTypeISAAndImmediateSigned
@ eInfoTypeISAAndImmediateSigned
Definition: EmulateInstruction.h:179
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)
Definition: DumpRegisterValue.cpp:18
lldb_private::EmulateInstruction::SetWriteRegCallback
void SetWriteRegCallback(WriteRegisterCallback write_reg_callback)
Definition: EmulateInstruction.cpp:238
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:191
lldb::RegisterKind
RegisterKind
Register numbering types.
Definition: lldb-enumerations.h:227
lldb_private::EmulateInstruction::eContextAdjustStackPointer
@ eContextAdjustStackPointer
Definition: EmulateInstruction.h:117
StreamFile.h
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::UnwindPlan::Clear
void Clear()
Definition: UnwindPlan.h:510
lldb_private::Status
Definition: Status.h:44
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:734
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::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:526
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:310
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:202
lldb_private::EmulateInstruction::eInfoTypeOffset
@ eInfoTypeOffset
Definition: EmulateInstruction.h:173
lldb_private::EmulateInstruction::eContextRegisterLoad
@ eContextRegisterLoad
Definition: EmulateInstruction.h:138
lldb_private::EmulateInstruction::eContextWriteRegisterRandomBits
@ eContextWriteRegisterRandomBits
Definition: EmulateInstruction.h:155
PluginManager.h
LLDB_INVALID_ADDRESS
#define LLDB_INVALID_ADDRESS
Definition: lldb-defines.h:86
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-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:534
lldb_private::StackFrame::CalculateProcess
lldb::ProcessSP CalculateProcess() override
Definition: StackFrame.cpp:1743
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::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:1123
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
ReadRegisterCallback
static bool ReadRegisterCallback(EmulateInstruction *instruction, void *baton, const RegisterInfo *reg_info, RegisterValue &reg_value)
Definition: NativeProcessSoftwareSingleStep.cpp:46
ConstString.h
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::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::Dump
void Dump(Stream &s, EmulateInstruction *instruction) const
Definition: EmulateInstruction.cpp:363
lldb_private::EmulateInstruction::eContextPopRegisterOffStack
@ eContextPopRegisterOffStack
Definition: EmulateInstruction.h:114
lldb_private::StackFrame
Definition: StackFrame.h:40
lldb_private::EmulateInstruction::ReadRegister
bool ReadRegister(const RegisterInfo *reg_info, RegisterValue &reg_value)
Definition: EmulateInstruction.cpp:75
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
Definition: SBAddress.h:15
lldb_private::EmulateInstruction::eContextPushRegisterOnStack
@ eContextPushRegisterOnStack
Definition: EmulateInstruction.h:110
lldb_private::EmulateInstruction::eContextRelativeBranchImmediate
@ eContextRelativeBranchImmediate
Definition: EmulateInstruction.h:141
RegisterContext.h
lldb_private::EmulateInstruction::GetRegisterInfo
virtual bool GetRegisterInfo(lldb::RegisterKind reg_kind, uint32_t reg_num, RegisterInfo &reg_info)=0
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::eFormatDefault
@ eFormatDefault
Definition: lldb-enumerations.h:156
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:498
lldb_private::EmulateInstruction::Context::info_type
enum InfoType info_type
Definition: EmulateInstruction.h:186