LLDB  mainline
LibCxx.cpp
Go to the documentation of this file.
1 //===-- LibCxx.cpp --------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "LibCxx.h"
10 
11 #include "lldb/Core/Debugger.h"
12 #include "lldb/Core/FormatEntity.h"
13 #include "lldb/Core/ValueObject.h"
21 #include "lldb/Target/Target.h"
24 #include "lldb/Utility/Endian.h"
25 #include "lldb/Utility/Status.h"
26 #include "lldb/Utility/Stream.h"
27 
30 #include "lldb/lldb-enumerations.h"
31 #include <tuple>
32 
33 using namespace lldb;
34 using namespace lldb_private;
35 using namespace lldb_private::formatters;
36 
38  ValueObject &obj, llvm::ArrayRef<ConstString> alternative_names) {
39  for (ConstString name : alternative_names) {
40  lldb::ValueObjectSP child_sp = obj.GetChildMemberWithName(name, true);
41 
42  if (child_sp)
43  return child_sp;
44  }
45  return {};
46 }
47 
49  ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
50  ValueObjectSP valobj_sp(valobj.GetNonSyntheticValue());
51  if (!valobj_sp)
52  return false;
53 
54  // An optional either contains a value or not, the member __engaged_ is
55  // a bool flag, it is true if the optional has a value and false otherwise.
56  ValueObjectSP engaged_sp(
57  valobj_sp->GetChildMemberWithName(ConstString("__engaged_"), true));
58 
59  if (!engaged_sp)
60  return false;
61 
62  llvm::StringRef engaged_as_cstring(
63  engaged_sp->GetValueAsUnsigned(0) == 1 ? "true" : "false");
64 
65  stream.Printf(" Has Value=%s ", engaged_as_cstring.data());
66 
67  return true;
68 }
69 
71  ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
72 
73  ValueObjectSP valobj_sp(valobj.GetNonSyntheticValue());
74 
75  if (!valobj_sp)
76  return false;
77 
78  ExecutionContext exe_ctx(valobj_sp->GetExecutionContextRef());
79  Process *process = exe_ctx.GetProcessPtr();
80 
81  if (process == nullptr)
82  return false;
83 
84  CPPLanguageRuntime *cpp_runtime = CPPLanguageRuntime::Get(*process);
85 
86  if (!cpp_runtime)
87  return false;
88 
90  cpp_runtime->FindLibCppStdFunctionCallableInfo(valobj_sp);
91 
92  switch (callable_info.callable_case) {
93  case CPPLanguageRuntime::LibCppStdFunctionCallableCase::Invalid:
94  stream.Printf(" __f_ = %" PRIu64, callable_info.member_f_pointer_value);
95  return false;
96  break;
97  case CPPLanguageRuntime::LibCppStdFunctionCallableCase::Lambda:
98  stream.Printf(
99  " Lambda in File %s at Line %u",
101  callable_info.callable_line_entry.line);
102  break;
103  case CPPLanguageRuntime::LibCppStdFunctionCallableCase::CallableObject:
104  stream.Printf(
105  " Function in File %s at Line %u",
107  callable_info.callable_line_entry.line);
108  break;
109  case CPPLanguageRuntime::LibCppStdFunctionCallableCase::FreeOrMemberFunction:
110  stream.Printf(" Function = %s ",
111  callable_info.callable_symbol.GetName().GetCString());
112  break;
113  }
114 
115  return true;
116 }
117 
119  ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
120  ValueObjectSP valobj_sp(valobj.GetNonSyntheticValue());
121  if (!valobj_sp)
122  return false;
123  ValueObjectSP ptr_sp(
124  valobj_sp->GetChildMemberWithName(ConstString("__ptr_"), true));
125  ValueObjectSP count_sp(valobj_sp->GetChildAtNamePath(
126  {ConstString("__cntrl_"), ConstString("__shared_owners_")}));
127  ValueObjectSP weakcount_sp(valobj_sp->GetChildAtNamePath(
128  {ConstString("__cntrl_"), ConstString("__shared_weak_owners_")}));
129 
130  if (!ptr_sp)
131  return false;
132 
133  if (ptr_sp->GetValueAsUnsigned(0) == 0) {
134  stream.Printf("nullptr");
135  return true;
136  } else {
137  bool print_pointee = false;
138  Status error;
139  ValueObjectSP pointee_sp = ptr_sp->Dereference(error);
140  if (pointee_sp && error.Success()) {
141  if (pointee_sp->DumpPrintableRepresentation(
142  stream, ValueObject::eValueObjectRepresentationStyleSummary,
144  ValueObject::PrintableRepresentationSpecialCases::eDisable,
145  false))
146  print_pointee = true;
147  }
148  if (!print_pointee)
149  stream.Printf("ptr = 0x%" PRIx64, ptr_sp->GetValueAsUnsigned(0));
150  }
151 
152  if (count_sp)
153  stream.Printf(" strong=%" PRIu64, 1 + count_sp->GetValueAsUnsigned(0));
154 
155  if (weakcount_sp)
156  stream.Printf(" weak=%" PRIu64, 1 + weakcount_sp->GetValueAsUnsigned(0));
157 
158  return true;
159 }
160 
162  ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
163  ValueObjectSP valobj_sp(valobj.GetNonSyntheticValue());
164  if (!valobj_sp)
165  return false;
166 
167  ValueObjectSP ptr_sp(
168  valobj_sp->GetChildMemberWithName(ConstString("__ptr_"), true));
169  if (!ptr_sp)
170  return false;
171 
172  ptr_sp = GetValueOfLibCXXCompressedPair(*ptr_sp);
173  if (!ptr_sp)
174  return false;
175 
176  if (ptr_sp->GetValueAsUnsigned(0) == 0) {
177  stream.Printf("nullptr");
178  return true;
179  } else {
180  bool print_pointee = false;
181  Status error;
182  ValueObjectSP pointee_sp = ptr_sp->Dereference(error);
183  if (pointee_sp && error.Success()) {
184  if (pointee_sp->DumpPrintableRepresentation(
185  stream, ValueObject::eValueObjectRepresentationStyleSummary,
187  ValueObject::PrintableRepresentationSpecialCases::eDisable,
188  false))
189  print_pointee = true;
190  }
191  if (!print_pointee)
192  stream.Printf("ptr = 0x%" PRIx64, ptr_sp->GetValueAsUnsigned(0));
193  }
194 
195  return true;
196 }
197 
198 /*
199  (lldb) fr var ibeg --raw --ptr-depth 1
200  (std::__1::__map_iterator<std::__1::__tree_iterator<std::__1::pair<int,
201  std::__1::basic_string<char, std::__1::char_traits<char>,
202  std::__1::allocator<char> > >, std::__1::__tree_node<std::__1::pair<int,
203  std::__1::basic_string<char, std::__1::char_traits<char>,
204  std::__1::allocator<char> > >, void *> *, long> >) ibeg = {
205  __i_ = {
206  __ptr_ = 0x0000000100103870 {
207  std::__1::__tree_node_base<void *> = {
208  std::__1::__tree_end_node<std::__1::__tree_node_base<void *> *> = {
209  __left_ = 0x0000000000000000
210  }
211  __right_ = 0x0000000000000000
212  __parent_ = 0x00000001001038b0
213  __is_black_ = true
214  }
215  __value_ = {
216  first = 0
217  second = { std::string }
218  */
219 
221  LibCxxMapIteratorSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp)
222  : SyntheticChildrenFrontEnd(*valobj_sp), m_pair_ptr(), m_pair_sp() {
223  if (valobj_sp)
224  Update();
225 }
226 
228  m_pair_sp.reset();
229  m_pair_ptr = nullptr;
230 
231  ValueObjectSP valobj_sp = m_backend.GetSP();
232  if (!valobj_sp)
233  return false;
234 
235  TargetSP target_sp(valobj_sp->GetTargetSP());
236 
237  if (!target_sp)
238  return false;
239 
240  if (!valobj_sp)
241  return false;
242 
243  static ConstString g_i_("__i_");
244 
245  // this must be a ValueObject* because it is a child of the ValueObject we
246  // are producing children for it if were a ValueObjectSP, we would end up
247  // with a loop (iterator -> synthetic -> child -> parent == iterator) and
248  // that would in turn leak memory by never allowing the ValueObjects to die
249  // and free their memory
250  m_pair_ptr = valobj_sp
251  ->GetValueForExpressionPath(
252  ".__i_.__ptr_->__value_", nullptr, nullptr,
254  .DontCheckDotVsArrowSyntax()
255  .SetSyntheticChildrenTraversal(
257  SyntheticChildrenTraversal::None),
258  nullptr)
259  .get();
260 
261  if (!m_pair_ptr) {
262  m_pair_ptr = valobj_sp
263  ->GetValueForExpressionPath(
264  ".__i_.__ptr_", nullptr, nullptr,
266  .DontCheckDotVsArrowSyntax()
267  .SetSyntheticChildrenTraversal(
269  SyntheticChildrenTraversal::None),
270  nullptr)
271  .get();
272  if (m_pair_ptr) {
273  auto __i_(valobj_sp->GetChildMemberWithName(g_i_, true));
274  if (!__i_) {
275  m_pair_ptr = nullptr;
276  return false;
277  }
278  CompilerType pair_type(
279  __i_->GetCompilerType().GetTypeTemplateArgument(0));
280  std::string name;
281  uint64_t bit_offset_ptr;
282  uint32_t bitfield_bit_size_ptr;
283  bool is_bitfield_ptr;
284  pair_type = pair_type.GetFieldAtIndex(
285  0, name, &bit_offset_ptr, &bitfield_bit_size_ptr, &is_bitfield_ptr);
286  if (!pair_type) {
287  m_pair_ptr = nullptr;
288  return false;
289  }
290 
291  auto addr(m_pair_ptr->GetValueAsUnsigned(LLDB_INVALID_ADDRESS));
292  m_pair_ptr = nullptr;
293  if (addr && addr != LLDB_INVALID_ADDRESS) {
294  TypeSystemClang *ast_ctx =
295  llvm::dyn_cast_or_null<TypeSystemClang>(pair_type.GetTypeSystem());
296  if (!ast_ctx)
297  return false;
298 
299  // Mimick layout of std::__tree_iterator::__ptr_ and read it in
300  // from process memory.
301  //
302  // The following shows the contiguous block of memory:
303  //
304  // +-----------------------------+ class __tree_end_node
305  // __ptr_ | pointer __left_; |
306  // +-----------------------------+ class __tree_node_base
307  // | pointer __right_; |
308  // | __parent_pointer __parent_; |
309  // | bool __is_black_; |
310  // +-----------------------------+ class __tree_node
311  // | __node_value_type __value_; | <<< our key/value pair
312  // +-----------------------------+
313  //
314  CompilerType tree_node_type = ast_ctx->CreateStructForIdentifier(
315  ConstString(),
316  {{"ptr0",
317  ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType()},
318  {"ptr1",
319  ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType()},
320  {"ptr2",
321  ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType()},
322  {"cw", ast_ctx->GetBasicType(lldb::eBasicTypeBool)},
323  {"payload", pair_type}});
324  llvm::Optional<uint64_t> size = tree_node_type.GetByteSize(nullptr);
325  if (!size)
326  return false;
327  WritableDataBufferSP buffer_sp(new DataBufferHeap(*size, 0));
328  ProcessSP process_sp(target_sp->GetProcessSP());
329  Status error;
330  process_sp->ReadMemory(addr, buffer_sp->GetBytes(),
331  buffer_sp->GetByteSize(), error);
332  if (error.Fail())
333  return false;
334  DataExtractor extractor(buffer_sp, process_sp->GetByteOrder(),
335  process_sp->GetAddressByteSize());
336  auto pair_sp = CreateValueObjectFromData(
337  "pair", extractor, valobj_sp->GetExecutionContextRef(),
338  tree_node_type);
339  if (pair_sp)
340  m_pair_sp = pair_sp->GetChildAtIndex(4, true);
341  }
342  }
343  }
344 
345  return false;
346 }
347 
350  return 2;
351 }
352 
353 lldb::ValueObjectSP
355  size_t idx) {
356  if (m_pair_ptr)
357  return m_pair_ptr->GetChildAtIndex(idx, true);
358  if (m_pair_sp)
359  return m_pair_sp->GetChildAtIndex(idx, true);
360  return lldb::ValueObjectSP();
361 }
362 
365  return true;
366 }
367 
370  if (name == "first")
371  return 0;
372  if (name == "second")
373  return 1;
374  return UINT32_MAX;
375 }
376 
379  // this will be deleted when its parent dies (since it's a child object)
380  // delete m_pair_ptr;
381 }
382 
385  CXXSyntheticChildren *, lldb::ValueObjectSP valobj_sp) {
386  return (valobj_sp ? new LibCxxMapIteratorSyntheticFrontEnd(valobj_sp)
387  : nullptr);
388 }
389 
391  LibCxxUnorderedMapIteratorSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp)
392  : SyntheticChildrenFrontEnd(*valobj_sp) {
393  if (valobj_sp)
394  Update();
395 }
396 
399  m_pair_sp.reset();
400  m_iter_ptr = nullptr;
401 
402  ValueObjectSP valobj_sp = m_backend.GetSP();
403  if (!valobj_sp)
404  return false;
405 
406  TargetSP target_sp(valobj_sp->GetTargetSP());
407 
408  if (!target_sp)
409  return false;
410 
411  if (!valobj_sp)
412  return false;
413 
414  auto exprPathOptions = ValueObject::GetValueForExpressionPathOptions()
418  SyntheticChildrenTraversal::None);
419 
420  // This must be a ValueObject* because it is a child of the ValueObject we
421  // are producing children for it if were a ValueObjectSP, we would end up
422  // with a loop (iterator -> synthetic -> child -> parent == iterator) and
423  // that would in turn leak memory by never allowing the ValueObjects to die
424  // and free their memory.
425  m_iter_ptr =
426  valobj_sp
427  ->GetValueForExpressionPath(".__i_.__node_", nullptr, nullptr,
428  exprPathOptions, nullptr)
429  .get();
430 
431  if (m_iter_ptr) {
432  auto iter_child(
433  valobj_sp->GetChildMemberWithName(ConstString("__i_"), true));
434  if (!iter_child) {
435  m_iter_ptr = nullptr;
436  return false;
437  }
438 
439  CompilerType node_type(iter_child->GetCompilerType()
440  .GetTypeTemplateArgument(0)
441  .GetPointeeType());
442 
443  CompilerType pair_type(node_type.GetTypeTemplateArgument(0));
444 
445  std::string name;
446  uint64_t bit_offset_ptr;
447  uint32_t bitfield_bit_size_ptr;
448  bool is_bitfield_ptr;
449 
450  pair_type = pair_type.GetFieldAtIndex(
451  0, name, &bit_offset_ptr, &bitfield_bit_size_ptr, &is_bitfield_ptr);
452  if (!pair_type) {
453  m_iter_ptr = nullptr;
454  return false;
455  }
456 
457  uint64_t addr = m_iter_ptr->GetValueAsUnsigned(LLDB_INVALID_ADDRESS);
458  m_iter_ptr = nullptr;
459 
460  if (addr == 0 || addr == LLDB_INVALID_ADDRESS)
461  return false;
462 
463  TypeSystemClang *ast_ctx =
464  llvm::dyn_cast_or_null<TypeSystemClang>(pair_type.GetTypeSystem());
465  if (!ast_ctx)
466  return false;
467 
468  // Mimick layout of std::__hash_iterator::__node_ and read it in
469  // from process memory.
470  //
471  // The following shows the contiguous block of memory:
472  //
473  // +-----------------------------+ class __hash_node_base
474  // __node_ | __next_pointer __next_; |
475  // +-----------------------------+ class __hash_node
476  // | size_t __hash_; |
477  // | __node_value_type __value_; | <<< our key/value pair
478  // +-----------------------------+
479  //
480  CompilerType tree_node_type = ast_ctx->CreateStructForIdentifier(
481  ConstString(),
482  {{"__next_",
483  ast_ctx->GetBasicType(lldb::eBasicTypeVoid).GetPointerType()},
484  {"__hash_", ast_ctx->GetBasicType(lldb::eBasicTypeUnsignedLongLong)},
485  {"__value_", pair_type}});
486  llvm::Optional<uint64_t> size = tree_node_type.GetByteSize(nullptr);
487  if (!size)
488  return false;
489  WritableDataBufferSP buffer_sp(new DataBufferHeap(*size, 0));
490  ProcessSP process_sp(target_sp->GetProcessSP());
491  Status error;
492  process_sp->ReadMemory(addr, buffer_sp->GetBytes(),
493  buffer_sp->GetByteSize(), error);
494  if (error.Fail())
495  return false;
496  DataExtractor extractor(buffer_sp, process_sp->GetByteOrder(),
497  process_sp->GetAddressByteSize());
498  auto pair_sp = CreateValueObjectFromData(
499  "pair", extractor, valobj_sp->GetExecutionContextRef(), tree_node_type);
500  if (pair_sp)
501  m_pair_sp = pair_sp->GetChildAtIndex(2, true);
502  }
503 
504  return false;
505 }
506 
509  return 2;
510 }
511 
512 lldb::ValueObjectSP lldb_private::formatters::
514  if (m_pair_sp)
515  return m_pair_sp->GetChildAtIndex(idx, true);
516  return lldb::ValueObjectSP();
517 }
518 
521  return true;
522 }
523 
526  if (name == "first")
527  return 0;
528  if (name == "second")
529  return 1;
530  return UINT32_MAX;
531 }
532 
535  CXXSyntheticChildren *, lldb::ValueObjectSP valobj_sp) {
536  return (valobj_sp ? new LibCxxUnorderedMapIteratorSyntheticFrontEnd(valobj_sp)
537  : nullptr);
538 }
539 
540 /*
541  (lldb) fr var ibeg --raw --ptr-depth 1 -T
542  (std::__1::__wrap_iter<int *>) ibeg = {
543  (std::__1::__wrap_iter<int *>::iterator_type) __i = 0x00000001001037a0 {
544  (int) *__i = 1
545  }
546  }
547 */
548 
551  CXXSyntheticChildren *, lldb::ValueObjectSP valobj_sp) {
552  return (valobj_sp ? new VectorIteratorSyntheticFrontEnd(
553  valobj_sp, {ConstString("__i_"), ConstString("__i")})
554  : nullptr);
555 }
556 
558  LibcxxSharedPtrSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp)
559  : SyntheticChildrenFrontEnd(*valobj_sp), m_cntrl(nullptr) {
560  if (valobj_sp)
561  Update();
562 }
563 
566  return (m_cntrl ? 1 : 0);
567 }
568 
569 lldb::ValueObjectSP
571  size_t idx) {
572  if (!m_cntrl)
573  return lldb::ValueObjectSP();
574 
575  ValueObjectSP valobj_sp = m_backend.GetSP();
576  if (!valobj_sp)
577  return lldb::ValueObjectSP();
578 
579  if (idx == 0)
580  return valobj_sp->GetChildMemberWithName(ConstString("__ptr_"), true);
581 
582  if (idx == 1) {
583  if (auto ptr_sp =
584  valobj_sp->GetChildMemberWithName(ConstString("__ptr_"), true)) {
585  Status status;
586  auto value_sp = ptr_sp->Dereference(status);
587  if (status.Success()) {
588  auto value_type_sp =
589  valobj_sp->GetCompilerType().GetTypeTemplateArgument(0);
590  return value_sp->Cast(value_type_sp);
591  }
592  }
593  }
594 
595  return lldb::ValueObjectSP();
596 }
597 
599  m_cntrl = nullptr;
600 
601  ValueObjectSP valobj_sp = m_backend.GetSP();
602  if (!valobj_sp)
603  return false;
604 
605  TargetSP target_sp(valobj_sp->GetTargetSP());
606  if (!target_sp)
607  return false;
608 
609  lldb::ValueObjectSP cntrl_sp(
610  valobj_sp->GetChildMemberWithName(ConstString("__cntrl_"), true));
611 
612  m_cntrl = cntrl_sp.get(); // need to store the raw pointer to avoid a circular
613  // dependency
614  return false;
615 }
616 
619  return true;
620 }
621 
624  if (name == "__ptr_")
625  return 0;
626  if (name == "$$dereference$$")
627  return 1;
628  return UINT32_MAX;
629 }
630 
633 
636  CXXSyntheticChildren *, lldb::ValueObjectSP valobj_sp) {
637  return (valobj_sp ? new LibcxxSharedPtrSyntheticFrontEnd(valobj_sp)
638  : nullptr);
639 }
640 
642  LibcxxUniquePtrSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp)
643  : SyntheticChildrenFrontEnd(*valobj_sp) {
644  if (valobj_sp)
645  Update();
646 }
647 
650 
653  CXXSyntheticChildren *, lldb::ValueObjectSP valobj_sp) {
654  return (valobj_sp ? new LibcxxUniquePtrSyntheticFrontEnd(valobj_sp)
655  : nullptr);
656 }
657 
660  return (m_value_ptr_sp ? 1 : 0);
661 }
662 
663 lldb::ValueObjectSP
665  size_t idx) {
666  if (!m_value_ptr_sp)
667  return lldb::ValueObjectSP();
668 
669  if (idx == 0)
670  return m_value_ptr_sp;
671 
672  if (idx == 1) {
673  Status status;
674  auto value_sp = m_value_ptr_sp->Dereference(status);
675  if (status.Success()) {
676  return value_sp;
677  }
678  }
679 
680  return lldb::ValueObjectSP();
681 }
682 
684  ValueObjectSP valobj_sp = m_backend.GetSP();
685  if (!valobj_sp)
686  return false;
687 
688  ValueObjectSP ptr_sp(
689  valobj_sp->GetChildMemberWithName(ConstString("__ptr_"), true));
690  if (!ptr_sp)
691  return false;
692 
693  m_value_ptr_sp = GetValueOfLibCXXCompressedPair(*ptr_sp);
694 
695  return false;
696 }
697 
700  return true;
701 }
702 
705  if (name == "__value_")
706  return 0;
707  if (name == "$$dereference$$")
708  return 1;
709  return UINT32_MAX;
710 }
711 
713  ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
714  if (valobj.IsPointerType()) {
715  uint64_t value = valobj.GetValueAsUnsigned(0);
716  if (!value)
717  return false;
718  stream.Printf("0x%016" PRIx64 " ", value);
719  }
720  return FormatEntity::FormatStringRef("size=${svar%#}", stream, nullptr,
721  nullptr, nullptr, &valobj, false, false);
722 }
723 
724 /// The field layout in a libc++ string (cap, side, data or data, size, cap).
725 namespace {
726 enum class StringLayout { CSD, DSC };
727 }
728 
729 /// Determine the size in bytes of \p valobj (a libc++ std::string object) and
730 /// extract its data payload. Return the size + payload pair.
731 // TODO: Support big-endian architectures.
732 static llvm::Optional<std::pair<uint64_t, ValueObjectSP>>
734  ValueObjectSP valobj_r_sp =
735  valobj.GetChildMemberWithName(ConstString("__r_"), /*can_create=*/true);
736  if (!valobj_r_sp || !valobj_r_sp->GetError().Success())
737  return {};
738 
739  // __r_ is a compressed_pair of the actual data and the allocator. The data we
740  // want is in the first base class.
741  ValueObjectSP valobj_r_base_sp =
742  valobj_r_sp->GetChildAtIndex(0, /*can_create=*/true);
743  if (!valobj_r_base_sp)
744  return {};
745 
746  ValueObjectSP valobj_rep_sp = valobj_r_base_sp->GetChildMemberWithName(
747  ConstString("__value_"), /*can_create=*/true);
748  if (!valobj_rep_sp)
749  return {};
750 
751  ValueObjectSP l = valobj_rep_sp->GetChildMemberWithName(ConstString("__l"),
752  /*can_create=*/true);
753  if (!l)
754  return {};
755 
756  StringLayout layout = l->GetIndexOfChildWithName(ConstString("__data_")) == 0
757  ? StringLayout::DSC
758  : StringLayout::CSD;
759 
760  bool short_mode = false; // this means the string is in short-mode and the
761  // data is stored inline
762  bool using_bitmasks = true; // Whether the class uses bitmasks for the mode
763  // flag (pre-D123580).
764  uint64_t size;
765  uint64_t size_mode_value = 0;
766 
767  ValueObjectSP short_sp = valobj_rep_sp->GetChildMemberWithName(
768  ConstString("__s"), /*can_create=*/true);
769  if (!short_sp)
770  return {};
771 
772  ValueObjectSP is_long =
773  short_sp->GetChildMemberWithName(ConstString("__is_long_"), true);
774  ValueObjectSP size_sp =
775  short_sp->GetChildAtNamePath({ConstString("__size_")});
776  if (!size_sp)
777  return {};
778 
779  if (is_long) {
780  using_bitmasks = false;
781  short_mode = !is_long->GetValueAsUnsigned(/*fail_value=*/0);
782  size = size_sp->GetValueAsUnsigned(/*fail_value=*/0);
783  } else {
784  // The string mode is encoded in the size field.
785  size_mode_value = size_sp->GetValueAsUnsigned(0);
786  uint8_t mode_mask = layout == StringLayout::DSC ? 0x80 : 1;
787  short_mode = (size_mode_value & mode_mask) == 0;
788  }
789 
790  if (short_mode) {
791  ValueObjectSP location_sp =
792  short_sp->GetChildMemberWithName(ConstString("__data_"), true);
793  if (using_bitmasks)
794  size = (layout == StringLayout::DSC) ? size_mode_value
795  : ((size_mode_value >> 1) % 256);
796 
797  // When the small-string optimization takes place, the data must fit in the
798  // inline string buffer (23 bytes on x86_64/Darwin). If it doesn't, it's
799  // likely that the string isn't initialized and we're reading garbage.
800  ExecutionContext exe_ctx(location_sp->GetExecutionContextRef());
801  const llvm::Optional<uint64_t> max_bytes =
802  location_sp->GetCompilerType().GetByteSize(
803  exe_ctx.GetBestExecutionContextScope());
804  if (!max_bytes || size > *max_bytes || !location_sp)
805  return {};
806 
807  return std::make_pair(size, location_sp);
808  }
809 
810  // we can use the layout_decider object as the data pointer
811  ValueObjectSP location_sp =
812  l->GetChildMemberWithName(ConstString("__data_"), /*can_create=*/true);
813  ValueObjectSP size_vo =
814  l->GetChildMemberWithName(ConstString("__size_"), /*can_create=*/true);
815  ValueObjectSP capacity_vo =
816  l->GetChildMemberWithName(ConstString("__cap_"), /*can_create=*/true);
817  if (!size_vo || !location_sp || !capacity_vo)
818  return {};
819  size = size_vo->GetValueAsUnsigned(LLDB_INVALID_OFFSET);
820  uint64_t capacity = capacity_vo->GetValueAsUnsigned(LLDB_INVALID_OFFSET);
821  if (!using_bitmasks && layout == StringLayout::CSD)
822  capacity *= 2;
823  if (size == LLDB_INVALID_OFFSET || capacity == LLDB_INVALID_OFFSET ||
824  capacity < size)
825  return {};
826  return std::make_pair(size, location_sp);
827 }
828 
829 static bool
831  const TypeSummaryOptions &summary_options,
832  ValueObjectSP location_sp, size_t size) {
833  if (size == 0) {
834  stream.Printf("L\"\"");
835  return true;
836  }
837  if (!location_sp)
838  return false;
839 
841  if (summary_options.GetCapping() == TypeSummaryCapping::eTypeSummaryCapped) {
842  const auto max_size = valobj.GetTargetSP()->GetMaximumSizeOfStringSummary();
843  if (size > max_size) {
844  size = max_size;
845  options.SetIsTruncated(true);
846  }
847  }
848 
849  DataExtractor extractor;
850  const size_t bytes_read = location_sp->GetPointeeData(extractor, 0, size);
851  if (bytes_read < size)
852  return false;
853 
854  // std::wstring::size() is measured in 'characters', not bytes
855  TypeSystemClang *ast_context =
857  if (!ast_context)
858  return false;
859 
860  auto wchar_t_size =
861  ast_context->GetBasicType(lldb::eBasicTypeWChar).GetByteSize(nullptr);
862  if (!wchar_t_size)
863  return false;
864 
865  options.SetData(std::move(extractor));
866  options.SetStream(&stream);
867  options.SetPrefixToken("L");
868  options.SetQuote('"');
869  options.SetSourceSize(size);
870  options.SetBinaryZeroIsTerminator(false);
871 
872  switch (*wchar_t_size) {
873  case 1:
876  options);
877  break;
878 
879  case 2:
882  options);
883  break;
884 
885  case 4:
888  options);
889  }
890  return false;
891 }
892 
894  ValueObject &valobj, Stream &stream,
895  const TypeSummaryOptions &summary_options) {
896  auto string_info = ExtractLibcxxStringInfo(valobj);
897  if (!string_info)
898  return false;
899  uint64_t size;
900  ValueObjectSP location_sp;
901  std::tie(size, location_sp) = *string_info;
902 
903  return ::LibcxxWStringSummaryProvider(valobj, stream, summary_options,
904  location_sp, size);
905 }
906 
907 template <StringPrinter::StringElementType element_type>
908 static bool
910  const TypeSummaryOptions &summary_options,
911  std::string prefix_token, ValueObjectSP location_sp,
912  uint64_t size) {
913 
914  if (size == 0) {
915  stream.Printf("\"\"");
916  return true;
917  }
918 
919  if (!location_sp)
920  return false;
921 
923 
924  if (summary_options.GetCapping() == TypeSummaryCapping::eTypeSummaryCapped) {
925  const auto max_size = valobj.GetTargetSP()->GetMaximumSizeOfStringSummary();
926  if (size > max_size) {
927  size = max_size;
928  options.SetIsTruncated(true);
929  }
930  }
931 
932  {
933  DataExtractor extractor;
934  const size_t bytes_read = location_sp->GetPointeeData(extractor, 0, size);
935  if (bytes_read < size)
936  return false;
937 
938  options.SetData(std::move(extractor));
939  }
940  options.SetStream(&stream);
941  if (prefix_token.empty())
942  options.SetPrefixToken(nullptr);
943  else
944  options.SetPrefixToken(prefix_token);
945  options.SetQuote('"');
946  options.SetSourceSize(size);
947  options.SetBinaryZeroIsTerminator(false);
948  return StringPrinter::ReadBufferAndDumpToStream<element_type>(options);
949 }
950 
951 template <StringPrinter::StringElementType element_type>
952 static bool
954  const TypeSummaryOptions &summary_options,
955  std::string prefix_token) {
956  auto string_info = ExtractLibcxxStringInfo(valobj);
957  if (!string_info)
958  return false;
959  uint64_t size;
960  ValueObjectSP location_sp;
961  std::tie(size, location_sp) = *string_info;
962 
963  return LibcxxStringSummaryProvider<element_type>(
964  valobj, stream, summary_options, prefix_token, location_sp, size);
965 }
966 template <StringPrinter::StringElementType element_type>
967 static bool formatStringImpl(ValueObject &valobj, Stream &stream,
968  const TypeSummaryOptions &summary_options,
969  std::string prefix_token) {
970  StreamString scratch_stream;
971  const bool success = LibcxxStringSummaryProvider<element_type>(
972  valobj, scratch_stream, summary_options, prefix_token);
973  if (success)
974  stream << scratch_stream.GetData();
975  else
976  stream << "Summary Unavailable";
977  return true;
978 }
979 
981  ValueObject &valobj, Stream &stream,
982  const TypeSummaryOptions &summary_options) {
983  return formatStringImpl<StringPrinter::StringElementType::ASCII>(
984  valobj, stream, summary_options, "");
985 }
986 
988  ValueObject &valobj, Stream &stream,
989  const TypeSummaryOptions &summary_options) {
990  return formatStringImpl<StringPrinter::StringElementType::UTF16>(
991  valobj, stream, summary_options, "u");
992 }
993 
995  ValueObject &valobj, Stream &stream,
996  const TypeSummaryOptions &summary_options) {
997  return formatStringImpl<StringPrinter::StringElementType::UTF32>(
998  valobj, stream, summary_options, "U");
999 }
1000 
1001 static std::tuple<bool, ValueObjectSP, size_t>
1003  auto dataobj = GetChildMemberWithName(
1004  valobj, {ConstString("__data_"), ConstString("__data")});
1005  auto sizeobj = GetChildMemberWithName(
1006  valobj, {ConstString("__size_"), ConstString("__size")});
1007  if (!dataobj || !sizeobj)
1008  return std::make_tuple<bool,ValueObjectSP,size_t>(false, {}, {});
1009 
1010  if (!dataobj->GetError().Success() || !sizeobj->GetError().Success())
1011  return std::make_tuple<bool,ValueObjectSP,size_t>(false, {}, {});
1012 
1013  bool success{false};
1014  uint64_t size = sizeobj->GetValueAsUnsigned(0, &success);
1015  if (!success)
1016  return std::make_tuple<bool,ValueObjectSP,size_t>(false, {}, {});
1017 
1018  return std::make_tuple(true,dataobj,size);
1019 }
1020 
1021 template <StringPrinter::StringElementType element_type>
1022 static bool formatStringViewImpl(ValueObject &valobj, Stream &stream,
1023  const TypeSummaryOptions &summary_options,
1024  std::string prefix_token) {
1025 
1026  bool success;
1027  ValueObjectSP dataobj;
1028  size_t size;
1029  std::tie(success, dataobj, size) = LibcxxExtractStringViewData(valobj);
1030 
1031  if (!success) {
1032  stream << "Summary Unavailable";
1033  return true;
1034  }
1035 
1036  return LibcxxStringSummaryProvider<element_type>(
1037  valobj, stream, summary_options, prefix_token, dataobj, size);
1038 }
1039 
1041  ValueObject &valobj, Stream &stream,
1042  const TypeSummaryOptions &summary_options) {
1043  return formatStringViewImpl<StringPrinter::StringElementType::ASCII>(
1044  valobj, stream, summary_options, "");
1045 }
1046 
1048  ValueObject &valobj, Stream &stream,
1049  const TypeSummaryOptions &summary_options) {
1050  return formatStringViewImpl<StringPrinter::StringElementType::UTF16>(
1051  valobj, stream, summary_options, "u");
1052 }
1053 
1055  ValueObject &valobj, Stream &stream,
1056  const TypeSummaryOptions &summary_options) {
1057  return formatStringViewImpl<StringPrinter::StringElementType::UTF32>(
1058  valobj, stream, summary_options, "U");
1059 }
1060 
1062  ValueObject &valobj, Stream &stream,
1063  const TypeSummaryOptions &summary_options) {
1064 
1065  bool success;
1066  ValueObjectSP dataobj;
1067  size_t size;
1068  std::tie( success, dataobj, size ) = LibcxxExtractStringViewData(valobj);
1069 
1070  if (!success) {
1071  stream << "Summary Unavailable";
1072  return true;
1073  }
1074 
1075 
1076  return ::LibcxxWStringSummaryProvider(valobj, stream, summary_options,
1077  dataobj, size);
1078 }
lldb_private::formatters::LibCxxUnorderedMapIteratorSyntheticFrontEnd::GetIndexOfChildWithName
size_t GetIndexOfChildWithName(ConstString name) override
Definition: LibCxx.cpp:525
lldb_private::formatters::StringPrinter::StringElementType::UTF16
@ UTF16
lldb_private::formatters::StringPrinter::DumpToStreamOptions::SetPrefixToken
void SetPrefixToken(const std::string &p)
Definition: StringPrinter.h:37
lldb_private::ValueObject::GetValueAsUnsigned
virtual uint64_t GetValueAsUnsigned(uint64_t fail_value, bool *success=nullptr)
Definition: ValueObject.cpp:1090
lldb_private::ExecutionContext
Definition: ExecutionContext.h:292
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:1042
lldb_private::CPPLanguageRuntime::LibCppStdFunctionCallableInfo::callable_symbol
Symbol callable_symbol
Definition: CPPLanguageRuntime.h:32
lldb_private::LineEntry::file
FileSpec file
The source file, possibly mapped by the target.source-map setting.
Definition: LineEntry.h:140
lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::~LibCxxMapIteratorSyntheticFrontEnd
~LibCxxMapIteratorSyntheticFrontEnd() override
Definition: LibCxx.cpp:378
lldb_private::formatters::LibcxxStringSummaryProviderUTF16
bool LibcxxStringSummaryProviderUTF16(ValueObject &valobj, Stream &stream, const TypeSummaryOptions &summary_options)
Definition: LibCxx.cpp:987
lldb_private::ValueObject::GetValueForExpressionPathOptions
Definition: ValueObject.h:196
lldb::eBasicTypeBool
@ eBasicTypeBool
Definition: lldb-enumerations.h:769
formatStringViewImpl
static bool formatStringViewImpl(ValueObject &valobj, Stream &stream, const TypeSummaryOptions &summary_options, std::string prefix_token)
Definition: LibCxx.cpp:1022
lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::GetIndexOfChildWithName
size_t GetIndexOfChildWithName(ConstString name) override
Definition: LibCxx.cpp:623
lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::CalculateNumChildren
size_t CalculateNumChildren() override
Definition: LibCxx.cpp:349
lldb_private::ExecutionContext::GetProcessPtr
Process * GetProcessPtr() const
Returns a pointer to the process object.
Definition: ExecutionContext.cpp:206
formatStringImpl
static bool formatStringImpl(ValueObject &valobj, Stream &stream, const TypeSummaryOptions &summary_options, std::string prefix_token)
Definition: LibCxx.cpp:967
lldb_private::formatters::LibcxxStringSummaryProviderUTF32
bool LibcxxStringSummaryProviderUTF32(ValueObject &valobj, Stream &stream, const TypeSummaryOptions &summary_options)
Definition: LibCxx.cpp:994
lldb_private::ValueObject::GetValueForExpressionPathOptions::SetSyntheticChildrenTraversal
GetValueForExpressionPathOptions & SetSyntheticChildrenTraversal(SyntheticChildrenTraversal traverse)
Definition: ValueObject.h:248
lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::GetChildAtIndex
lldb::ValueObjectSP GetChildAtIndex(size_t idx) override
Definition: LibCxx.cpp:354
lldb_private::Process
Definition: Process.h:338
lldb_private::formatters::StringPrinter::ReadBufferAndDumpToStreamOptions
Definition: StringPrinter.h:127
lldb_private::formatters::StringPrinter::ReadBufferAndDumpToStream
static bool ReadBufferAndDumpToStream(const ReadBufferAndDumpToStreamOptions &options)
VectorIterator.h
lldb_private::SyntheticChildrenFrontEnd
Definition: TypeSynthetic.h:27
SectionLoadList.h
lldb_private::FileSpec::GetFilename
const ConstString & GetFilename() const
Filename string const get accessor.
Definition: FileSpec.h:239
lldb_private::CompilerType::GetByteSize
llvm::Optional< uint64_t > GetByteSize(ExecutionContextScope *exe_scope) const
Return the size of the type in bytes.
Definition: CompilerType.cpp:489
lldb_private::ValueObject::IsPointerType
virtual bool IsPointerType()
Definition: ValueObject.h:382
lldb_private::Stream
Definition: Stream.h:28
lldb_private::formatters::StringPrinter::DumpToStreamOptions::SetSourceSize
void SetSourceSize(uint32_t s)
Definition: StringPrinter.h:53
lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::LibcxxUniquePtrSyntheticFrontEnd
LibcxxUniquePtrSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp)
Definition: LibCxx.cpp:642
lldb_private::formatters::VectorIteratorSyntheticFrontEnd
Definition: VectorIterator.h:22
Debugger.h
lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEndCreator
SyntheticChildrenFrontEnd * LibCxxMapIteratorSyntheticFrontEndCreator(CXXSyntheticChildren *, lldb::ValueObjectSP)
Definition: LibCxx.cpp:384
lldb_private::formatters::StringPrinter::DumpToStreamOptions::SetBinaryZeroIsTerminator
void SetBinaryZeroIsTerminator(bool e)
Definition: StringPrinter.h:61
Target.h
lldb_private::TypeSystemClang::CreateStructForIdentifier
CompilerType CreateStructForIdentifier(ConstString type_name, const std::initializer_list< std::pair< const char *, CompilerType >> &type_fields, bool packed=false)
Definition: TypeSystemClang.cpp:2269
lldb::eTypeSummaryCapped
@ eTypeSummaryCapped
Definition: lldb-enumerations.h:1143
lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::CalculateNumChildren
size_t CalculateNumChildren() override
Definition: LibCxx.cpp:565
lldb_private::formatters::LibCxxUnorderedMapIteratorSyntheticFrontEnd::LibCxxUnorderedMapIteratorSyntheticFrontEnd
LibCxxUnorderedMapIteratorSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp)
Definition: LibCxx.cpp:391
lldb_private::formatters::LibcxxWStringSummaryProvider
bool LibcxxWStringSummaryProvider(ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options)
Definition: LibCxx.cpp:893
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
LibcxxExtractStringViewData
static std::tuple< bool, ValueObjectSP, size_t > LibcxxExtractStringViewData(ValueObject &valobj)
Definition: LibCxx.cpp:1002
ExtractLibcxxStringInfo
static llvm::Optional< std::pair< uint64_t, ValueObjectSP > > ExtractLibcxxStringInfo(ValueObject &valobj)
Determine the size in bytes of valobj (a libc++ std::string object) and extract its data payload.
Definition: LibCxx.cpp:733
lldb_private::Status::Success
bool Success() const
Test for success condition.
Definition: Status.cpp:287
lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::LibcxxSharedPtrSyntheticFrontEnd
LibcxxSharedPtrSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp)
Definition: LibCxx.cpp:558
lldb_private::formatters::LibcxxStringViewSummaryProviderASCII
bool LibcxxStringViewSummaryProviderASCII(ValueObject &valueObj, Stream &stream, const TypeSummaryOptions &summary_options)
Definition: LibCxx.cpp:1040
lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::Update
bool Update() override
Definition: LibCxx.cpp:598
LLDB_INVALID_OFFSET
#define LLDB_INVALID_OFFSET
Definition: lldb-defines.h:85
lldb_private::DataExtractor
Definition: DataExtractor.h:48
lldb_private::formatters::StringPrinter::DumpToStreamOptions::SetQuote
void SetQuote(char q)
Definition: StringPrinter.h:49
lldb_private::formatters::LibcxxFunctionSummaryProvider
bool LibcxxFunctionSummaryProvider(ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options)
Definition: LibCxx.cpp:70
TypeSystemClang.h
lldb_private::ValueObject::GetChildMemberWithName
virtual lldb::ValueObjectSP GetChildMemberWithName(ConstString name, bool can_create)
Definition: ValueObject.cpp:468
lldb_private::formatters::LibcxxSmartPointerSummaryProvider
bool LibcxxSmartPointerSummaryProvider(ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options)
Definition: LibCxx.cpp:118
lldb_private::formatters::LibCxxUnorderedMapIteratorSyntheticFrontEndCreator
SyntheticChildrenFrontEnd * LibCxxUnorderedMapIteratorSyntheticFrontEndCreator(CXXSyntheticChildren *, lldb::ValueObjectSP)
Definition: LibCxx.cpp:534
lldb_private::formatters::StringPrinter::ReadBufferAndDumpToStreamOptions::SetIsTruncated
void SetIsTruncated(bool t)
Definition: StringPrinter.h:140
lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::GetChildAtIndex
lldb::ValueObjectSP GetChildAtIndex(size_t idx) override
Definition: LibCxx.cpp:570
lldb_private::StreamString::GetData
const char * GetData() const
Definition: StreamString.h:43
LibcxxWStringSummaryProvider
static bool LibcxxWStringSummaryProvider(ValueObject &valobj, Stream &stream, const TypeSummaryOptions &summary_options, ValueObjectSP location_sp, size_t size)
Definition: LibCxx.cpp:830
lldb_private::ValueObject::GetNonSyntheticValue
virtual lldb::ValueObjectSP GetNonSyntheticValue()
Definition: ValueObject.h:592
LibcxxStringSummaryProvider
static bool LibcxxStringSummaryProvider(ValueObject &valobj, Stream &stream, const TypeSummaryOptions &summary_options, std::string prefix_token, ValueObjectSP location_sp, uint64_t size)
Definition: LibCxx.cpp:909
lldb_private::formatters::LibCxxUnorderedMapIteratorSyntheticFrontEnd::Update
bool Update() override
Definition: LibCxx.cpp:398
lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::~LibcxxUniquePtrSyntheticFrontEnd
~LibcxxUniquePtrSyntheticFrontEnd() override
lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::Update
bool Update() override
Definition: LibCxx.cpp:227
lldb_private::formatters::GetValueOfLibCXXCompressedPair
lldb::ValueObjectSP GetValueOfLibCXXCompressedPair(ValueObject &pair)
Definition: FormattersHelpers.cpp:150
lldb_private::formatters::LibCxxUnorderedMapIteratorSyntheticFrontEnd::CalculateNumChildren
size_t CalculateNumChildren() override
Definition: LibCxx.cpp:508
lldb_private::ConstString
Definition: ConstString.h:39
lldb_private::StreamString
Definition: StreamString.h:23
lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd
Definition: LibCxx.h:185
lldb-enumerations.h
lldb_private::formatters::LibCxxUnorderedMapIteratorSyntheticFrontEnd::GetChildAtIndex
lldb::ValueObjectSP GetChildAtIndex(size_t idx) override
Definition: LibCxx.cpp:513
lldb::eBasicTypeVoid
@ eBasicTypeVoid
Definition: lldb-enumerations.h:749
lldb_private::formatters::StringPrinter::StringElementType::UTF32
@ UTF32
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:40
lldb::eBasicTypeUnsignedLongLong
@ eBasicTypeUnsignedLongLong
Definition: lldb-enumerations.h:766
lldb_private::formatters::LibcxxStringSummaryProviderASCII
bool LibcxxStringSummaryProviderASCII(ValueObject &valobj, Stream &stream, const TypeSummaryOptions &summary_options)
Definition: LibCxx.cpp:980
lldb_private::CPPLanguageRuntime::FindLibCppStdFunctionCallableInfo
LibCppStdFunctionCallableInfo FindLibCppStdFunctionCallableInfo(lldb::ValueObjectSP &valobj_sp)
Definition: CPPLanguageRuntime.cpp:100
CPPLanguageRuntime.h
ValueObject.h
lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::Update
bool Update() override
Definition: LibCxx.cpp:683
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::formatters::GetChildMemberWithName
lldb::ValueObjectSP GetChildMemberWithName(ValueObject &obj, llvm::ArrayRef< ConstString > alternative_names)
Find a child member of obj_sp, trying all alternative names in order.
Definition: LibCxx.cpp:37
lldb_private::formatters::LibcxxStringViewSummaryProviderUTF16
bool LibcxxStringViewSummaryProviderUTF16(ValueObject &valobj, Stream &stream, const TypeSummaryOptions &summary_options)
Definition: LibCxx.cpp:1047
ValueObjectConstResult.h
lldb_private::CPPLanguageRuntime::LibCppStdFunctionCallableInfo::callable_case
LibCppStdFunctionCallableCase callable_case
Definition: CPPLanguageRuntime.h:36
lldb_private::Symbol::GetName
ConstString GetName() const
Definition: Symbol.cpp:500
ProcessStructReader.h
lldb_private::Status
Definition: Status.h:44
lldb_private::ValueObject
ValueObject:
Definition: ValueObject.h:105
lldb_private::formatters::LibcxxContainerSummaryProvider
bool LibcxxContainerSummaryProvider(ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options)
Definition: LibCxx.cpp:712
TypeSummary.h
lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::~LibcxxSharedPtrSyntheticFrontEnd
~LibcxxSharedPtrSyntheticFrontEnd() override
uint32_t
lldb_private::ExecutionContext::GetBestExecutionContextScope
ExecutionContextScope * GetBestExecutionContextScope() const
Definition: ExecutionContext.cpp:214
lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEndCreator
SyntheticChildrenFrontEnd * LibcxxUniquePtrSyntheticFrontEndCreator(CXXSyntheticChildren *, lldb::ValueObjectSP)
Definition: LibCxx.cpp:652
lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEndCreator
SyntheticChildrenFrontEnd * LibcxxSharedPtrSyntheticFrontEndCreator(CXXSyntheticChildren *, lldb::ValueObjectSP)
Definition: LibCxx.cpp:635
lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::GetIndexOfChildWithName
size_t GetIndexOfChildWithName(ConstString name) override
Definition: LibCxx.cpp:369
lldb_private::CompilerType::GetTypeSystem
TypeSystem * GetTypeSystem() const
Accessors.
Definition: CompilerType.h:162
lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::MightHaveChildren
bool MightHaveChildren() override
Definition: LibCxx.cpp:699
lldb_private::formatters::LibcxxStringViewSummaryProviderUTF32
bool LibcxxStringViewSummaryProviderUTF32(ValueObject &valobj, Stream &stream, const TypeSummaryOptions &summary_options)
Definition: LibCxx.cpp:1054
UINT32_MAX
#define UINT32_MAX
Definition: lldb-defines.h:19
lldb_private::formatters::StringPrinter::StringElementType::UTF8
@ UTF8
FormatEntity.h
lldb_private::TypeSummaryOptions
Definition: TypeSummary.h:26
lldb_private::ScratchTypeSystemClang::GetForTarget
static TypeSystemClang * GetForTarget(Target &target, llvm::Optional< IsolatedASTKind > ast_kind=DefaultAST, bool create_on_demand=true)
Returns the scratch TypeSystemClang for the given target.
Definition: TypeSystemClang.cpp:9841
LLDB_INVALID_ADDRESS
#define LLDB_INVALID_ADDRESS
Definition: lldb-defines.h:74
lldb_private::ConstString::GetCString
const char * GetCString() const
Get the string value as a C string.
Definition: ConstString.h:215
lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::GetIndexOfChildWithName
size_t GetIndexOfChildWithName(ConstString name) override
Definition: LibCxx.cpp:704
lldb_private::CompilerType
Generic representation of a type in a programming language.
Definition: CompilerType.h:33
lldb_private::Stream::Printf
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition: Stream.cpp:107
lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::GetChildAtIndex
lldb::ValueObjectSP GetChildAtIndex(size_t idx) override
Definition: LibCxx.cpp:664
lldb_private::formatters::LibcxxUniquePointerSummaryProvider
bool LibcxxUniquePointerSummaryProvider(ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options)
Definition: LibCxx.cpp:161
Status.h
lldb_private::formatters
Definition: CXXFunctionPointer.h:15
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::TypeSummaryOptions::GetCapping
lldb::TypeSummaryCapping GetCapping() const
Definition: TypeSummary.cpp:33
LibCxx.h
lldb_private::formatters::LibCxxUnorderedMapIteratorSyntheticFrontEnd::MightHaveChildren
bool MightHaveChildren() override
Definition: LibCxx.cpp:520
lldb_private::TypeSystemClang::GetBasicType
CompilerType GetBasicType(lldb::BasicType type)
Definition: TypeSystemClang.cpp:930
lldb_private::CompilerType::GetTypeTemplateArgument
CompilerType GetTypeTemplateArgument(size_t idx, bool expand_pack=false) const
Definition: CompilerType.cpp:676
lldb_private::CPPLanguageRuntime::LibCppStdFunctionCallableInfo
Definition: CPPLanguageRuntime.h:31
lldb_private::TypeSystemClang
A TypeSystem implementation based on Clang.
Definition: TypeSystemClang.h:105
ConstString.h
lldb_private::ValueObject::GetTargetSP
lldb::TargetSP GetTargetSP() const
Definition: ValueObject.h:334
lldb_private::formatters::StringPrinter::ReadBufferAndDumpToStreamOptions::SetData
void SetData(DataExtractor &&d)
Definition: StringPrinter.h:136
StringPrinter.h
lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::MightHaveChildren
bool MightHaveChildren() override
Definition: LibCxx.cpp:364
lldb_private::formatters::LibCxxVectorIteratorSyntheticFrontEndCreator
SyntheticChildrenFrontEnd * LibCxxVectorIteratorSyntheticFrontEndCreator(CXXSyntheticChildren *, lldb::ValueObjectSP)
Definition: LibCxx.cpp:550
Stream.h
lldb_private::CompilerType::GetFieldAtIndex
CompilerType GetFieldAtIndex(size_t idx, std::string &name, uint64_t *bit_offset_ptr, uint32_t *bitfield_bit_size_ptr, bool *is_bitfield_ptr) const
Definition: CompilerType.cpp:543
lldb_private::formatters::LibcxxWStringViewSummaryProvider
bool LibcxxWStringViewSummaryProvider(ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options)
Definition: LibCxx.cpp:1061
lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::CalculateNumChildren
size_t CalculateNumChildren() override
Definition: LibCxx.cpp:659
lldb_private::CXXSyntheticChildren
Definition: TypeSynthetic.h:358
lldb_private::formatters::LibcxxOptionalSummaryProvider
bool LibcxxOptionalSummaryProvider(ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options)
Definition: LibCxx.cpp:48
lldb_private::CPPLanguageRuntime::LibCppStdFunctionCallableInfo::callable_line_entry
LineEntry callable_line_entry
Definition: CPPLanguageRuntime.h:34
lldb_private::formatters::StringPrinter::DumpToStreamOptions::SetStream
void SetStream(Stream *s)
Definition: StringPrinter.h:33
FormattersHelpers.h
lldb_private::CPPLanguageRuntime
Definition: CPPLanguageRuntime.h:22
lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd
Definition: LibCxx.h:165
lldb_private::DataBufferHeap
Definition: DataBufferHeap.h:30
lldb
Definition: SBAddress.h:15
Endian.h
lldb::eBasicTypeWChar
@ eBasicTypeWChar
Definition: lldb-enumerations.h:753
lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd
Definition: LibCxx.h:86
DataBufferHeap.h
lldb_private::formatters::LibCxxUnorderedMapIteratorSyntheticFrontEnd
Formats libcxx's std::unordered_map iterators.
Definition: LibCxx.h:131
lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::MightHaveChildren
bool MightHaveChildren() override
Definition: LibCxx.cpp:618
lldb::eFormatInvalid
@ eFormatInvalid
Definition: lldb-enumerations.h:157
lldb_private::ValueObject::GetValueForExpressionPathOptions::DontCheckDotVsArrowSyntax
GetValueForExpressionPathOptions & DontCheckDotVsArrowSyntax()
Definition: ValueObject.h:222
lldb_private::CPPLanguageRuntime::LibCppStdFunctionCallableInfo::member_f_pointer_value
lldb::addr_t member_f_pointer_value
Definition: CPPLanguageRuntime.h:35
lldb_private::formatters::LibCxxMapIteratorSyntheticFrontEnd::LibCxxMapIteratorSyntheticFrontEnd
LibCxxMapIteratorSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp)
Definition: LibCxx.cpp:221