LLDB  mainline
NSArray.cpp
Go to the documentation of this file.
1 //===-- NSArray.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 "clang/AST/ASTContext.h"
10 #include "clang/Basic/TargetInfo.h"
11 
12 #include "Cocoa.h"
13 
16 
17 #include "lldb/Core/ValueObject.h"
21 #include "lldb/Target/Language.h"
22 #include "lldb/Target/Target.h"
24 #include "lldb/Utility/Endian.h"
25 #include "lldb/Utility/Status.h"
26 #include "lldb/Utility/Stream.h"
27 
28 using namespace lldb;
29 using namespace lldb_private;
30 using namespace lldb_private::formatters;
31 
32 namespace lldb_private {
33 namespace formatters {
34 std::map<ConstString, CXXFunctionSummaryFormat::Callback> &
35 NSArray_Additionals::GetAdditionalSummaries() {
36  static std::map<ConstString, CXXFunctionSummaryFormat::Callback> g_map;
37  return g_map;
38 }
39 
40 std::map<ConstString, CXXSyntheticChildren::CreateFrontEndCallback> &
41 NSArray_Additionals::GetAdditionalSynthetics() {
42  static std::map<ConstString, CXXSyntheticChildren::CreateFrontEndCallback>
43  g_map;
44  return g_map;
45 }
46 
48 public:
49  NSArrayMSyntheticFrontEndBase(lldb::ValueObjectSP valobj_sp);
50 
51  ~NSArrayMSyntheticFrontEndBase() override = default;
52 
53  size_t CalculateNumChildren() override;
54 
55  lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
56 
57  bool Update() override = 0;
58 
59  bool MightHaveChildren() override;
60 
61  size_t GetIndexOfChildWithName(ConstString name) override;
62 
63 protected:
64  virtual lldb::addr_t GetDataAddress() = 0;
65 
66  virtual uint64_t GetUsedCount() = 0;
67 
68  virtual uint64_t GetOffset() = 0;
69 
70  virtual uint64_t GetSize() = 0;
71 
73  uint8_t m_ptr_size;
75 };
76 
77 template <typename D32, typename D64>
79 public:
80  GenericNSArrayMSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);
81 
83 
84  bool Update() override;
85 
86 protected:
87  lldb::addr_t GetDataAddress() override;
88 
89  uint64_t GetUsedCount() override;
90 
91  uint64_t GetOffset() override;
92 
93  uint64_t GetSize() override;
94 
95 private:
96  D32 *m_data_32;
97  D64 *m_data_64;
98 };
99 
100 namespace Foundation1010 {
101  namespace {
102  struct DataDescriptor_32 {
106  uint64_t _priv1 : 4;
109  };
110 
111  struct DataDescriptor_64 {
112  uint64_t _used;
113  uint64_t _offset;
114  uint64_t _size : 60;
115  uint64_t _priv1 : 4;
117  uint64_t _data;
118  };
119  }
120 
123 }
124 
125 namespace Foundation1428 {
126  namespace {
127  struct DataDescriptor_32 {
128  uint32_t _used;
130  uint32_t _size;
131  uint32_t _data;
132  };
133 
134  struct DataDescriptor_64 {
135  uint64_t _used;
136  uint64_t _offset;
137  uint64_t _size;
138  uint64_t _data;
139  };
140  }
141 
144 }
145 
146 namespace Foundation1437 {
147  template <typename PtrType>
148  struct DataDescriptor {
149  PtrType _cow;
150  // __deque
151  PtrType _data;
156  };
157 
161 
162  template <typename DD>
163  uint64_t
165  lldb::addr_t valobj_addr, Status &error) {
166  const lldb::addr_t start_of_descriptor =
167  valobj_addr + process.GetAddressByteSize();
168  DD descriptor = DD();
169  process.ReadMemory(start_of_descriptor, &descriptor,
170  sizeof(descriptor), error);
171  if (error.Fail()) {
172  return 0;
173  }
174  return descriptor._used;
175  }
176 
177  uint64_t
179  Status &error) {
180  if (process.GetAddressByteSize() == 4) {
181  return __NSArrayMSize_Impl<DataDescriptor<uint32_t>>(process, valobj_addr,
182  error);
183  } else {
184  return __NSArrayMSize_Impl<DataDescriptor<uint64_t>>(process, valobj_addr,
185  error);
186  }
187  }
188 
189 }
190 
191 namespace CallStackArray {
196  const uint32_t _size = 0;
197 };
198 
200  uint64_t _data;
201  uint64_t _used;
202  uint64_t _offset;
203  const uint64_t _size = 0;
204 };
205 
208 } // namespace CallStackArray
209 
210 template <typename D32, typename D64, bool Inline>
212 public:
213  GenericNSArrayISyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);
214 
216 
217  size_t CalculateNumChildren() override;
218 
219  lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
220 
221  bool Update() override;
222 
223  bool MightHaveChildren() override;
224 
225  size_t GetIndexOfChildWithName(ConstString name) override;
226 
227 private:
229  uint8_t m_ptr_size;
230 
231  D32 *m_data_32;
232  D64 *m_data_64;
234 };
235 
236 namespace Foundation1300 {
237  struct IDD32 {
240  };
241 
242  struct IDD64 {
243  uint64_t used;
244  uint64_t list;
245  };
246 
249 }
250 
251 namespace Foundation1430 {
254 }
255 
256 namespace Foundation1436 {
257  struct IDD32 {
259  uint32_t list; // in Inline cases, this is the first element
260  };
261 
262  struct IDD64 {
263  uint64_t used;
264  uint64_t list; // in Inline cases, this is the first element
265  };
266 
269 
272 
275 
276  uint64_t
278  Status &error) {
279  return Foundation1437::__NSArrayMSize(process, valobj_addr, error);
280  }
281 }
282 
284 public:
285  NSArray0SyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);
286 
287  ~NSArray0SyntheticFrontEnd() override = default;
288 
289  size_t CalculateNumChildren() override;
290 
291  lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
292 
293  bool Update() override;
294 
295  bool MightHaveChildren() override;
296 
297  size_t GetIndexOfChildWithName(ConstString name) override;
298 };
299 
301 public:
302  NSArray1SyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);
303 
304  ~NSArray1SyntheticFrontEnd() override = default;
305 
306  size_t CalculateNumChildren() override;
307 
308  lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
309 
310  bool Update() override;
311 
312  bool MightHaveChildren() override;
313 
314  size_t GetIndexOfChildWithName(ConstString name) override;
315 };
316 } // namespace formatters
317 } // namespace lldb_private
318 
320  ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
321  static ConstString g_TypeHint("NSArray");
322 
323  ProcessSP process_sp = valobj.GetProcessSP();
324  if (!process_sp)
325  return false;
326 
327  ObjCLanguageRuntime *runtime = ObjCLanguageRuntime::Get(*process_sp);
328 
329  if (!runtime)
330  return false;
331 
333  runtime->GetClassDescriptor(valobj));
334 
335  if (!descriptor || !descriptor->IsValid())
336  return false;
337 
338  uint32_t ptr_size = process_sp->GetAddressByteSize();
339 
340  lldb::addr_t valobj_addr = valobj.GetValueAsUnsigned(0);
341 
342  if (!valobj_addr)
343  return false;
344 
345  uint64_t value = 0;
346 
347  ConstString class_name(descriptor->GetClassName());
348 
349  static const ConstString g_NSArrayI("__NSArrayI");
350  static const ConstString g_NSArrayM("__NSArrayM");
351  static const ConstString g_NSArrayI_Transfer("__NSArrayI_Transfer");
352  static const ConstString g_NSFrozenArrayM("__NSFrozenArrayM");
353  static const ConstString g_NSArray0("__NSArray0");
354  static const ConstString g_NSArray1("__NSSingleObjectArrayI");
355  static const ConstString g_NSArrayCF("__NSCFArray");
356  static const ConstString g_NSArrayMLegacy("__NSArrayM_Legacy");
357  static const ConstString g_NSArrayMImmutable("__NSArrayM_Immutable");
358  static const ConstString g_NSCallStackArray("_NSCallStackArray");
359 
360  if (class_name.IsEmpty())
361  return false;
362 
363  if (class_name == g_NSArrayI) {
364  Status error;
365  value = process_sp->ReadUnsignedIntegerFromMemory(valobj_addr + ptr_size,
366  ptr_size, 0, error);
367  if (error.Fail())
368  return false;
369  } else if (class_name == g_NSArrayM) {
370  AppleObjCRuntime *apple_runtime =
371  llvm::dyn_cast_or_null<AppleObjCRuntime>(runtime);
372  Status error;
373  if (apple_runtime && apple_runtime->GetFoundationVersion() >= 1437) {
374  value = Foundation1437::__NSArrayMSize(*process_sp, valobj_addr, error);
375  } else {
376  value = process_sp->ReadUnsignedIntegerFromMemory(valobj_addr + ptr_size,
377  ptr_size, 0, error);
378  }
379  if (error.Fail())
380  return false;
381  } else if (class_name == g_NSArrayI_Transfer) {
382  Status error;
383  value = process_sp->ReadUnsignedIntegerFromMemory(valobj_addr + ptr_size,
384  ptr_size, 0, error);
385  if (error.Fail())
386  return false;
387  } else if (class_name == g_NSFrozenArrayM) {
388  Status error;
389  value = Foundation1436::__NSFrozenArrayMSize(*process_sp, valobj_addr, error);
390  if (error.Fail())
391  return false;
392  } else if (class_name == g_NSArrayMLegacy) {
393  Status error;
394  value = process_sp->ReadUnsignedIntegerFromMemory(valobj_addr + ptr_size,
395  ptr_size, 0, error);
396  if (error.Fail())
397  return false;
398  } else if (class_name == g_NSArrayMImmutable) {
399  Status error;
400  value = process_sp->ReadUnsignedIntegerFromMemory(valobj_addr + ptr_size,
401  ptr_size, 0, error);
402  if (error.Fail())
403  return false;
404  } else if (class_name == g_NSArray0) {
405  value = 0;
406  } else if (class_name == g_NSArray1) {
407  value = 1;
408  } else if (class_name == g_NSArrayCF || class_name == g_NSCallStackArray) {
409  // __NSCFArray and _NSCallStackArray store the number of elements as a
410  // pointer-sized value at offset `2 * ptr_size`.
411  Status error;
412  value = process_sp->ReadUnsignedIntegerFromMemory(
413  valobj_addr + 2 * ptr_size, ptr_size, 0, error);
414  if (error.Fail())
415  return false;
416  } else {
417  auto &map(NSArray_Additionals::GetAdditionalSummaries());
418  auto iter = map.find(class_name), end = map.end();
419  if (iter != end)
420  return iter->second(valobj, stream, options);
421  else
422  return false;
423  }
424 
425  std::string prefix, suffix;
426  if (Language *language = Language::FindPlugin(options.GetLanguage())) {
427  if (!language->GetFormatterPrefixSuffix(valobj, g_TypeHint, prefix,
428  suffix)) {
429  prefix.clear();
430  suffix.clear();
431  }
432  }
433 
434  stream.Printf("%s%" PRIu64 " %s%s%s", prefix.c_str(), value, "element",
435  value == 1 ? "" : "s", suffix.c_str());
436  return true;
437 }
438 
440  lldb::ValueObjectSP valobj_sp)
441  : SyntheticChildrenFrontEnd(*valobj_sp), m_exe_ctx_ref(), m_ptr_size(8),
442  m_id_type() {
443  if (valobj_sp) {
444  auto *clang_ast_context = ScratchTypeSystemClang::GetForTarget(
445  *valobj_sp->GetExecutionContextRef().GetTargetSP());
446  if (clang_ast_context)
448  clang_ast_context,
449  clang_ast_context->getASTContext().ObjCBuiltinIdTy.getAsOpaquePtr());
450  if (valobj_sp->GetProcessSP())
451  m_ptr_size = valobj_sp->GetProcessSP()->GetAddressByteSize();
452  }
453 }
454 
455 template <typename D32, typename D64>
458  GenericNSArrayMSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp)
459  : NSArrayMSyntheticFrontEndBase(valobj_sp), m_data_32(nullptr),
460  m_data_64(nullptr) {}
461 
462 size_t
464  return GetUsedCount();
465 }
466 
467 lldb::ValueObjectSP
469  size_t idx) {
470  if (idx >= CalculateNumChildren())
471  return lldb::ValueObjectSP();
472  lldb::addr_t object_at_idx = GetDataAddress();
473  size_t pyhs_idx = idx;
474  pyhs_idx += GetOffset();
475  if (GetSize() <= pyhs_idx)
476  pyhs_idx -= GetSize();
477  object_at_idx += (pyhs_idx * m_ptr_size);
478  StreamString idx_name;
479  idx_name.Printf("[%" PRIu64 "]", (uint64_t)idx);
480  return CreateValueObjectFromAddress(idx_name.GetString(), object_at_idx,
481  m_exe_ctx_ref, m_id_type);
482 }
483 
484 template <typename D32, typename D64>
485 bool
488  ValueObjectSP valobj_sp = m_backend.GetSP();
489  m_ptr_size = 0;
490  delete m_data_32;
491  m_data_32 = nullptr;
492  delete m_data_64;
493  m_data_64 = nullptr;
494  if (!valobj_sp)
495  return false;
496  m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
497  Status error;
498  error.Clear();
499  lldb::ProcessSP process_sp(valobj_sp->GetProcessSP());
500  if (!process_sp)
501  return false;
502  m_ptr_size = process_sp->GetAddressByteSize();
503  uint64_t data_location = valobj_sp->GetValueAsUnsigned(0) + m_ptr_size;
504  if (m_ptr_size == 4) {
505  m_data_32 = new D32();
506  process_sp->ReadMemory(data_location, m_data_32, sizeof(D32),
507  error);
508  } else {
509  m_data_64 = new D64();
510  process_sp->ReadMemory(data_location, m_data_64, sizeof(D64),
511  error);
512  }
513  if (error.Fail())
514  return false;
515  return false;
516 }
517 
518 bool
520  return true;
521 }
522 
523 size_t
525  ConstString name) {
526  const char *item_name = name.GetCString();
527  uint32_t idx = ExtractIndexFromString(item_name);
528  if (idx < UINT32_MAX && idx >= CalculateNumChildren())
529  return UINT32_MAX;
530  return idx;
531 }
532 
533 template <typename D32, typename D64>
534 lldb_private::formatters::
535  GenericNSArrayMSyntheticFrontEnd<D32, D64>::
536  ~GenericNSArrayMSyntheticFrontEnd<D32, D64>() {
537  delete m_data_32;
538  m_data_32 = nullptr;
539  delete m_data_64;
540  m_data_64 = nullptr;
541 }
542 
543 template <typename D32, typename D64>
545 lldb_private::formatters::
546  GenericNSArrayMSyntheticFrontEnd<D32, D64>::
547  GenericNSArrayMSyntheticFrontEnd::GetDataAddress() {
548  if (!m_data_32 && !m_data_64)
549  return LLDB_INVALID_ADDRESS;
550  return m_data_32 ? m_data_32->_data : m_data_64->_data;
551 }
552 
553 template <typename D32, typename D64>
554 uint64_t
555 lldb_private::formatters::
556  GenericNSArrayMSyntheticFrontEnd<D32, D64>::
557  GenericNSArrayMSyntheticFrontEnd::GetUsedCount() {
558  if (!m_data_32 && !m_data_64)
559  return 0;
560  return m_data_32 ? m_data_32->_used : m_data_64->_used;
561 }
562 
563 template <typename D32, typename D64>
564 uint64_t
565 lldb_private::formatters::
566  GenericNSArrayMSyntheticFrontEnd<D32, D64>::
567  GenericNSArrayMSyntheticFrontEnd::GetOffset() {
568  if (!m_data_32 && !m_data_64)
569  return 0;
570  return m_data_32 ? m_data_32->_offset : m_data_64->_offset;
571 }
572 
573 template <typename D32, typename D64>
574 uint64_t
575 lldb_private::formatters::
576  GenericNSArrayMSyntheticFrontEnd<D32, D64>::
577  GenericNSArrayMSyntheticFrontEnd::GetSize() {
578  if (!m_data_32 && !m_data_64)
579  return 0;
580  return m_data_32 ? m_data_32->_size : m_data_64->_size;
581 }
582 
583 template <typename D32, typename D64, bool Inline>
586  lldb::ValueObjectSP valobj_sp)
587  : SyntheticChildrenFrontEnd(*valobj_sp), m_exe_ctx_ref(), m_ptr_size(8),
588  m_data_32(nullptr), m_data_64(nullptr) {
589  if (valobj_sp) {
590  CompilerType type = valobj_sp->GetCompilerType();
591  if (type) {
592  auto *clang_ast_context = ScratchTypeSystemClang::GetForTarget(
593  *valobj_sp->GetExecutionContextRef().GetTargetSP());
594  if (clang_ast_context)
595  m_id_type = clang_ast_context->GetType(
596  clang_ast_context->getASTContext().ObjCBuiltinIdTy);
597  }
598  }
599 }
600 
601 template <typename D32, typename D64, bool Inline>
604  delete m_data_32;
605  m_data_32 = nullptr;
606  delete m_data_64;
607  m_data_64 = nullptr;
608 }
609 
610 template <typename D32, typename D64, bool Inline>
611 size_t
614  const char *item_name = name.GetCString();
615  uint32_t idx = ExtractIndexFromString(item_name);
616  if (idx < UINT32_MAX && idx >= CalculateNumChildren())
617  return UINT32_MAX;
618  return idx;
619 }
620 
621 template <typename D32, typename D64, bool Inline>
622 size_t
625  return m_data_32 ? m_data_32->used : m_data_64->used;
626 }
627 
628 template <typename D32, typename D64, bool Inline>
629 bool
632  ValueObjectSP valobj_sp = m_backend.GetSP();
633  m_ptr_size = 0;
634  delete m_data_32;
635  m_data_32 = nullptr;
636  delete m_data_64;
637  m_data_64 = nullptr;
638  if (!valobj_sp)
639  return false;
640  m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
641  Status error;
642  error.Clear();
643  lldb::ProcessSP process_sp(valobj_sp->GetProcessSP());
644  if (!process_sp)
645  return false;
646  m_ptr_size = process_sp->GetAddressByteSize();
647  uint64_t data_location = valobj_sp->GetValueAsUnsigned(0) + m_ptr_size;
648  if (m_ptr_size == 4) {
649  m_data_32 = new D32();
650  process_sp->ReadMemory(data_location, m_data_32, sizeof(D32),
651  error);
652  } else {
653  m_data_64 = new D64();
654  process_sp->ReadMemory(data_location, m_data_64, sizeof(D64),
655  error);
656  }
657  if (error.Fail())
658  return false;
659  return false;
660 }
661 
662 template <typename D32, typename D64, bool Inline>
663 bool
666  return true;
667 }
668 
669 template <typename D32, typename D64, bool Inline>
670 lldb::ValueObjectSP
672  GetChildAtIndex(size_t idx) {
673  if (idx >= CalculateNumChildren())
674  return lldb::ValueObjectSP();
675  lldb::addr_t object_at_idx;
676  if (Inline) {
677  object_at_idx = m_backend.GetSP()->GetValueAsUnsigned(0) + m_ptr_size;
678  object_at_idx += m_ptr_size == 4 ? sizeof(D32) : sizeof(D64); // skip the data header
679  object_at_idx -= m_ptr_size; // we treat the last entry in the data header as the first pointer
680  } else {
681  object_at_idx = m_data_32 ? m_data_32->list : m_data_64->list;
682  }
683  object_at_idx += (idx * m_ptr_size);
684 
685  ProcessSP process_sp = m_exe_ctx_ref.GetProcessSP();
686  if (!process_sp)
687  return lldb::ValueObjectSP();
688  Status error;
689  if (error.Fail())
690  return lldb::ValueObjectSP();
691  StreamString idx_name;
692  idx_name.Printf("[%" PRIu64 "]", (uint64_t)idx);
693  return CreateValueObjectFromAddress(idx_name.GetString(), object_at_idx,
694  m_exe_ctx_ref, m_id_type);
695 }
696 
698  lldb::ValueObjectSP valobj_sp)
699  : SyntheticChildrenFrontEnd(*valobj_sp) {}
700 
701 size_t
703  ConstString name) {
704  return UINT32_MAX;
705 }
706 
707 size_t
709  return 0;
710 }
711 
713  return false;
714 }
715 
717  return false;
718 }
719 
720 lldb::ValueObjectSP
722  size_t idx) {
723  return lldb::ValueObjectSP();
724 }
725 
727  lldb::ValueObjectSP valobj_sp)
728  : SyntheticChildrenFrontEnd(*valobj_sp.get()) {}
729 
730 size_t
732  ConstString name) {
733  static const ConstString g_zero("[0]");
734 
735  if (name == g_zero)
736  return 0;
737 
738  return UINT32_MAX;
739 }
740 
741 size_t
743  return 1;
744 }
745 
747  return false;
748 }
749 
751  return true;
752 }
753 
754 lldb::ValueObjectSP
756  size_t idx) {
757  static const ConstString g_zero("[0]");
758 
759  if (idx == 0) {
760  auto *clang_ast_context =
761  ScratchTypeSystemClang::GetForTarget(*m_backend.GetTargetSP());
762  if (clang_ast_context) {
763  CompilerType id_type(
764  clang_ast_context->GetBasicType(lldb::eBasicTypeObjCID));
765  return m_backend.GetSyntheticChildAtOffset(
766  m_backend.GetProcessSP()->GetAddressByteSize(), id_type, true,
767  g_zero);
768  }
769  }
770  return lldb::ValueObjectSP();
771 }
772 
775  CXXSyntheticChildren *synth, lldb::ValueObjectSP valobj_sp) {
776  if (!valobj_sp)
777  return nullptr;
778 
779  lldb::ProcessSP process_sp(valobj_sp->GetProcessSP());
780  if (!process_sp)
781  return nullptr;
782  AppleObjCRuntime *runtime = llvm::dyn_cast_or_null<AppleObjCRuntime>(
783  ObjCLanguageRuntime::Get(*process_sp));
784  if (!runtime)
785  return nullptr;
786 
787  CompilerType valobj_type(valobj_sp->GetCompilerType());
788  Flags flags(valobj_type.GetTypeInfo());
789 
790  if (flags.IsClear(eTypeIsPointer)) {
791  Status error;
792  valobj_sp = valobj_sp->AddressOf(error);
793  if (error.Fail() || !valobj_sp)
794  return nullptr;
795  }
796 
798  runtime->GetClassDescriptor(*valobj_sp));
799 
800  if (!descriptor || !descriptor->IsValid())
801  return nullptr;
802 
803  ConstString class_name(descriptor->GetClassName());
804 
805  static const ConstString g_NSArrayI("__NSArrayI");
806  static const ConstString g_NSArrayI_Transfer("__NSArrayI_Transfer");
807  static const ConstString g_NSFrozenArrayM("__NSFrozenArrayM");
808  static const ConstString g_NSArrayM("__NSArrayM");
809  static const ConstString g_NSArray0("__NSArray0");
810  static const ConstString g_NSArray1("__NSSingleObjectArrayI");
811  static const ConstString g_NSArrayMLegacy("__NSArrayM_Legacy");
812  static const ConstString g_NSArrayMImmutable("__NSArrayM_Immutable");
813  static const ConstString g_NSCallStackArray("_NSCallStackArray");
814 
815  if (class_name.IsEmpty())
816  return nullptr;
817 
818  if (class_name == g_NSArrayI) {
819  if (runtime->GetFoundationVersion() >= 1436)
820  return (new Foundation1436::NSArrayISyntheticFrontEnd(valobj_sp));
821  if (runtime->GetFoundationVersion() >= 1430)
822  return (new Foundation1430::NSArrayISyntheticFrontEnd(valobj_sp));
823  return (new Foundation1300::NSArrayISyntheticFrontEnd(valobj_sp));
824  } else if (class_name == g_NSArrayI_Transfer) {
826  } else if (class_name == g_NSFrozenArrayM) {
827  return (new Foundation1436::NSFrozenArrayMSyntheticFrontEnd(valobj_sp));
828  } else if (class_name == g_NSArray0) {
829  return (new NSArray0SyntheticFrontEnd(valobj_sp));
830  } else if (class_name == g_NSArray1) {
831  return (new NSArray1SyntheticFrontEnd(valobj_sp));
832  } else if (class_name == g_NSArrayM) {
833  if (runtime->GetFoundationVersion() >= 1437)
834  return (new Foundation1437::NSArrayMSyntheticFrontEnd(valobj_sp));
835  if (runtime->GetFoundationVersion() >= 1428)
836  return (new Foundation1428::NSArrayMSyntheticFrontEnd(valobj_sp));
837  if (runtime->GetFoundationVersion() >= 1100)
838  return (new Foundation1010::NSArrayMSyntheticFrontEnd(valobj_sp));
839  } else if (class_name == g_NSCallStackArray) {
841  } else {
843  auto iter = map.find(class_name), end = map.end();
844  if (iter != end)
845  return iter->second(synth, valobj_sp);
846  }
847 
848  return nullptr;
849 }
lldb_private::ValueObject::GetValueAsUnsigned
virtual uint64_t GetValueAsUnsigned(uint64_t fail_value, bool *success=nullptr)
Definition: ValueObject.cpp:1088
lldb_private::formatters::NSArray0SyntheticFrontEnd::GetIndexOfChildWithName
size_t GetIndexOfChildWithName(ConstString name) override
Definition: NSArray.cpp:702
lldb_private::formatters::Foundation1437::DataDescriptor::_used
uint32_t _used
Definition: NSArray.cpp:155
lldb_private::formatters::Foundation1436::IDD32::used
uint32_t used
Definition: NSArray.cpp:258
lldb_private::Process::ReadMemory
virtual size_t ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, Status &error)
Read of memory from a process.
Definition: Process.cpp:1892
FunctionCaller.h
lldb_private::formatters::GenericNSArrayMSyntheticFrontEnd::GenericNSArrayMSyntheticFrontEnd
GenericNSArrayMSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp)
Definition: NSArray.cpp:458
lldb_private::ObjCLanguageRuntime
Definition: ObjCLanguageRuntime.h:34
lldb_private::formatters::GenericNSArrayISyntheticFrontEnd::m_data_32
D32 * m_data_32
Definition: NSArray.cpp:231
lldb_private::ObjCLanguageRuntime::ClassDescriptorSP
std::shared_ptr< ClassDescriptor > ClassDescriptorSP
Definition: ObjCLanguageRuntime.h:44
lldb_private::formatters::Foundation1437::__NSArrayMSize_Impl
uint64_t __NSArrayMSize_Impl(lldb_private::Process &process, lldb::addr_t valobj_addr, Status &error)
Definition: NSArray.cpp:164
lldb_private::formatters::NSArrayMSyntheticFrontEndBase::m_id_type
CompilerType m_id_type
Definition: NSArray.cpp:74
lldb_private::formatters::GenericNSArrayMSyntheticFrontEnd
Definition: NSArray.cpp:78
lldb_private::formatters::GenericNSArrayISyntheticFrontEnd::CalculateNumChildren
size_t CalculateNumChildren() override
Definition: NSArray.cpp:624
lldb_private::ObjCLanguageRuntime::Get
static ObjCLanguageRuntime * Get(Process &process)
Definition: ObjCLanguageRuntime.h:215
lldb_private::formatters::NSArrayMSyntheticFrontEndBase::CalculateNumChildren
size_t CalculateNumChildren() override
Definition: NSArray.cpp:463
lldb_private::Process
Definition: Process.h:343
lldb_private::formatters::NSArraySummaryProvider
bool NSArraySummaryProvider(ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options)
Definition: NSArray.cpp:319
CalculateNumChildren
static size_t CalculateNumChildren(CompilerType container_type, CompilerType element_type, lldb_private::ExecutionContextScope *exe_scope=nullptr)
Definition: VectorType.cpp:169
lldb_private::Flags
Definition: Flags.h:22
lldb_private::SyntheticChildrenFrontEnd
Definition: TypeSynthetic.h:27
lldb_private::formatters::Foundation1437::__NSArrayMSize
uint64_t __NSArrayMSize(lldb_private::Process &process, lldb::addr_t valobj_addr, Status &error)
Definition: NSArray.cpp:178
lldb_private::formatters::NSArray1SyntheticFrontEnd::GetChildAtIndex
lldb::ValueObjectSP GetChildAtIndex(size_t idx) override
Definition: NSArray.cpp:755
lldb_private::formatters::GenericNSArrayISyntheticFrontEnd::MightHaveChildren
bool MightHaveChildren() override
Definition: NSArray.cpp:665
lldb_private::formatters::CallStackArray::DataDescriptor_64::_offset
uint64_t _offset
Definition: NSArray.cpp:202
lldb_private::Stream
Definition: Stream.h:28
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
Language.h
lldb_private::formatters::NSArraySyntheticFrontEndCreator
SyntheticChildrenFrontEnd * NSArraySyntheticFrontEndCreator(CXXSyntheticChildren *, lldb::ValueObjectSP)
Definition: NSArray.cpp:774
lldb_private::formatters::NSArray1SyntheticFrontEnd::NSArray1SyntheticFrontEnd
NSArray1SyntheticFrontEnd(lldb::ValueObjectSP valobj_sp)
Definition: NSArray.cpp:726
lldb_private::formatters::Foundation1437::DataDescriptor
Definition: NSArray.cpp:148
lldb_private::StreamString::GetString
llvm::StringRef GetString() const
Definition: StreamString.cpp:51
lldb_private::formatters::Foundation1436::IDD32::list
uint32_t list
Definition: NSArray.cpp:259
lldb_private::formatters::NSArray0SyntheticFrontEnd::Update
bool Update() override
Definition: NSArray.cpp:712
lldb_private::formatters::Foundation1437::DataDescriptor::_muts
uint32_t _muts
Definition: NSArray.cpp:154
Target.h
_data
uint32_t _data
Definition: NSArray.cpp:108
lldb_private::ValueObject::GetProcessSP
lldb::ProcessSP GetProcessSP() const
Definition: ValueObject.h:338
lldb_private::TypeSummaryOptions::GetLanguage
lldb::LanguageType GetLanguage() const
Definition: TypeSummary.cpp:32
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
lldb_private::formatters::NSArray1SyntheticFrontEnd::GetIndexOfChildWithName
size_t GetIndexOfChildWithName(ConstString name) override
Definition: NSArray.cpp:731
lldb_private::formatters::Foundation1436::IDD64::list
uint64_t list
Definition: NSArray.cpp:264
lldb_private::formatters::NSArray0SyntheticFrontEnd::NSArray0SyntheticFrontEnd
NSArray0SyntheticFrontEnd(lldb::ValueObjectSP valobj_sp)
Definition: NSArray.cpp:697
lldb_private::formatters::NSArrayMSyntheticFrontEndBase::m_ptr_size
uint8_t m_ptr_size
Definition: NSArray.cpp:73
TypeSystemClang.h
lldb_private::ConstString::IsEmpty
bool IsEmpty() const
Test for empty string.
Definition: ConstString.h:304
lldb_private::formatters::GenericNSArrayISyntheticFrontEnd::GenericNSArrayISyntheticFrontEnd
GenericNSArrayISyntheticFrontEnd(lldb::ValueObjectSP valobj_sp)
Definition: NSArray.cpp:585
lldb_private::formatters::GenericNSArrayMSyntheticFrontEnd::m_data_64
D64 * m_data_64
Definition: NSArray.cpp:97
lldb_private::ObjCLanguageRuntime::GetClassDescriptor
virtual ClassDescriptorSP GetClassDescriptor(ValueObject &in_value)
Definition: ObjCLanguageRuntime.cpp:235
lldb_private::formatters::CallStackArray::DataDescriptor_32::_data
uint32_t _data
Definition: NSArray.cpp:193
lldb_private::Process::GetAddressByteSize
uint32_t GetAddressByteSize() const
Definition: Process.cpp:3307
lldb_private::ConstString
Definition: ConstString.h:40
lldb_private::formatters::CallStackArray::DataDescriptor_64
Definition: NSArray.cpp:199
lldb_private::StreamString
Definition: StreamString.h:23
lldb_private::formatters::CallStackArray::DataDescriptor_32::_offset
uint32_t _offset
Definition: NSArray.cpp:195
lldb_private::formatters::NSArrayMSyntheticFrontEndBase::NSArrayMSyntheticFrontEndBase
NSArrayMSyntheticFrontEndBase(lldb::ValueObjectSP valobj_sp)
Definition: NSArray.cpp:439
lldb_private::AppleObjCRuntime
Definition: AppleObjCRuntime.h:23
lldb_private::formatters::NSArrayMSyntheticFrontEndBase::m_exe_ctx_ref
ExecutionContextRef m_exe_ctx_ref
Definition: NSArray.cpp:72
lldb_private::formatters::GenericNSArrayISyntheticFrontEnd::m_exe_ctx_ref
ExecutionContextRef m_exe_ctx_ref
Definition: NSArray.cpp:228
lldb_private::formatters::Foundation1437::DataDescriptor::_data
PtrType _data
Definition: NSArray.cpp:151
lldb_private::formatters::CallStackArray::DataDescriptor_32
Definition: NSArray.cpp:192
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:38
lldb_private::formatters::Foundation1300::IDD32
Definition: NSArray.cpp:237
lldb_private::formatters::CallStackArray::DataDescriptor_32::_used
uint32_t _used
Definition: NSArray.cpp:194
lldb_private::formatters::GenericNSArrayMSyntheticFrontEnd::m_data_32
D32 * m_data_32
Definition: NSArray.cpp:96
lldb_private::formatters::Foundation1437::DataDescriptor::_cow
PtrType _cow
Definition: NSArray.cpp:149
lldb_private::formatters::NSArray1SyntheticFrontEnd::MightHaveChildren
bool MightHaveChildren() override
Definition: NSArray.cpp:750
ValueObject.h
lldb_private::formatters::GenericNSArrayISyntheticFrontEnd
Definition: NSArray.cpp:211
lldb_private::formatters::NSArray0SyntheticFrontEnd::MightHaveChildren
bool MightHaveChildren() override
Definition: NSArray.cpp:716
_used
uint32_t _used
Definition: NSArray.cpp:103
lldb_private::formatters::GenericNSArrayISyntheticFrontEnd::GetChildAtIndex
lldb::ValueObjectSP GetChildAtIndex(size_t idx) override
Definition: NSArray.cpp:672
ValueObjectConstResult.h
lldb_private::formatters::Foundation1436::__NSFrozenArrayMSize
uint64_t __NSFrozenArrayMSize(lldb_private::Process &process, lldb::addr_t valobj_addr, Status &error)
Definition: NSArray.cpp:277
lldb::eBasicTypeObjCID
@ eBasicTypeObjCID
Definition: lldb-enumerations.h:769
lldb_private::formatters::GenericNSArrayISyntheticFrontEnd::m_ptr_size
uint8_t m_ptr_size
Definition: NSArray.cpp:229
lldb_private::Status
Definition: Status.h:44
lldb_private::ValueObject
ValueObject:
Definition: ValueObject.h:105
lldb_private::formatters::NSArray1SyntheticFrontEnd::Update
bool Update() override
Definition: NSArray.cpp:746
lldb_private::formatters::CallStackArray::DataDescriptor_64::_used
uint64_t _used
Definition: NSArray.cpp:201
lldb_private::formatters::NSArray0SyntheticFrontEnd::CalculateNumChildren
size_t CalculateNumChildren() override
Definition: NSArray.cpp:708
uint32_t
lldb_private::formatters::GenericNSArrayISyntheticFrontEnd::m_data_64
D64 * m_data_64
Definition: NSArray.cpp:232
lldb_private::formatters::NSArray1SyntheticFrontEnd
Definition: NSArray.cpp:300
lldb_private::Language
Definition: Language.h:29
lldb_private::formatters::Foundation1436::IDD64::used
uint64_t used
Definition: NSArray.cpp:263
lldb_private::AppleObjCRuntime::GetFoundationVersion
uint32_t GetFoundationVersion()
Definition: AppleObjCRuntime.cpp:320
lldb_private::formatters::NSArray0SyntheticFrontEnd::GetChildAtIndex
lldb::ValueObjectSP GetChildAtIndex(size_t idx) override
Definition: NSArray.cpp:721
lldb_private::formatters::Foundation1436::IDD32
Definition: NSArray.cpp:257
lldb_private::formatters::Foundation1437::NSArrayMSyntheticFrontEnd
GenericNSArrayMSyntheticFrontEnd< DataDescriptor< uint32_t >, DataDescriptor< uint64_t > > NSArrayMSyntheticFrontEnd
Definition: NSArray.cpp:160
lldb_private::CompilerType::GetTypeInfo
uint32_t GetTypeInfo(CompilerType *pointee_or_element_compiler_type=nullptr) const
Definition: CompilerType.cpp:290
_offset
uint32_t _offset
Definition: NSArray.cpp:104
UINT32_MAX
#define UINT32_MAX
Definition: lldb-defines.h:31
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:9670
lldb_private::formatters::Foundation1300::IDD64
Definition: NSArray.cpp:242
LLDB_INVALID_ADDRESS
#define LLDB_INVALID_ADDRESS
Invalid value definitions.
Definition: lldb-defines.h:85
lldb_private::ConstString::GetCString
const char * GetCString() const
Get the string value as a C string.
Definition: ConstString.h:216
_priv1
uint64_t _priv1
Definition: NSArray.cpp:106
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::Foundation1300::IDD32::used
uint32_t used
Definition: NSArray.cpp:238
Status.h
lldb_private::formatters::NSArrayMSyntheticFrontEndBase
Definition: NSArray.cpp:47
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::formatters::NSArray0SyntheticFrontEnd
Definition: NSArray.cpp:283
lldb_private::formatters::GenericNSArrayMSyntheticFrontEnd::Update
bool Update() override
Definition: NSArray.cpp:487
lldb_private::formatters::GenericNSArrayISyntheticFrontEnd::Update
bool Update() override
Definition: NSArray.cpp:631
lldb_private::formatters::GenericNSArrayISyntheticFrontEnd::GetIndexOfChildWithName
size_t GetIndexOfChildWithName(ConstString name) override
Definition: NSArray.cpp:613
_priv2
uint32_t _priv2
Definition: NSArray.cpp:107
lldb_private::formatters::NSArray1SyntheticFrontEnd::CalculateNumChildren
size_t CalculateNumChildren() override
Definition: NSArray.cpp:742
lldb_private::formatters::NSArrayMSyntheticFrontEndBase::GetChildAtIndex
lldb::ValueObjectSP GetChildAtIndex(size_t idx) override
Definition: NSArray.cpp:468
Stream.h
Cocoa.h
lldb_private::formatters::CallStackArray::DataDescriptor_64::_data
uint64_t _data
Definition: NSArray.cpp:200
lldb_private::formatters::NSArrayMSyntheticFrontEndBase::MightHaveChildren
bool MightHaveChildren() override
Definition: NSArray.cpp:519
lldb_private::formatters::Foundation1300::IDD64::used
uint64_t used
Definition: NSArray.cpp:243
lldb_private::CXXSyntheticChildren
Definition: TypeSynthetic.h:358
lldb_private::formatters::NSArray_Additionals::GetAdditionalSynthetics
static std::map< ConstString, CXXSyntheticChildren::CreateFrontEndCallback > & GetAdditionalSynthetics()
Definition: NSArray.cpp:41
lldb_private::formatters::Foundation1300::IDD64::list
uint64_t list
Definition: NSArray.cpp:244
lldb_private::formatters::Foundation1437::DataDescriptor::_size
uint32_t _size
Definition: NSArray.cpp:153
_size
uint32_t _size
Definition: NSArray.cpp:105
lldb_private::formatters::NSArrayMSyntheticFrontEndBase::GetIndexOfChildWithName
size_t GetIndexOfChildWithName(ConstString name) override
Definition: NSArray.cpp:524
FormattersHelpers.h
lldb_private::formatters::Foundation1436::IDD64
Definition: NSArray.cpp:262
lldb
Definition: SBAddress.h:15
Endian.h
lldb_private::Flags::IsClear
bool IsClear(ValueType bit) const
Test a single flag bit to see if it is clear (zero).
Definition: Flags.h:111
lldb_private::formatters::Foundation1300::IDD32::list
uint32_t list
Definition: NSArray.cpp:239
lldb_private::ExecutionContextRef
Execution context objects refer to objects in the execution of the program that is being debugged.
Definition: ExecutionContext.h:72
lldb_private::formatters::ExtractIndexFromString
size_t ExtractIndexFromString(const char *item_name)
Definition: FormattersHelpers.cpp:119
AppleObjCRuntime.h
lldb_private::formatters::Foundation1437::DataDescriptor::_offset
uint32_t _offset
Definition: NSArray.cpp:152
lldb_private::formatters::GenericNSArrayISyntheticFrontEnd::m_id_type
CompilerType m_id_type
Definition: NSArray.cpp:233
DataBufferHeap.h