LLDB  mainline
FormatEntity.cpp
Go to the documentation of this file.
1 //===-- FormatEntity.cpp --------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
10 
11 #include "lldb/Core/Address.h"
12 #include "lldb/Core/AddressRange.h"
13 #include "lldb/Core/Debugger.h"
15 #include "lldb/Core/Module.h"
16 #include "lldb/Core/ValueObject.h"
24 #include "lldb/Symbol/Block.h"
27 #include "lldb/Symbol/Function.h"
28 #include "lldb/Symbol/LineEntry.h"
29 #include "lldb/Symbol/Symbol.h"
34 #include "lldb/Target/Language.h"
35 #include "lldb/Target/Process.h"
38 #include "lldb/Target/StackFrame.h"
39 #include "lldb/Target/StopInfo.h"
40 #include "lldb/Target/Target.h"
41 #include "lldb/Target/Thread.h"
43 #include "lldb/Utility/ArchSpec.h"
46 #include "lldb/Utility/FileSpec.h"
47 #include "lldb/Utility/LLDBLog.h"
48 #include "lldb/Utility/Log.h"
50 #include "lldb/Utility/Status.h"
51 #include "lldb/Utility/Stream.h"
55 #include "lldb/lldb-defines.h"
56 #include "lldb/lldb-forward.h"
57 #include "llvm/ADT/STLExtras.h"
58 #include "llvm/ADT/StringRef.h"
59 #include "llvm/ADT/Triple.h"
60 #include "llvm/Support/Compiler.h"
61 
62 #include <cctype>
63 #include <cinttypes>
64 #include <cstdio>
65 #include <cstdlib>
66 #include <cstring>
67 #include <memory>
68 #include <type_traits>
69 #include <utility>
70 
71 namespace lldb_private {
72 class ScriptInterpreter;
73 }
74 namespace lldb_private {
75 struct RegisterInfo;
76 }
77 
78 using namespace lldb;
79 using namespace lldb_private;
80 
84 
86 
87 constexpr Definition g_string_entry[] = {
88  Definition("*", EntryType::ParentString)};
89 
90 constexpr Definition g_addr_entries[] = {
91  Definition("load", EntryType::AddressLoad),
92  Definition("file", EntryType::AddressFile)};
93 
95  Definition("basename", EntryType::ParentNumber, FileKind::Basename),
96  Definition("dirname", EntryType::ParentNumber, FileKind::Dirname),
97  Definition("fullpath", EntryType::ParentNumber, FileKind::Fullpath)};
98 
100  Definition("index", EntryType::FrameIndex),
101  Definition("pc", EntryType::FrameRegisterPC),
102  Definition("fp", EntryType::FrameRegisterFP),
103  Definition("sp", EntryType::FrameRegisterSP),
104  Definition("flags", EntryType::FrameRegisterFlags),
105  Definition("no-debug", EntryType::FrameNoDebug),
106  Entry::DefinitionWithChildren("reg", EntryType::FrameRegisterByName,
108  Definition("is-artificial", EntryType::FrameIsArtificial),
109 };
110 
112  Definition("id", EntryType::FunctionID),
113  Definition("name", EntryType::FunctionName),
114  Definition("name-without-args", EntryType::FunctionNameNoArgs),
115  Definition("name-with-args", EntryType::FunctionNameWithArgs),
116  Definition("mangled-name", EntryType::FunctionMangledName),
117  Definition("addr-offset", EntryType::FunctionAddrOffset),
118  Definition("concrete-only-addr-offset-no-padding",
119  EntryType::FunctionAddrOffsetConcrete),
120  Definition("line-offset", EntryType::FunctionLineOffset),
121  Definition("pc-offset", EntryType::FunctionPCOffset),
122  Definition("initial-function", EntryType::FunctionInitial),
123  Definition("changed", EntryType::FunctionChanged),
124  Definition("is-optimized", EntryType::FunctionIsOptimized)};
125 
127  Entry::DefinitionWithChildren("file", EntryType::LineEntryFile,
129  Definition("number", EntryType::LineEntryLineNumber),
130  Definition("column", EntryType::LineEntryColumn),
131  Definition("start-addr", EntryType::LineEntryStartAddress),
132  Definition("end-addr", EntryType::LineEntryEndAddress),
133 };
134 
136  "file", EntryType::ModuleFile, g_file_child_entries)};
137 
139  Definition("id", EntryType::ProcessID),
140  Definition("name", EntryType::ProcessFile, FileKind::Basename),
141  Entry::DefinitionWithChildren("file", EntryType::ProcessFile,
143 
145  Definition("*", EntryType::ParentString)};
146 
148  Definition("*", EntryType::ParentString)};
149 
151  Definition("id", EntryType::ThreadID),
152  Definition("protocol_id", EntryType::ThreadProtocolID),
153  Definition("index", EntryType::ThreadIndexID),
154  Entry::DefinitionWithChildren("info", EntryType::ThreadInfo,
156  Definition("queue", EntryType::ThreadQueue),
157  Definition("name", EntryType::ThreadName),
158  Definition("stop-reason", EntryType::ThreadStopReason),
159  Definition("stop-reason-raw", EntryType::ThreadStopReasonRaw),
160  Definition("return-value", EntryType::ThreadReturnValue),
161  Definition("completed-expression", EntryType::ThreadCompletedExpression)};
162 
164  Definition("arch", EntryType::TargetArch)};
165 
166 #define _TO_STR2(_val) #_val
167 #define _TO_STR(_val) _TO_STR2(_val)
168 
170  Definition("black",
173  Definition("green",
175  Definition("yellow",
178  Definition("purple",
181  Definition("white",
183 };
184 
186  Definition("black",
189  Definition("green",
191  Definition("yellow",
194  Definition("purple",
197  Definition("white",
199 };
200 
201 constexpr Definition g_ansi_entries[] = {
202  Entry::DefinitionWithChildren("fg", EntryType::Invalid, g_ansi_fg_entries),
203  Entry::DefinitionWithChildren("bg", EntryType::Invalid, g_ansi_bg_entries),
208  Definition("underline",
210  Definition("slow-blink",
212  Definition("fast-blink",
214  Definition("negative",
216  Definition("conceal",
218  Definition("crossed-out",
220 };
221 
223  Definition("frame", EntryType::ScriptFrame),
224  Definition("process", EntryType::ScriptProcess),
225  Definition("target", EntryType::ScriptTarget),
226  Definition("thread", EntryType::ScriptThread),
227  Definition("var", EntryType::ScriptVariable),
228  Definition("svar", EntryType::ScriptVariableSynthetic),
229  Definition("thread", EntryType::ScriptThread)};
230 
232  Entry::DefinitionWithChildren("addr", EntryType::AddressLoadOrFile,
234  Definition("addr-file-or-load", EntryType::AddressLoadOrFile),
235  Entry::DefinitionWithChildren("ansi", EntryType::Invalid, g_ansi_entries),
236  Definition("current-pc-arrow", EntryType::CurrentPCArrow),
237  Entry::DefinitionWithChildren("file", EntryType::File,
239  Definition("language", EntryType::Lang),
240  Entry::DefinitionWithChildren("frame", EntryType::Invalid,
242  Entry::DefinitionWithChildren("function", EntryType::Invalid,
244  Entry::DefinitionWithChildren("line", EntryType::Invalid,
246  Entry::DefinitionWithChildren("module", EntryType::Invalid,
248  Entry::DefinitionWithChildren("process", EntryType::Invalid,
250  Entry::DefinitionWithChildren("script", EntryType::Invalid,
252  Entry::DefinitionWithChildren("svar", EntryType::VariableSynthetic,
253  g_svar_child_entries, true),
254  Entry::DefinitionWithChildren("thread", EntryType::Invalid,
256  Entry::DefinitionWithChildren("target", EntryType::Invalid,
258  Entry::DefinitionWithChildren("var", EntryType::Variable,
259  g_var_child_entries, true)};
260 
262  "<root>", EntryType::Root, g_top_level_entries);
263 
264 FormatEntity::Entry::Entry(llvm::StringRef s)
265  : string(s.data(), s.size()), printf_format(), children(),
266  type(Type::String) {}
267 
269  : string(1, ch), printf_format(), children(), type(Type::String) {}
270 
272  if (children.empty() || children.back().type != Entry::Type::String)
273  children.push_back(Entry(ch));
274  else
275  children.back().string.append(1, ch);
276 }
277 
278 void FormatEntity::Entry::AppendText(const llvm::StringRef &s) {
279  if (children.empty() || children.back().type != Entry::Type::String)
280  children.push_back(Entry(s));
281  else
282  children.back().string.append(s.data(), s.size());
283 }
284 
285 void FormatEntity::Entry::AppendText(const char *cstr) {
286  return AppendText(llvm::StringRef(cstr));
287 }
288 
289 Status FormatEntity::Parse(const llvm::StringRef &format_str, Entry &entry) {
290  entry.Clear();
291  entry.type = Entry::Type::Root;
292  llvm::StringRef modifiable_format(format_str);
293  return ParseInternal(modifiable_format, entry, 0);
294 }
295 
296 #define ENUM_TO_CSTR(eee) \
297  case FormatEntity::Entry::Type::eee: \
298  return #eee
299 
301  switch (t) {
303  ENUM_TO_CSTR(ParentNumber);
304  ENUM_TO_CSTR(ParentString);
305  ENUM_TO_CSTR(EscapeCode);
306  ENUM_TO_CSTR(Root);
307  ENUM_TO_CSTR(String);
308  ENUM_TO_CSTR(Scope);
310  ENUM_TO_CSTR(VariableSynthetic);
311  ENUM_TO_CSTR(ScriptVariable);
312  ENUM_TO_CSTR(ScriptVariableSynthetic);
313  ENUM_TO_CSTR(AddressLoad);
314  ENUM_TO_CSTR(AddressFile);
315  ENUM_TO_CSTR(AddressLoadOrFile);
316  ENUM_TO_CSTR(ProcessID);
317  ENUM_TO_CSTR(ProcessFile);
318  ENUM_TO_CSTR(ScriptProcess);
319  ENUM_TO_CSTR(ThreadID);
320  ENUM_TO_CSTR(ThreadProtocolID);
321  ENUM_TO_CSTR(ThreadIndexID);
322  ENUM_TO_CSTR(ThreadName);
323  ENUM_TO_CSTR(ThreadQueue);
324  ENUM_TO_CSTR(ThreadStopReason);
325  ENUM_TO_CSTR(ThreadStopReasonRaw);
326  ENUM_TO_CSTR(ThreadReturnValue);
327  ENUM_TO_CSTR(ThreadCompletedExpression);
328  ENUM_TO_CSTR(ScriptThread);
329  ENUM_TO_CSTR(ThreadInfo);
330  ENUM_TO_CSTR(TargetArch);
331  ENUM_TO_CSTR(ScriptTarget);
332  ENUM_TO_CSTR(ModuleFile);
334  ENUM_TO_CSTR(Lang);
335  ENUM_TO_CSTR(FrameIndex);
336  ENUM_TO_CSTR(FrameNoDebug);
337  ENUM_TO_CSTR(FrameRegisterPC);
338  ENUM_TO_CSTR(FrameRegisterSP);
339  ENUM_TO_CSTR(FrameRegisterFP);
340  ENUM_TO_CSTR(FrameRegisterFlags);
341  ENUM_TO_CSTR(FrameRegisterByName);
342  ENUM_TO_CSTR(FrameIsArtificial);
343  ENUM_TO_CSTR(ScriptFrame);
344  ENUM_TO_CSTR(FunctionID);
345  ENUM_TO_CSTR(FunctionDidChange);
346  ENUM_TO_CSTR(FunctionInitialFunction);
347  ENUM_TO_CSTR(FunctionName);
348  ENUM_TO_CSTR(FunctionNameWithArgs);
349  ENUM_TO_CSTR(FunctionNameNoArgs);
350  ENUM_TO_CSTR(FunctionMangledName);
351  ENUM_TO_CSTR(FunctionAddrOffset);
352  ENUM_TO_CSTR(FunctionAddrOffsetConcrete);
353  ENUM_TO_CSTR(FunctionLineOffset);
354  ENUM_TO_CSTR(FunctionPCOffset);
355  ENUM_TO_CSTR(FunctionInitial);
356  ENUM_TO_CSTR(FunctionChanged);
357  ENUM_TO_CSTR(FunctionIsOptimized);
358  ENUM_TO_CSTR(LineEntryFile);
359  ENUM_TO_CSTR(LineEntryLineNumber);
360  ENUM_TO_CSTR(LineEntryColumn);
361  ENUM_TO_CSTR(LineEntryStartAddress);
362  ENUM_TO_CSTR(LineEntryEndAddress);
363  ENUM_TO_CSTR(CurrentPCArrow);
364  }
365  return "???";
366 }
367 
368 #undef ENUM_TO_CSTR
369 
370 void FormatEntity::Entry::Dump(Stream &s, int depth) const {
371  s.Printf("%*.*s%-20s: ", depth * 2, depth * 2, "", TypeToCString(type));
372  if (fmt != eFormatDefault)
373  s.Printf("lldb-format = %s, ", FormatManager::GetFormatAsCString(fmt));
374  if (!string.empty())
375  s.Printf("string = \"%s\"", string.c_str());
376  if (!printf_format.empty())
377  s.Printf("printf_format = \"%s\"", printf_format.c_str());
378  if (number != 0)
379  s.Printf("number = %" PRIu64 " (0x%" PRIx64 "), ", number, number);
380  if (deref)
381  s.Printf("deref = true, ");
382  s.EOL();
383  for (const auto &child : children) {
384  child.Dump(s, depth + 1);
385  }
386 }
387 
388 template <typename T>
389 static bool RunScriptFormatKeyword(Stream &s, const SymbolContext *sc,
390  const ExecutionContext *exe_ctx, T t,
391  const char *script_function_name) {
392  Target *target = Target::GetTargetFromContexts(exe_ctx, sc);
393 
394  if (target) {
395  ScriptInterpreter *script_interpreter =
396  target->GetDebugger().GetScriptInterpreter();
397  if (script_interpreter) {
398  Status error;
399  std::string script_output;
400 
401  if (script_interpreter->RunScriptFormatKeyword(script_function_name, t,
402  script_output, error) &&
403  error.Success()) {
404  s.Printf("%s", script_output.c_str());
405  return true;
406  } else {
407  s.Printf("<error: %s>", error.AsCString());
408  }
409  }
410  }
411  return false;
412 }
413 
414 static bool DumpAddressAndContent(Stream &s, const SymbolContext *sc,
415  const ExecutionContext *exe_ctx,
416  const Address &addr,
417  bool print_file_addr_or_load_addr) {
418  Target *target = Target::GetTargetFromContexts(exe_ctx, sc);
420  if (exe_ctx && !target->GetSectionLoadList().IsEmpty())
421  vaddr = addr.GetLoadAddress(target);
422  if (vaddr == LLDB_INVALID_ADDRESS)
423  vaddr = addr.GetFileAddress();
424 
425  if (vaddr != LLDB_INVALID_ADDRESS) {
426  int addr_width = 0;
427  if (exe_ctx && target) {
428  addr_width = target->GetArchitecture().GetAddressByteSize() * 2;
429  }
430  if (addr_width == 0)
431  addr_width = 16;
432  if (print_file_addr_or_load_addr) {
433  ExecutionContextScope *exe_scope = nullptr;
434  if (exe_ctx)
435  exe_scope = exe_ctx->GetBestExecutionContextScope();
436  addr.Dump(&s, exe_scope, Address::DumpStyleLoadAddress,
438  } else {
439  s.Printf("0x%*.*" PRIx64, addr_width, addr_width, vaddr);
440  }
441  return true;
442  }
443  return false;
444 }
445 
447  const ExecutionContext *exe_ctx,
448  const Address &format_addr,
449  bool concrete_only, bool no_padding,
450  bool print_zero_offsets) {
451  if (format_addr.IsValid()) {
452  Address func_addr;
453 
454  if (sc) {
455  if (sc->function) {
456  func_addr = sc->function->GetAddressRange().GetBaseAddress();
457  if (sc->block && !concrete_only) {
458  // Check to make sure we aren't in an inline function. If we are, use
459  // the inline block range that contains "format_addr" since blocks
460  // can be discontiguous.
461  Block *inline_block = sc->block->GetContainingInlinedBlock();
462  AddressRange inline_range;
463  if (inline_block && inline_block->GetRangeContainingAddress(
464  format_addr, inline_range))
465  func_addr = inline_range.GetBaseAddress();
466  }
467  } else if (sc->symbol && sc->symbol->ValueIsAddress())
468  func_addr = sc->symbol->GetAddressRef();
469  }
470 
471  if (func_addr.IsValid()) {
472  const char *addr_offset_padding = no_padding ? "" : " ";
473 
474  if (func_addr.GetSection() == format_addr.GetSection()) {
475  addr_t func_file_addr = func_addr.GetFileAddress();
476  addr_t addr_file_addr = format_addr.GetFileAddress();
477  if (addr_file_addr > func_file_addr ||
478  (addr_file_addr == func_file_addr && print_zero_offsets)) {
479  s.Printf("%s+%s%" PRIu64, addr_offset_padding, addr_offset_padding,
480  addr_file_addr - func_file_addr);
481  } else if (addr_file_addr < func_file_addr) {
482  s.Printf("%s-%s%" PRIu64, addr_offset_padding, addr_offset_padding,
483  func_file_addr - addr_file_addr);
484  }
485  return true;
486  } else {
487  Target *target = Target::GetTargetFromContexts(exe_ctx, sc);
488  if (target) {
489  addr_t func_load_addr = func_addr.GetLoadAddress(target);
490  addr_t addr_load_addr = format_addr.GetLoadAddress(target);
491  if (addr_load_addr > func_load_addr ||
492  (addr_load_addr == func_load_addr && print_zero_offsets)) {
493  s.Printf("%s+%s%" PRIu64, addr_offset_padding, addr_offset_padding,
494  addr_load_addr - func_load_addr);
495  } else if (addr_load_addr < func_load_addr) {
496  s.Printf("%s-%s%" PRIu64, addr_offset_padding, addr_offset_padding,
497  func_load_addr - addr_load_addr);
498  }
499  return true;
500  }
501  }
502  }
503  }
504  return false;
505 }
506 
507 static bool ScanBracketedRange(llvm::StringRef subpath,
508  size_t &close_bracket_index,
509  const char *&var_name_final_if_array_range,
510  int64_t &index_lower, int64_t &index_higher) {
512  close_bracket_index = llvm::StringRef::npos;
513  const size_t open_bracket_index = subpath.find('[');
514  if (open_bracket_index == llvm::StringRef::npos) {
515  LLDB_LOGF(log,
516  "[ScanBracketedRange] no bracketed range, skipping entirely");
517  return false;
518  }
519 
520  close_bracket_index = subpath.find(']', open_bracket_index + 1);
521 
522  if (close_bracket_index == llvm::StringRef::npos) {
523  LLDB_LOGF(log,
524  "[ScanBracketedRange] no bracketed range, skipping entirely");
525  return false;
526  } else {
527  var_name_final_if_array_range = subpath.data() + open_bracket_index;
528 
529  if (close_bracket_index - open_bracket_index == 1) {
530  LLDB_LOGF(
531  log,
532  "[ScanBracketedRange] '[]' detected.. going from 0 to end of data");
533  index_lower = 0;
534  } else {
535  const size_t separator_index = subpath.find('-', open_bracket_index + 1);
536 
537  if (separator_index == llvm::StringRef::npos) {
538  const char *index_lower_cstr = subpath.data() + open_bracket_index + 1;
539  index_lower = ::strtoul(index_lower_cstr, nullptr, 0);
540  index_higher = index_lower;
541  LLDB_LOGF(log,
542  "[ScanBracketedRange] [%" PRId64
543  "] detected, high index is same",
544  index_lower);
545  } else {
546  const char *index_lower_cstr = subpath.data() + open_bracket_index + 1;
547  const char *index_higher_cstr = subpath.data() + separator_index + 1;
548  index_lower = ::strtoul(index_lower_cstr, nullptr, 0);
549  index_higher = ::strtoul(index_higher_cstr, nullptr, 0);
550  LLDB_LOGF(log,
551  "[ScanBracketedRange] [%" PRId64 "-%" PRId64 "] detected",
552  index_lower, index_higher);
553  }
554  if (index_lower > index_higher && index_higher > 0) {
555  LLDB_LOGF(log, "[ScanBracketedRange] swapping indices");
556  const int64_t temp = index_lower;
557  index_lower = index_higher;
558  index_higher = temp;
559  }
560  }
561  }
562  return true;
563 }
564 
565 static bool DumpFile(Stream &s, const FileSpec &file, FileKind file_kind) {
566  switch (file_kind) {
567  case FileKind::FileError:
568  break;
569 
570  case FileKind::Basename:
571  if (file.GetFilename()) {
572  s << file.GetFilename();
573  return true;
574  }
575  break;
576 
577  case FileKind::Dirname:
578  if (file.GetDirectory()) {
579  s << file.GetDirectory();
580  return true;
581  }
582  break;
583 
584  case FileKind::Fullpath:
585  if (file) {
586  s << file;
587  return true;
588  }
589  break;
590  }
591  return false;
592 }
593 
594 static bool DumpRegister(Stream &s, StackFrame *frame, RegisterKind reg_kind,
595  uint32_t reg_num, Format format) {
596  if (frame) {
597  RegisterContext *reg_ctx = frame->GetRegisterContext().get();
598 
599  if (reg_ctx) {
600  const uint32_t lldb_reg_num =
601  reg_ctx->ConvertRegisterKindToRegisterNumber(reg_kind, reg_num);
602  if (lldb_reg_num != LLDB_INVALID_REGNUM) {
603  const RegisterInfo *reg_info =
604  reg_ctx->GetRegisterInfoAtIndex(lldb_reg_num);
605  if (reg_info) {
606  RegisterValue reg_value;
607  if (reg_ctx->ReadRegister(reg_info, reg_value)) {
608  DumpRegisterValue(reg_value, &s, reg_info, false, false, format);
609  return true;
610  }
611  }
612  }
613  }
614  }
615  return false;
616 }
617 
618 static ValueObjectSP ExpandIndexedExpression(ValueObject *valobj, size_t index,
619  bool deref_pointer) {
621  const char *ptr_deref_format = "[%d]";
622  std::string ptr_deref_buffer(10, 0);
623  ::sprintf(&ptr_deref_buffer[0], ptr_deref_format, index);
624  LLDB_LOGF(log, "[ExpandIndexedExpression] name to deref: %s",
625  ptr_deref_buffer.c_str());
632  ValueObjectSP item = valobj->GetValueForExpressionPath(
633  ptr_deref_buffer.c_str(), &reason_to_stop, &final_value_type, options,
634  &what_next);
635  if (!item) {
636  LLDB_LOGF(log,
637  "[ExpandIndexedExpression] ERROR: why stopping = %d,"
638  " final_value_type %d",
639  reason_to_stop, final_value_type);
640  } else {
641  LLDB_LOGF(log,
642  "[ExpandIndexedExpression] ALL RIGHT: why stopping = %d,"
643  " final_value_type %d",
644  reason_to_stop, final_value_type);
645  }
646  return item;
647 }
648 
651  switch (style) {
653  return '@';
655  return 'V';
657  return 'L';
659  return 'S';
661  return '#';
663  return 'T';
665  return 'N';
667  return '>';
668  }
669  return '\0';
670 }
671 
672 static bool DumpValue(Stream &s, const SymbolContext *sc,
673  const ExecutionContext *exe_ctx,
674  const FormatEntity::Entry &entry, ValueObject *valobj) {
675  if (valobj == nullptr)
676  return false;
677 
679  Format custom_format = eFormatInvalid;
681  entry.string.empty()
684 
685  bool do_deref_pointer = entry.deref;
686  bool is_script = false;
687  switch (entry.type) {
689  is_script = true;
690  break;
691 
693  custom_format = entry.fmt;
694  val_obj_display = (ValueObject::ValueObjectRepresentationStyle)entry.number;
695  break;
696 
698  is_script = true;
699  [[fallthrough]];
701  custom_format = entry.fmt;
702  val_obj_display = (ValueObject::ValueObjectRepresentationStyle)entry.number;
703  if (!valobj->IsSynthetic()) {
704  valobj = valobj->GetSyntheticValue().get();
705  if (valobj == nullptr)
706  return false;
707  }
708  break;
709 
710  default:
711  return false;
712  }
713 
718  options.DontCheckDotVsArrowSyntax()
723  SyntheticChildrenTraversal::Both);
724  ValueObject *target = nullptr;
725  const char *var_name_final_if_array_range = nullptr;
726  size_t close_bracket_index = llvm::StringRef::npos;
727  int64_t index_lower = -1;
728  int64_t index_higher = -1;
729  bool is_array_range = false;
730  bool was_plain_var = false;
731  bool was_var_format = false;
732  bool was_var_indexed = false;
737 
738  if (is_script) {
739  return RunScriptFormatKeyword(s, sc, exe_ctx, valobj, entry.string.c_str());
740  }
741 
742  llvm::StringRef subpath(entry.string);
743  // simplest case ${var}, just print valobj's value
744  if (entry.string.empty()) {
745  if (entry.printf_format.empty() && entry.fmt == eFormatDefault &&
747  was_plain_var = true;
748  else
749  was_var_format = true;
750  target = valobj;
751  } else // this is ${var.something} or multiple .something nested
752  {
753  if (entry.string[0] == '[')
754  was_var_indexed = true;
755  ScanBracketedRange(subpath, close_bracket_index,
756  var_name_final_if_array_range, index_lower,
757  index_higher);
758 
759  Status error;
760 
761  const std::string &expr_path = entry.string;
762 
763  LLDB_LOGF(log, "[Debugger::FormatPrompt] symbol to expand: %s",
764  expr_path.c_str());
765 
766  target =
767  valobj
768  ->GetValueForExpressionPath(expr_path.c_str(), &reason_to_stop,
769  &final_value_type, options, &what_next)
770  .get();
771 
772  if (!target) {
773  LLDB_LOGF(log,
774  "[Debugger::FormatPrompt] ERROR: why stopping = %d,"
775  " final_value_type %d",
776  reason_to_stop, final_value_type);
777  return false;
778  } else {
779  LLDB_LOGF(log,
780  "[Debugger::FormatPrompt] ALL RIGHT: why stopping = %d,"
781  " final_value_type %d",
782  reason_to_stop, final_value_type);
783  target = target
785  target->GetDynamicValueType(), true)
786  .get();
787  }
788  }
789 
790  is_array_range =
791  (final_value_type ==
793  final_value_type ==
795 
796  do_deref_pointer =
798 
799  if (do_deref_pointer && !is_array_range) {
800  // I have not deref-ed yet, let's do it
801  // this happens when we are not going through
802  // GetValueForVariableExpressionPath to get to the target ValueObject
803  Status error;
804  target = target->Dereference(error).get();
805  if (error.Fail()) {
806  LLDB_LOGF(log, "[Debugger::FormatPrompt] ERROR: %s\n",
807  error.AsCString("unknown"));
808  return false;
809  }
810  do_deref_pointer = false;
811  }
812 
813  if (!target) {
814  LLDB_LOGF(log, "[Debugger::FormatPrompt] could not calculate target for "
815  "prompt expression");
816  return false;
817  }
818 
819  // we do not want to use the summary for a bitfield of type T:n if we were
820  // originally dealing with just a T - that would get us into an endless
821  // recursion
822  if (target->IsBitfield() && was_var_indexed) {
823  // TODO: check for a (T:n)-specific summary - we should still obey that
824  StreamString bitfield_name;
825  bitfield_name.Printf("%s:%d", target->GetTypeName().AsCString(),
826  target->GetBitfieldBitSize());
827  auto type_sp = std::make_shared<TypeNameSpecifierImpl>(
828  bitfield_name.GetString(), lldb::eFormatterMatchExact);
829  if (val_obj_display ==
833  }
834 
835  // TODO use flags for these
836  const uint32_t type_info_flags =
837  target->GetCompilerType().GetTypeInfo(nullptr);
838  bool is_array = (type_info_flags & eTypeIsArray) != 0;
839  bool is_pointer = (type_info_flags & eTypeIsPointer) != 0;
840  bool is_aggregate = target->GetCompilerType().IsAggregateType();
841 
842  if ((is_array || is_pointer) && (!is_array_range) &&
843  val_obj_display ==
845  // wrong, but there
846  // are some
847  // exceptions
848  {
849  StreamString str_temp;
850  LLDB_LOGF(log,
851  "[Debugger::FormatPrompt] I am into array || pointer && !range");
852 
853  if (target->HasSpecialPrintableRepresentation(val_obj_display,
854  custom_format)) {
855  // try to use the special cases
856  bool success = target->DumpPrintableRepresentation(
857  str_temp, val_obj_display, custom_format);
858  LLDB_LOGF(log, "[Debugger::FormatPrompt] special cases did%s match",
859  success ? "" : "n't");
860 
861  // should not happen
862  if (success)
863  s << str_temp.GetString();
864  return true;
865  } else {
866  if (was_plain_var) // if ${var}
867  {
868  s << target->GetTypeName() << " @ " << target->GetLocationAsCString();
869  } else if (is_pointer) // if pointer, value is the address stored
870  {
872  s, val_obj_display, custom_format,
874  }
875  return true;
876  }
877  }
878 
879  // if directly trying to print ${var}, and this is an aggregate, display a
880  // nice type @ location message
881  if (is_aggregate && was_plain_var) {
882  s << target->GetTypeName() << " @ " << target->GetLocationAsCString();
883  return true;
884  }
885 
886  // if directly trying to print ${var%V}, and this is an aggregate, do not let
887  // the user do it
888  if (is_aggregate &&
889  ((was_var_format &&
890  val_obj_display ==
892  s << "<invalid use of aggregate type>";
893  return true;
894  }
895 
896  if (!is_array_range) {
897  LLDB_LOGF(log,
898  "[Debugger::FormatPrompt] dumping ordinary printable output");
899  return target->DumpPrintableRepresentation(s, val_obj_display,
900  custom_format);
901  } else {
902  LLDB_LOGF(log,
903  "[Debugger::FormatPrompt] checking if I can handle as array");
904  if (!is_array && !is_pointer)
905  return false;
906  LLDB_LOGF(log, "[Debugger::FormatPrompt] handle as array");
907  StreamString special_directions_stream;
908  llvm::StringRef special_directions;
909  if (close_bracket_index != llvm::StringRef::npos &&
910  subpath.size() > close_bracket_index) {
911  ConstString additional_data(subpath.drop_front(close_bracket_index + 1));
912  special_directions_stream.Printf("${%svar%s", do_deref_pointer ? "*" : "",
913  additional_data.GetCString());
914 
915  if (entry.fmt != eFormatDefault) {
916  const char format_char =
918  if (format_char != '\0')
919  special_directions_stream.Printf("%%%c", format_char);
920  else {
921  const char *format_cstr =
923  special_directions_stream.Printf("%%%s", format_cstr);
924  }
925  } else if (entry.number != 0) {
926  const char style_char = ConvertValueObjectStyleToChar(
928  if (style_char)
929  special_directions_stream.Printf("%%%c", style_char);
930  }
931  special_directions_stream.PutChar('}');
932  special_directions =
933  llvm::StringRef(special_directions_stream.GetString());
934  }
935 
936  // let us display items index_lower thru index_higher of this array
937  s.PutChar('[');
938 
939  if (index_higher < 0)
940  index_higher = valobj->GetNumChildren() - 1;
941 
942  uint32_t max_num_children =
943  target->GetTargetSP()->GetMaximumNumberOfChildrenToDisplay();
944 
945  bool success = true;
946  for (int64_t index = index_lower; index <= index_higher; ++index) {
947  ValueObject *item = ExpandIndexedExpression(target, index, false).get();
948 
949  if (!item) {
950  LLDB_LOGF(log,
951  "[Debugger::FormatPrompt] ERROR in getting child item at "
952  "index %" PRId64,
953  index);
954  } else {
955  LLDB_LOGF(
956  log,
957  "[Debugger::FormatPrompt] special_directions for child item: %s",
958  special_directions.data() ? special_directions.data() : "");
959  }
960 
961  if (special_directions.empty()) {
962  success &= item->DumpPrintableRepresentation(s, val_obj_display,
963  custom_format);
964  } else {
966  special_directions, s, sc, exe_ctx, nullptr, item, false, false);
967  }
968 
969  if (--max_num_children == 0) {
970  s.PutCString(", ...");
971  break;
972  }
973 
974  if (index < index_higher)
975  s.PutChar(',');
976  }
977  s.PutChar(']');
978  return success;
979  }
980 }
981 
982 static bool DumpRegister(Stream &s, StackFrame *frame, const char *reg_name,
983  Format format) {
984  if (frame) {
985  RegisterContext *reg_ctx = frame->GetRegisterContext().get();
986 
987  if (reg_ctx) {
988  const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName(reg_name);
989  if (reg_info) {
990  RegisterValue reg_value;
991  if (reg_ctx->ReadRegister(reg_info, reg_value)) {
992  DumpRegisterValue(reg_value, &s, reg_info, false, false, format);
993  return true;
994  }
995  }
996  }
997  }
998  return false;
999 }
1000 
1002  const FormatEntity::Entry &entry,
1003  const StructuredData::ObjectSP &thread_info_dictionary,
1004  const SymbolContext *sc, const ExecutionContext *exe_ctx, Stream &s) {
1005  llvm::StringRef path(entry.string);
1006 
1007  StructuredData::ObjectSP value =
1008  thread_info_dictionary->GetObjectForDotSeparatedPath(path);
1009 
1010  if (value) {
1011  if (value->GetType() == eStructuredDataTypeInteger) {
1012  const char *token_format = "0x%4.4" PRIx64;
1013  if (!entry.printf_format.empty())
1014  token_format = entry.printf_format.c_str();
1015  s.Printf(token_format, value->GetAsInteger()->GetValue());
1016  return true;
1017  } else if (value->GetType() == eStructuredDataTypeFloat) {
1018  s.Printf("%f", value->GetAsFloat()->GetValue());
1019  return true;
1020  } else if (value->GetType() == eStructuredDataTypeString) {
1021  s.Format("{0}", value->GetAsString()->GetValue());
1022  return true;
1023  } else if (value->GetType() == eStructuredDataTypeArray) {
1024  if (value->GetAsArray()->GetSize() > 0) {
1025  s.Printf("%zu", value->GetAsArray()->GetSize());
1026  return true;
1027  }
1028  } else if (value->GetType() == eStructuredDataTypeDictionary) {
1029  s.Printf("%zu",
1030  value->GetAsDictionary()->GetKeys()->GetAsArray()->GetSize());
1031  return true;
1032  }
1033  }
1034 
1035  return false;
1036 }
1037 
1038 static inline bool IsToken(const char *var_name_begin, const char *var) {
1039  return (::strncmp(var_name_begin, var, strlen(var)) == 0);
1040 }
1041 
1042 /// Parses the basename out of a demangled function name
1043 /// that may include function arguments. Supports
1044 /// template functions.
1045 ///
1046 /// Returns pointers to the opening and closing parenthesis of
1047 /// `full_name`. Can return nullptr for either parenthesis if
1048 /// none is exists.
1049 static std::pair<char const *, char const *>
1050 ParseBaseName(char const *full_name) {
1051  const char *open_paren = strchr(full_name, '(');
1052  const char *close_paren = nullptr;
1053  const char *generic = strchr(full_name, '<');
1054  // if before the arguments list begins there is a template sign
1055  // then scan to the end of the generic args before you try to find
1056  // the arguments list
1057  if (generic && open_paren && generic < open_paren) {
1058  int generic_depth = 1;
1059  ++generic;
1060  for (; *generic && generic_depth > 0; generic++) {
1061  if (*generic == '<')
1062  generic_depth++;
1063  if (*generic == '>')
1064  generic_depth--;
1065  }
1066  if (*generic)
1067  open_paren = strchr(generic, '(');
1068  else
1069  open_paren = nullptr;
1070  }
1071 
1072  if (open_paren) {
1073  if (IsToken(open_paren, "(anonymous namespace)")) {
1074  open_paren = strchr(open_paren + strlen("(anonymous namespace)"), '(');
1075  if (open_paren)
1076  close_paren = strchr(open_paren, ')');
1077  } else
1078  close_paren = strchr(open_paren, ')');
1079  }
1080 
1081  return {open_paren, close_paren};
1082 }
1083 
1084 /// Writes out the function name in 'full_name' to 'out_stream'
1085 /// but replaces each argument type with the variable name
1086 /// and the corresponding pretty-printed value
1087 static void PrettyPrintFunctionNameWithArgs(Stream &out_stream,
1088  char const *full_name,
1089  ExecutionContextScope *exe_scope,
1090  VariableList const &args) {
1091  auto [open_paren, close_paren] = ParseBaseName(full_name);
1092  if (open_paren)
1093  out_stream.Write(full_name, open_paren - full_name + 1);
1094  else {
1095  out_stream.PutCString(full_name);
1096  out_stream.PutChar('(');
1097  }
1098 
1099  FormatEntity::PrettyPrintFunctionArguments(out_stream, args, exe_scope);
1100 
1101  if (close_paren)
1102  out_stream.PutCString(close_paren);
1103  else
1104  out_stream.PutChar(')');
1105 }
1106 
1107 bool FormatEntity::FormatStringRef(const llvm::StringRef &format_str, Stream &s,
1108  const SymbolContext *sc,
1109  const ExecutionContext *exe_ctx,
1110  const Address *addr, ValueObject *valobj,
1111  bool function_changed,
1112  bool initial_function) {
1113  if (!format_str.empty()) {
1114  FormatEntity::Entry root;
1115  Status error = FormatEntity::Parse(format_str, root);
1116  if (error.Success()) {
1117  return FormatEntity::Format(root, s, sc, exe_ctx, addr, valobj,
1118  function_changed, initial_function);
1119  }
1120  }
1121  return false;
1122 }
1123 
1124 bool FormatEntity::FormatCString(const char *format, Stream &s,
1125  const SymbolContext *sc,
1126  const ExecutionContext *exe_ctx,
1127  const Address *addr, ValueObject *valobj,
1128  bool function_changed, bool initial_function) {
1129  if (format && format[0]) {
1130  FormatEntity::Entry root;
1131  llvm::StringRef format_str(format);
1132  Status error = FormatEntity::Parse(format_str, root);
1133  if (error.Success()) {
1134  return FormatEntity::Format(root, s, sc, exe_ctx, addr, valobj,
1135  function_changed, initial_function);
1136  }
1137  }
1138  return false;
1139 }
1140 
1141 bool FormatEntity::Format(const Entry &entry, Stream &s,
1142  const SymbolContext *sc,
1143  const ExecutionContext *exe_ctx, const Address *addr,
1144  ValueObject *valobj, bool function_changed,
1145  bool initial_function) {
1146  switch (entry.type) {
1147  case Entry::Type::Invalid:
1148  case Entry::Type::ParentNumber: // Only used for
1149  // FormatEntity::Entry::Definition encoding
1150  case Entry::Type::ParentString: // Only used for
1151  // FormatEntity::Entry::Definition encoding
1152  return false;
1154  if (exe_ctx) {
1155  if (Target *target = exe_ctx->GetTargetPtr()) {
1156  Debugger &debugger = target->GetDebugger();
1157  if (debugger.GetUseColor()) {
1158  s.PutCString(entry.string);
1159  }
1160  }
1161  }
1162  // Always return true, so colors being disabled is transparent.
1163  return true;
1164 
1165  case Entry::Type::Root:
1166  for (const auto &child : entry.children) {
1167  if (!Format(child, s, sc, exe_ctx, addr, valobj, function_changed,
1168  initial_function)) {
1169  return false; // If any item of root fails, then the formatting fails
1170  }
1171  }
1172  return true; // Only return true if all items succeeded
1173 
1174  case Entry::Type::String:
1175  s.PutCString(entry.string);
1176  return true;
1177 
1178  case Entry::Type::Scope: {
1179  StreamString scope_stream;
1180  bool success = false;
1181  for (const auto &child : entry.children) {
1182  success = Format(child, scope_stream, sc, exe_ctx, addr, valobj,
1183  function_changed, initial_function);
1184  if (!success)
1185  break;
1186  }
1187  // Only if all items in a scope succeed, then do we print the output into
1188  // the main stream
1189  if (success)
1190  s.Write(scope_stream.GetString().data(), scope_stream.GetString().size());
1191  }
1192  return true; // Scopes always successfully print themselves
1193 
1194  case Entry::Type::Variable:
1198  return DumpValue(s, sc, exe_ctx, entry, valobj);
1199 
1203  return (
1204  addr != nullptr && addr->IsValid() &&
1205  DumpAddressAndContent(s, sc, exe_ctx, *addr,
1207 
1209  if (exe_ctx) {
1210  Process *process = exe_ctx->GetProcessPtr();
1211  if (process) {
1212  const char *format = "%" PRIu64;
1213  if (!entry.printf_format.empty())
1214  format = entry.printf_format.c_str();
1215  s.Printf(format, process->GetID());
1216  return true;
1217  }
1218  }
1219  return false;
1220 
1222  if (exe_ctx) {
1223  Process *process = exe_ctx->GetProcessPtr();
1224  if (process) {
1225  Module *exe_module = process->GetTarget().GetExecutableModulePointer();
1226  if (exe_module) {
1227  if (DumpFile(s, exe_module->GetFileSpec(), (FileKind)entry.number))
1228  return true;
1229  }
1230  }
1231  }
1232  return false;
1233 
1235  if (exe_ctx) {
1236  Process *process = exe_ctx->GetProcessPtr();
1237  if (process)
1238  return RunScriptFormatKeyword(s, sc, exe_ctx, process,
1239  entry.string.c_str());
1240  }
1241  return false;
1242 
1243  case Entry::Type::ThreadID:
1244  if (exe_ctx) {
1245  Thread *thread = exe_ctx->GetThreadPtr();
1246  if (thread) {
1247  const char *format = "0x%4.4" PRIx64;
1248  if (!entry.printf_format.empty()) {
1249  // Watch for the special "tid" format...
1250  if (entry.printf_format == "tid") {
1251  // TODO(zturner): Rather than hardcoding this to be platform
1252  // specific, it should be controlled by a setting and the default
1253  // value of the setting can be different depending on the platform.
1254  Target &target = thread->GetProcess()->GetTarget();
1255  ArchSpec arch(target.GetArchitecture());
1256  llvm::Triple::OSType ostype = arch.IsValid()
1257  ? arch.GetTriple().getOS()
1258  : llvm::Triple::UnknownOS;
1259  if ((ostype == llvm::Triple::FreeBSD) ||
1260  (ostype == llvm::Triple::Linux) ||
1261  (ostype == llvm::Triple::NetBSD)) {
1262  format = "%" PRIu64;
1263  }
1264  } else {
1265  format = entry.printf_format.c_str();
1266  }
1267  }
1268  s.Printf(format, thread->GetID());
1269  return true;
1270  }
1271  }
1272  return false;
1273 
1275  if (exe_ctx) {
1276  Thread *thread = exe_ctx->GetThreadPtr();
1277  if (thread) {
1278  const char *format = "0x%4.4" PRIx64;
1279  if (!entry.printf_format.empty())
1280  format = entry.printf_format.c_str();
1281  s.Printf(format, thread->GetProtocolID());
1282  return true;
1283  }
1284  }
1285  return false;
1286 
1288  if (exe_ctx) {
1289  Thread *thread = exe_ctx->GetThreadPtr();
1290  if (thread) {
1291  const char *format = "%" PRIu32;
1292  if (!entry.printf_format.empty())
1293  format = entry.printf_format.c_str();
1294  s.Printf(format, thread->GetIndexID());
1295  return true;
1296  }
1297  }
1298  return false;
1299 
1301  if (exe_ctx) {
1302  Thread *thread = exe_ctx->GetThreadPtr();
1303  if (thread) {
1304  const char *cstr = thread->GetName();
1305  if (cstr && cstr[0]) {
1306  s.PutCString(cstr);
1307  return true;
1308  }
1309  }
1310  }
1311  return false;
1312 
1314  if (exe_ctx) {
1315  Thread *thread = exe_ctx->GetThreadPtr();
1316  if (thread) {
1317  const char *cstr = thread->GetQueueName();
1318  if (cstr && cstr[0]) {
1319  s.PutCString(cstr);
1320  return true;
1321  }
1322  }
1323  }
1324  return false;
1325 
1327  if (exe_ctx) {
1328  if (Thread *thread = exe_ctx->GetThreadPtr()) {
1329  std::string stop_description = thread->GetStopDescription();
1330  if (!stop_description.empty()) {
1331  s.PutCString(stop_description);
1332  return true;
1333  }
1334  }
1335  }
1336  return false;
1337 
1339  if (exe_ctx) {
1340  if (Thread *thread = exe_ctx->GetThreadPtr()) {
1341  std::string stop_description = thread->GetStopDescriptionRaw();
1342  if (!stop_description.empty()) {
1343  s.PutCString(stop_description);
1344  return true;
1345  }
1346  }
1347  }
1348  return false;
1349 
1351  if (exe_ctx) {
1352  Thread *thread = exe_ctx->GetThreadPtr();
1353  if (thread) {
1354  StopInfoSP stop_info_sp = thread->GetStopInfo();
1355  if (stop_info_sp && stop_info_sp->IsValid()) {
1356  ValueObjectSP return_valobj_sp =
1357  StopInfo::GetReturnValueObject(stop_info_sp);
1358  if (return_valobj_sp) {
1359  return_valobj_sp->Dump(s);
1360  return true;
1361  }
1362  }
1363  }
1364  }
1365  return false;
1366 
1368  if (exe_ctx) {
1369  Thread *thread = exe_ctx->GetThreadPtr();
1370  if (thread) {
1371  StopInfoSP stop_info_sp = thread->GetStopInfo();
1372  if (stop_info_sp && stop_info_sp->IsValid()) {
1373  ExpressionVariableSP expression_var_sp =
1374  StopInfo::GetExpressionVariable(stop_info_sp);
1375  if (expression_var_sp && expression_var_sp->GetValueObject()) {
1376  expression_var_sp->GetValueObject()->Dump(s);
1377  return true;
1378  }
1379  }
1380  }
1381  }
1382  return false;
1383 
1385  if (exe_ctx) {
1386  Thread *thread = exe_ctx->GetThreadPtr();
1387  if (thread)
1388  return RunScriptFormatKeyword(s, sc, exe_ctx, thread,
1389  entry.string.c_str());
1390  }
1391  return false;
1392 
1394  if (exe_ctx) {
1395  Thread *thread = exe_ctx->GetThreadPtr();
1396  if (thread) {
1397  StructuredData::ObjectSP object_sp = thread->GetExtendedInfo();
1398  if (object_sp &&
1399  object_sp->GetType() == eStructuredDataTypeDictionary) {
1400  if (FormatThreadExtendedInfoRecurse(entry, object_sp, sc, exe_ctx, s))
1401  return true;
1402  }
1403  }
1404  }
1405  return false;
1406 
1408  if (exe_ctx) {
1409  Target *target = exe_ctx->GetTargetPtr();
1410  if (target) {
1411  const ArchSpec &arch = target->GetArchitecture();
1412  if (arch.IsValid()) {
1413  s.PutCString(arch.GetArchitectureName());
1414  return true;
1415  }
1416  }
1417  }
1418  return false;
1419 
1421  if (exe_ctx) {
1422  Target *target = exe_ctx->GetTargetPtr();
1423  if (target)
1424  return RunScriptFormatKeyword(s, sc, exe_ctx, target,
1425  entry.string.c_str());
1426  }
1427  return false;
1428 
1430  if (sc) {
1431  Module *module = sc->module_sp.get();
1432  if (module) {
1433  if (DumpFile(s, module->GetFileSpec(), (FileKind)entry.number))
1434  return true;
1435  }
1436  }
1437  return false;
1438 
1439  case Entry::Type::File:
1440  if (sc) {
1441  CompileUnit *cu = sc->comp_unit;
1442  if (cu) {
1443  if (DumpFile(s, cu->GetPrimaryFile(), (FileKind)entry.number))
1444  return true;
1445  }
1446  }
1447  return false;
1448 
1449  case Entry::Type::Lang:
1450  if (sc) {
1451  CompileUnit *cu = sc->comp_unit;
1452  if (cu) {
1453  const char *lang_name =
1455  if (lang_name) {
1456  s.PutCString(lang_name);
1457  return true;
1458  }
1459  }
1460  }
1461  return false;
1462 
1464  if (exe_ctx) {
1465  StackFrame *frame = exe_ctx->GetFramePtr();
1466  if (frame) {
1467  const char *format = "%" PRIu32;
1468  if (!entry.printf_format.empty())
1469  format = entry.printf_format.c_str();
1470  s.Printf(format, frame->GetFrameIndex());
1471  return true;
1472  }
1473  }
1474  return false;
1475 
1477  if (exe_ctx) {
1478  StackFrame *frame = exe_ctx->GetFramePtr();
1479  if (frame) {
1480  const Address &pc_addr = frame->GetFrameCodeAddress();
1481  if (pc_addr.IsValid()) {
1482  if (DumpAddressAndContent(s, sc, exe_ctx, pc_addr, false))
1483  return true;
1484  }
1485  }
1486  }
1487  return false;
1488 
1490  if (exe_ctx) {
1491  StackFrame *frame = exe_ctx->GetFramePtr();
1492  if (frame) {
1494  (lldb::Format)entry.number))
1495  return true;
1496  }
1497  }
1498  return false;
1499 
1501  if (exe_ctx) {
1502  StackFrame *frame = exe_ctx->GetFramePtr();
1503  if (frame) {
1505  (lldb::Format)entry.number))
1506  return true;
1507  }
1508  }
1509  return false;
1510 
1512  if (exe_ctx) {
1513  StackFrame *frame = exe_ctx->GetFramePtr();
1514  if (frame) {
1515  if (DumpRegister(s, frame, eRegisterKindGeneric,
1517  return true;
1518  }
1519  }
1520  return false;
1521 
1523  if (exe_ctx) {
1524  StackFrame *frame = exe_ctx->GetFramePtr();
1525  if (frame) {
1526  return !frame->HasDebugInformation();
1527  }
1528  }
1529  return true;
1530 
1532  if (exe_ctx) {
1533  StackFrame *frame = exe_ctx->GetFramePtr();
1534  if (frame) {
1535  if (DumpRegister(s, frame, entry.string.c_str(),
1536  (lldb::Format)entry.number))
1537  return true;
1538  }
1539  }
1540  return false;
1541 
1543  if (exe_ctx)
1544  if (StackFrame *frame = exe_ctx->GetFramePtr())
1545  return frame->IsArtificial();
1546  return false;
1547  }
1548 
1550  if (exe_ctx) {
1551  StackFrame *frame = exe_ctx->GetFramePtr();
1552  if (frame)
1553  return RunScriptFormatKeyword(s, sc, exe_ctx, frame,
1554  entry.string.c_str());
1555  }
1556  return false;
1557 
1559  if (sc) {
1560  if (sc->function) {
1561  s.Printf("function{0x%8.8" PRIx64 "}", sc->function->GetID());
1562  return true;
1563  } else if (sc->symbol) {
1564  s.Printf("symbol[%u]", sc->symbol->GetID());
1565  return true;
1566  }
1567  }
1568  return false;
1569 
1571  return function_changed;
1572 
1574  return initial_function;
1575 
1577  if (!sc)
1578  return false;
1579 
1580  Language *language_plugin = nullptr;
1581  bool language_plugin_handled = false;
1582  StreamString ss;
1583 
1584  if (sc->function)
1585  language_plugin = Language::FindPlugin(sc->function->GetLanguage());
1586  else if (sc->symbol)
1587  language_plugin = Language::FindPlugin(sc->symbol->GetLanguage());
1588 
1589  if (language_plugin)
1590  language_plugin_handled = language_plugin->GetFunctionDisplayName(
1592 
1593  if (language_plugin_handled) {
1594  s << ss.GetString();
1595  return true;
1596  } else {
1597  const char *name = nullptr;
1598  if (sc->function)
1599  name = sc->function->GetName().AsCString(nullptr);
1600  else if (sc->symbol)
1601  name = sc->symbol->GetName().AsCString(nullptr);
1602 
1603  if (name) {
1604  s.PutCString(name);
1605 
1606  if (sc->block) {
1607  Block *inline_block = sc->block->GetContainingInlinedBlock();
1608  if (inline_block) {
1609  const InlineFunctionInfo *inline_info =
1611  if (inline_info) {
1612  s.PutCString(" [inlined] ");
1613  inline_info->GetName().Dump(&s);
1614  }
1615  }
1616  }
1617  return true;
1618  }
1619  }
1620  }
1621  return false;
1622 
1624  if (!sc)
1625  return false;
1626 
1627  Language *language_plugin = nullptr;
1628  bool language_plugin_handled = false;
1629  StreamString ss;
1630  if (sc->function)
1631  language_plugin = Language::FindPlugin(sc->function->GetLanguage());
1632  else if (sc->symbol)
1633  language_plugin = Language::FindPlugin(sc->symbol->GetLanguage());
1634 
1635  if (language_plugin)
1636  language_plugin_handled = language_plugin->GetFunctionDisplayName(
1638  ss);
1639 
1640  if (language_plugin_handled) {
1641  s << ss.GetString();
1642  return true;
1643  } else {
1644  ConstString name;
1645  if (sc->function)
1646  name = sc->function->GetNameNoArguments();
1647  else if (sc->symbol)
1648  name = sc->symbol->GetNameNoArguments();
1649  if (name) {
1650  s.PutCString(name.GetCString());
1651  return true;
1652  }
1653  }
1654  }
1655  return false;
1656 
1658  if (!sc)
1659  return false;
1660 
1661  Language *language_plugin = nullptr;
1662  bool language_plugin_handled = false;
1663  StreamString ss;
1664  if (sc->function)
1665  language_plugin = Language::FindPlugin(sc->function->GetLanguage());
1666  else if (sc->symbol)
1667  language_plugin = Language::FindPlugin(sc->symbol->GetLanguage());
1668 
1669  if (language_plugin)
1670  language_plugin_handled = language_plugin->GetFunctionDisplayName(
1672 
1673  if (language_plugin_handled) {
1674  s << ss.GetString();
1675  return true;
1676  } else {
1677  // Print the function name with arguments in it
1678  if (sc->function) {
1679  ExecutionContextScope *exe_scope =
1680  exe_ctx ? exe_ctx->GetBestExecutionContextScope() : nullptr;
1681  const char *cstr = sc->function->GetName().AsCString(nullptr);
1682  if (cstr) {
1683  const InlineFunctionInfo *inline_info = nullptr;
1684  VariableListSP variable_list_sp;
1685  bool get_function_vars = true;
1686  if (sc->block) {
1687  Block *inline_block = sc->block->GetContainingInlinedBlock();
1688 
1689  if (inline_block) {
1690  get_function_vars = false;
1691  inline_info = sc->block->GetInlinedFunctionInfo();
1692  if (inline_info)
1693  variable_list_sp = inline_block->GetBlockVariableList(true);
1694  }
1695  }
1696 
1697  if (get_function_vars) {
1698  variable_list_sp =
1699  sc->function->GetBlock(true).GetBlockVariableList(true);
1700  }
1701 
1702  if (inline_info) {
1703  s.PutCString(cstr);
1704  s.PutCString(" [inlined] ");
1705  cstr = inline_info->GetName().GetCString();
1706  }
1707 
1708  VariableList args;
1709  if (variable_list_sp)
1710  variable_list_sp->AppendVariablesWithScope(
1712  if (args.GetSize() > 0) {
1713  PrettyPrintFunctionNameWithArgs(s, cstr, exe_scope, args);
1714  } else {
1715  s.PutCString(cstr);
1716  }
1717  return true;
1718  }
1719  } else if (sc->symbol) {
1720  const char *cstr = sc->symbol->GetName().AsCString(nullptr);
1721  if (cstr) {
1722  s.PutCString(cstr);
1723  return true;
1724  }
1725  }
1726  }
1727  }
1728  return false;
1729 
1731  if (!sc)
1732  return false;
1733 
1734  const char *name = nullptr;
1735  if (sc->symbol)
1736  name =
1737  sc->symbol->GetMangled().GetName(Mangled::ePreferMangled).AsCString();
1738  else if (sc->function)
1739  name = sc->function->GetMangled()
1740  .GetName(Mangled::ePreferMangled)
1741  .AsCString();
1742 
1743  if (!name)
1744  return false;
1745  s.PutCString(name);
1746 
1747  if (sc->block && sc->block->GetContainingInlinedBlock()) {
1748  if (const InlineFunctionInfo *inline_info =
1749  sc->block->GetInlinedFunctionInfo()) {
1750  s.PutCString(" [inlined] ");
1751  inline_info->GetName().Dump(&s);
1752  }
1753  }
1754  return true;
1755  }
1757  if (addr) {
1758  if (DumpAddressOffsetFromFunction(s, sc, exe_ctx, *addr, false, false,
1759  false))
1760  return true;
1761  }
1762  return false;
1763 
1765  if (addr) {
1766  if (DumpAddressOffsetFromFunction(s, sc, exe_ctx, *addr, true, true,
1767  true))
1768  return true;
1769  }
1770  return false;
1771 
1773  if (sc)
1775  s, sc, exe_ctx, sc->line_entry.range.GetBaseAddress(), false, false,
1776  false));
1777  return false;
1778 
1780  if (exe_ctx) {
1781  StackFrame *frame = exe_ctx->GetFramePtr();
1782  if (frame) {
1783  if (DumpAddressOffsetFromFunction(s, sc, exe_ctx,
1784  frame->GetFrameCodeAddress(), false,
1785  false, false))
1786  return true;
1787  }
1788  }
1789  return false;
1790 
1792  return function_changed;
1793 
1795  bool is_optimized = false;
1796  if (sc && sc->function && sc->function->GetIsOptimized()) {
1797  is_optimized = true;
1798  }
1799  return is_optimized;
1800  }
1801 
1803  return initial_function;
1804 
1806  if (sc && sc->line_entry.IsValid()) {
1807  Module *module = sc->module_sp.get();
1808  if (module) {
1809  if (DumpFile(s, sc->line_entry.file, (FileKind)entry.number))
1810  return true;
1811  }
1812  }
1813  return false;
1814 
1816  if (sc && sc->line_entry.IsValid()) {
1817  const char *format = "%" PRIu32;
1818  if (!entry.printf_format.empty())
1819  format = entry.printf_format.c_str();
1820  s.Printf(format, sc->line_entry.line);
1821  return true;
1822  }
1823  return false;
1824 
1826  if (sc && sc->line_entry.IsValid() && sc->line_entry.column) {
1827  const char *format = "%" PRIu32;
1828  if (!entry.printf_format.empty())
1829  format = entry.printf_format.c_str();
1830  s.Printf(format, sc->line_entry.column);
1831  return true;
1832  }
1833  return false;
1834 
1837  if (sc && sc->line_entry.range.GetBaseAddress().IsValid()) {
1838  Address addr = sc->line_entry.range.GetBaseAddress();
1839 
1841  addr.Slide(sc->line_entry.range.GetByteSize());
1842  if (DumpAddressAndContent(s, sc, exe_ctx, addr, false))
1843  return true;
1844  }
1845  return false;
1846 
1848  if (addr && exe_ctx && exe_ctx->GetFramePtr()) {
1849  RegisterContextSP reg_ctx =
1850  exe_ctx->GetFramePtr()->GetRegisterContextSP();
1851  if (reg_ctx) {
1852  addr_t pc_loadaddr = reg_ctx->GetPC();
1853  if (pc_loadaddr != LLDB_INVALID_ADDRESS) {
1854  Address pc;
1855  pc.SetLoadAddress(pc_loadaddr, exe_ctx->GetTargetPtr());
1856  if (pc == *addr) {
1857  s.Printf("-> ");
1858  return true;
1859  }
1860  }
1861  }
1862  s.Printf(" ");
1863  return true;
1864  }
1865  return false;
1866  }
1867  return false;
1868 }
1869 
1871  const Definition *parent) {
1872  if (parent->children) {
1873  const size_t n = parent->num_children;
1874  for (size_t i = 0; i < n; ++i) {
1875  if (i > 0)
1876  s.PutCString(", ");
1877  s.Printf("\"%s\"", parent->children[i].name);
1878  }
1879  return true;
1880  }
1881  return false;
1882 }
1883 
1884 static Status ParseEntry(const llvm::StringRef &format_str,
1885  const Definition *parent, FormatEntity::Entry &entry) {
1886  Status error;
1887 
1888  const size_t sep_pos = format_str.find_first_of(".[:");
1889  const char sep_char =
1890  (sep_pos == llvm::StringRef::npos) ? '\0' : format_str[sep_pos];
1891  llvm::StringRef key = format_str.substr(0, sep_pos);
1892 
1893  const size_t n = parent->num_children;
1894  for (size_t i = 0; i < n; ++i) {
1895  const Definition *entry_def = parent->children + i;
1896  if (key.equals(entry_def->name) || entry_def->name[0] == '*') {
1897  llvm::StringRef value;
1898  if (sep_char)
1899  value =
1900  format_str.substr(sep_pos + (entry_def->keep_separator ? 0 : 1));
1901  switch (entry_def->type) {
1903  entry.string = format_str.str();
1904  return error; // Success
1905 
1907  entry.number = entry_def->data;
1908  return error; // Success
1909 
1911  entry.type = entry_def->type;
1912  entry.string = entry_def->string;
1913  return error; // Success
1914 
1915  default:
1916  entry.type = entry_def->type;
1917  break;
1918  }
1919 
1920  if (value.empty()) {
1921  if (entry_def->type == FormatEntity::Entry::Type::Invalid) {
1922  if (entry_def->children) {
1923  StreamString error_strm;
1924  error_strm.Printf("'%s' can't be specified on its own, you must "
1925  "access one of its children: ",
1926  entry_def->name);
1927  DumpCommaSeparatedChildEntryNames(error_strm, entry_def);
1928  error.SetErrorStringWithFormat("%s", error_strm.GetData());
1929  } else if (sep_char == ':') {
1930  // Any value whose separator is a with a ':' means this value has a
1931  // string argument that needs to be stored in the entry (like
1932  // "${script.var:}"). In this case the string value is the empty
1933  // string which is ok.
1934  } else {
1935  error.SetErrorStringWithFormat("%s", "invalid entry definitions");
1936  }
1937  }
1938  } else {
1939  if (entry_def->children) {
1940  error = ParseEntry(value, entry_def, entry);
1941  } else if (sep_char == ':') {
1942  // Any value whose separator is a with a ':' means this value has a
1943  // string argument that needs to be stored in the entry (like
1944  // "${script.var:modulename.function}")
1945  entry.string = value.str();
1946  } else {
1947  error.SetErrorStringWithFormat(
1948  "'%s' followed by '%s' but it has no children", key.str().c_str(),
1949  value.str().c_str());
1950  }
1951  }
1952  return error;
1953  }
1954  }
1955  StreamString error_strm;
1956  if (parent->type == FormatEntity::Entry::Type::Root)
1957  error_strm.Printf(
1958  "invalid top level item '%s'. Valid top level items are: ",
1959  key.str().c_str());
1960  else
1961  error_strm.Printf("invalid member '%s' in '%s'. Valid members are: ",
1962  key.str().c_str(), parent->name);
1963  DumpCommaSeparatedChildEntryNames(error_strm, parent);
1964  error.SetErrorStringWithFormat("%s", error_strm.GetData());
1965  return error;
1966 }
1967 
1968 static const Definition *FindEntry(const llvm::StringRef &format_str,
1969  const Definition *parent,
1970  llvm::StringRef &remainder) {
1971  Status error;
1972 
1973  std::pair<llvm::StringRef, llvm::StringRef> p = format_str.split('.');
1974  const size_t n = parent->num_children;
1975  for (size_t i = 0; i < n; ++i) {
1976  const Definition *entry_def = parent->children + i;
1977  if (p.first.equals(entry_def->name) || entry_def->name[0] == '*') {
1978  if (p.second.empty()) {
1979  if (format_str.back() == '.')
1980  remainder = format_str.drop_front(format_str.size() - 1);
1981  else
1982  remainder = llvm::StringRef(); // Exact match
1983  return entry_def;
1984  } else {
1985  if (entry_def->children) {
1986  return FindEntry(p.second, entry_def, remainder);
1987  } else {
1988  remainder = p.second;
1989  return entry_def;
1990  }
1991  }
1992  }
1993  }
1994  remainder = format_str;
1995  return parent;
1996 }
1997 
1998 Status FormatEntity::ParseInternal(llvm::StringRef &format, Entry &parent_entry,
1999  uint32_t depth) {
2000  Status error;
2001  while (!format.empty() && error.Success()) {
2002  const size_t non_special_chars = format.find_first_of("${}\\");
2003 
2004  if (non_special_chars == llvm::StringRef::npos) {
2005  // No special characters, just string bytes so add them and we are done
2006  parent_entry.AppendText(format);
2007  return error;
2008  }
2009 
2010  if (non_special_chars > 0) {
2011  // We have a special character, so add all characters before these as a
2012  // plain string
2013  parent_entry.AppendText(format.substr(0, non_special_chars));
2014  format = format.drop_front(non_special_chars);
2015  }
2016 
2017  switch (format[0]) {
2018  case '\0':
2019  return error;
2020 
2021  case '{': {
2022  format = format.drop_front(); // Skip the '{'
2023  Entry scope_entry(Entry::Type::Scope);
2024  error = FormatEntity::ParseInternal(format, scope_entry, depth + 1);
2025  if (error.Fail())
2026  return error;
2027  parent_entry.AppendEntry(std::move(scope_entry));
2028  } break;
2029 
2030  case '}':
2031  if (depth == 0)
2032  error.SetErrorString("unmatched '}' character");
2033  else
2034  format =
2035  format
2036  .drop_front(); // Skip the '}' as we are at the end of the scope
2037  return error;
2038 
2039  case '\\': {
2040  format = format.drop_front(); // Skip the '\' character
2041  if (format.empty()) {
2042  error.SetErrorString(
2043  "'\\' character was not followed by another character");
2044  return error;
2045  }
2046 
2047  const char desens_char = format[0];
2048  format = format.drop_front(); // Skip the desensitized char character
2049  switch (desens_char) {
2050  case 'a':
2051  parent_entry.AppendChar('\a');
2052  break;
2053  case 'b':
2054  parent_entry.AppendChar('\b');
2055  break;
2056  case 'f':
2057  parent_entry.AppendChar('\f');
2058  break;
2059  case 'n':
2060  parent_entry.AppendChar('\n');
2061  break;
2062  case 'r':
2063  parent_entry.AppendChar('\r');
2064  break;
2065  case 't':
2066  parent_entry.AppendChar('\t');
2067  break;
2068  case 'v':
2069  parent_entry.AppendChar('\v');
2070  break;
2071  case '\'':
2072  parent_entry.AppendChar('\'');
2073  break;
2074  case '\\':
2075  parent_entry.AppendChar('\\');
2076  break;
2077  case '0':
2078  // 1 to 3 octal chars
2079  {
2080  // Make a string that can hold onto the initial zero char, up to 3
2081  // octal digits, and a terminating NULL.
2082  char oct_str[5] = {0, 0, 0, 0, 0};
2083 
2084  int i;
2085  for (i = 0; (format[i] >= '0' && format[i] <= '7') && i < 4; ++i)
2086  oct_str[i] = format[i];
2087 
2088  // We don't want to consume the last octal character since the main
2089  // for loop will do this for us, so we advance p by one less than i
2090  // (even if i is zero)
2091  format = format.drop_front(i);
2092  unsigned long octal_value = ::strtoul(oct_str, nullptr, 8);
2093  if (octal_value <= UINT8_MAX) {
2094  parent_entry.AppendChar((char)octal_value);
2095  } else {
2096  error.SetErrorString("octal number is larger than a single byte");
2097  return error;
2098  }
2099  }
2100  break;
2101 
2102  case 'x':
2103  // hex number in the format
2104  if (isxdigit(format[0])) {
2105  // Make a string that can hold onto two hex chars plus a
2106  // NULL terminator
2107  char hex_str[3] = {0, 0, 0};
2108  hex_str[0] = format[0];
2109 
2110  format = format.drop_front();
2111 
2112  if (isxdigit(format[0])) {
2113  hex_str[1] = format[0];
2114  format = format.drop_front();
2115  }
2116 
2117  unsigned long hex_value = strtoul(hex_str, nullptr, 16);
2118  if (hex_value <= UINT8_MAX) {
2119  parent_entry.AppendChar((char)hex_value);
2120  } else {
2121  error.SetErrorString("hex number is larger than a single byte");
2122  return error;
2123  }
2124  } else {
2125  parent_entry.AppendChar(desens_char);
2126  }
2127  break;
2128 
2129  default:
2130  // Just desensitize any other character by just printing what came
2131  // after the '\'
2132  parent_entry.AppendChar(desens_char);
2133  break;
2134  }
2135  } break;
2136 
2137  case '$':
2138  if (format.size() == 1) {
2139  // '$' at the end of a format string, just print the '$'
2140  parent_entry.AppendText("$");
2141  } else {
2142  format = format.drop_front(); // Skip the '$'
2143 
2144  if (format[0] == '{') {
2145  format = format.drop_front(); // Skip the '{'
2146 
2147  llvm::StringRef variable, variable_format;
2148  error = FormatEntity::ExtractVariableInfo(format, variable,
2149  variable_format);
2150  if (error.Fail())
2151  return error;
2152  bool verify_is_thread_id = false;
2153  Entry entry;
2154  if (!variable_format.empty()) {
2155  entry.printf_format = variable_format.str();
2156 
2157  // If the format contains a '%' we are going to assume this is a
2158  // printf style format. So if you want to format your thread ID
2159  // using "0x%llx" you can use: ${thread.id%0x%llx}
2160  //
2161  // If there is no '%' in the format, then it is assumed to be a
2162  // LLDB format name, or one of the extended formats specified in
2163  // the switch statement below.
2164 
2165  if (entry.printf_format.find('%') == std::string::npos) {
2166  bool clear_printf = false;
2167 
2169  entry.printf_format.c_str(), false, entry.fmt)) {
2170  // We have an LLDB format, so clear the printf format
2171  clear_printf = true;
2172  } else if (entry.printf_format.size() == 1) {
2173  switch (entry.printf_format[0]) {
2174  case '@': // if this is an @ sign, print ObjC description
2175  entry.number = ValueObject::
2177  clear_printf = true;
2178  break;
2179  case 'V': // if this is a V, print the value using the default
2180  // format
2181  entry.number =
2183  clear_printf = true;
2184  break;
2185  case 'L': // if this is an L, print the location of the value
2186  entry.number =
2188  clear_printf = true;
2189  break;
2190  case 'S': // if this is an S, print the summary after all
2191  entry.number =
2193  clear_printf = true;
2194  break;
2195  case '#': // if this is a '#', print the number of children
2196  entry.number =
2198  clear_printf = true;
2199  break;
2200  case 'T': // if this is a 'T', print the type
2201  entry.number =
2203  clear_printf = true;
2204  break;
2205  case 'N': // if this is a 'N', print the name
2206  entry.number =
2208  clear_printf = true;
2209  break;
2210  case '>': // if this is a '>', print the expression path
2211  entry.number = ValueObject::
2213  clear_printf = true;
2214  break;
2215  default:
2216  error.SetErrorStringWithFormat("invalid format: '%s'",
2217  entry.printf_format.c_str());
2218  return error;
2219  }
2221  entry.printf_format.c_str(), true, entry.fmt)) {
2222  clear_printf = true;
2223  } else if (entry.printf_format == "tid") {
2224  verify_is_thread_id = true;
2225  } else {
2226  error.SetErrorStringWithFormat("invalid format: '%s'",
2227  entry.printf_format.c_str());
2228  return error;
2229  }
2230 
2231  // Our format string turned out to not be a printf style format
2232  // so lets clear the string
2233  if (clear_printf)
2234  entry.printf_format.clear();
2235  }
2236  }
2237 
2238  // Check for dereferences
2239  if (variable[0] == '*') {
2240  entry.deref = true;
2241  variable = variable.drop_front();
2242  }
2243 
2244  error = ParseEntry(variable, &g_root, entry);
2245  if (error.Fail())
2246  return error;
2247 
2248  if (verify_is_thread_id) {
2249  if (entry.type != Entry::Type::ThreadID &&
2251  error.SetErrorString("the 'tid' format can only be used on "
2252  "${thread.id} and ${thread.protocol_id}");
2253  }
2254  }
2255 
2256  switch (entry.type) {
2257  case Entry::Type::Variable:
2259  if (entry.number == 0) {
2260  if (entry.string.empty())
2261  entry.number =
2263  else
2264  entry.number =
2266  }
2267  break;
2268  default:
2269  // Make sure someone didn't try to dereference anything but ${var}
2270  // or ${svar}
2271  if (entry.deref) {
2272  error.SetErrorStringWithFormat(
2273  "${%s} can't be dereferenced, only ${var} and ${svar} can.",
2274  variable.str().c_str());
2275  return error;
2276  }
2277  }
2278  parent_entry.AppendEntry(std::move(entry));
2279  }
2280  }
2281  break;
2282  }
2283  }
2284  return error;
2285 }
2286 
2287 Status FormatEntity::ExtractVariableInfo(llvm::StringRef &format_str,
2288  llvm::StringRef &variable_name,
2289  llvm::StringRef &variable_format) {
2290  Status error;
2291  variable_name = llvm::StringRef();
2292  variable_format = llvm::StringRef();
2293 
2294  const size_t paren_pos = format_str.find('}');
2295  if (paren_pos != llvm::StringRef::npos) {
2296  const size_t percent_pos = format_str.find('%');
2297  if (percent_pos < paren_pos) {
2298  if (percent_pos > 0) {
2299  if (percent_pos > 1)
2300  variable_name = format_str.substr(0, percent_pos);
2301  variable_format =
2302  format_str.substr(percent_pos + 1, paren_pos - (percent_pos + 1));
2303  }
2304  } else {
2305  variable_name = format_str.substr(0, paren_pos);
2306  }
2307  // Strip off elements and the formatting and the trailing '}'
2308  format_str = format_str.substr(paren_pos + 1);
2309  } else {
2310  error.SetErrorStringWithFormat(
2311  "missing terminating '}' character for '${%s'",
2312  format_str.str().c_str());
2313  }
2314  return error;
2315 }
2316 
2318  llvm::StringRef variable_name,
2319  llvm::StringRef variable_format) {
2320  if (variable_name.empty() || variable_name.equals(".fullpath")) {
2321  file_spec.Dump(s.AsRawOstream());
2322  return true;
2323  } else if (variable_name.equals(".basename")) {
2324  s.PutCString(file_spec.GetFilename().GetStringRef());
2325  return true;
2326  } else if (variable_name.equals(".dirname")) {
2327  s.PutCString(file_spec.GetFilename().GetStringRef());
2328  return true;
2329  }
2330  return false;
2331 }
2332 
2333 static std::string MakeMatch(const llvm::StringRef &prefix,
2334  const char *suffix) {
2335  std::string match(prefix.str());
2336  match.append(suffix);
2337  return match;
2338 }
2339 
2340 static void AddMatches(const Definition *def, const llvm::StringRef &prefix,
2341  const llvm::StringRef &match_prefix,
2342  StringList &matches) {
2343  const size_t n = def->num_children;
2344  if (n > 0) {
2345  for (size_t i = 0; i < n; ++i) {
2346  std::string match = prefix.str();
2347  if (match_prefix.empty())
2348  matches.AppendString(MakeMatch(prefix, def->children[i].name));
2349  else if (strncmp(def->children[i].name, match_prefix.data(),
2350  match_prefix.size()) == 0)
2351  matches.AppendString(
2352  MakeMatch(prefix, def->children[i].name + match_prefix.size()));
2353  }
2354  }
2355 }
2356 
2358  llvm::StringRef str = request.GetCursorArgumentPrefix();
2359 
2360  const size_t dollar_pos = str.rfind('$');
2361  if (dollar_pos == llvm::StringRef::npos)
2362  return;
2363 
2364  // Hitting TAB after $ at the end of the string add a "{"
2365  if (dollar_pos == str.size() - 1) {
2366  std::string match = str.str();
2367  match.append("{");
2368  request.AddCompletion(match);
2369  return;
2370  }
2371 
2372  if (str[dollar_pos + 1] != '{')
2373  return;
2374 
2375  const size_t close_pos = str.find('}', dollar_pos + 2);
2376  if (close_pos != llvm::StringRef::npos)
2377  return;
2378 
2379  const size_t format_pos = str.find('%', dollar_pos + 2);
2380  if (format_pos != llvm::StringRef::npos)
2381  return;
2382 
2383  llvm::StringRef partial_variable(str.substr(dollar_pos + 2));
2384  if (partial_variable.empty()) {
2385  // Suggest all top level entities as we are just past "${"
2386  StringList new_matches;
2387  AddMatches(&g_root, str, llvm::StringRef(), new_matches);
2388  request.AddCompletions(new_matches);
2389  return;
2390  }
2391 
2392  // We have a partially specified variable, find it
2393  llvm::StringRef remainder;
2394  const Definition *entry_def = FindEntry(partial_variable, &g_root, remainder);
2395  if (!entry_def)
2396  return;
2397 
2398  const size_t n = entry_def->num_children;
2399 
2400  if (remainder.empty()) {
2401  // Exact match
2402  if (n > 0) {
2403  // "${thread.info" <TAB>
2404  request.AddCompletion(MakeMatch(str, "."));
2405  } else {
2406  // "${thread.id" <TAB>
2407  request.AddCompletion(MakeMatch(str, "}"));
2408  }
2409  } else if (remainder.equals(".")) {
2410  // "${thread." <TAB>
2411  StringList new_matches;
2412  AddMatches(entry_def, str, llvm::StringRef(), new_matches);
2413  request.AddCompletions(new_matches);
2414  } else {
2415  // We have a partial match
2416  // "${thre" <TAB>
2417  StringList new_matches;
2418  AddMatches(entry_def, str, remainder, new_matches);
2419  request.AddCompletions(new_matches);
2420  }
2421 }
2422 
2424  Stream &out_stream, VariableList const &args,
2425  ExecutionContextScope *exe_scope) {
2426  const size_t num_args = args.GetSize();
2427  for (size_t arg_idx = 0; arg_idx < num_args; ++arg_idx) {
2428  std::string buffer;
2429 
2430  VariableSP var_sp(args.GetVariableAtIndex(arg_idx));
2431  ValueObjectSP var_value_sp(ValueObjectVariable::Create(exe_scope, var_sp));
2432  StreamString ss;
2433  llvm::StringRef var_representation;
2434  const char *var_name = var_value_sp->GetName().GetCString();
2435  if (var_value_sp->GetCompilerType().IsValid()) {
2436  if (exe_scope && exe_scope->CalculateTarget())
2437  var_value_sp = var_value_sp->GetQualifiedRepresentationIfAvailable(
2438  exe_scope->CalculateTarget()
2439  ->TargetProperties::GetPreferDynamicValue(),
2440  exe_scope->CalculateTarget()
2441  ->TargetProperties::GetEnableSyntheticValue());
2442  if (var_value_sp->GetCompilerType().IsAggregateType() &&
2445  .SetHideItemNames(false)
2446  .SetShowMembersOneLiner(true),
2447  "");
2448  format.FormatObject(var_value_sp.get(), buffer, TypeSummaryOptions());
2449  var_representation = buffer;
2450  } else
2451  var_value_sp->DumpPrintableRepresentation(
2452  ss,
2454  eValueObjectRepresentationStyleSummary,
2457  }
2458 
2459  if (!ss.GetString().empty())
2460  var_representation = ss.GetString();
2461  if (arg_idx > 0)
2462  out_stream.PutCString(", ");
2463  if (var_value_sp->GetError().Success()) {
2464  if (!var_representation.empty())
2465  out_stream.Printf("%s=%s", var_name, var_representation.str().c_str());
2466  else
2467  out_stream.Printf("%s=%s at %s", var_name,
2468  var_value_sp->GetTypeName().GetCString(),
2469  var_value_sp->GetLocationAsCString());
2470  } else
2471  out_stream.Printf("%s=<unavailable>", var_name);
2472  }
2473 }
lldb_private::FormatEntity::Entry::Type::FrameRegisterFP
@ FrameRegisterFP
ANSI_BG_COLOR_RED
#define ANSI_BG_COLOR_RED
Definition: AnsiTerminal.h:31
lldb_private::ValueObject::IsBitfield
bool IsBitfield()
Definition: ValueObject.h:428
lldb_private::FormatEntity::FormatCString
static bool FormatCString(const char *format, Stream &s, const SymbolContext *sc, const ExecutionContext *exe_ctx, const Address *addr, ValueObject *valobj, bool function_changed, bool initial_function)
Definition: FormatEntity.cpp:1124
ParseBaseName
static std::pair< char const *, char const * > ParseBaseName(char const *full_name)
Parses the basename out of a demangled function name that may include function arguments.
Definition: FormatEntity.cpp:1050
lldb_private::AddressRange::GetBaseAddress
Address & GetBaseAddress()
Get accessor for the base address of the range.
Definition: AddressRange.h:209
lldb_private::FormatEntity::Entry::Type::FunctionInitial
@ FunctionInitial
Block.h
lldb_private::Stream::Format
void Format(const char *format, Args &&... args)
Definition: Stream.h:309
g_root
constexpr Definition g_root
Definition: FormatEntity.cpp:261
lldb_private::Language::FunctionNameRepresentation::eNameWithNoArgs
@ eNameWithNoArgs
lldb_private::FormatEntity::PrettyPrintFunctionArguments
static void PrettyPrintFunctionArguments(Stream &out_stream, VariableList const &args, ExecutionContextScope *exe_scope)
For each variable in 'args' this function writes the variable name and it's pretty-printed value repr...
Definition: FormatEntity.cpp:2423
lldb_private::FormatEntity::Entry::Type::FrameIsArtificial
@ FrameIsArtificial
ANSI_CTRL_CONCEAL
#define ANSI_CTRL_CONCEAL
Definition: AnsiTerminal.h:59
lldb_private::Block::GetRangeContainingAddress
bool GetRangeContainingAddress(const Address &addr, AddressRange &range)
Definition: Block.cpp:250
lldb_private::SymbolContext::block
Block * block
The Block for a given query.
Definition: SymbolContext.h:321
lldb_private::ValueObject::GetValueForExpressionPath
lldb::ValueObjectSP GetValueForExpressionPath(llvm::StringRef expression, ExpressionPathScanEndReason *reason_to_stop=nullptr, ExpressionPathEndResultType *final_value_type=nullptr, const GetValueForExpressionPathOptions &options=GetValueForExpressionPathOptions::DefaultOptions(), ExpressionPathAftermath *final_task_on_target=nullptr)
Definition: ValueObject.cpp:1996
lldb_private::ExecutionContext
Definition: ExecutionContext.h:292
ANSI_ESC_END
#define ANSI_ESC_END
Definition: AnsiTerminal.h:63
lldb_private::SymbolContext::comp_unit
CompileUnit * comp_unit
The CompileUnit for a given query.
Definition: SymbolContext.h:319
lldb_private::FormatEntity::FormatStringRef
static bool FormatStringRef(const llvm::StringRef &format, Stream &s, const SymbolContext *sc, const ExecutionContext *exe_ctx, const Address *addr, ValueObject *valobj, bool function_changed, bool initial_function)
Definition: FormatEntity.cpp:1107
lldb_private::LineEntry::file
FileSpec file
The source file, possibly mapped by the target.source-map setting.
Definition: LineEntry.h:140
ExpressionVariable.h
lldb_private::FormatEntity::Entry::Type::FrameNoDebug
@ FrameNoDebug
lldb_private::FormatEntity::Entry::Type::Variable
@ Variable
lldb_private::ArchSpec
Definition: ArchSpec.h:32
lldb_private::ValueObject::eExpressionPathAftermathNothing
@ eExpressionPathAftermathNothing
Just return it.
Definition: ValueObject.h:175
lldb_private::Block::GetBlockVariableList
lldb::VariableListSP GetBlockVariableList(bool can_create)
Get the variable list for this block only.
Definition: Block.cpp:399
Basename
@ Basename
Definition: FormatEntity.cpp:85
ANSI_CTRL_UNDERLINE
#define ANSI_CTRL_UNDERLINE
Definition: AnsiTerminal.h:55
g_function_child_entries
constexpr Definition g_function_child_entries[]
Definition: FormatEntity.cpp:111
lldb_private::FormatEntity::Entry::Definition::data
const uint64_t data
Data that is returned as the value of the format string.
Definition: FormatEntity.h:114
lldb_private::FormatEntity::Entry::Type::FunctionChanged
@ FunctionChanged
lldb_private::FormatEntity::Entry::Type::FunctionAddrOffset
@ FunctionAddrOffset
LLDB_INVALID_REGNUM
#define LLDB_INVALID_REGNUM
Definition: lldb-defines.h:79
lldb_private::Address::IsValid
bool IsValid() const
Check if the object state is valid.
Definition: Address.h:345
lldb_private::FormatEntity::Entry::Type::ThreadReturnValue
@ ThreadReturnValue
lldb_private::FormatEntity::Entry::Type::LineEntryColumn
@ LineEntryColumn
ANSI_ESC_START
#define ANSI_ESC_START
Definition: AnsiTerminal.h:62
lldb_private::ValueObject::GetValueForExpressionPathOptions
Definition: ValueObject.h:196
lldb_private::Thread::GetIndexID
uint32_t GetIndexID() const
Definition: Thread.cpp:1403
lldb_private::FormatEntity::Entry::Type::AddressFile
@ AddressFile
lldb::Format
Format
Display format definitions.
Definition: lldb-enumerations.h:156
lldb_private::InlineFunctionInfo
Definition: Function.h:125
ANSI_FG_COLOR_BLACK
#define ANSI_FG_COLOR_BLACK
Definition: AnsiTerminal.h:12
CompileUnit.h
lldb_private::LineEntry::IsValid
bool IsValid() const
Check if a line entry object is valid.
Definition: LineEntry.cpp:46
lldb_private::FormatEntity::Entry::Type::FunctionInitialFunction
@ FunctionInitialFunction
lldb_private::RegisterValue
Definition: RegisterValue.h:28
lldb_private::Function::GetAddressRange
const AddressRange & GetAddressRange()
Definition: Function.h:457
g_frame_child_entries
constexpr Definition g_frame_child_entries[]
Definition: FormatEntity.cpp:99
ANSI_CTRL_NORMAL
#define ANSI_CTRL_NORMAL
Definition: AnsiTerminal.h:51
lldb_private::FormatEntity::Entry::Type::FrameRegisterSP
@ FrameRegisterSP
ANSI_CTRL_IMAGE_NEGATIVE
#define ANSI_CTRL_IMAGE_NEGATIVE
Definition: AnsiTerminal.h:58
StructuredData.h
lldb_private::Symbol::ValueIsAddress
bool ValueIsAddress() const
Definition: Symbol.cpp:117
lldb_private::ExecutionContext::GetProcessPtr
Process * GetProcessPtr() const
Returns a pointer to the process object.
Definition: ExecutionContext.cpp:206
ANSI_CTRL_FAINT
#define ANSI_CTRL_FAINT
Definition: AnsiTerminal.h:53
lldb_private::FormatEntity::Entry::type
Type type
Definition: FormatEntity.h:203
FormatClasses.h
lldb::eRegisterKindGeneric
@ eRegisterKindGeneric
insn ptr reg, stack ptr reg, etc not specific to any particular target
Definition: lldb-enumerations.h:231
lldb_private::ValueObject::IsSynthetic
virtual bool IsSynthetic()
Definition: ValueObject.h:598
lldb::eStructuredDataTypeString
@ eStructuredDataTypeString
Definition: lldb-enumerations.h:801
AddMatches
static void AddMatches(const Definition *def, const llvm::StringRef &prefix, const llvm::StringRef &match_prefix, StringList &matches)
Definition: FormatEntity.cpp:2340
lldb_private::VariableList::AppendVariablesWithScope
size_t AppendVariablesWithScope(lldb::ValueType type, VariableList &var_list, bool if_unique=true)
Definition: VariableList.cpp:128
lldb::eStructuredDataTypeDictionary
@ eStructuredDataTypeDictionary
Definition: lldb-enumerations.h:802
lldb_private::FormatEntity::Entry::Type::ThreadProtocolID
@ ThreadProtocolID
ANSI_BG_COLOR_BLUE
#define ANSI_BG_COLOR_BLUE
Definition: AnsiTerminal.h:34
ANSI_CTRL_SLOW_BLINK
#define ANSI_CTRL_SLOW_BLINK
Definition: AnsiTerminal.h:56
lldb_private::FormatEntity::Entry::Type::CurrentPCArrow
@ CurrentPCArrow
lldb_private::ValueObject::GetValueForExpressionPathOptions::SetSyntheticChildrenTraversal
GetValueForExpressionPathOptions & SetSyntheticChildrenTraversal(SyntheticChildrenTraversal traverse)
Definition: ValueObject.h:248
lldb_private::ValueObject::eValueObjectRepresentationStyleValue
@ eValueObjectRepresentationStyleValue
Definition: ValueObject.h:113
lldb-defines.h
g_process_child_entries
constexpr Definition g_process_child_entries[]
Definition: FormatEntity.cpp:138
g_top_level_entries
constexpr Definition g_top_level_entries[]
Definition: FormatEntity.cpp:231
FormatManager.h
lldb_private::FormatEntity::Entry::TypeToCString
static const char * TypeToCString(Type t)
Definition: FormatEntity.cpp:300
lldb_private::FormatEntity::Entry::number
lldb::addr_t number
Definition: FormatEntity.h:205
lldb_private::TypeSummaryImpl::Flags
Definition: TypeSummary.h:53
lldb_private::FormatEntity::Entry::Type::FrameIndex
@ FrameIndex
lldb_private::FormatEntity::Entry::Type::ProcessFile
@ ProcessFile
lldb_private::FormatManager::GetFormatAsFormatChar
static char GetFormatAsFormatChar(lldb::Format format)
Definition: FormatManager.cpp:144
lldb_private::StackFrame::GetFrameCodeAddress
const Address & GetFrameCodeAddress()
Get an Address for the current pc value in this StackFrame.
Definition: StackFrame.cpp:190
lldb_private::FormatEntity::Entry::Type::FrameRegisterByName
@ FrameRegisterByName
lldb_private::FormatEntity::Entry::deref
bool deref
Definition: FormatEntity.h:206
lldb_private::FormatEntity::Entry::Type::LineEntryEndAddress
@ LineEntryEndAddress
lldb_private::RegisterContext::ReadRegister
virtual bool ReadRegister(const RegisterInfo *reg_info, RegisterValue &reg_value)=0
LLDB_LOGF
#define LLDB_LOGF(log,...)
Definition: Log.h:344
lldb_private::Process
Definition: Process.h:338
lldb_private::StringList::AppendString
void AppendString(const std::string &s)
Definition: StringList.cpp:43
lldb_private::Target::GetExecutableModulePointer
Module * GetExecutableModulePointer()
Definition: Target.cpp:1385
lldb_private::FormatEntity::Entry::Type::ModuleFile
@ ModuleFile
lldb_private::AddressRange::GetByteSize
lldb::addr_t GetByteSize() const
Get accessor for the byte size of this range.
Definition: AddressRange.h:221
Module.h
lldb_private::Language::GetFunctionDisplayName
virtual bool GetFunctionDisplayName(const SymbolContext *sc, const ExecutionContext *exe_ctx, FunctionNameRepresentation representation, Stream &s)
Definition: Language.cpp:451
IsToken
static bool IsToken(const char *var_name_begin, const char *var)
Definition: FormatEntity.cpp:1038
lldb_private::RegisterContext::ConvertRegisterKindToRegisterNumber
virtual uint32_t ConvertRegisterKindToRegisterNumber(lldb::RegisterKind kind, uint32_t num)
Convert from a given register numbering scheme to the lldb register numbering scheme.
Definition: RegisterContext.cpp:268
g_svar_child_entries
constexpr Definition g_svar_child_entries[]
Definition: FormatEntity.cpp:144
lldb_private::Process::GetTarget
Target & GetTarget()
Get the target object pointer for this module.
Definition: Process.h:1219
FindEntry
static const Definition * FindEntry(const llvm::StringRef &format_str, const Definition *parent, llvm::StringRef &remainder)
Definition: FormatEntity.cpp:1968
lldb_private::FormatEntity::Entry::Type::LineEntryStartAddress
@ LineEntryStartAddress
lldb_private::FormatEntity::Entry::Type::ThreadID
@ ThreadID
lldb_private::FormatEntity::Entry::Type::FunctionName
@ FunctionName
lldb_private::VariableList::GetSize
size_t GetSize() const
Definition: VariableList.cpp:165
lldb_private::ValueObject::GetQualifiedRepresentationIfAvailable
lldb::ValueObjectSP GetQualifiedRepresentationIfAvailable(lldb::DynamicValueType dynValue, bool synthValue)
Definition: ValueObject.cpp:2606
DumpCommaSeparatedChildEntryNames
static bool DumpCommaSeparatedChildEntryNames(Stream &s, const Definition *parent)
Definition: FormatEntity.cpp:1870
lldb_private::Module
Definition: Module.h:86
SectionLoadList.h
lldb_private::ExecutionContext::GetFramePtr
StackFrame * GetFramePtr() const
Returns a pointer to the frame object.
Definition: ExecutionContext.h:408
lldb_private::ConstString::AsCString
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
Definition: ConstString.h:192
lldb_private::FormatEntity::Entry::AppendText
void AppendText(const llvm::StringRef &s)
Definition: FormatEntity.cpp:278
lldb_private::ValueObject::eExpressionPathAftermathDereference
@ eExpressionPathAftermathDereference
Dereference the target.
Definition: ValueObject.h:177
lldb_private::FileSpec::GetFilename
const ConstString & GetFilename() const
Filename string const get accessor.
Definition: FileSpec.h:239
RegisterValue.h
g_var_child_entries
constexpr Definition g_var_child_entries[]
Definition: FormatEntity.cpp:147
lldb_private::ValueObject::GetBitfieldBitSize
virtual uint32_t GetBitfieldBitSize()
Definition: ValueObject.h:424
StackFrame.h
g_ansi_entries
constexpr Definition g_ansi_entries[]
Definition: FormatEntity.cpp:201
g_target_child_entries
constexpr Definition g_target_child_entries[]
Definition: FormatEntity.cpp:163
lldb_private::Function::GetNameNoArguments
ConstString GetNameNoArguments() const
Definition: Function.cpp:658
lldb_private::Target::GetTargetFromContexts
static Target * GetTargetFromContexts(const ExecutionContext *exe_ctx_ptr, const SymbolContext *sc_ptr)
Definition: Target.cpp:2503
lldb_private::FormatEntity::Entry::Definition::type
const Entry::Type type
Entry::Type corresponding to this definition.
Definition: FormatEntity.h:112
lldb_private::FormatEntity::Entry::Type::ThreadQueue
@ ThreadQueue
lldb_private::FormatEntity::Entry::Type::ProcessID
@ ProcessID
lldb_private::Stream
Definition: Stream.h:28
lldb_private::FormatEntity::Entry::Type::File
@ File
lldb_private::ArchSpec::GetTriple
llvm::Triple & GetTriple()
Architecture triple accessor.
Definition: ArchSpec.h:463
lldb_private::CompilerType::IsAggregateType
bool IsAggregateType() const
Definition: CompilerType.cpp:31
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
Language.h
lldb_private::ValueObject::eValueObjectRepresentationStyleName
@ eValueObjectRepresentationStyleName
Definition: ValueObject.h:119
pc
@ pc
Definition: CompactUnwindInfo.cpp:1251
ANSI_FG_COLOR_WHITE
#define ANSI_FG_COLOR_WHITE
Definition: AnsiTerminal.h:19
lldb_private::FormatEntity::Entry::fmt
lldb::Format fmt
Definition: FormatEntity.h:204
Fullpath
@ Fullpath
Definition: FormatEntity.cpp:85
DumpRegister
static bool DumpRegister(Stream &s, StackFrame *frame, RegisterKind reg_kind, uint32_t reg_num, Format format)
Definition: FormatEntity.cpp:594
lldb_private::FormatEntity::Entry::Type::FunctionPCOffset
@ FunctionPCOffset
g_file_child_entries
constexpr Definition g_file_child_entries[]
Definition: FormatEntity.cpp:94
lldb_private::FormatEntity::Entry::Type::Invalid
@ Invalid
lldb_private::Target::GetDebugger
Debugger & GetDebugger()
Definition: Target.h:1030
lldb_private::RegisterContext::GetRegisterInfoAtIndex
virtual const RegisterInfo * GetRegisterInfoAtIndex(size_t reg)=0
Debugger.h
lldb_private::FormatEntity::Entry::Type::TargetArch
@ TargetArch
lldb_private::SymbolContext
Definition: SymbolContext.h:33
lldb_private::Target
Definition: Target.h:469
lldb_private::Debugger::GetScriptInterpreter
ScriptInterpreter * GetScriptInterpreter(bool can_create=true, llvm::Optional< lldb::ScriptLanguage > language={})
Definition: Debugger.cpp:1496
CompletionRequest.h
lldb_private::StackFrame::HasDebugInformation
bool HasDebugInformation()
Determine whether this StackFrame has debug information available or not.
Definition: StackFrame.cpp:1153
lldb_private::FormatEntity::Entry::children
std::vector< Entry > children
Definition: FormatEntity.h:202
g_line_child_entries
constexpr Definition g_line_child_entries[]
Definition: FormatEntity.cpp:126
lldb_private::ExecutionContext::GetThreadPtr
Thread * GetThreadPtr() const
Returns a pointer to the thread object.
Definition: ExecutionContext.h:399
lldb_private::Thread::GetProtocolID
virtual lldb::user_id_t GetProtocolID() const
Definition: Thread.h:1082
lldb_private::ValueObject::GetTypeName
virtual ConstString GetTypeName()
Definition: ValueObject.h:365
lldb_private::FormatEntity::Entry::Definition::string
const char * string
Insert this exact string into the output.
Definition: FormatEntity.h:110
lldb_private::FormatEntity::Entry::Type::FunctionIsOptimized
@ FunctionIsOptimized
lldb_private::VariableList
Definition: VariableList.h:18
lldb_private::StreamString::GetString
llvm::StringRef GetString() const
Definition: StreamString.cpp:51
lldb_private::FormatEntity::Entry::Definition::num_children
const uint32_t num_children
The number of children of this node in the tree of format strings.
Definition: FormatEntity.h:116
lldb_private::ValueObject::eValueObjectRepresentationStyleLocation
@ eValueObjectRepresentationStyleLocation
Definition: ValueObject.h:116
lldb_private::FormatEntity::Entry::Type::FunctionMangledName
@ FunctionMangledName
Process.h
lldb_private::FormatEntity::Entry::Type::FrameRegisterFlags
@ FrameRegisterFlags
ANSI_FG_COLOR_GREEN
#define ANSI_FG_COLOR_GREEN
Definition: AnsiTerminal.h:14
lldb_private::CompileUnit
Definition: CompileUnit.h:38
lldb_private::VariableList::GetVariableAtIndex
lldb::VariableSP GetVariableAtIndex(size_t idx) const
Definition: VariableList.cpp:47
RunScriptFormatKeyword
static bool RunScriptFormatKeyword(Stream &s, const SymbolContext *sc, const ExecutionContext *exe_ctx, T t, const char *script_function_name)
Definition: FormatEntity.cpp:389
lldb_private::FormatManager::GetFormatFromCString
static bool GetFormatFromCString(const char *format_cstr, bool partial_match_ok, lldb::Format &format)
Definition: FormatManager.cpp:126
lldb_private::Thread::GetName
virtual const char * GetName()
Definition: Thread.h:281
DumpRegisterValue.h
Target.h
PrettyPrintFunctionNameWithArgs
static void PrettyPrintFunctionNameWithArgs(Stream &out_stream, char const *full_name, ExecutionContextScope *exe_scope, VariableList const &args)
Writes out the function name in 'full_name' to 'out_stream' but replaces each argument type with the ...
Definition: FormatEntity.cpp:1087
lldb_private::Module::GetFileSpec
const FileSpec & GetFileSpec() const
Get const accessor for the module file specification.
Definition: Module.h:497
Dirname
@ Dirname
Definition: FormatEntity.cpp:85
lldb_private::Thread::GetProcess
lldb::ProcessSP GetProcess() const
Definition: Thread.h:153
LLDB_REGNUM_GENERIC_FLAGS
#define LLDB_REGNUM_GENERIC_FLAGS
Definition: lldb-defines.h:55
lldb_private::FileSpec
Definition: FileSpec.h:55
lldb_private::FormatEntity::Entry::Type::FunctionNameNoArgs
@ FunctionNameNoArgs
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
lldb_private::SymbolContext::symbol
Symbol * symbol
The Symbol for a given query.
Definition: SymbolContext.h:323
g_module_child_entries
constexpr Definition g_module_child_entries[]
Definition: FormatEntity.cpp:135
lldb_private::FormatEntity::Entry::Type::FunctionAddrOffsetConcrete
@ FunctionAddrOffsetConcrete
DumpFile
static bool DumpFile(Stream &s, const FileSpec &file, FileKind file_kind)
Definition: FormatEntity.cpp:565
lldb_private::ValueObject::ExpressionPathEndResultType
ExpressionPathEndResultType
Definition: ValueObject.h:159
ArchiveType::Invalid
@ Invalid
lldb_private::Address::DumpStyleLoadAddress
@ DumpStyleLoadAddress
Display as the load address (if resolved).
Definition: Address.h:96
lldb_private::ValueObject::eExpressionPathEndResultTypeUnboundedRange
@ eExpressionPathEndResultTypeUnboundedRange
A range [].
Definition: ValueObject.h:167
lldb_private::Function::GetName
ConstString GetName() const
Definition: Function.cpp:654
lldb_private::ConstString::GetStringRef
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
Definition: ConstString.h:201
lldb_private::ValueObject::Dereference
virtual lldb::ValueObjectSP Dereference(Status &error)
Definition: ValueObject.cpp:2641
Log.h
lldb_private::ExecutionContextScope
Definition: ExecutionContextScope.h:32
lldb_private::FormatManager::GetFormatAsCString
static const char * GetFormatAsCString(lldb::Format format)
Definition: FormatManager.cpp:152
ANSI_CTRL_BOLD
#define ANSI_CTRL_BOLD
Definition: AnsiTerminal.h:52
lldb_private::ValueObject::ExpressionPathAftermath
ExpressionPathAftermath
Definition: ValueObject.h:173
lldb_private::Thread
Definition: Thread.h:61
lldb_private::Function::GetBlock
Block & GetBlock(bool can_create)
Get accessor for the block list.
Definition: Function.cpp:345
g_addr_entries
constexpr Definition g_addr_entries[]
Definition: FormatEntity.cpp:90
lldb_private::FormatEntity::Entry::Type::FunctionID
@ FunctionID
LineEntry.h
lldb_private::StructuredData::ObjectSP
std::shared_ptr< Object > ObjectSP
Definition: StructuredData.h:59
lldb_private::StreamString::GetData
const char * GetData() const
Definition: StreamString.h:43
lldb_private::ValueObject::eValueObjectRepresentationStyleChildrenCount
@ eValueObjectRepresentationStyleChildrenCount
Definition: ValueObject.h:117
lldb_private::SymbolContext::function
Function * function
The Function for a given query.
Definition: SymbolContext.h:320
StreamString.h
lldb_private::Address::GetFileAddress
lldb::addr_t GetFileAddress() const
Get the file address.
Definition: Address.cpp:291
lldb_private::FormatEntity::Entry::Type::ParentString
@ ParentString
lldb_private::Symbol::GetAddressRef
Address & GetAddressRef()
Definition: Symbol.h:57
lldb_private::FormatEntity::Entry::Type::ScriptVariable
@ ScriptVariable
lldb_private::FormatEntity::ParseInternal
static Status ParseInternal(llvm::StringRef &format, Entry &parent_entry, uint32_t depth)
Definition: FormatEntity.cpp:1998
FileError
@ FileError
Definition: FormatEntity.cpp:85
lldb_private::FormatEntity::Entry::Definition::keep_separator
const bool keep_separator
Whether the separator is kept during parsing or not.
Definition: FormatEntity.h:121
lldb_private::FormatEntity::Entry::Type::Scope
@ Scope
lldb_private::StringList
Definition: StringList.h:26
lldb_private::ConstString
Definition: ConstString.h:39
lldb_private::Language::FunctionNameRepresentation::eName
@ eName
lldb_private::StreamString
Definition: StreamString.h:23
lldb_private::FormatEntity::Entry::Type::AddressLoadOrFile
@ AddressLoadOrFile
lldb_private::FormatEntity::Entry::Type::ParentNumber
@ ParentNumber
lldb_private::FormatEntity::Entry::Type::ThreadInfo
@ ThreadInfo
lldb_private::FormatEntity::Entry::Type::FunctionDidChange
@ FunctionDidChange
lldb_private::AddressRange
Definition: AddressRange.h:25
ParseEntry
static Status ParseEntry(const llvm::StringRef &format_str, const Definition *parent, FormatEntity::Entry &entry)
Definition: FormatEntity.cpp:1884
lldb_private::FormatEntity::Entry::Type::VariableSynthetic
@ VariableSynthetic
lldb_private::ValueObject::eValueObjectRepresentationStyleLanguageSpecific
@ eValueObjectRepresentationStyleLanguageSpecific
Definition: ValueObject.h:115
ANSI_CTRL_FAST_BLINK
#define ANSI_CTRL_FAST_BLINK
Definition: AnsiTerminal.h:57
DumpAddressAndContent
static bool DumpAddressAndContent(Stream &s, const SymbolContext *sc, const ExecutionContext *exe_ctx, const Address &addr, bool print_file_addr_or_load_addr)
Definition: FormatEntity.cpp:414
ANSI_BG_COLOR_GREEN
#define ANSI_BG_COLOR_GREEN
Definition: AnsiTerminal.h:32
lldb_private::InlineFunctionInfo::GetName
ConstString GetName() const
Definition: Function.cpp:96
lldb_private::FormatEntity::Entry::Type::FunctionNameWithArgs
@ FunctionNameWithArgs
lldb_private::ValueObject::eExpressionPathScanEndReasonEndOfString
@ eExpressionPathScanEndReasonEndOfString
Out of data to parse.
Definition: ValueObject.h:125
lldb_private::File
Definition: File.h:35
lldb_private::Function::GetIsOptimized
bool GetIsOptimized()
Get whether compiler optimizations were enabled for this function.
Definition: Function.cpp:466
lldb_private::Thread::GetExtendedInfo
StructuredData::ObjectSP GetExtendedInfo()
Retrieve a dictionary of information about this thread.
Definition: Thread.h:273
lldb_private::FormatEntity::Entry::Type::ThreadIndexID
@ ThreadIndexID
lldb_private::FormatEntity::Entry::Type::ThreadCompletedExpression
@ ThreadCompletedExpression
lldb_private::FormatEntity::Entry::Definition
Definition: FormatEntity.h:106
lldb_private::Debugger
Definition: Debugger.h:74
lldb_private::CompileUnit::GetPrimaryFile
const FileSpec & GetPrimaryFile() const
Return the primary source file associated with this compile unit.
Definition: CompileUnit.h:227
lldb_private::CompletionRequest::GetCursorArgumentPrefix
llvm::StringRef GetCursorArgumentPrefix() const
Definition: CompletionRequest.h:217
lldb_private::ScriptInterpreter::RunScriptFormatKeyword
virtual bool RunScriptFormatKeyword(const char *impl_function, Process *process, std::string &output, Status &error)
Definition: ScriptInterpreter.h:487
lldb::eValueTypeVariableArgument
@ eValueTypeVariableArgument
function argument variables
Definition: lldb-enumerations.h:320
ANSI_BG_COLOR_BLACK
#define ANSI_BG_COLOR_BLACK
Definition: AnsiTerminal.h:30
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:40
lldb_private::CompletionRequest::AddCompletions
void AddCompletions(const StringList &completions)
Adds multiple possible completion strings.
Definition: CompletionRequest.h:196
lldb_private::FormatEntity::Entry::Type::ScriptVariableSynthetic
@ ScriptVariableSynthetic
StringList.h
lldb_private::ArchSpec::IsValid
bool IsValid() const
Tests if this ArchSpec is valid.
Definition: ArchSpec.h:361
lldb::eFormatterMatchExact
@ eFormatterMatchExact
Definition: lldb-enumerations.h:837
lldb_private::Address::GetSection
lldb::SectionSP GetSection() const
Get const accessor for the section.
Definition: Address.h:429
lldb_private::FormatEntity::Entry::AppendChar
void AppendChar(char ch)
Definition: FormatEntity.cpp:271
lldb_private::CompileUnit::GetLanguage
lldb::LanguageType GetLanguage()
Definition: CompileUnit.cpp:150
Thread.h
lldb_private::LineEntry::column
uint16_t column
The column number of the source line, or zero if there is no column information.
Definition: LineEntry.h:146
lldb_private::Stream::PutChar
size_t PutChar(char ch)
Definition: Stream.cpp:104
ENUM_TO_CSTR
#define ENUM_TO_CSTR(eee)
Definition: FormatEntity.cpp:296
lldb_private::Symbol::GetMangled
Mangled & GetMangled()
Definition: Symbol.h:131
ANSI_CTRL_ITALIC
#define ANSI_CTRL_ITALIC
Definition: AnsiTerminal.h:54
lldb_private::ConstString::Dump
void Dump(Stream *s, const char *value_if_empty=nullptr) const
Dump the object description to a stream.
Definition: ConstString.cpp:282
CompilerType.h
Address.h
VariableList.h
AnsiTerminal.h
lldb_private::RegisterContext
Definition: RegisterContext.h:17
lldb_private::Address::DumpStyleModuleWithFileAddress
@ DumpStyleModuleWithFileAddress
Display as the file address with the module name prepended (if any).
Definition: Address.h:90
lldb_private::Language::FindPlugin
static Language * FindPlugin(lldb::LanguageType language)
Definition: Language.cpp:53
ValueObject.h
lldb_private::ArchSpec::GetAddressByteSize
uint32_t GetAddressByteSize() const
Returns the size in bytes of an address of the current architecture.
Definition: ArchSpec.cpp:694
lldb_private::LineEntry::line
uint32_t line
The source line number, or zero if there is no line number information.
Definition: LineEntry.h:143
lldb_private::UserID::GetID
lldb::user_id_t GetID() const
Get accessor for the user ID.
Definition: UserID.h:47
lldb::RegisterKind
RegisterKind
Register numbering types.
Definition: lldb-enumerations.h:228
ConvertValueObjectStyleToChar
static char ConvertValueObjectStyleToChar(ValueObject::ValueObjectRepresentationStyle style)
Definition: FormatEntity.cpp:649
lldb_private::FormatEntity::Parse
static Status Parse(const llvm::StringRef &format, Entry &entry)
Definition: FormatEntity.cpp:289
lldb_private::FormatEntity::Entry::Type::AddressLoad
@ AddressLoad
lldb_private::FormatEntity::Format
static bool Format(const Entry &entry, Stream &s, const SymbolContext *sc, const ExecutionContext *exe_ctx, const Address *addr, ValueObject *valobj, bool function_changed, bool initial_function)
Definition: FormatEntity.cpp:1141
lldb_private::FormatEntity::Entry::DefinitionWithChildren
static constexpr Definition DefinitionWithChildren(const char *name, const FormatEntity::Entry::Type t, const Definition(&children)[N], bool keep_separator=false)
Definition: FormatEntity.h:143
lldb_private::FormatEntity::Entry::AppendEntry
void AppendEntry(const Entry &&entry)
Definition: FormatEntity.h:162
lldb_private::ValueObject::GetNumChildren
size_t GetNumChildren(uint32_t max=UINT32_MAX)
Definition: ValueObject.cpp:496
Symbol.h
lldb_private::Symbol::GetName
ConstString GetName() const
Definition: Symbol.cpp:500
lldb_private::ValueObject::eValueObjectRepresentationStyleExpressionPath
@ eValueObjectRepresentationStyleExpressionPath
Definition: ValueObject.h:120
lldb_private::FormatEntity::AutoComplete
static void AutoComplete(lldb_private::CompletionRequest &request)
Definition: FormatEntity.cpp:2357
lldb_private::FormatEntity::Entry::Type::FrameRegisterPC
@ FrameRegisterPC
lldb_private::DataVisualization::GetSummaryForType
static lldb::TypeSummaryImplSP GetSummaryForType(lldb::TypeNameSpecifierImplSP type_sp)
Definition: DataVisualization.cpp:48
lldb_private::SectionLoadList::IsEmpty
bool IsEmpty() const
Definition: SectionLoadList.cpp:38
_TO_STR
#define _TO_STR(_val)
Definition: FormatEntity.cpp:167
lldb_private::FormatEntity::ExtractVariableInfo
static Status ExtractVariableInfo(llvm::StringRef &format_str, llvm::StringRef &variable_name, llvm::StringRef &variable_format)
Definition: FormatEntity.cpp:2287
lldb_private::Target::GetArchitecture
const ArchSpec & GetArchitecture() const
Definition: Target.h:989
lldb_private::Thread::GetStopInfo
lldb::StopInfoSP GetStopInfo()
Definition: Thread.cpp:335
Definition
lldb_private::FormatEntity::Entry::Definition Definition
Definition: FormatEntity.cpp:81
lldb_private::Status
Definition: Status.h:44
lldb_private::ValueObject
ValueObject:
Definition: ValueObject.h:105
DataVisualization.h
TypeSummary.h
lldb_private::ArchSpec::GetArchitectureName
const char * GetArchitectureName() const
Returns a static string representing the current architecture.
Definition: ArchSpec.cpp:547
lldb_private::Address::Dump
bool Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style, DumpStyle fallback_style=DumpStyleInvalid, uint32_t addr_byte_size=UINT32_MAX, bool all_ranges=false) const
Dump a description of this object to a Stream.
Definition: Address.cpp:406
ANSI_BG_COLOR_WHITE
#define ANSI_BG_COLOR_WHITE
Definition: AnsiTerminal.h:37
lldb_private::Block
Definition: Block.h:41
lldb_private::StringSummaryFormat::FormatObject
bool FormatObject(ValueObject *valobj, std::string &dest, const TypeSummaryOptions &options) override
Definition: TypeSummary.cpp:68
uint32_t
ANSI_BG_COLOR_CYAN
#define ANSI_BG_COLOR_CYAN
Definition: AnsiTerminal.h:36
lldb_private::FormatEntity::Entry::Type::String
@ String
lldb_private::ExecutionContext::GetBestExecutionContextScope
ExecutionContextScope * GetBestExecutionContextScope() const
Definition: ExecutionContext.cpp:214
lldb_private::Language
Definition: Language.h:29
lldb_private::FormatEntity::Entry::Dump
void Dump(Stream &s, int depth=0) const
Definition: FormatEntity.cpp:370
lldb_private::FileSpec::GetDirectory
const ConstString & GetDirectory() const
Directory string const get accessor.
Definition: FileSpec.h:222
lldb_private::StackFrame::GetRegisterContextSP
const lldb::RegisterContextSP & GetRegisterContextSP() const
Definition: StackFrame.h:241
lldb_private::Address
Definition: Address.h:59
LLDB_REGNUM_GENERIC_SP
#define LLDB_REGNUM_GENERIC_SP
Definition: lldb-defines.h:52
lldb_private::StopInfo::GetExpressionVariable
static lldb::ExpressionVariableSP GetExpressionVariable(lldb::StopInfoSP &stop_info_sp)
Definition: StopInfo.cpp:1433
lldb_private::Stream::EOL
size_t EOL()
Output and End of Line character to the stream.
Definition: Stream.cpp:128
g_string_entry
constexpr Definition g_string_entry[]
Definition: FormatEntity.cpp:87
FormatThreadExtendedInfoRecurse
static bool FormatThreadExtendedInfoRecurse(const FormatEntity::Entry &entry, const StructuredData::ObjectSP &thread_info_dictionary, const SymbolContext *sc, const ExecutionContext *exe_ctx, Stream &s)
Definition: FormatEntity.cpp:1001
lldb_private::Symbol::GetLanguage
lldb::LanguageType GetLanguage() const
Definition: Symbol.h:123
lldb_private::FormatEntity::Entry::Type::ThreadStopReasonRaw
@ ThreadStopReasonRaw
lldb_private::ValueObject::PrintableRepresentationSpecialCases::eDisable
@ eDisable
ANSI_FG_COLOR_BLUE
#define ANSI_FG_COLOR_BLUE
Definition: AnsiTerminal.h:16
lldb_private::CompilerType::GetTypeInfo
uint32_t GetTypeInfo(CompilerType *pointee_or_element_compiler_type=nullptr) const
Definition: CompilerType.cpp:329
ExecutionContextScope.h
lldb_private::FormatEntity::Entry::Type::Root
@ Root
lldb_private::FormatEntity::Entry::Type::ScriptTarget
@ ScriptTarget
lldb_private::ValueObject::eExpressionPathEndResultTypePlain
@ eExpressionPathEndResultTypePlain
Anything but...
Definition: ValueObject.h:161
lldb_private::Address::GetLoadAddress
lldb::addr_t GetLoadAddress(Target *target) const
Get the load address.
Definition: Address.cpp:311
lldb_private::FormatEntity::Entry::Type::EscapeCode
@ EscapeCode
g_thread_child_entries
constexpr Definition g_thread_child_entries[]
Definition: FormatEntity.cpp:150
lldb_private::FormatEntity::Entry::Type::LineEntryLineNumber
@ LineEntryLineNumber
ArchSpec.h
lldb_private::FormatEntity::Entry
Definition: FormatEntity.h:40
lldb_private::Stream::AsRawOstream
llvm::raw_ostream & AsRawOstream()
Returns a raw_ostream that forwards the data to this Stream object.
Definition: Stream.h:357
lldb_private::ValueObject::GetValueForExpressionPathOptions::DoAllowBitfieldSyntax
GetValueForExpressionPathOptions & DoAllowBitfieldSyntax()
Definition: ValueObject.h:237
lldb_private::ValueObject::GetCompilerType
CompilerType GetCompilerType()
Definition: ValueObject.h:352
DumpAddressOffsetFromFunction
static bool DumpAddressOffsetFromFunction(Stream &s, const SymbolContext *sc, const ExecutionContext *exe_ctx, const Address &format_addr, bool concrete_only, bool no_padding, bool print_zero_offsets)
Definition: FormatEntity.cpp:446
lldb_private::Language::FunctionNameRepresentation::eNameWithArgs
@ eNameWithArgs
FormatEntity.h
lldb_private::LineEntry::range
AddressRange range
The section offset address range for this line entry.
Definition: LineEntry.h:139
lldb_private::FormatEntity::Entry::printf_format
std::string printf_format
Definition: FormatEntity.h:201
lldb_private::TypeSummaryOptions
Definition: TypeSummary.h:26
lldb_private::ValueObject::GetDynamicValueType
lldb::DynamicValueType GetDynamicValueType()
Definition: ValueObject.cpp:3070
StopInfo.h
lldb_private::SymbolContext::module_sp
lldb::ModuleSP module_sp
The Module for a given query.
Definition: SymbolContext.h:318
lldb_private::FileSpec::Dump
void Dump(llvm::raw_ostream &s) const
Dump this object to a Stream.
Definition: FileSpec.cpp:322
g_ansi_fg_entries
constexpr Definition g_ansi_fg_entries[]
Definition: FormatEntity.cpp:169
MakeMatch
static std::string MakeMatch(const llvm::StringRef &prefix, const char *suffix)
Definition: FormatEntity.cpp:2333
lldb::eStructuredDataTypeInteger
@ eStructuredDataTypeInteger
Definition: lldb-enumerations.h:798
lldb_private::ValueObject::eValueObjectRepresentationStyleType
@ eValueObjectRepresentationStyleType
Definition: ValueObject.h:118
lldb_private::DumpRegisterValue
bool DumpRegisterValue(const RegisterValue &reg_val, Stream *s, const RegisterInfo *reg_info, bool prefix_with_name, bool prefix_with_alt_name, lldb::Format format, uint32_t reg_name_right_align_at=0, ExecutionContextScope *exe_scope=nullptr)
Definition: DumpRegisterValue.cpp:18
lldb::eStructuredDataTypeFloat
@ eStructuredDataTypeFloat
Definition: lldb-enumerations.h:799
lldb_private::Target::GetSectionLoadList
SectionLoadList & GetSectionLoadList()
Definition: Target.h:1102
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
ANSI_FG_COLOR_RED
#define ANSI_FG_COLOR_RED
Definition: AnsiTerminal.h:13
lldb_private::ScriptInterpreter
Definition: ScriptInterpreter.h:126
g_script_child_entries
constexpr Definition g_script_child_entries[]
Definition: FormatEntity.cpp:222
lldb_private::FormatEntity::Entry::Definition::children
const Definition * children
An array of "num_children" Definition entries.
Definition: FormatEntity.h:118
Function.h
ANSI_CTRL_CROSSED_OUT
#define ANSI_CTRL_CROSSED_OUT
Definition: AnsiTerminal.h:60
lldb_private::ValueObject::GetLocationAsCString
virtual const char * GetLocationAsCString()
Definition: ValueObject.h:508
lldb_private::Stream::Printf
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition: Stream.cpp:107
FileKind
FileKind
Definition: FormatEntity.cpp:85
lldb_private::Process::GetID
lldb::pid_t GetID() const
Returns the pid of the process or LLDB_INVALID_PROCESS_ID if there is no known pid.
Definition: Process.h:526
lldb-forward.h
lldb_private::Debugger::GetUseColor
bool GetUseColor() const
Definition: Debugger.cpp:376
lldb_private::FormatEntity::Entry::string
std::string string
Definition: FormatEntity.h:200
lldb_private::ValueObject::HasSpecialPrintableRepresentation
bool HasSpecialPrintableRepresentation(ValueObjectRepresentationStyle val_obj_display, lldb::Format custom_format)
Definition: ValueObject.cpp:1138
lldb_private::ValueObject::ExpressionPathScanEndReason
ExpressionPathScanEndReason
Definition: ValueObject.h:123
lldb_private::FormatEntity::Entry::Type::LineEntryFile
@ LineEntryFile
lldb_private::Function::GetMangled
const Mangled & GetMangled() const
Definition: Function.h:538
lldb_private::FormatEntity::Entry::Type::Lang
@ Lang
Status.h
SymbolContext.h
lldb_private::LLDBLog::DataFormatters
@ DataFormatters
ScanBracketedRange
static bool ScanBracketedRange(llvm::StringRef subpath, size_t &close_bracket_index, const char *&var_name_final_if_array_range, int64_t &index_lower, int64_t &index_higher)
Definition: FormatEntity.cpp:507
lldb_private::FormatEntity::Entry::Type::FunctionLineOffset
@ FunctionLineOffset
g_ansi_bg_entries
constexpr Definition g_ansi_bg_entries[]
Definition: FormatEntity.cpp:185
lldb_private::FormatEntity::Entry::Type::ScriptThread
@ ScriptThread
lldb_private::FormatEntity::Entry::Type::ThreadName
@ ThreadName
lldb_private::FormatEntity::FormatFileSpec
static bool FormatFileSpec(const FileSpec &file, Stream &s, llvm::StringRef elements, llvm::StringRef element_format)
Definition: FormatEntity.cpp:2317
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
LLDB_REGNUM_GENERIC_FP
#define LLDB_REGNUM_GENERIC_FP
Definition: lldb-defines.h:53
lldb_private::FormatEntity::Entry::Type::ThreadStopReason
@ ThreadStopReason
lldb_private::ExecutionContextScope::CalculateTarget
virtual lldb::TargetSP CalculateTarget()=0
lldb_private::StackFrame::GetRegisterContext
lldb::RegisterContextSP GetRegisterContext()
Get the RegisterContext for this frame, if possible.
Definition: StackFrame.cpp:1143
lldb_private::ValueObject::PrintableRepresentationSpecialCases::eAllow
@ eAllow
ANSI_FG_COLOR_YELLOW
#define ANSI_FG_COLOR_YELLOW
Definition: AnsiTerminal.h:15
FileSpec.h
lldb_private::CompletionRequest::AddCompletion
void AddCompletion(llvm::StringRef completion, llvm::StringRef description="", CompletionMode mode=CompletionMode::Normal)
Adds a possible completion string.
Definition: CompletionRequest.h:167
lldb_private::Stream::Write
size_t Write(const void *src, size_t src_len)
Output character bytes to the stream.
Definition: Stream.h:101
ANSI_BG_COLOR_YELLOW
#define ANSI_BG_COLOR_YELLOW
Definition: AnsiTerminal.h:33
CommandInterpreter.h
lldb::eStructuredDataTypeArray
@ eStructuredDataTypeArray
Definition: lldb-enumerations.h:797
ConstString.h
lldb_private::ValueObject::GetTargetSP
lldb::TargetSP GetTargetSP() const
Definition: ValueObject.h:334
lldb_private::ValueObject::ValueObjectRepresentationStyle
ValueObjectRepresentationStyle
Definition: ValueObject.h:112
Entry
FormatEntity::Entry Entry
Definition: FormatEntity.cpp:82
ValueObjectVariable.h
lldb_private::Symbol::GetNameNoArguments
ConstString GetNameNoArguments() const
Definition: Symbol.cpp:502
lldb_private::FormatEntity::Entry::Type::ScriptProcess
@ ScriptProcess
lldb_private::ValueObject::DumpPrintableRepresentation
bool DumpPrintableRepresentation(Stream &s, ValueObjectRepresentationStyle val_obj_display=eValueObjectRepresentationStyleSummary, lldb::Format custom_format=lldb::eFormatInvalid, PrintableRepresentationSpecialCases special=PrintableRepresentationSpecialCases::eAllow, bool do_dump_error=true)
Definition: ValueObject.cpp:1171
lldb_private::StringSummaryFormat
Definition: TypeSummary.h:278
Stream.h
lldb_private::Log
Definition: Log.h:115
lldb_private::StackFrame::GetFrameIndex
uint32_t GetFrameIndex() const
Query this frame to find what frame it is in this Thread's StackFrameList.
Definition: StackFrame.cpp:175
lldb_private::Variable
Definition: Variable.h:25
lldb_private::Block::GetInlinedFunctionInfo
const InlineFunctionInfo * GetInlinedFunctionInfo() const
Get const accessor for any inlined function information.
Definition: Block.h:276
lldb_private::Stream::PutCString
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Definition: Stream.cpp:63
lldb_private::StopInfo::GetReturnValueObject
static lldb::ValueObjectSP GetReturnValueObject(lldb::StopInfoSP &stop_info_sp)
Definition: StopInfo.cpp:1423
lldb_private::ValueObjectVariable::Create
static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope, const lldb::VariableSP &var_sp)
Definition: ValueObjectVariable.cpp:51
lldb_private::FormatEntity::Entry::Entry
Entry(Type t=Type::Invalid, const char *s=nullptr, const char *f=nullptr)
Definition: FormatEntity.h:149
lldb_private::SymbolContext::line_entry
LineEntry line_entry
The LineEntry for a given query.
Definition: SymbolContext.h:322
lldb_private::ValueObject::eExpressionPathEndResultTypeBoundedRange
@ eExpressionPathEndResultTypeBoundedRange
A range [low-high].
Definition: ValueObject.h:165
lldb_private::Language::GetNameForLanguageType
static const char * GetNameForLanguageType(lldb::LanguageType language)
Definition: Language.cpp:217
lldb_private::GetLog
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
Definition: Log.h:309
ANSI_FG_COLOR_PURPLE
#define ANSI_FG_COLOR_PURPLE
Definition: AnsiTerminal.h:17
lldb_private::StackFrame
Definition: StackFrame.h:40
lldb_private::FormatEntity::Entry::Type::ScriptFrame
@ ScriptFrame
lldb_private::FormatEntity::Entry::Clear
void Clear()
Definition: FormatEntity.h:164
lldb_private::DataVisualization::ShouldPrintAsOneLiner
static bool ShouldPrintAsOneLiner(ValueObject &valobj)
Definition: DataVisualization.cpp:26
AddressRange.h
lldb_private::ValueObject::eValueObjectRepresentationStyleSummary
@ eValueObjectRepresentationStyleSummary
Definition: ValueObject.h:114
lldb_private::Address::Slide
bool Slide(int64_t offset)
Definition: Address.h:449
lldb_private::FormatEntity::Entry::Definition::name
const char * name
The name/string placeholder that corresponds to this definition.
Definition: FormatEntity.h:108
lldb
Definition: SBAddress.h:15
lldb_private::Function::GetLanguage
lldb::LanguageType GetLanguage() const
Definition: Function.cpp:643
lldb_private::ValueObject::GetSyntheticValue
lldb::ValueObjectSP GetSyntheticValue()
Definition: ValueObject.cpp:1856
ANSI_FG_COLOR_CYAN
#define ANSI_FG_COLOR_CYAN
Definition: AnsiTerminal.h:18
RegisterContext.h
lldb_private::ValueObject::GetValueForExpressionPathOptions::DoAllowFragileIVar
GetValueForExpressionPathOptions & DoAllowFragileIVar()
Definition: ValueObject.h:227
LLDBLog.h
lldb_private::Block::GetContainingInlinedBlock
Block * GetContainingInlinedBlock()
Get the inlined block that contains this block.
Definition: Block.cpp:208
lldb::eFormatDefault
@ eFormatDefault
Definition: lldb-enumerations.h:157
ExpandIndexedExpression
static ValueObjectSP ExpandIndexedExpression(ValueObject *valobj, size_t index, bool deref_pointer)
Definition: FormatEntity.cpp:618
lldb_private::ExecutionContext::GetTargetPtr
Target * GetTargetPtr() const
Returns a pointer to the target object.
Definition: ExecutionContext.cpp:198
ExecutionContext.h
DumpValue
static bool DumpValue(Stream &s, const SymbolContext *sc, const ExecutionContext *exe_ctx, const FormatEntity::Entry &entry, ValueObject *valobj)
Definition: FormatEntity.cpp:672
lldb_private::Thread::GetQueueName
virtual const char * GetQueueName()
Retrieve the Queue name for the queue currently using this Thread.
Definition: Thread.h:333
lldb_private::RegisterContext::GetRegisterInfoByName
const RegisterInfo * GetRegisterInfoByName(llvm::StringRef reg_name, uint32_t start_idx=0)
Definition: RegisterContext.cpp:52
lldb_private::CompletionRequest
Definition: CompletionRequest.h:100
ANSI_BG_COLOR_PURPLE
#define ANSI_BG_COLOR_PURPLE
Definition: AnsiTerminal.h:35
lldb::eFormatInvalid
@ eFormatInvalid
Definition: lldb-enumerations.h:158
lldb_private::ValueObject::GetValueForExpressionPathOptions::DontCheckDotVsArrowSyntax
GetValueForExpressionPathOptions & DontCheckDotVsArrowSyntax()
Definition: ValueObject.h:222
lldb_private::FormatEntity::Entry::Type
Type
Definition: FormatEntity.h:41
lldb_private::Symbol::GetID
uint32_t GetID() const
Definition: Symbol.h:121