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