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