LLDB  mainline
CommandObjectMemory.cpp
Go to the documentation of this file.
1 //===-- CommandObjectMemory.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 
9 #include "CommandObjectMemory.h"
10 #include "CommandObjectMemoryTag.h"
12 #include "lldb/Core/Section.h"
15 #include "lldb/Host/OptionParser.h"
26 #include "lldb/Symbol/SymbolFile.h"
27 #include "lldb/Symbol/TypeList.h"
28 #include "lldb/Target/ABI.h"
29 #include "lldb/Target/Language.h"
32 #include "lldb/Target/Process.h"
33 #include "lldb/Target/StackFrame.h"
34 #include "lldb/Target/Target.h"
35 #include "lldb/Target/Thread.h"
36 #include "lldb/Utility/Args.h"
39 #include "llvm/Support/MathExtras.h"
40 #include <cinttypes>
41 #include <memory>
42 
43 using namespace lldb;
44 using namespace lldb_private;
45 
46 #define LLDB_OPTIONS_memory_read
47 #include "CommandOptions.inc"
48 
50 public:
52  : m_num_per_line(1, 1), m_offset(0, 0),
53  m_language_for_type(eLanguageTypeUnknown) {}
54 
55  ~OptionGroupReadMemory() override = default;
56 
57  llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
58  return llvm::makeArrayRef(g_memory_read_options);
59  }
60 
61  Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_value,
62  ExecutionContext *execution_context) override {
63  Status error;
64  const int short_option = g_memory_read_options[option_idx].short_option;
65 
66  switch (short_option) {
67  case 'l':
68  error = m_num_per_line.SetValueFromString(option_value);
69  if (m_num_per_line.GetCurrentValue() == 0)
70  error.SetErrorStringWithFormat(
71  "invalid value for --num-per-line option '%s'",
72  option_value.str().c_str());
73  break;
74 
75  case 'b':
76  m_output_as_binary = true;
77  break;
78 
79  case 't':
80  error = m_view_as_type.SetValueFromString(option_value);
81  break;
82 
83  case 'r':
84  m_force = true;
85  break;
86 
87  case 'x':
88  error = m_language_for_type.SetValueFromString(option_value);
89  break;
90 
91  case 'E':
92  error = m_offset.SetValueFromString(option_value);
93  break;
94 
95  default:
96  llvm_unreachable("Unimplemented option");
97  }
98  return error;
99  }
100 
101  void OptionParsingStarting(ExecutionContext *execution_context) override {
102  m_num_per_line.Clear();
103  m_output_as_binary = false;
104  m_view_as_type.Clear();
105  m_force = false;
106  m_offset.Clear();
107  m_language_for_type.Clear();
108  }
109 
110  Status FinalizeSettings(Target *target, OptionGroupFormat &format_options) {
111  Status error;
112  OptionValueUInt64 &byte_size_value = format_options.GetByteSizeValue();
113  OptionValueUInt64 &count_value = format_options.GetCountValue();
114  const bool byte_size_option_set = byte_size_value.OptionWasSet();
115  const bool num_per_line_option_set = m_num_per_line.OptionWasSet();
116  const bool count_option_set = format_options.GetCountValue().OptionWasSet();
117 
118  switch (format_options.GetFormat()) {
119  default:
120  break;
121 
122  case eFormatBoolean:
123  if (!byte_size_option_set)
124  byte_size_value = 1;
125  if (!num_per_line_option_set)
126  m_num_per_line = 1;
127  if (!count_option_set)
128  format_options.GetCountValue() = 8;
129  break;
130 
131  case eFormatCString:
132  break;
133 
134  case eFormatInstruction:
135  if (count_option_set)
136  byte_size_value = target->GetArchitecture().GetMaximumOpcodeByteSize();
137  m_num_per_line = 1;
138  break;
139 
140  case eFormatAddressInfo:
141  if (!byte_size_option_set)
142  byte_size_value = target->GetArchitecture().GetAddressByteSize();
143  m_num_per_line = 1;
144  if (!count_option_set)
145  format_options.GetCountValue() = 8;
146  break;
147 
148  case eFormatPointer:
149  byte_size_value = target->GetArchitecture().GetAddressByteSize();
150  if (!num_per_line_option_set)
151  m_num_per_line = 4;
152  if (!count_option_set)
153  format_options.GetCountValue() = 8;
154  break;
155 
156  case eFormatBinary:
157  case eFormatFloat:
158  case eFormatOctal:
159  case eFormatDecimal:
160  case eFormatEnum:
161  case eFormatUnicode8:
162  case eFormatUnicode16:
163  case eFormatUnicode32:
164  case eFormatUnsigned:
165  case eFormatHexFloat:
166  if (!byte_size_option_set)
167  byte_size_value = 4;
168  if (!num_per_line_option_set)
169  m_num_per_line = 1;
170  if (!count_option_set)
171  format_options.GetCountValue() = 8;
172  break;
173 
174  case eFormatBytes:
176  if (byte_size_option_set) {
177  if (byte_size_value > 1)
178  error.SetErrorStringWithFormat(
179  "display format (bytes/bytes with ASCII) conflicts with the "
180  "specified byte size %" PRIu64 "\n"
181  "\tconsider using a different display format or don't specify "
182  "the byte size.",
183  byte_size_value.GetCurrentValue());
184  } else
185  byte_size_value = 1;
186  if (!num_per_line_option_set)
187  m_num_per_line = 16;
188  if (!count_option_set)
189  format_options.GetCountValue() = 32;
190  break;
191 
192  case eFormatCharArray:
193  case eFormatChar:
195  if (!byte_size_option_set)
196  byte_size_value = 1;
197  if (!num_per_line_option_set)
198  m_num_per_line = 32;
199  if (!count_option_set)
200  format_options.GetCountValue() = 64;
201  break;
202 
203  case eFormatComplex:
204  if (!byte_size_option_set)
205  byte_size_value = 8;
206  if (!num_per_line_option_set)
207  m_num_per_line = 1;
208  if (!count_option_set)
209  format_options.GetCountValue() = 8;
210  break;
211 
213  if (!byte_size_option_set)
214  byte_size_value = 8;
215  if (!num_per_line_option_set)
216  m_num_per_line = 1;
217  if (!count_option_set)
218  format_options.GetCountValue() = 8;
219  break;
220 
221  case eFormatHex:
222  if (!byte_size_option_set)
223  byte_size_value = 4;
224  if (!num_per_line_option_set) {
225  switch (byte_size_value) {
226  case 1:
227  case 2:
228  m_num_per_line = 8;
229  break;
230  case 4:
231  m_num_per_line = 4;
232  break;
233  case 8:
234  m_num_per_line = 2;
235  break;
236  default:
237  m_num_per_line = 1;
238  break;
239  }
240  }
241  if (!count_option_set)
242  count_value = 8;
243  break;
244 
245  case eFormatVectorOfChar:
258  if (!byte_size_option_set)
259  byte_size_value = 128;
260  if (!num_per_line_option_set)
261  m_num_per_line = 1;
262  if (!count_option_set)
263  count_value = 4;
264  break;
265  }
266  return error;
267  }
268 
269  bool AnyOptionWasSet() const {
270  return m_num_per_line.OptionWasSet() || m_output_as_binary ||
271  m_view_as_type.OptionWasSet() || m_offset.OptionWasSet() ||
272  m_language_for_type.OptionWasSet();
273  }
274 
276  bool m_output_as_binary = false;
278  bool m_force = false;
281 };
282 
283 // Read memory from the inferior process
285 public:
288  interpreter, "memory read",
289  "Read from the memory of the current target process.", nullptr,
290  eCommandRequiresTarget | eCommandProcessMustBePaused),
291  m_format_options(eFormatBytesWithASCII, 1, 8),
292  m_memory_tag_options(/*note_binary=*/true),
293  m_prev_format_options(eFormatBytesWithASCII, 1, 8) {
296  CommandArgumentData start_addr_arg;
297  CommandArgumentData end_addr_arg;
298 
299  // Define the first (and only) variant of this arg.
300  start_addr_arg.arg_type = eArgTypeAddressOrExpression;
301  start_addr_arg.arg_repetition = eArgRepeatPlain;
302 
303  // There is only one variant this argument could be; put it into the
304  // argument entry.
305  arg1.push_back(start_addr_arg);
306 
307  // Define the first (and only) variant of this arg.
308  end_addr_arg.arg_type = eArgTypeAddressOrExpression;
309  end_addr_arg.arg_repetition = eArgRepeatOptional;
310 
311  // There is only one variant this argument could be; put it into the
312  // argument entry.
313  arg2.push_back(end_addr_arg);
314 
315  // Push the data for the first argument into the m_arguments vector.
316  m_arguments.push_back(arg1);
317  m_arguments.push_back(arg2);
318 
319  // Add the "--format" and "--count" options to group 1 and 3
320  m_option_group.Append(&m_format_options,
321  OptionGroupFormat::OPTION_GROUP_FORMAT |
322  OptionGroupFormat::OPTION_GROUP_COUNT,
324  m_option_group.Append(&m_format_options,
325  OptionGroupFormat::OPTION_GROUP_GDB_FMT,
327  // Add the "--size" option to group 1 and 2
328  m_option_group.Append(&m_format_options,
329  OptionGroupFormat::OPTION_GROUP_SIZE,
331  m_option_group.Append(&m_memory_options);
332  m_option_group.Append(&m_outfile_options, LLDB_OPT_SET_ALL,
334  m_option_group.Append(&m_varobj_options, LLDB_OPT_SET_ALL, LLDB_OPT_SET_3);
335  m_option_group.Append(&m_memory_tag_options, LLDB_OPT_SET_ALL,
337  m_option_group.Finalize();
338  }
339 
340  ~CommandObjectMemoryRead() override = default;
341 
342  Options *GetOptions() override { return &m_option_group; }
343 
344  llvm::Optional<std::string> GetRepeatCommand(Args &current_command_args,
345  uint32_t index) override {
346  return m_cmd_name;
347  }
348 
349 protected:
350  bool DoExecute(Args &command, CommandReturnObject &result) override {
351  // No need to check "target" for validity as eCommandRequiresTarget ensures
352  // it is valid
353  Target *target = m_exe_ctx.GetTargetPtr();
354 
355  const size_t argc = command.GetArgumentCount();
356 
357  if ((argc == 0 && m_next_addr == LLDB_INVALID_ADDRESS) || argc > 2) {
358  result.AppendErrorWithFormat("%s takes a start address expression with "
359  "an optional end address expression.\n",
360  m_cmd_name.c_str());
361  result.AppendWarning("Expressions should be quoted if they contain "
362  "spaces or other special characters.");
363  return false;
364  }
365 
366  CompilerType compiler_type;
367  Status error;
368 
369  const char *view_as_type_cstr =
370  m_memory_options.m_view_as_type.GetCurrentValue();
371  if (view_as_type_cstr && view_as_type_cstr[0]) {
372  // We are viewing memory as a type
373 
374  const bool exact_match = false;
375  TypeList type_list;
376  uint32_t reference_count = 0;
377  uint32_t pointer_count = 0;
378  size_t idx;
379 
380 #define ALL_KEYWORDS \
381  KEYWORD("const") \
382  KEYWORD("volatile") \
383  KEYWORD("restrict") \
384  KEYWORD("struct") \
385  KEYWORD("class") \
386  KEYWORD("union")
387 
388 #define KEYWORD(s) s,
389  static const char *g_keywords[] = {ALL_KEYWORDS};
390 #undef KEYWORD
391 
392 #define KEYWORD(s) (sizeof(s) - 1),
393  static const int g_keyword_lengths[] = {ALL_KEYWORDS};
394 #undef KEYWORD
395 
396 #undef ALL_KEYWORDS
397 
398  static size_t g_num_keywords = sizeof(g_keywords) / sizeof(const char *);
399  std::string type_str(view_as_type_cstr);
400 
401  // Remove all instances of g_keywords that are followed by spaces
402  for (size_t i = 0; i < g_num_keywords; ++i) {
403  const char *keyword = g_keywords[i];
404  int keyword_len = g_keyword_lengths[i];
405 
406  idx = 0;
407  while ((idx = type_str.find(keyword, idx)) != std::string::npos) {
408  if (type_str[idx + keyword_len] == ' ' ||
409  type_str[idx + keyword_len] == '\t') {
410  type_str.erase(idx, keyword_len + 1);
411  idx = 0;
412  } else {
413  idx += keyword_len;
414  }
415  }
416  }
417  bool done = type_str.empty();
418  //
419  idx = type_str.find_first_not_of(" \t");
420  if (idx > 0 && idx != std::string::npos)
421  type_str.erase(0, idx);
422  while (!done) {
423  // Strip trailing spaces
424  if (type_str.empty())
425  done = true;
426  else {
427  switch (type_str[type_str.size() - 1]) {
428  case '*':
429  ++pointer_count;
430  [[fallthrough]];
431  case ' ':
432  case '\t':
433  type_str.erase(type_str.size() - 1);
434  break;
435 
436  case '&':
437  if (reference_count == 0) {
438  reference_count = 1;
439  type_str.erase(type_str.size() - 1);
440  } else {
441  result.AppendErrorWithFormat("invalid type string: '%s'\n",
442  view_as_type_cstr);
443  return false;
444  }
445  break;
446 
447  default:
448  done = true;
449  break;
450  }
451  }
452  }
453 
454  llvm::DenseSet<lldb_private::SymbolFile *> searched_symbol_files;
455  ConstString lookup_type_name(type_str.c_str());
456  StackFrame *frame = m_exe_ctx.GetFramePtr();
457  ModuleSP search_first;
458  if (frame) {
459  search_first = frame->GetSymbolContext(eSymbolContextModule).module_sp;
460  }
461  target->GetImages().FindTypes(search_first.get(), lookup_type_name,
462  exact_match, 1, searched_symbol_files,
463  type_list);
464 
465  if (type_list.GetSize() == 0 && lookup_type_name.GetCString()) {
466  LanguageType language_for_type =
467  m_memory_options.m_language_for_type.GetCurrentValue();
468  std::set<LanguageType> languages_to_check;
469  if (language_for_type != eLanguageTypeUnknown) {
470  languages_to_check.insert(language_for_type);
471  } else {
472  languages_to_check = Language::GetSupportedLanguages();
473  }
474 
475  std::set<CompilerType> user_defined_types;
476  for (auto lang : languages_to_check) {
477  if (auto *persistent_vars =
479  if (llvm::Optional<CompilerType> type =
480  persistent_vars->GetCompilerTypeFromPersistentDecl(
481  lookup_type_name)) {
482  user_defined_types.emplace(*type);
483  }
484  }
485  }
486 
487  if (user_defined_types.size() > 1) {
488  result.AppendErrorWithFormat(
489  "Mutiple types found matching raw type '%s', please disambiguate "
490  "by specifying the language with -x",
491  lookup_type_name.GetCString());
492  return false;
493  }
494 
495  if (user_defined_types.size() == 1) {
496  compiler_type = *user_defined_types.begin();
497  }
498  }
499 
500  if (!compiler_type.IsValid()) {
501  if (type_list.GetSize() == 0) {
502  result.AppendErrorWithFormat("unable to find any types that match "
503  "the raw type '%s' for full type '%s'\n",
504  lookup_type_name.GetCString(),
505  view_as_type_cstr);
506  return false;
507  } else {
508  TypeSP type_sp(type_list.GetTypeAtIndex(0));
509  compiler_type = type_sp->GetFullCompilerType();
510  }
511  }
512 
513  while (pointer_count > 0) {
514  CompilerType pointer_type = compiler_type.GetPointerType();
515  if (pointer_type.IsValid())
516  compiler_type = pointer_type;
517  else {
518  result.AppendError("unable make a pointer type\n");
519  return false;
520  }
521  --pointer_count;
522  }
523 
524  llvm::Optional<uint64_t> size = compiler_type.GetByteSize(nullptr);
525  if (!size) {
526  result.AppendErrorWithFormat(
527  "unable to get the byte size of the type '%s'\n",
528  view_as_type_cstr);
529  return false;
530  }
531  m_format_options.GetByteSizeValue() = *size;
532 
533  if (!m_format_options.GetCountValue().OptionWasSet())
534  m_format_options.GetCountValue() = 1;
535  } else {
536  error = m_memory_options.FinalizeSettings(target, m_format_options);
537  }
538 
539  // Look for invalid combinations of settings
540  if (error.Fail()) {
541  result.AppendError(error.AsCString());
542  return false;
543  }
544 
545  lldb::addr_t addr;
546  size_t total_byte_size = 0;
547  if (argc == 0) {
548  // Use the last address and byte size and all options as they were if no
549  // options have been set
550  addr = m_next_addr;
551  total_byte_size = m_prev_byte_size;
552  compiler_type = m_prev_compiler_type;
553  if (!m_format_options.AnyOptionWasSet() &&
554  !m_memory_options.AnyOptionWasSet() &&
555  !m_outfile_options.AnyOptionWasSet() &&
556  !m_varobj_options.AnyOptionWasSet() &&
557  !m_memory_tag_options.AnyOptionWasSet()) {
558  m_format_options = m_prev_format_options;
559  m_memory_options = m_prev_memory_options;
560  m_outfile_options = m_prev_outfile_options;
561  m_varobj_options = m_prev_varobj_options;
562  m_memory_tag_options = m_prev_memory_tag_options;
563  }
564  }
565 
566  size_t item_count = m_format_options.GetCountValue().GetCurrentValue();
567 
568  // TODO For non-8-bit byte addressable architectures this needs to be
569  // revisited to fully support all lldb's range of formatting options.
570  // Furthermore code memory reads (for those architectures) will not be
571  // correctly formatted even w/o formatting options.
572  size_t item_byte_size =
573  target->GetArchitecture().GetDataByteSize() > 1
574  ? target->GetArchitecture().GetDataByteSize()
575  : m_format_options.GetByteSizeValue().GetCurrentValue();
576 
577  const size_t num_per_line =
578  m_memory_options.m_num_per_line.GetCurrentValue();
579 
580  if (total_byte_size == 0) {
581  total_byte_size = item_count * item_byte_size;
582  if (total_byte_size == 0)
583  total_byte_size = 32;
584  }
585 
586  if (argc > 0)
587  addr = OptionArgParser::ToAddress(&m_exe_ctx, command[0].ref(),
589 
590  if (addr == LLDB_INVALID_ADDRESS) {
591  result.AppendError("invalid start address expression.");
592  result.AppendError(error.AsCString());
593  return false;
594  }
595 
596  ABISP abi;
597  if (Process *proc = m_exe_ctx.GetProcessPtr())
598  abi = proc->GetABI();
599 
600  if (abi)
601  addr = abi->FixDataAddress(addr);
602 
603  if (argc == 2) {
604  lldb::addr_t end_addr = OptionArgParser::ToAddress(
605  &m_exe_ctx, command[1].ref(), LLDB_INVALID_ADDRESS, nullptr);
606  if (end_addr != LLDB_INVALID_ADDRESS && abi)
607  end_addr = abi->FixDataAddress(end_addr);
608 
609  if (end_addr == LLDB_INVALID_ADDRESS) {
610  result.AppendError("invalid end address expression.");
611  result.AppendError(error.AsCString());
612  return false;
613  } else if (end_addr <= addr) {
614  result.AppendErrorWithFormat(
615  "end address (0x%" PRIx64
616  ") must be greater than the start address (0x%" PRIx64 ").\n",
617  end_addr, addr);
618  return false;
619  } else if (m_format_options.GetCountValue().OptionWasSet()) {
620  result.AppendErrorWithFormat(
621  "specify either the end address (0x%" PRIx64
622  ") or the count (--count %" PRIu64 "), not both.\n",
623  end_addr, (uint64_t)item_count);
624  return false;
625  }
626 
627  total_byte_size = end_addr - addr;
628  item_count = total_byte_size / item_byte_size;
629  }
630 
631  uint32_t max_unforced_size = target->GetMaximumMemReadSize();
632 
633  if (total_byte_size > max_unforced_size && !m_memory_options.m_force) {
634  result.AppendErrorWithFormat(
635  "Normally, \'memory read\' will not read over %" PRIu32
636  " bytes of data.\n",
637  max_unforced_size);
638  result.AppendErrorWithFormat(
639  "Please use --force to override this restriction just once.\n");
640  result.AppendErrorWithFormat("or set target.max-memory-read-size if you "
641  "will often need a larger limit.\n");
642  return false;
643  }
644 
645  WritableDataBufferSP data_sp;
646  size_t bytes_read = 0;
647  if (compiler_type.GetOpaqueQualType()) {
648  // Make sure we don't display our type as ASCII bytes like the default
649  // memory read
650  if (!m_format_options.GetFormatValue().OptionWasSet())
651  m_format_options.GetFormatValue().SetCurrentValue(eFormatDefault);
652 
653  llvm::Optional<uint64_t> size = compiler_type.GetByteSize(nullptr);
654  if (!size) {
655  result.AppendError("can't get size of type");
656  return false;
657  }
658  bytes_read = *size * m_format_options.GetCountValue().GetCurrentValue();
659 
660  if (argc > 0)
661  addr = addr + (*size * m_memory_options.m_offset.GetCurrentValue());
662  } else if (m_format_options.GetFormatValue().GetCurrentValue() !=
663  eFormatCString) {
664  data_sp = std::make_shared<DataBufferHeap>(total_byte_size, '\0');
665  if (data_sp->GetBytes() == nullptr) {
666  result.AppendErrorWithFormat(
667  "can't allocate 0x%" PRIx32
668  " bytes for the memory read buffer, specify a smaller size to read",
669  (uint32_t)total_byte_size);
670  return false;
671  }
672 
673  Address address(addr, nullptr);
674  bytes_read = target->ReadMemory(address, data_sp->GetBytes(),
675  data_sp->GetByteSize(), error, true);
676  if (bytes_read == 0) {
677  const char *error_cstr = error.AsCString();
678  if (error_cstr && error_cstr[0]) {
679  result.AppendError(error_cstr);
680  } else {
681  result.AppendErrorWithFormat(
682  "failed to read memory from 0x%" PRIx64 ".\n", addr);
683  }
684  return false;
685  }
686 
687  if (bytes_read < total_byte_size)
689  "Not all bytes (%" PRIu64 "/%" PRIu64
690  ") were able to be read from 0x%" PRIx64 ".\n",
691  (uint64_t)bytes_read, (uint64_t)total_byte_size, addr);
692  } else {
693  // we treat c-strings as a special case because they do not have a fixed
694  // size
695  if (m_format_options.GetByteSizeValue().OptionWasSet() &&
696  !m_format_options.HasGDBFormat())
697  item_byte_size = m_format_options.GetByteSizeValue().GetCurrentValue();
698  else
699  item_byte_size = target->GetMaximumSizeOfStringSummary();
700  if (!m_format_options.GetCountValue().OptionWasSet())
701  item_count = 1;
702  data_sp = std::make_shared<DataBufferHeap>(
703  (item_byte_size + 1) * item_count,
704  '\0'); // account for NULLs as necessary
705  if (data_sp->GetBytes() == nullptr) {
706  result.AppendErrorWithFormat(
707  "can't allocate 0x%" PRIx64
708  " bytes for the memory read buffer, specify a smaller size to read",
709  (uint64_t)((item_byte_size + 1) * item_count));
710  return false;
711  }
712  uint8_t *data_ptr = data_sp->GetBytes();
713  auto data_addr = addr;
714  auto count = item_count;
715  item_count = 0;
716  bool break_on_no_NULL = false;
717  while (item_count < count) {
718  std::string buffer;
719  buffer.resize(item_byte_size + 1, 0);
720  Status error;
721  size_t read = target->ReadCStringFromMemory(data_addr, &buffer[0],
722  item_byte_size + 1, error);
723  if (error.Fail()) {
724  result.AppendErrorWithFormat(
725  "failed to read memory from 0x%" PRIx64 ".\n", addr);
726  return false;
727  }
728 
729  if (item_byte_size == read) {
731  "unable to find a NULL terminated string at 0x%" PRIx64
732  ". Consider increasing the maximum read length.\n",
733  data_addr);
734  --read;
735  break_on_no_NULL = true;
736  } else
737  ++read; // account for final NULL byte
738 
739  memcpy(data_ptr, &buffer[0], read);
740  data_ptr += read;
741  data_addr += read;
742  bytes_read += read;
743  item_count++; // if we break early we know we only read item_count
744  // strings
745 
746  if (break_on_no_NULL)
747  break;
748  }
749  data_sp =
750  std::make_shared<DataBufferHeap>(data_sp->GetBytes(), bytes_read + 1);
751  }
752 
753  m_next_addr = addr + bytes_read;
754  m_prev_byte_size = bytes_read;
755  m_prev_format_options = m_format_options;
756  m_prev_memory_options = m_memory_options;
757  m_prev_outfile_options = m_outfile_options;
758  m_prev_varobj_options = m_varobj_options;
759  m_prev_memory_tag_options = m_memory_tag_options;
760  m_prev_compiler_type = compiler_type;
761 
762  std::unique_ptr<Stream> output_stream_storage;
763  Stream *output_stream_p = nullptr;
764  const FileSpec &outfile_spec =
765  m_outfile_options.GetFile().GetCurrentValue();
766 
767  std::string path = outfile_spec.GetPath();
768  if (outfile_spec) {
769 
770  File::OpenOptions open_options =
771  File::eOpenOptionWriteOnly | File::eOpenOptionCanCreate;
772  const bool append = m_outfile_options.GetAppend().GetCurrentValue();
773  open_options |=
774  append ? File::eOpenOptionAppend : File::eOpenOptionTruncate;
775 
776  auto outfile = FileSystem::Instance().Open(outfile_spec, open_options);
777 
778  if (outfile) {
779  auto outfile_stream_up =
780  std::make_unique<StreamFile>(std::move(outfile.get()));
781  if (m_memory_options.m_output_as_binary) {
782  const size_t bytes_written =
783  outfile_stream_up->Write(data_sp->GetBytes(), bytes_read);
784  if (bytes_written > 0) {
785  result.GetOutputStream().Printf(
786  "%zi bytes %s to '%s'\n", bytes_written,
787  append ? "appended" : "written", path.c_str());
788  return true;
789  } else {
790  result.AppendErrorWithFormat("Failed to write %" PRIu64
791  " bytes to '%s'.\n",
792  (uint64_t)bytes_read, path.c_str());
793  return false;
794  }
795  } else {
796  // We are going to write ASCII to the file just point the
797  // output_stream to our outfile_stream...
798  output_stream_storage = std::move(outfile_stream_up);
799  output_stream_p = output_stream_storage.get();
800  }
801  } else {
802  result.AppendErrorWithFormat("Failed to open file '%s' for %s:\n",
803  path.c_str(), append ? "append" : "write");
804 
805  result.AppendError(llvm::toString(outfile.takeError()));
806  return false;
807  }
808  } else {
809  output_stream_p = &result.GetOutputStream();
810  }
811 
812  ExecutionContextScope *exe_scope = m_exe_ctx.GetBestExecutionContextScope();
813  if (compiler_type.GetOpaqueQualType()) {
814  for (uint32_t i = 0; i < item_count; ++i) {
815  addr_t item_addr = addr + (i * item_byte_size);
816  Address address(item_addr);
817  StreamString name_strm;
818  name_strm.Printf("0x%" PRIx64, item_addr);
819  ValueObjectSP valobj_sp(ValueObjectMemory::Create(
820  exe_scope, name_strm.GetString(), address, compiler_type));
821  if (valobj_sp) {
822  Format format = m_format_options.GetFormat();
823  if (format != eFormatDefault)
824  valobj_sp->SetFormat(format);
825 
826  DumpValueObjectOptions options(m_varobj_options.GetAsDumpOptions(
828 
829  valobj_sp->Dump(*output_stream_p, options);
830  } else {
831  result.AppendErrorWithFormat(
832  "failed to create a value object for: (%s) %s\n",
833  view_as_type_cstr, name_strm.GetData());
834  return false;
835  }
836  }
837  return true;
838  }
839 
841  DataExtractor data(data_sp, target->GetArchitecture().GetByteOrder(),
843  target->GetArchitecture().GetDataByteSize());
844 
845  Format format = m_format_options.GetFormat();
846  if (((format == eFormatChar) || (format == eFormatCharPrintable)) &&
847  (item_byte_size != 1)) {
848  // if a count was not passed, or it is 1
849  if (!m_format_options.GetCountValue().OptionWasSet() || item_count == 1) {
850  // this turns requests such as
851  // memory read -fc -s10 -c1 *charPtrPtr
852  // which make no sense (what is a char of size 10?) into a request for
853  // fetching 10 chars of size 1 from the same memory location
854  format = eFormatCharArray;
855  item_count = item_byte_size;
856  item_byte_size = 1;
857  } else {
858  // here we passed a count, and it was not 1 so we have a byte_size and
859  // a count we could well multiply those, but instead let's just fail
860  result.AppendErrorWithFormat(
861  "reading memory as characters of size %" PRIu64 " is not supported",
862  (uint64_t)item_byte_size);
863  return false;
864  }
865  }
866 
867  assert(output_stream_p);
868  size_t bytes_dumped = DumpDataExtractor(
869  data, output_stream_p, 0, format, item_byte_size, item_count,
870  num_per_line / target->GetArchitecture().GetDataByteSize(), addr, 0, 0,
871  exe_scope, m_memory_tag_options.GetShowTags().GetCurrentValue());
872  m_next_addr = addr + bytes_dumped;
873  output_stream_p->EOL();
874  return true;
875  }
876 
884  lldb::addr_t m_prev_byte_size = 0;
891 };
892 
893 #define LLDB_OPTIONS_memory_find
894 #include "CommandOptions.inc"
895 
896 // Find the specified data in memory
898 public:
900  public:
901  OptionGroupFindMemory() : m_count(1), m_offset(0) {}
902 
903  ~OptionGroupFindMemory() override = default;
904 
905  llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
906  return llvm::makeArrayRef(g_memory_find_options);
907  }
908 
909  Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_value,
910  ExecutionContext *execution_context) override {
911  Status error;
912  const int short_option = g_memory_find_options[option_idx].short_option;
913 
914  switch (short_option) {
915  case 'e':
916  m_expr.SetValueFromString(option_value);
917  break;
918 
919  case 's':
920  m_string.SetValueFromString(option_value);
921  break;
922 
923  case 'c':
924  if (m_count.SetValueFromString(option_value).Fail())
925  error.SetErrorString("unrecognized value for count");
926  break;
927 
928  case 'o':
929  if (m_offset.SetValueFromString(option_value).Fail())
930  error.SetErrorString("unrecognized value for dump-offset");
931  break;
932 
933  default:
934  llvm_unreachable("Unimplemented option");
935  }
936  return error;
937  }
938 
939  void OptionParsingStarting(ExecutionContext *execution_context) override {
940  m_expr.Clear();
941  m_string.Clear();
942  m_count.Clear();
943  }
944 
949  };
950 
953  interpreter, "memory find",
954  "Find a value in the memory of the current target process.",
955  nullptr, eCommandRequiresProcess | eCommandProcessMustBeLaunched) {
958  CommandArgumentData addr_arg;
959  CommandArgumentData value_arg;
960 
961  // Define the first (and only) variant of this arg.
963  addr_arg.arg_repetition = eArgRepeatPlain;
964 
965  // There is only one variant this argument could be; put it into the
966  // argument entry.
967  arg1.push_back(addr_arg);
968 
969  // Define the first (and only) variant of this arg.
971  value_arg.arg_repetition = eArgRepeatPlain;
972 
973  // There is only one variant this argument could be; put it into the
974  // argument entry.
975  arg2.push_back(value_arg);
976 
977  // Push the data for the first argument into the m_arguments vector.
978  m_arguments.push_back(arg1);
979  m_arguments.push_back(arg2);
980 
981  m_option_group.Append(&m_memory_options);
982  m_option_group.Append(&m_memory_tag_options, LLDB_OPT_SET_ALL,
984  m_option_group.Finalize();
985  }
986 
987  ~CommandObjectMemoryFind() override = default;
988 
989  Options *GetOptions() override { return &m_option_group; }
990 
991 protected:
993  public:
994  ProcessMemoryIterator(ProcessSP process_sp, lldb::addr_t base)
995  : m_process_sp(process_sp), m_base_addr(base) {
996  lldbassert(process_sp.get() != nullptr);
997  }
998 
999  bool IsValid() { return m_is_valid; }
1000 
1001  uint8_t operator[](lldb::addr_t offset) {
1002  if (!IsValid())
1003  return 0;
1004 
1005  uint8_t retval = 0;
1006  Status error;
1007  if (0 ==
1008  m_process_sp->ReadMemory(m_base_addr + offset, &retval, 1, error)) {
1009  m_is_valid = false;
1010  return 0;
1011  }
1012 
1013  return retval;
1014  }
1015 
1016  private:
1017  ProcessSP m_process_sp;
1019  bool m_is_valid = true;
1020  };
1021  bool DoExecute(Args &command, CommandReturnObject &result) override {
1022  // No need to check "process" for validity as eCommandRequiresProcess
1023  // ensures it is valid
1024  Process *process = m_exe_ctx.GetProcessPtr();
1025 
1026  const size_t argc = command.GetArgumentCount();
1027 
1028  if (argc != 2) {
1029  result.AppendError("two addresses needed for memory find");
1030  return false;
1031  }
1032 
1033  Status error;
1034  lldb::addr_t low_addr = OptionArgParser::ToAddress(
1035  &m_exe_ctx, command[0].ref(), LLDB_INVALID_ADDRESS, &error);
1036  if (low_addr == LLDB_INVALID_ADDRESS || error.Fail()) {
1037  result.AppendError("invalid low address");
1038  return false;
1039  }
1040  lldb::addr_t high_addr = OptionArgParser::ToAddress(
1041  &m_exe_ctx, command[1].ref(), LLDB_INVALID_ADDRESS, &error);
1042  if (high_addr == LLDB_INVALID_ADDRESS || error.Fail()) {
1043  result.AppendError("invalid high address");
1044  return false;
1045  }
1046 
1047  ABISP abi = m_exe_ctx.GetProcessPtr()->GetABI();
1048  if (abi) {
1049  low_addr = abi->FixDataAddress(low_addr);
1050  high_addr = abi->FixDataAddress(high_addr);
1051  }
1052 
1053  if (high_addr <= low_addr) {
1054  result.AppendError(
1055  "starting address must be smaller than ending address");
1056  return false;
1057  }
1058 
1059  lldb::addr_t found_location = LLDB_INVALID_ADDRESS;
1060 
1061  DataBufferHeap buffer;
1062 
1063  if (m_memory_options.m_string.OptionWasSet()) {
1064  llvm::StringRef str = m_memory_options.m_string.GetStringValue();
1065  if (str.empty()) {
1066  result.AppendError("search string must have non-zero length.");
1067  return false;
1068  }
1069  buffer.CopyData(str);
1070  } else if (m_memory_options.m_expr.OptionWasSet()) {
1071  StackFrame *frame = m_exe_ctx.GetFramePtr();
1072  ValueObjectSP result_sp;
1073  if ((eExpressionCompleted ==
1074  process->GetTarget().EvaluateExpression(
1075  m_memory_options.m_expr.GetStringValue(), frame, result_sp)) &&
1076  result_sp) {
1077  uint64_t value = result_sp->GetValueAsUnsigned(0);
1078  llvm::Optional<uint64_t> size =
1079  result_sp->GetCompilerType().GetByteSize(nullptr);
1080  if (!size)
1081  return false;
1082  switch (*size) {
1083  case 1: {
1084  uint8_t byte = (uint8_t)value;
1085  buffer.CopyData(&byte, 1);
1086  } break;
1087  case 2: {
1088  uint16_t word = (uint16_t)value;
1089  buffer.CopyData(&word, 2);
1090  } break;
1091  case 4: {
1092  uint32_t lword = (uint32_t)value;
1093  buffer.CopyData(&lword, 4);
1094  } break;
1095  case 8: {
1096  buffer.CopyData(&value, 8);
1097  } break;
1098  case 3:
1099  case 5:
1100  case 6:
1101  case 7:
1102  result.AppendError("unknown type. pass a string instead");
1103  return false;
1104  default:
1105  result.AppendError(
1106  "result size larger than 8 bytes. pass a string instead");
1107  return false;
1108  }
1109  } else {
1110  result.AppendError(
1111  "expression evaluation failed. pass a string instead");
1112  return false;
1113  }
1114  } else {
1115  result.AppendError(
1116  "please pass either a block of text, or an expression to evaluate.");
1117  return false;
1118  }
1119 
1120  size_t count = m_memory_options.m_count.GetCurrentValue();
1121  found_location = low_addr;
1122  bool ever_found = false;
1123  while (count) {
1124  found_location = FastSearch(found_location, high_addr, buffer.GetBytes(),
1125  buffer.GetByteSize());
1126  if (found_location == LLDB_INVALID_ADDRESS) {
1127  if (!ever_found) {
1128  result.AppendMessage("data not found within the range.\n");
1130  } else
1131  result.AppendMessage("no more matches within the range.\n");
1132  break;
1133  }
1134  result.AppendMessageWithFormat("data found at location: 0x%" PRIx64 "\n",
1135  found_location);
1136 
1137  DataBufferHeap dumpbuffer(32, 0);
1138  process->ReadMemory(
1139  found_location + m_memory_options.m_offset.GetCurrentValue(),
1140  dumpbuffer.GetBytes(), dumpbuffer.GetByteSize(), error);
1141  if (!error.Fail()) {
1142  DataExtractor data(dumpbuffer.GetBytes(), dumpbuffer.GetByteSize(),
1143  process->GetByteOrder(),
1144  process->GetAddressByteSize());
1146  data, &result.GetOutputStream(), 0, lldb::eFormatBytesWithASCII, 1,
1147  dumpbuffer.GetByteSize(), 16,
1148  found_location + m_memory_options.m_offset.GetCurrentValue(), 0, 0,
1149  m_exe_ctx.GetBestExecutionContextScope(),
1150  m_memory_tag_options.GetShowTags().GetCurrentValue());
1151  result.GetOutputStream().EOL();
1152  }
1153 
1154  --count;
1155  found_location++;
1156  ever_found = true;
1157  }
1158 
1160  return true;
1161  }
1162 
1163  lldb::addr_t FastSearch(lldb::addr_t low, lldb::addr_t high, uint8_t *buffer,
1164  size_t buffer_size) {
1165  const size_t region_size = high - low;
1166 
1167  if (region_size < buffer_size)
1168  return LLDB_INVALID_ADDRESS;
1169 
1170  std::vector<size_t> bad_char_heuristic(256, buffer_size);
1171  ProcessSP process_sp = m_exe_ctx.GetProcessSP();
1172  ProcessMemoryIterator iterator(process_sp, low);
1173 
1174  for (size_t idx = 0; idx < buffer_size - 1; idx++) {
1175  decltype(bad_char_heuristic)::size_type bcu_idx = buffer[idx];
1176  bad_char_heuristic[bcu_idx] = buffer_size - idx - 1;
1177  }
1178  for (size_t s = 0; s <= (region_size - buffer_size);) {
1179  int64_t j = buffer_size - 1;
1180  while (j >= 0 && buffer[j] == iterator[s + j])
1181  j--;
1182  if (j < 0)
1183  return low + s;
1184  else
1185  s += bad_char_heuristic[iterator[s + buffer_size - 1]];
1186  }
1187 
1188  return LLDB_INVALID_ADDRESS;
1189  }
1190 
1194 };
1195 
1196 #define LLDB_OPTIONS_memory_write
1197 #include "CommandOptions.inc"
1198 
1199 // Write memory to the inferior process
1201 public:
1203  public:
1204  OptionGroupWriteMemory() = default;
1205 
1206  ~OptionGroupWriteMemory() override = default;
1207 
1208  llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
1209  return llvm::makeArrayRef(g_memory_write_options);
1210  }
1211 
1212  Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_value,
1213  ExecutionContext *execution_context) override {
1214  Status error;
1215  const int short_option = g_memory_write_options[option_idx].short_option;
1216 
1217  switch (short_option) {
1218  case 'i':
1219  m_infile.SetFile(option_value, FileSpec::Style::native);
1220  FileSystem::Instance().Resolve(m_infile);
1221  if (!FileSystem::Instance().Exists(m_infile)) {
1222  m_infile.Clear();
1223  error.SetErrorStringWithFormat("input file does not exist: '%s'",
1224  option_value.str().c_str());
1225  }
1226  break;
1227 
1228  case 'o': {
1229  if (option_value.getAsInteger(0, m_infile_offset)) {
1230  m_infile_offset = 0;
1231  error.SetErrorStringWithFormat("invalid offset string '%s'",
1232  option_value.str().c_str());
1233  }
1234  } break;
1235 
1236  default:
1237  llvm_unreachable("Unimplemented option");
1238  }
1239  return error;
1240  }
1241 
1242  void OptionParsingStarting(ExecutionContext *execution_context) override {
1243  m_infile.Clear();
1244  m_infile_offset = 0;
1245  }
1246 
1249  };
1250 
1253  interpreter, "memory write",
1254  "Write to the memory of the current target process.", nullptr,
1255  eCommandRequiresProcess | eCommandProcessMustBeLaunched),
1256  m_format_options(
1258  {std::make_tuple(
1260  "The format to use for each of the value to be written."),
1261  std::make_tuple(eArgTypeByteSize,
1262  "The size in bytes to write from input file or "
1263  "each value.")}) {
1264  CommandArgumentEntry arg1;
1265  CommandArgumentEntry arg2;
1266  CommandArgumentData addr_arg;
1267  CommandArgumentData value_arg;
1268 
1269  // Define the first (and only) variant of this arg.
1270  addr_arg.arg_type = eArgTypeAddress;
1271  addr_arg.arg_repetition = eArgRepeatPlain;
1272 
1273  // There is only one variant this argument could be; put it into the
1274  // argument entry.
1275  arg1.push_back(addr_arg);
1276 
1277  // Define the first (and only) variant of this arg.
1278  value_arg.arg_type = eArgTypeValue;
1279  value_arg.arg_repetition = eArgRepeatPlus;
1280  value_arg.arg_opt_set_association = LLDB_OPT_SET_1;
1281 
1282  // There is only one variant this argument could be; put it into the
1283  // argument entry.
1284  arg2.push_back(value_arg);
1285 
1286  // Push the data for the first argument into the m_arguments vector.
1287  m_arguments.push_back(arg1);
1288  m_arguments.push_back(arg2);
1289 
1290  m_option_group.Append(&m_format_options,
1291  OptionGroupFormat::OPTION_GROUP_FORMAT,
1292  LLDB_OPT_SET_1);
1293  m_option_group.Append(&m_format_options,
1294  OptionGroupFormat::OPTION_GROUP_SIZE,
1296  m_option_group.Append(&m_memory_options, LLDB_OPT_SET_ALL, LLDB_OPT_SET_2);
1297  m_option_group.Finalize();
1298  }
1299 
1300  ~CommandObjectMemoryWrite() override = default;
1301 
1302  Options *GetOptions() override { return &m_option_group; }
1303 
1304 protected:
1305  bool DoExecute(Args &command, CommandReturnObject &result) override {
1306  // No need to check "process" for validity as eCommandRequiresProcess
1307  // ensures it is valid
1308  Process *process = m_exe_ctx.GetProcessPtr();
1309 
1310  const size_t argc = command.GetArgumentCount();
1311 
1312  if (m_memory_options.m_infile) {
1313  if (argc < 1) {
1314  result.AppendErrorWithFormat(
1315  "%s takes a destination address when writing file contents.\n",
1316  m_cmd_name.c_str());
1317  return false;
1318  }
1319  if (argc > 1) {
1320  result.AppendErrorWithFormat(
1321  "%s takes only a destination address when writing file contents.\n",
1322  m_cmd_name.c_str());
1323  return false;
1324  }
1325  } else if (argc < 2) {
1326  result.AppendErrorWithFormat(
1327  "%s takes a destination address and at least one value.\n",
1328  m_cmd_name.c_str());
1329  return false;
1330  }
1331 
1332  StreamString buffer(
1333  Stream::eBinary,
1335  process->GetTarget().GetArchitecture().GetByteOrder());
1336 
1337  OptionValueUInt64 &byte_size_value = m_format_options.GetByteSizeValue();
1338  size_t item_byte_size = byte_size_value.GetCurrentValue();
1339 
1340  Status error;
1341  lldb::addr_t addr = OptionArgParser::ToAddress(
1342  &m_exe_ctx, command[0].ref(), LLDB_INVALID_ADDRESS, &error);
1343 
1344  if (addr == LLDB_INVALID_ADDRESS) {
1345  result.AppendError("invalid address expression\n");
1346  result.AppendError(error.AsCString());
1347  return false;
1348  }
1349 
1350  if (m_memory_options.m_infile) {
1351  size_t length = SIZE_MAX;
1352  if (item_byte_size > 1)
1353  length = item_byte_size;
1354  auto data_sp = FileSystem::Instance().CreateDataBuffer(
1355  m_memory_options.m_infile.GetPath(), length,
1356  m_memory_options.m_infile_offset);
1357  if (data_sp) {
1358  length = data_sp->GetByteSize();
1359  if (length > 0) {
1360  Status error;
1361  size_t bytes_written =
1362  process->WriteMemory(addr, data_sp->GetBytes(), length, error);
1363 
1364  if (bytes_written == length) {
1365  // All bytes written
1366  result.GetOutputStream().Printf(
1367  "%" PRIu64 " bytes were written to 0x%" PRIx64 "\n",
1368  (uint64_t)bytes_written, addr);
1370  } else if (bytes_written > 0) {
1371  // Some byte written
1372  result.GetOutputStream().Printf(
1373  "%" PRIu64 " bytes of %" PRIu64
1374  " requested were written to 0x%" PRIx64 "\n",
1375  (uint64_t)bytes_written, (uint64_t)length, addr);
1377  } else {
1378  result.AppendErrorWithFormat("Memory write to 0x%" PRIx64
1379  " failed: %s.\n",
1380  addr, error.AsCString());
1381  }
1382  }
1383  } else {
1384  result.AppendErrorWithFormat("Unable to read contents of file.\n");
1385  }
1386  return result.Succeeded();
1387  } else if (item_byte_size == 0) {
1388  if (m_format_options.GetFormat() == eFormatPointer)
1389  item_byte_size = buffer.GetAddressByteSize();
1390  else
1391  item_byte_size = 1;
1392  }
1393 
1394  command.Shift(); // shift off the address argument
1395  uint64_t uval64;
1396  int64_t sval64;
1397  bool success = false;
1398  for (auto &entry : command) {
1399  switch (m_format_options.GetFormat()) {
1400  case kNumFormats:
1401  case eFormatFloat: // TODO: add support for floats soon
1402  case eFormatCharPrintable:
1403  case eFormatBytesWithASCII:
1404  case eFormatComplex:
1405  case eFormatEnum:
1406  case eFormatUnicode8:
1407  case eFormatUnicode16:
1408  case eFormatUnicode32:
1409  case eFormatVectorOfChar:
1410  case eFormatVectorOfSInt8:
1411  case eFormatVectorOfUInt8:
1412  case eFormatVectorOfSInt16:
1413  case eFormatVectorOfUInt16:
1414  case eFormatVectorOfSInt32:
1415  case eFormatVectorOfUInt32:
1416  case eFormatVectorOfSInt64:
1417  case eFormatVectorOfUInt64:
1422  case eFormatOSType:
1423  case eFormatComplexInteger:
1424  case eFormatAddressInfo:
1425  case eFormatHexFloat:
1426  case eFormatInstruction:
1427  case eFormatVoid:
1428  result.AppendError("unsupported format for writing memory");
1429  return false;
1430 
1431  case eFormatDefault:
1432  case eFormatBytes:
1433  case eFormatHex:
1434  case eFormatHexUppercase:
1435  case eFormatPointer: {
1436  // Decode hex bytes
1437  // Be careful, getAsInteger with a radix of 16 rejects "0xab" so we
1438  // have to special case that:
1439  bool success = false;
1440  if (entry.ref().startswith("0x"))
1441  success = !entry.ref().getAsInteger(0, uval64);
1442  if (!success)
1443  success = !entry.ref().getAsInteger(16, uval64);
1444  if (!success) {
1445  result.AppendErrorWithFormat(
1446  "'%s' is not a valid hex string value.\n", entry.c_str());
1447  return false;
1448  } else if (!llvm::isUIntN(item_byte_size * 8, uval64)) {
1449  result.AppendErrorWithFormat("Value 0x%" PRIx64
1450  " is too large to fit in a %" PRIu64
1451  " byte unsigned integer value.\n",
1452  uval64, (uint64_t)item_byte_size);
1453  return false;
1454  }
1455  buffer.PutMaxHex64(uval64, item_byte_size);
1456  break;
1457  }
1458  case eFormatBoolean:
1459  uval64 = OptionArgParser::ToBoolean(entry.ref(), false, &success);
1460  if (!success) {
1461  result.AppendErrorWithFormat(
1462  "'%s' is not a valid boolean string value.\n", entry.c_str());
1463  return false;
1464  }
1465  buffer.PutMaxHex64(uval64, item_byte_size);
1466  break;
1467 
1468  case eFormatBinary:
1469  if (entry.ref().getAsInteger(2, uval64)) {
1470  result.AppendErrorWithFormat(
1471  "'%s' is not a valid binary string value.\n", entry.c_str());
1472  return false;
1473  } else if (!llvm::isUIntN(item_byte_size * 8, uval64)) {
1474  result.AppendErrorWithFormat("Value 0x%" PRIx64
1475  " is too large to fit in a %" PRIu64
1476  " byte unsigned integer value.\n",
1477  uval64, (uint64_t)item_byte_size);
1478  return false;
1479  }
1480  buffer.PutMaxHex64(uval64, item_byte_size);
1481  break;
1482 
1483  case eFormatCharArray:
1484  case eFormatChar:
1485  case eFormatCString: {
1486  if (entry.ref().empty())
1487  break;
1488 
1489  size_t len = entry.ref().size();
1490  // Include the NULL for C strings...
1491  if (m_format_options.GetFormat() == eFormatCString)
1492  ++len;
1493  Status error;
1494  if (process->WriteMemory(addr, entry.c_str(), len, error) == len) {
1495  addr += len;
1496  } else {
1497  result.AppendErrorWithFormat("Memory write to 0x%" PRIx64
1498  " failed: %s.\n",
1499  addr, error.AsCString());
1500  return false;
1501  }
1502  break;
1503  }
1504  case eFormatDecimal:
1505  if (entry.ref().getAsInteger(0, sval64)) {
1506  result.AppendErrorWithFormat(
1507  "'%s' is not a valid signed decimal value.\n", entry.c_str());
1508  return false;
1509  } else if (!llvm::isIntN(item_byte_size * 8, sval64)) {
1510  result.AppendErrorWithFormat(
1511  "Value %" PRIi64 " is too large or small to fit in a %" PRIu64
1512  " byte signed integer value.\n",
1513  sval64, (uint64_t)item_byte_size);
1514  return false;
1515  }
1516  buffer.PutMaxHex64(sval64, item_byte_size);
1517  break;
1518 
1519  case eFormatUnsigned:
1520 
1521  if (entry.ref().getAsInteger(0, uval64)) {
1522  result.AppendErrorWithFormat(
1523  "'%s' is not a valid unsigned decimal string value.\n",
1524  entry.c_str());
1525  return false;
1526  } else if (!llvm::isUIntN(item_byte_size * 8, uval64)) {
1527  result.AppendErrorWithFormat("Value %" PRIu64
1528  " is too large to fit in a %" PRIu64
1529  " byte unsigned integer value.\n",
1530  uval64, (uint64_t)item_byte_size);
1531  return false;
1532  }
1533  buffer.PutMaxHex64(uval64, item_byte_size);
1534  break;
1535 
1536  case eFormatOctal:
1537  if (entry.ref().getAsInteger(8, uval64)) {
1538  result.AppendErrorWithFormat(
1539  "'%s' is not a valid octal string value.\n", entry.c_str());
1540  return false;
1541  } else if (!llvm::isUIntN(item_byte_size * 8, uval64)) {
1542  result.AppendErrorWithFormat("Value %" PRIo64
1543  " is too large to fit in a %" PRIu64
1544  " byte unsigned integer value.\n",
1545  uval64, (uint64_t)item_byte_size);
1546  return false;
1547  }
1548  buffer.PutMaxHex64(uval64, item_byte_size);
1549  break;
1550  }
1551  }
1552 
1553  if (!buffer.GetString().empty()) {
1554  Status error;
1555  if (process->WriteMemory(addr, buffer.GetString().data(),
1556  buffer.GetString().size(),
1557  error) == buffer.GetString().size())
1558  return true;
1559  else {
1560  result.AppendErrorWithFormat("Memory write to 0x%" PRIx64
1561  " failed: %s.\n",
1562  addr, error.AsCString());
1563  return false;
1564  }
1565  }
1566  return true;
1567  }
1568 
1572 };
1573 
1574 // Get malloc/free history of a memory address.
1576 public:
1578  : CommandObjectParsed(interpreter, "memory history",
1579  "Print recorded stack traces for "
1580  "allocation/deallocation events "
1581  "associated with an address.",
1582  nullptr,
1583  eCommandRequiresTarget | eCommandRequiresProcess |
1584  eCommandProcessMustBePaused |
1585  eCommandProcessMustBeLaunched) {
1586  CommandArgumentEntry arg1;
1587  CommandArgumentData addr_arg;
1588 
1589  // Define the first (and only) variant of this arg.
1590  addr_arg.arg_type = eArgTypeAddress;
1591  addr_arg.arg_repetition = eArgRepeatPlain;
1592 
1593  // There is only one variant this argument could be; put it into the
1594  // argument entry.
1595  arg1.push_back(addr_arg);
1596 
1597  // Push the data for the first argument into the m_arguments vector.
1598  m_arguments.push_back(arg1);
1599  }
1600 
1601  ~CommandObjectMemoryHistory() override = default;
1602 
1603  llvm::Optional<std::string> GetRepeatCommand(Args &current_command_args,
1604  uint32_t index) override {
1605  return m_cmd_name;
1606  }
1607 
1608 protected:
1609  bool DoExecute(Args &command, CommandReturnObject &result) override {
1610  const size_t argc = command.GetArgumentCount();
1611 
1612  if (argc == 0 || argc > 1) {
1613  result.AppendErrorWithFormat("%s takes an address expression",
1614  m_cmd_name.c_str());
1615  return false;
1616  }
1617 
1618  Status error;
1619  lldb::addr_t addr = OptionArgParser::ToAddress(
1620  &m_exe_ctx, command[0].ref(), LLDB_INVALID_ADDRESS, &error);
1621 
1622  if (addr == LLDB_INVALID_ADDRESS) {
1623  result.AppendError("invalid address expression");
1624  result.AppendError(error.AsCString());
1625  return false;
1626  }
1627 
1628  Stream *output_stream = &result.GetOutputStream();
1629 
1630  const ProcessSP &process_sp = m_exe_ctx.GetProcessSP();
1631  const MemoryHistorySP &memory_history =
1632  MemoryHistory::FindPlugin(process_sp);
1633 
1634  if (!memory_history) {
1635  result.AppendError("no available memory history provider");
1636  return false;
1637  }
1638 
1639  HistoryThreads thread_list = memory_history->GetHistoryThreads(addr);
1640 
1641  const bool stop_format = false;
1642  for (auto thread : thread_list) {
1643  thread->GetStatus(*output_stream, 0, UINT32_MAX, 0, stop_format);
1644  }
1645 
1647 
1648  return true;
1649  }
1650 };
1651 
1652 // CommandObjectMemoryRegion
1653 #pragma mark CommandObjectMemoryRegion
1654 
1655 #define LLDB_OPTIONS_memory_region
1656 #include "CommandOptions.inc"
1657 
1659 public:
1661  public:
1662  OptionGroupMemoryRegion() : m_all(false, false) {}
1663 
1664  ~OptionGroupMemoryRegion() override = default;
1665 
1666  llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
1667  return llvm::makeArrayRef(g_memory_region_options);
1668  }
1669 
1670  Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_value,
1671  ExecutionContext *execution_context) override {
1672  Status status;
1673  const int short_option = g_memory_region_options[option_idx].short_option;
1674 
1675  switch (short_option) {
1676  case 'a':
1677  m_all.SetCurrentValue(true);
1678  m_all.SetOptionWasSet();
1679  break;
1680  default:
1681  llvm_unreachable("Unimplemented option");
1682  }
1683 
1684  return status;
1685  }
1686 
1687  void OptionParsingStarting(ExecutionContext *execution_context) override {
1688  m_all.Clear();
1689  }
1690 
1692  };
1693 
1695  : CommandObjectParsed(interpreter, "memory region",
1696  "Get information on the memory region containing "
1697  "an address in the current target process.",
1698  "memory region <address-expression> (or --all)",
1699  eCommandRequiresProcess | eCommandTryTargetAPILock |
1700  eCommandProcessMustBeLaunched) {
1701  // Address in option set 1.
1702  m_arguments.push_back(CommandArgumentEntry{CommandArgumentData(
1704  // "--all" will go in option set 2.
1705  m_option_group.Append(&m_memory_region_options);
1706  m_option_group.Finalize();
1707  }
1708 
1709  ~CommandObjectMemoryRegion() override = default;
1710 
1711  Options *GetOptions() override { return &m_option_group; }
1712 
1713 protected:
1714  void DumpRegion(CommandReturnObject &result, Target &target,
1715  const MemoryRegionInfo &range_info, lldb::addr_t load_addr) {
1716  lldb_private::Address addr;
1717  ConstString section_name;
1718  if (target.ResolveLoadAddress(load_addr, addr)) {
1719  SectionSP section_sp(addr.GetSection());
1720  if (section_sp) {
1721  // Got the top most section, not the deepest section
1722  while (section_sp->GetParent())
1723  section_sp = section_sp->GetParent();
1724  section_name = section_sp->GetName();
1725  }
1726  }
1727 
1728  ConstString name = range_info.GetName();
1729  result.AppendMessageWithFormatv(
1730  "[{0:x16}-{1:x16}) {2:r}{3:w}{4:x}{5}{6}{7}{8}",
1731  range_info.GetRange().GetRangeBase(),
1732  range_info.GetRange().GetRangeEnd(), range_info.GetReadable(),
1733  range_info.GetWritable(), range_info.GetExecutable(), name ? " " : "",
1734  name, section_name ? " " : "", section_name);
1735  MemoryRegionInfo::OptionalBool memory_tagged = range_info.GetMemoryTagged();
1736  if (memory_tagged == MemoryRegionInfo::OptionalBool::eYes)
1737  result.AppendMessage("memory tagging: enabled");
1738 
1739  const llvm::Optional<std::vector<addr_t>> &dirty_page_list =
1740  range_info.GetDirtyPageList();
1741  if (dirty_page_list) {
1742  const size_t page_count = dirty_page_list.value().size();
1743  result.AppendMessageWithFormat(
1744  "Modified memory (dirty) page list provided, %zu entries.\n",
1745  page_count);
1746  if (page_count > 0) {
1747  bool print_comma = false;
1748  result.AppendMessageWithFormat("Dirty pages: ");
1749  for (size_t i = 0; i < page_count; i++) {
1750  if (print_comma)
1751  result.AppendMessageWithFormat(", ");
1752  else
1753  print_comma = true;
1754  result.AppendMessageWithFormat("0x%" PRIx64, (*dirty_page_list)[i]);
1755  }
1756  result.AppendMessageWithFormat(".\n");
1757  }
1758  }
1759  }
1760 
1761  bool DoExecute(Args &command, CommandReturnObject &result) override {
1762  ProcessSP process_sp = m_exe_ctx.GetProcessSP();
1763  if (!process_sp) {
1764  m_prev_end_addr = LLDB_INVALID_ADDRESS;
1765  result.AppendError("invalid process");
1766  return false;
1767  }
1768 
1769  Status error;
1770  lldb::addr_t load_addr = m_prev_end_addr;
1771  m_prev_end_addr = LLDB_INVALID_ADDRESS;
1772 
1773  const size_t argc = command.GetArgumentCount();
1774  const lldb::ABISP &abi = process_sp->GetABI();
1775 
1776  if (argc == 1) {
1777  if (m_memory_region_options.m_all) {
1778  result.AppendError(
1779  "The \"--all\" option cannot be used when an address "
1780  "argument is given");
1781  return false;
1782  }
1783 
1784  auto load_addr_str = command[0].ref();
1785  // Non-address bits in this will be handled later by GetMemoryRegion
1786  load_addr = OptionArgParser::ToAddress(&m_exe_ctx, load_addr_str,
1788  if (error.Fail() || load_addr == LLDB_INVALID_ADDRESS) {
1789  result.AppendErrorWithFormat("invalid address argument \"%s\": %s\n",
1790  command[0].c_str(), error.AsCString());
1791  return false;
1792  }
1793  } else if (argc > 1 ||
1794  // When we're repeating the command, the previous end address is
1795  // used for load_addr. If that was 0xF...F then we must have
1796  // reached the end of memory.
1797  (argc == 0 && !m_memory_region_options.m_all &&
1798  load_addr == LLDB_INVALID_ADDRESS) ||
1799  // If the target has non-address bits (tags, limited virtual
1800  // address size, etc.), the end of mappable memory will be lower
1801  // than that. So if we find any non-address bit set, we must be
1802  // at the end of the mappable range.
1803  (abi && (abi->FixAnyAddress(load_addr) != load_addr))) {
1804  result.AppendErrorWithFormat(
1805  "'%s' takes one argument or \"--all\" option:\nUsage: %s\n",
1806  m_cmd_name.c_str(), m_cmd_syntax.c_str());
1807  return false;
1808  }
1809 
1810  // Is is important that we track the address used to request the region as
1811  // this will give the correct section name in the case that regions overlap.
1812  // On Windows we get mutliple regions that start at the same place but are
1813  // different sizes and refer to different sections.
1814  std::vector<std::pair<lldb_private::MemoryRegionInfo, lldb::addr_t>>
1815  region_list;
1816  if (m_memory_region_options.m_all) {
1817  // We don't use GetMemoryRegions here because it doesn't include unmapped
1818  // areas like repeating the command would. So instead, emulate doing that.
1819  lldb::addr_t addr = 0;
1820  while (error.Success() && addr != LLDB_INVALID_ADDRESS &&
1821  // When there are non-address bits the last range will not extend
1822  // to LLDB_INVALID_ADDRESS but to the max virtual address.
1823  // This prevents us looping forever if that is the case.
1824  (!abi || (abi->FixAnyAddress(addr) == addr))) {
1825  lldb_private::MemoryRegionInfo region_info;
1826  error = process_sp->GetMemoryRegionInfo(addr, region_info);
1827 
1828  if (error.Success()) {
1829  region_list.push_back({region_info, addr});
1830  addr = region_info.GetRange().GetRangeEnd();
1831  }
1832  }
1833  } else {
1834  lldb_private::MemoryRegionInfo region_info;
1835  error = process_sp->GetMemoryRegionInfo(load_addr, region_info);
1836  if (error.Success())
1837  region_list.push_back({region_info, load_addr});
1838  }
1839 
1840  if (error.Success()) {
1841  for (std::pair<MemoryRegionInfo, addr_t> &range : region_list) {
1842  DumpRegion(result, process_sp->GetTarget(), range.first, range.second);
1843  m_prev_end_addr = range.first.GetRange().GetRangeEnd();
1844  }
1845 
1847  return true;
1848  }
1849 
1850  result.AppendErrorWithFormat("%s\n", error.AsCString());
1851  return false;
1852  }
1853 
1854  llvm::Optional<std::string> GetRepeatCommand(Args &current_command_args,
1855  uint32_t index) override {
1856  // If we repeat this command, repeat it without any arguments so we can
1857  // show the next memory range
1858  return m_cmd_name;
1859  }
1860 
1862 
1865 };
1866 
1867 // CommandObjectMemory
1868 
1869 CommandObjectMemory::CommandObjectMemory(CommandInterpreter &interpreter)
1871  interpreter, "memory",
1872  "Commands for operating on memory in the current target process.",
1873  "memory <subcommand> [<subcommand-options>]") {
1874  LoadSubCommand("find",
1875  CommandObjectSP(new CommandObjectMemoryFind(interpreter)));
1876  LoadSubCommand("read",
1877  CommandObjectSP(new CommandObjectMemoryRead(interpreter)));
1878  LoadSubCommand("write",
1879  CommandObjectSP(new CommandObjectMemoryWrite(interpreter)));
1880  LoadSubCommand("history",
1881  CommandObjectSP(new CommandObjectMemoryHistory(interpreter)));
1882  LoadSubCommand("region",
1883  CommandObjectSP(new CommandObjectMemoryRegion(interpreter)));
1884  LoadSubCommand("tag",
1885  CommandObjectSP(new CommandObjectMemoryTag(interpreter)));
1886 }
1887 
lldb_private::toString
const char * toString(AppleArm64ExceptionClass EC)
Definition: AppleArm64ExceptionClass.h:38
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::eArgRepeatOptional
@ eArgRepeatOptional
Definition: lldb-private-enumerations.h:96
lldb_private::CommandObjectParsed
Definition: CommandObject.h:389
lldb::eFormatVectorOfUInt64
@ eFormatVectorOfUInt64
Definition: lldb-enumerations.h:187
lldb::eFormatOSType
@ eFormatOSType
OS character codes encoded into an integer 'PICT' 'text' etc...
Definition: lldb-enumerations.h:173
MemoryHistory.h
lldb::eFormatPointer
@ eFormatPointer
Definition: lldb-enumerations.h:178
CommandObjectMemoryFind::OptionGroupFindMemory::OptionGroupFindMemory
OptionGroupFindMemory()
Definition: CommandObjectMemory.cpp:901
lldb_private::Range::GetRangeBase
BaseType GetRangeBase() const
Definition: RangeMap.h:46
lldb_private::ExecutionContext
Definition: ExecutionContext.h:292
lldb_private::ArchSpec::GetByteOrder
lldb::ByteOrder GetByteOrder() const
Returns the byte order for the architecture specification.
Definition: ArchSpec.cpp:729
lldb_private::DataBufferHeap::GetByteSize
lldb::offset_t GetByteSize() const override
Definition: DataBufferHeap.cpp:43
ExpressionVariable.h
lldb_private::Stream::GetAddressByteSize
uint32_t GetAddressByteSize() const
Get the address size in bytes.
Definition: Stream.cpp:179
lldb::eArgTypeAddress
@ eArgTypeAddress
Definition: lldb-enumerations.h:516
OptionGroupFormat.h
lldb::eFormatVectorOfChar
@ eFormatVectorOfChar
Definition: lldb-enumerations.h:179
OptionGroupReadMemory
Definition: CommandObjectMemory.cpp:49
lldb_private::OptionValueUInt64::GetCurrentValue
uint64_t GetCurrentValue() const
Definition: OptionValueUInt64.h:63
lldb::eFormatVectorOfUInt128
@ eFormatVectorOfUInt128
Definition: lldb-enumerations.h:191
lldb_private::ArchSpec::GetMaximumOpcodeByteSize
uint32_t GetMaximumOpcodeByteSize() const
Definition: ArchSpec.cpp:922
OptionGroupReadMemory::OptionGroupReadMemory
OptionGroupReadMemory()
Definition: CommandObjectMemory.cpp:51
lldb_private::OptionValue::OptionWasSet
bool OptionWasSet() const
Definition: OptionValue.h:314
lldb_private::eArgRepeatPlain
@ eArgRepeatPlain
Definition: lldb-private-enumerations.h:95
lldb_private::Process::ReadMemory
virtual size_t ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, Status &error)
Read of memory from a process.
Definition: Process.cpp:1922
CommandObjectMemoryFind::m_memory_tag_options
OptionGroupMemoryTag m_memory_tag_options
Definition: CommandObjectMemory.cpp:1193
lldb::Format
Format
Display format definitions.
Definition: lldb-enumerations.h:155
OptionGroupReadMemory::FinalizeSettings
Status FinalizeSettings(Target *target, OptionGroupFormat &format_options)
Definition: CommandObjectMemory.cpp:110
CommandObjectMemoryRegion::m_option_group
OptionGroupOptions m_option_group
Definition: CommandObjectMemory.cpp:1863
CommandObjectMemoryFind::FastSearch
lldb::addr_t FastSearch(lldb::addr_t low, lldb::addr_t high, uint8_t *buffer, size_t buffer_size)
Definition: CommandObjectMemory.cpp:1163
CommandObjectMemoryRead::m_prev_format_options
OptionGroupFormat m_prev_format_options
Definition: CommandObjectMemory.cpp:885
CommandObjectMemoryWrite::OptionGroupWriteMemory::GetDefinitions
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
Definition: CommandObjectMemory.cpp:1208
lldb_private::File::OpenOptions
OpenOptions
Definition: File.h:49
lldb_private::OptionValueBoolean
Definition: OptionValueBoolean.h:16
CommandObjectMemoryHistory::DoExecute
bool DoExecute(Args &command, CommandReturnObject &result) override
Definition: CommandObjectMemory.cpp:1609
lldb_private::TargetProperties::GetMaximumSizeOfStringSummary
uint32_t GetMaximumSizeOfStringSummary() const
Definition: Target.cpp:4423
lldb_private::Args::Shift
void Shift()
Shifts the first argument C string value of the array off the argument array.
Definition: Args.cpp:286
lldb_private::Process
Definition: Process.h:338
CommandObjectMemoryHistory::CommandObjectMemoryHistory
CommandObjectMemoryHistory(CommandInterpreter &interpreter)
Definition: CommandObjectMemory.cpp:1577
lldb_private::OptionGroupOptions
Definition: Options.h:255
CommandObjectMemoryWrite::m_format_options
OptionGroupFormat m_format_options
Definition: CommandObjectMemory.cpp:1570
lldb::eFormatInstruction
@ eFormatInstruction
Disassemble an opcode.
Definition: lldb-enumerations.h:199
lldb_private::CommandObject::CommandArgumentData
Used to build individual command argument lists.
Definition: CommandObject.h:91
lldb_private::DataBufferHeap::CopyData
void CopyData(const void *src, lldb::offset_t src_len)
Makes a copy of the src_len bytes in src.
Definition: DataBufferHeap.cpp:53
CommandObjectMemoryWrite::DoExecute
bool DoExecute(Args &command, CommandReturnObject &result) override
Definition: CommandObjectMemory.cpp:1305
lldb_private::Process::GetTarget
Target & GetTarget()
Get the target object pointer for this module.
Definition: Process.h:1219
lldb_private::OptionGroup
Definition: Options.h:233
lldb::eArgTypeAddressOrExpression
@ eArgTypeAddressOrExpression
Definition: lldb-enumerations.h:517
lldb::eFormatVectorOfSInt16
@ eFormatVectorOfSInt16
Definition: lldb-enumerations.h:182
lldb::eFormatVectorOfSInt32
@ eFormatVectorOfSInt32
Definition: lldb-enumerations.h:184
CommandObjectMemory.h
lldb::LanguageType
LanguageType
Programming language type.
Definition: lldb-enumerations.h:436
lldb::eFormatBoolean
@ eFormatBoolean
Definition: lldb-enumerations.h:158
CommandObjectMemoryRegion::OptionGroupMemoryRegion::m_all
OptionValueBoolean m_all
Definition: CommandObjectMemory.cpp:1691
CommandObjectMemoryWrite::m_option_group
OptionGroupOptions m_option_group
Definition: CommandObjectMemory.cpp:1569
OptionArgParser.h
CommandObjectMemoryRegion::CommandObjectMemoryRegion
CommandObjectMemoryRegion(CommandInterpreter &interpreter)
Definition: CommandObjectMemory.cpp:1694
CommandObjectMemoryRead::m_prev_memory_options
OptionGroupReadMemory m_prev_memory_options
Definition: CommandObjectMemory.cpp:886
lldb_private::CompilerType::GetByteSize
llvm::Optional< uint64_t > GetByteSize(ExecutionContextScope *exe_scope) const
Return the size of the type in bytes.
Definition: CompilerType.cpp:489
CommandObjectMemoryHistory::GetRepeatCommand
llvm::Optional< std::string > GetRepeatCommand(Args &current_command_args, uint32_t index) override
Get the command that appropriate for a "repeat" of the current command.
Definition: CommandObjectMemory.cpp:1603
lldb_private::CompilerType::GetOpaqueQualType
lldb::opaque_compiler_type_t GetOpaqueQualType() const
Definition: CompilerType.h:173
lldb_private::MemoryRegionInfo
Definition: MemoryRegionInfo.h:21
StackFrame.h
CommandObjectMemoryRegion::DoExecute
bool DoExecute(Args &command, CommandReturnObject &result) override
Definition: CommandObjectMemory.cpp:1761
lldb_private::CommandObject::CommandArgumentData::arg_repetition
ArgumentRepetitionType arg_repetition
Definition: CommandObject.h:93
OptionGroupReadMemory::SetOptionValue
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_value, ExecutionContext *execution_context) override
Definition: CommandObjectMemory.cpp:61
ValueObjectMemory.h
lldb_private::OptionGroupFormat::GetByteSizeValue
OptionValueUInt64 & GetByteSizeValue()
Definition: OptionGroupFormat.h:56
lldb::eArgTypeValue
@ eArgTypeValue
Definition: lldb-enumerations.h:593
lldb_private::Stream
Definition: Stream.h:28
lldb_private::Args
Definition: Args.h:33
lldb::eFormatBytesWithASCII
@ eFormatBytesWithASCII
Definition: lldb-enumerations.h:161
lldb_private::TypeList::GetTypeAtIndex
lldb::TypeSP GetTypeAtIndex(uint32_t idx)
Definition: TypeList.cpp:66
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
Language.h
lldb_private::CommandReturnObject::Succeeded
bool Succeeded() const
Definition: CommandReturnObject.cpp:131
lldb_private::eArgRepeatPlus
@ eArgRepeatPlus
Definition: lldb-private-enumerations.h:97
CommandObjectMemoryFind::m_option_group
OptionGroupOptions m_option_group
Definition: CommandObjectMemory.cpp:1191
lldb_private::Process::WriteMemory
size_t WriteMemory(lldb::addr_t vm_addr, const void *buf, size_t size, Status &error)
Write memory to a process.
Definition: Process.cpp:2121
CommandObjectMemoryWrite::GetOptions
Options * GetOptions() override
Definition: CommandObjectMemory.cpp:1302
CommandReturnObject.h
lldb_private::DumpDataExtractor
lldb::offset_t DumpDataExtractor(const DataExtractor &DE, Stream *s, lldb::offset_t offset, lldb::Format item_format, size_t item_byte_size, size_t item_count, size_t num_per_line, uint64_t base_addr, uint32_t item_bit_size, uint32_t item_bit_offset, ExecutionContextScope *exe_scope=nullptr, bool show_memory_tags=false)
Dumps item_count objects into the stream s.
Definition: DumpDataExtractor.cpp:341
lldb_private::Target::ResolveLoadAddress
bool ResolveLoadAddress(lldb::addr_t load_addr, Address &so_addr, uint32_t stop_id=SectionLoadHistory::eStopIDNow)
Definition: Target.cpp:2915
lldb_private::MemoryRegionInfo::GetMemoryTagged
OptionalBool GetMemoryTagged() const
Definition: MemoryRegionInfo.h:56
lldb_private::Target
Definition: Target.h:469
CommandObjectMemoryRead::m_memory_tag_options
OptionGroupMemoryTag m_memory_tag_options
Definition: CommandObjectMemory.cpp:882
Section.h
CommandObjectMemoryFind::ProcessMemoryIterator::ProcessMemoryIterator
ProcessMemoryIterator(ProcessSP process_sp, lldb::addr_t base)
Definition: CommandObjectMemory.cpp:994
ABI.h
lldb_private::Target::GetImages
const ModuleList & GetImages() const
Get accessor for the images for this process.
Definition: Target.h:947
lldb_private::StreamString::GetString
llvm::StringRef GetString() const
Definition: StreamString.cpp:51
CommandObjectMemoryRegion::OptionGroupMemoryRegion
Definition: CommandObjectMemory.cpp:1660
Process.h
CommandObjectMemoryFind::OptionGroupFindMemory
Definition: CommandObjectMemory.cpp:899
lldb::eReturnStatusSuccessFinishNoResult
@ eReturnStatusSuccessFinishNoResult
Definition: lldb-enumerations.h:260
lldb::eFormatVectorOfSInt8
@ eFormatVectorOfSInt8
Definition: lldb-enumerations.h:180
CommandObjectMemoryFind::ProcessMemoryIterator::m_base_addr
lldb::addr_t m_base_addr
Definition: CommandObjectMemory.cpp:1018
lldb_private::MemoryRegionInfo::GetWritable
OptionalBool GetWritable() const
Definition: MemoryRegionInfo.h:46
Target.h
CommandObjectMemoryWrite
Definition: CommandObjectMemory.cpp:1200
lldb::eFormatBytes
@ eFormatBytes
Definition: lldb-enumerations.h:160
lldb_private::MemoryRegionInfo::OptionalBool
OptionalBool
Definition: MemoryRegionInfo.h:25
OptionGroupValueObjectDisplay.h
lldb_private::FileSpec
Definition: FileSpec.h:55
CommandObjectMemoryWrite::m_memory_options
OptionGroupWriteMemory m_memory_options
Definition: CommandObjectMemory.cpp:1571
lldb::eArgTypeByteSize
@ eArgTypeByteSize
Definition: lldb-enumerations.h:525
lldb_private::CommandObjectMultiword
Definition: CommandObjectMultiword.h:19
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
Options.h
lldb::eFormatVectorOfFloat64
@ eFormatVectorOfFloat64
Definition: lldb-enumerations.h:190
lldb::eFormatUnicode8
@ eFormatUnicode8
Definition: lldb-enumerations.h:201
lldb::eFormatVectorOfUInt32
@ eFormatVectorOfUInt32
Definition: lldb-enumerations.h:185
lldb_private::OptionValueLanguage
Definition: OptionValueLanguage.h:18
lldb_private::Target::ReadCStringFromMemory
size_t ReadCStringFromMemory(const Address &addr, std::string &out_str, Status &error, bool force_live_memory=false)
Definition: Target.cpp:1864
CommandObjectMemoryRead::m_prev_memory_tag_options
OptionGroupMemoryTag m_prev_memory_tag_options
Definition: CommandObjectMemory.cpp:889
lldb_private::Options
Definition: Options.h:57
CommandObjectMemoryRead::m_outfile_options
OptionGroupOutputFile m_outfile_options
Definition: CommandObjectMemory.cpp:880
lldb_private::MemoryRegionInfo::GetExecutable
OptionalBool GetExecutable() const
Definition: MemoryRegionInfo.h:48
CommandObjectMemoryRead::m_memory_options
OptionGroupReadMemory m_memory_options
Definition: CommandObjectMemory.cpp:879
lldb_private::DataExtractor
Definition: DataExtractor.h:48
CommandObjectMemoryRead::CommandObjectMemoryRead
CommandObjectMemoryRead(CommandInterpreter &interpreter)
Definition: CommandObjectMemory.cpp:286
lldb_private::ExecutionContextScope
Definition: ExecutionContextScope.h:32
CommandObjectMemoryRead::GetOptions
Options * GetOptions() override
Definition: CommandObjectMemory.cpp:342
Args.h
OptionGroupMemoryTag.h
MemoryRegionInfo.h
CommandObjectMemoryFind::CommandObjectMemoryFind
CommandObjectMemoryFind(CommandInterpreter &interpreter)
Definition: CommandObjectMemory.cpp:951
lldb_private::CommandObjectMultiword::LoadSubCommand
bool LoadSubCommand(llvm::StringRef cmd_name, const lldb::CommandObjectSP &command_obj) override
Definition: CommandObjectMultiword.cpp:80
CommandObjectMemoryFind::m_memory_options
OptionGroupFindMemory m_memory_options
Definition: CommandObjectMemory.cpp:1192
CommandObjectMemoryRead::GetRepeatCommand
llvm::Optional< std::string > GetRepeatCommand(Args &current_command_args, uint32_t index) override
Get the command that appropriate for a "repeat" of the current command.
Definition: CommandObjectMemory.cpp:344
CommandObjectMemoryRegion::OptionGroupMemoryRegion::OptionParsingStarting
void OptionParsingStarting(ExecutionContext *execution_context) override
Definition: CommandObjectMemory.cpp:1687
OptionValueLanguage.h
LLDB_OPT_SET_1
#define LLDB_OPT_SET_1
Definition: lldb-defines.h:102
lldb_private::CommandReturnObject::SetStatus
void SetStatus(lldb::ReturnStatus status)
Definition: CommandReturnObject.cpp:127
lldb_private::OptionGroupFormat
Definition: OptionGroupFormat.h:24
CommandObjectMemoryWrite::OptionGroupWriteMemory::m_infile
FileSpec m_infile
Definition: CommandObjectMemory.cpp:1247
CommandObjectMemoryRead::DoExecute
bool DoExecute(Args &command, CommandReturnObject &result) override
Definition: CommandObjectMemory.cpp:350
OptionGroupOutputFile.h
LLDB_OPT_SET_3
#define LLDB_OPT_SET_3
Definition: lldb-defines.h:104
lldb_private::StreamString::GetData
const char * GetData() const
Definition: StreamString.h:43
lldb_private::CommandObjectMemory::~CommandObjectMemory
~CommandObjectMemory() override
lldb::eExpressionCompleted
@ eExpressionCompleted
Definition: lldb-enumerations.h:271
StreamString.h
lldb_private::OptionGroupFormat::GetFormat
lldb::Format GetFormat() const
Definition: OptionGroupFormat.h:50
lldb_private::CommandReturnObject::GetOutputStream
Stream & GetOutputStream()
Definition: CommandReturnObject.h:46
LLDB_OPT_SET_ALL
#define LLDB_OPT_SET_ALL
Definition: lldb-defines.h:101
lldb_private::TypeList::GetSize
uint32_t GetSize() const
Definition: TypeList.cpp:60
lldb_private::OptionGroupOutputFile
Definition: OptionGroupOutputFile.h:19
lldb_private::Process::GetAddressByteSize
uint32_t GetAddressByteSize() const
Definition: Process.cpp:3366
lldb_private::ConstString
Definition: ConstString.h:39
lldb_private::StreamString
Definition: StreamString.h:23
lldb_private::CommandObjectMemoryTag
Definition: CommandObjectMemoryTag.h:16
CommandObjectMemoryFind::ProcessMemoryIterator::operator[]
uint8_t operator[](lldb::addr_t offset)
Definition: CommandObjectMemory.cpp:1001
CommandObjectMemoryFind::ProcessMemoryIterator
Definition: CommandObjectMemory.cpp:992
lldb_private::CommandInterpreter
Definition: CommandInterpreter.h:214
lldb::eFormatDecimal
@ eFormatDecimal
Definition: lldb-enumerations.h:167
OptionGroupReadMemory::GetDefinitions
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
Definition: CommandObjectMemory.cpp:57
lldb_private::OptionGroupFormat::GetCountValue
OptionValueUInt64 & GetCountValue()
Definition: OptionGroupFormat.h:60
lldb_private::MemoryRegionInfo::GetName
ConstString GetName() const
Definition: MemoryRegionInfo.h:54
CommandObjectMemoryFind::OptionGroupFindMemory::m_string
OptionValueString m_string
Definition: CommandObjectMemory.cpp:946
CommandObjectMemoryFind::ProcessMemoryIterator::IsValid
bool IsValid()
Definition: CommandObjectMemory.cpp:999
lldb_private::OptionValueString
Definition: OptionValueString.h:20
lldb::eFormatVectorOfUInt16
@ eFormatVectorOfUInt16
Definition: lldb-enumerations.h:183
CommandObjectMemoryWrite::OptionGroupWriteMemory::SetOptionValue
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_value, ExecutionContext *execution_context) override
Definition: CommandObjectMemory.cpp:1212
lldb_private::CommandObject::CommandArgumentData::arg_type
lldb::CommandArgumentType arg_type
Definition: CommandObject.h:92
lldb_private::Target::GetPersistentExpressionStateForLanguage
PersistentExpressionState * GetPersistentExpressionStateForLanguage(lldb::LanguageType language)
Definition: Target.cpp:2353
OptionGroupReadMemory::OptionParsingStarting
void OptionParsingStarting(ExecutionContext *execution_context) override
Definition: CommandObjectMemory.cpp:101
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:40
lldb_private::OptionGroupValueObjectDisplay
Definition: OptionGroupValueObjectDisplay.h:19
lldb::kNumFormats
@ kNumFormats
Definition: lldb-enumerations.h:202
CommandObjectMemoryFind::OptionGroupFindMemory::m_offset
OptionValueUInt64 m_offset
Definition: CommandObjectMemory.cpp:948
lldb_private::Address::GetSection
lldb::SectionSP GetSection() const
Get const accessor for the section.
Definition: Address.h:429
OptionValueString.h
Thread.h
CommandObjectMemoryFind::DoExecute
bool DoExecute(Args &command, CommandReturnObject &result) override
Definition: CommandObjectMemory.cpp:1021
CommandObjectMemoryWrite::OptionGroupWriteMemory::m_infile_offset
off_t m_infile_offset
Definition: CommandObjectMemory.cpp:1248
DumpDataExtractor.h
CommandObjectMemoryRead::m_varobj_options
OptionGroupValueObjectDisplay m_varobj_options
Definition: CommandObjectMemory.cpp:881
lldb_private::CompilerType::IsValid
bool IsValid() const
Definition: CompilerType.h:72
lldb_private::ArchSpec::GetAddressByteSize
uint32_t GetAddressByteSize() const
Returns the size in bytes of an address of the current architecture.
Definition: ArchSpec.cpp:682
CommandObjectMemoryRegion
Definition: CommandObjectMemory.cpp:1658
lldb::eFormatVectorOfFloat16
@ eFormatVectorOfFloat16
Definition: lldb-enumerations.h:188
lldb::eFormatChar
@ eFormatChar
Definition: lldb-enumerations.h:162
CommandObjectMemoryRead::m_prev_varobj_options
OptionGroupValueObjectDisplay m_prev_varobj_options
Definition: CommandObjectMemory.cpp:888
lldb::eFormatHexFloat
@ eFormatHexFloat
ISO C99 hex float string.
Definition: lldb-enumerations.h:198
CommandObjectMemoryWrite::OptionGroupWriteMemory
Definition: CommandObjectMemory.cpp:1202
lldb::eFormatVoid
@ eFormatVoid
Do not print this.
Definition: lldb-enumerations.h:200
TypeList.h
CommandObjectMemoryRegion::GetOptions
Options * GetOptions() override
Definition: CommandObjectMemory.cpp:1711
CommandObjectMemoryRegion::GetRepeatCommand
llvm::Optional< std::string > GetRepeatCommand(Args &current_command_args, uint32_t index) override
Get the command that appropriate for a "repeat" of the current command.
Definition: CommandObjectMemory.cpp:1854
lldb::eFormatUnicode16
@ eFormatUnicode16
Definition: lldb-enumerations.h:175
lldb::eFormatUnsigned
@ eFormatUnsigned
Definition: lldb-enumerations.h:177
lldbassert
#define lldbassert(x)
Definition: LLDBAssert.h:15
CommandObjectMemoryWrite::OptionGroupWriteMemory::OptionParsingStarting
void OptionParsingStarting(ExecutionContext *execution_context) override
Definition: CommandObjectMemory.cpp:1242
CommandObjectMemoryRegion::OptionGroupMemoryRegion::SetOptionValue
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_value, ExecutionContext *execution_context) override
Definition: CommandObjectMemory.cpp:1670
lldb_private::Target::GetArchitecture
const ArchSpec & GetArchitecture() const
Definition: Target.h:989
CommandObjectMemoryTag.h
lldb_private::Status
Definition: Status.h:44
CommandObjectMemoryFind::GetOptions
Options * GetOptions() override
Definition: CommandObjectMemory.cpp:989
lldb_private::CompilerType::GetPointerType
CompilerType GetPointerType() const
Return a new CompilerType that is a pointer to this type.
Definition: CompilerType.cpp:407
CommandObjectMemoryRead::m_format_options
OptionGroupFormat m_format_options
Definition: CommandObjectMemory.cpp:878
lldb_private::Target::ReadMemory
size_t ReadMemory(const Address &addr, void *dst, size_t dst_len, Status &error, bool force_live_memory=false, lldb::addr_t *load_addr_ptr=nullptr)
Definition: Target.cpp:1743
CommandObjectMemoryRead
Definition: CommandObjectMemory.cpp:284
lldb::eLanguageTypeUnknown
@ eLanguageTypeUnknown
Unknown or invalid language value.
Definition: lldb-enumerations.h:437
lldb_private::CommandReturnObject
Definition: CommandReturnObject.h:26
uint32_t
CommandObjectMemoryRead::m_option_group
OptionGroupOptions m_option_group
Definition: CommandObjectMemory.cpp:877
CommandObjectMemoryFind::OptionGroupFindMemory::OptionParsingStarting
void OptionParsingStarting(ExecutionContext *execution_context) override
Definition: CommandObjectMemory.cpp:939
lldb::eReturnStatusSuccessFinishResult
@ eReturnStatusSuccessFinishResult
Definition: lldb-enumerations.h:261
CommandObjectMemoryHistory
Definition: CommandObjectMemory.cpp:1575
lldb_private::Address
Definition: Address.h:59
lldb_private::eLanguageRuntimeDescriptionDisplayVerbosityFull
@ eLanguageRuntimeDescriptionDisplayVerbosityFull
Definition: lldb-private-enumerations.h:158
OptionGroupReadMemory::m_language_for_type
OptionValueLanguage m_language_for_type
Definition: CommandObjectMemory.cpp:280
lldb_private::Target::EvaluateExpression
lldb::ExpressionResults EvaluateExpression(llvm::StringRef expression, ExecutionContextScope *exe_scope, lldb::ValueObjectSP &result_valobj_sp, const EvaluateExpressionOptions &options=EvaluateExpressionOptions(), std::string *fixed_expression=nullptr, ValueObject *ctx_obj=nullptr)
Definition: Target.cpp:2475
lldb_private::CommandReturnObject::AppendWarning
void void AppendWarning(llvm::StringRef in_string)
Definition: CommandReturnObject.cpp:94
lldb::eFormatCString
@ eFormatCString
NULL terminated C strings.
Definition: lldb-enumerations.h:166
lldb_private::Stream::EOL
size_t EOL()
Output and End of Line character to the stream.
Definition: Stream.cpp:128
lldb_private::CommandReturnObject::AppendMessageWithFormat
void AppendMessageWithFormat(const char *format,...) __attribute__((format(printf
Definition: CommandReturnObject.cpp:64
CommandObjectMemoryRead::m_prev_compiler_type
CompilerType m_prev_compiler_type
Definition: CommandObjectMemory.cpp:890
lldb::eFormatVectorOfSInt64
@ eFormatVectorOfSInt64
Definition: lldb-enumerations.h:186
UINT32_MAX
#define UINT32_MAX
Definition: lldb-defines.h:19
lldb_private::CommandReturnObject::AppendWarningWithFormat
void AppendWarningWithFormat(const char *format,...) __attribute__((format(printf
Definition: CommandReturnObject.cpp:76
lldb::eFormatCharPrintable
@ eFormatCharPrintable
Only printable characters, '.' if not printable.
Definition: lldb-enumerations.h:163
lldb_private::SymbolContext::module_sp
lldb::ModuleSP module_sp
The Module for a given query.
Definition: SymbolContext.h:318
uint16_t
lldb::eFormatCharArray
@ eFormatCharArray
Print characters with no single quotes, used for character arrays that can contain non printable char...
Definition: lldb-enumerations.h:193
CommandObjectMemoryRegion::OptionGroupMemoryRegion::GetDefinitions
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
Definition: CommandObjectMemory.cpp:1666
LLDB_INVALID_ADDRESS
#define LLDB_INVALID_ADDRESS
Definition: lldb-defines.h:74
lldb_private::ConstString::GetCString
const char * GetCString() const
Get the string value as a C string.
Definition: ConstString.h:215
lldb_private::CompilerType
Generic representation of a type in a programming language.
Definition: CompilerType.h:33
lldb_private::ArchSpec::GetDataByteSize
uint32_t GetDataByteSize() const
Architecture data byte width accessor.
Definition: ArchSpec.cpp:658
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::eArgTypeFormat
@ eArgTypeFormat
Definition: lldb-enumerations.h:538
lldb::eFormatBinary
@ eFormatBinary
Definition: lldb-enumerations.h:159
lldb_private::MemoryRegionInfo::GetRange
RangeType & GetRange()
Definition: MemoryRegionInfo.h:38
OptionGroupReadMemory::m_view_as_type
OptionValueString m_view_as_type
Definition: CommandObjectMemory.cpp:277
CommandObjectMemoryFind
Definition: CommandObjectMemory.cpp:897
lldb_private::DumpValueObjectOptions
Definition: DumpValueObjectOptions.h:22
lldb_private::CommandReturnObject::AppendErrorWithFormat
void AppendErrorWithFormat(const char *format,...) __attribute__((format(printf
Definition: CommandReturnObject.cpp:46
CommandObjectMemoryFind::ProcessMemoryIterator::m_process_sp
ProcessSP m_process_sp
Definition: CommandObjectMemory.cpp:1017
lldb::eFormatComplexInteger
@ eFormatComplexInteger
Integer complex type.
Definition: lldb-enumerations.h:192
CommandObjectMemoryFind::OptionGroupFindMemory::m_expr
OptionValueString m_expr
Definition: CommandObjectMemory.cpp:945
OptionParser.h
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb::eFormatHex
@ eFormatHex
Definition: lldb-enumerations.h:169
CommandObjectMemoryRegion::DumpRegion
void DumpRegion(CommandReturnObject &result, Target &target, const MemoryRegionInfo &range_info, lldb::addr_t load_addr)
Definition: CommandObjectMemory.cpp:1714
lldb::eFormatUnicode32
@ eFormatUnicode32
Definition: lldb-enumerations.h:176
lldb_private::OptionValueUInt64
Definition: OptionValueUInt64.h:17
lldb_private::TypeList
Definition: TypeList.h:20
lldb_private::TargetProperties::GetMaximumMemReadSize
uint32_t GetMaximumMemReadSize() const
Definition: Target.cpp:4429
lldb::eFormatEnum
@ eFormatEnum
Definition: lldb-enumerations.h:168
CommandObjectMemoryFind::OptionGroupFindMemory::GetDefinitions
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
Definition: CommandObjectMemory.cpp:905
CommandOptionArgumentTable.h
CommandObjectMemoryFind::OptionGroupFindMemory::m_count
OptionValueUInt64 m_count
Definition: CommandObjectMemory.cpp:947
OptionGroupReadMemory::m_offset
OptionValueUInt64 m_offset
Definition: CommandObjectMemory.cpp:279
lldb_private::HistoryThreads
std::vector< lldb::ThreadSP > HistoryThreads
Definition: MemoryHistory.h:21
lldb_private::Process::GetByteOrder
lldb::ByteOrder GetByteOrder() const
Definition: Process.cpp:3362
lldb_private::ModuleList::FindTypes
void FindTypes(Module *search_first, ConstString name, bool name_is_fully_qualified, size_t max_matches, llvm::DenseSet< SymbolFile * > &searched_symbol_files, TypeList &types) const
Find types by name.
Definition: ModuleList.cpp:569
CommandObjectMemoryFind::OptionGroupFindMemory::SetOptionValue
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_value, ExecutionContext *execution_context) override
Definition: CommandObjectMemory.cpp:909
CommandObjectMemoryWrite::CommandObjectMemoryWrite
CommandObjectMemoryWrite(CommandInterpreter &interpreter)
Definition: CommandObjectMemory.cpp:1251
lldb::eFormatVectorOfFloat32
@ eFormatVectorOfFloat32
Definition: lldb-enumerations.h:189
lldb_private::MemoryRegionInfo::GetDirtyPageList
const llvm::Optional< std::vector< lldb::addr_t > > & GetDirtyPageList() const
Get a vector of target VM pages that are dirty – that have been modified – within this memory region.
Definition: MemoryRegionInfo.h:123
lldb_private::CommandObject::CommandArgumentEntry
std::vector< CommandArgumentData > CommandArgumentEntry
Definition: CommandObject.h:106
CommandObjectMemoryRegion::m_memory_region_options
OptionGroupMemoryRegion m_memory_region_options
Definition: CommandObjectMemory.cpp:1864
lldb_private::FileSpec::GetPath
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
Definition: FileSpec.cpp:364
lldb::eFormatFloat
@ eFormatFloat
Definition: lldb-enumerations.h:171
lldb_private::OptionGroupMemoryTag
Definition: OptionGroupMemoryTag.h:17
lldb_private::CommandReturnObject::AppendError
void void AppendError(llvm::StringRef in_string)
Definition: CommandReturnObject.cpp:100
lldb_private::StackFrame
Definition: StackFrame.h:40
lldb_private::Args::GetArgumentCount
size_t GetArgumentCount() const
Gets the number of arguments left in this command object.
Definition: Args.h:116
lldb_private::DataBufferHeap
Definition: DataBufferHeap.h:30
LLDB_OPT_SET_2
#define LLDB_OPT_SET_2
Definition: lldb-defines.h:103
lldb
Definition: SBAddress.h:15
CommandObjectMemoryRegion::OptionGroupMemoryRegion::OptionGroupMemoryRegion
OptionGroupMemoryRegion()
Definition: CommandObjectMemory.cpp:1662
OptionGroupReadMemory::AnyOptionWasSet
bool AnyOptionWasSet() const
Definition: CommandObjectMemory.cpp:269
lldb::eFormatAddressInfo
@ eFormatAddressInfo
Describe what an address points to (func + offset.
Definition: lldb-enumerations.h:196
CommandObjectMemoryRead::m_prev_outfile_options
OptionGroupOutputFile m_prev_outfile_options
Definition: CommandObjectMemory.cpp:887
lldb_private::StackFrame::GetSymbolContext
const SymbolContext & GetSymbolContext(lldb::SymbolContextItem resolve_scope)
Provide a SymbolContext for this StackFrame's current pc value.
Definition: StackFrame.cpp:300
lldb_private::CommandReturnObject::AppendMessage
void AppendMessage(llvm::StringRef in_string)
Definition: CommandReturnObject.cpp:88
lldb_private::CommandReturnObject::AppendMessageWithFormatv
void void AppendMessageWithFormatv(const char *format, Args &&... args)
Definition: CommandReturnObject.h:120
SymbolFile.h
lldb::eFormatVectorOfUInt8
@ eFormatVectorOfUInt8
Definition: lldb-enumerations.h:181
lldb::eFormatDefault
@ eFormatDefault
Definition: lldb-enumerations.h:156
lldb::eFormatComplex
@ eFormatComplex
Floating point complex type.
Definition: lldb-enumerations.h:164
DataBufferHeap.h
OptionGroupReadMemory::m_num_per_line
OptionValueUInt64 m_num_per_line
Definition: CommandObjectMemory.cpp:275
UINT64_MAX
#define UINT64_MAX
Definition: lldb-defines.h:23
lldb::eFormatOctal
@ eFormatOctal
Definition: lldb-enumerations.h:172
ALL_KEYWORDS
#define ALL_KEYWORDS
lldb::eFormatHexUppercase
@ eFormatHexUppercase
Definition: lldb-enumerations.h:170
lldb_private::MemoryRegionInfo::GetReadable
OptionalBool GetReadable() const
Definition: MemoryRegionInfo.h:44
lldb_private::Range::GetRangeEnd
BaseType GetRangeEnd() const
Definition: RangeMap.h:78