Coverage Report

Created: 2022-01-22 13:19

/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/source/Plugins/Language/ObjC/NSArray.cpp
Line
Count
Source (jump to first uncovered line)
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
14
#include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.h"
15
#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
16
17
#include "lldb/Core/ValueObject.h"
18
#include "lldb/Core/ValueObjectConstResult.h"
19
#include "lldb/DataFormatters/FormattersHelpers.h"
20
#include "lldb/Expression/FunctionCaller.h"
21
#include "lldb/Target/Language.h"
22
#include "lldb/Target/Target.h"
23
#include "lldb/Utility/DataBufferHeap.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
0
NSArray_Additionals::GetAdditionalSummaries() {
36
0
  static std::map<ConstString, CXXFunctionSummaryFormat::Callback> g_map;
37
0
  return g_map;
38
0
}
39
40
std::map<ConstString, CXXSyntheticChildren::CreateFrontEndCallback> &
41
30
NSArray_Additionals::GetAdditionalSynthetics() {
42
30
  static std::map<ConstString, CXXSyntheticChildren::CreateFrontEndCallback>
43
30
      g_map;
44
30
  return g_map;
45
30
}
46
47
class NSArrayMSyntheticFrontEndBase : public SyntheticChildrenFrontEnd {
48
public:
49
  NSArrayMSyntheticFrontEndBase(lldb::ValueObjectSP valobj_sp);
50
51
61
  ~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
72
  ExecutionContextRef m_exe_ctx_ref;
73
  uint8_t m_ptr_size;
74
  CompilerType m_id_type;
75
};
76
77
template <typename D32, typename D64>
78
class GenericNSArrayMSyntheticFrontEnd : public NSArrayMSyntheticFrontEndBase {
79
public:
80
  GenericNSArrayMSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);
81
82
  ~GenericNSArrayMSyntheticFrontEnd() override;
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 {
103
      uint32_t _used;
104
      uint32_t _offset;
105
      uint32_t _size : 28;
106
      uint64_t _priv1 : 4;
107
      uint32_t _priv2;
108
      uint32_t _data;
109
    };
110
111
    struct DataDescriptor_64 {
112
      uint64_t _used;
113
      uint64_t _offset;
114
      uint64_t _size : 60;
115
      uint64_t _priv1 : 4;
116
      uint32_t _priv2;
117
      uint64_t _data;
118
    };
119
  }
120
121
  using NSArrayMSyntheticFrontEnd =
122
      GenericNSArrayMSyntheticFrontEnd<DataDescriptor_32, DataDescriptor_64>;
123
}
124
125
namespace Foundation1428 {
126
  namespace {
127
    struct DataDescriptor_32 {
128
      uint32_t _used;
129
      uint32_t _offset;
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
142
  using NSArrayMSyntheticFrontEnd =
143
      GenericNSArrayMSyntheticFrontEnd<DataDescriptor_32, DataDescriptor_64>;
144
}
145
146
namespace Foundation1437 {
147
  template <typename PtrType>
148
  struct DataDescriptor {
149
    PtrType _cow;
150
    // __deque
151
    PtrType _data;
152
    uint32_t _offset;
153
    uint32_t _size;
154
    uint32_t _muts;
155
    uint32_t _used;
156
  };
157
158
  using NSArrayMSyntheticFrontEnd =
159
     GenericNSArrayMSyntheticFrontEnd<
160
        DataDescriptor<uint32_t>, DataDescriptor<uint64_t>>;
161
162
  template <typename DD>
163
  uint64_t
164
  __NSArrayMSize_Impl(lldb_private::Process &process,
165
58
                      lldb::addr_t valobj_addr, Status &error) {
166
58
    const lldb::addr_t start_of_descriptor =
167
58
    valobj_addr + process.GetAddressByteSize();
168
58
    DD descriptor = DD();
169
58
    process.ReadMemory(start_of_descriptor, &descriptor,
170
58
                       sizeof(descriptor), error);
171
58
    if (error.Fail()) {
172
0
      return 0;
173
0
    }
174
58
    return descriptor._used;
175
58
  }
Unexecuted instantiation: unsigned long long lldb_private::formatters::Foundation1437::__NSArrayMSize_Impl<lldb_private::formatters::Foundation1437::DataDescriptor<unsigned int> >(lldb_private::Process&, unsigned long long, lldb_private::Status&)
unsigned long long lldb_private::formatters::Foundation1437::__NSArrayMSize_Impl<lldb_private::formatters::Foundation1437::DataDescriptor<unsigned long long> >(lldb_private::Process&, unsigned long long, lldb_private::Status&)
Line
Count
Source
165
58
                      lldb::addr_t valobj_addr, Status &error) {
166
58
    const lldb::addr_t start_of_descriptor =
167
58
    valobj_addr + process.GetAddressByteSize();
168
58
    DD descriptor = DD();
169
58
    process.ReadMemory(start_of_descriptor, &descriptor,
170
58
                       sizeof(descriptor), error);
171
58
    if (error.Fail()) {
172
0
      return 0;
173
0
    }
174
58
    return descriptor._used;
175
58
  }
176
177
  uint64_t
178
  __NSArrayMSize(lldb_private::Process &process, lldb::addr_t valobj_addr,
179
58
                 Status &error) {
180
58
    if (process.GetAddressByteSize() == 4) {
181
0
      return __NSArrayMSize_Impl<DataDescriptor<uint32_t>>(process, valobj_addr,
182
0
                                                           error);
183
58
    } else {
184
58
      return __NSArrayMSize_Impl<DataDescriptor<uint64_t>>(process, valobj_addr,
185
58
                                                           error);
186
58
    }
187
58
  }
188
189
}
190
191
namespace CallStackArray {
192
struct DataDescriptor_32 {
193
  uint32_t _data;
194
  uint32_t _used;
195
  uint32_t _offset;
196
  const uint32_t _size = 0;
197
};
198
199
struct DataDescriptor_64 {
200
  uint64_t _data;
201
  uint64_t _used;
202
  uint64_t _offset;
203
  const uint64_t _size = 0;
204
};
205
206
using NSCallStackArraySyntheticFrontEnd =
207
    GenericNSArrayMSyntheticFrontEnd<DataDescriptor_32, DataDescriptor_64>;
208
} // namespace CallStackArray
209
210
template <typename D32, typename D64, bool Inline>
211
class GenericNSArrayISyntheticFrontEnd : public SyntheticChildrenFrontEnd {
212
public:
213
  GenericNSArrayISyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);
214
215
  ~GenericNSArrayISyntheticFrontEnd() override;
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:
228
  ExecutionContextRef m_exe_ctx_ref;
229
  uint8_t m_ptr_size;
230
231
  D32 *m_data_32;
232
  D64 *m_data_64;
233
  CompilerType m_id_type;
234
};
235
236
namespace Foundation1300 {
237
    struct IDD32 {
238
        uint32_t used;
239
        uint32_t list;
240
    };
241
242
    struct IDD64 {
243
        uint64_t used;
244
        uint64_t list;
245
    };
246
247
    using NSArrayISyntheticFrontEnd =
248
        GenericNSArrayISyntheticFrontEnd<IDD32, IDD64, true>;
249
}
250
251
namespace Foundation1430 {
252
    using NSArrayISyntheticFrontEnd =
253
        Foundation1428::NSArrayMSyntheticFrontEnd;
254
}
255
256
namespace Foundation1436 {
257
    struct IDD32 {
258
        uint32_t used;
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
267
    using NSArrayI_TransferSyntheticFrontEnd =
268
        GenericNSArrayISyntheticFrontEnd<IDD32, IDD64, false>;
269
270
    using NSArrayISyntheticFrontEnd =
271
        GenericNSArrayISyntheticFrontEnd<IDD32, IDD64, true>;
272
273
    using NSFrozenArrayMSyntheticFrontEnd =
274
        Foundation1437::NSArrayMSyntheticFrontEnd;
275
276
    uint64_t
277
    __NSFrozenArrayMSize(lldb_private::Process &process, lldb::addr_t valobj_addr,
278
0
                         Status &error) {
279
0
      return Foundation1437::__NSArrayMSize(process, valobj_addr, error);
280
0
    }
281
}
282
283
namespace ConstantArray {
284
285
struct ConstantArray32 {
286
  uint64_t used;
287
  uint32_t list;
288
};
289
290
struct ConstantArray64 {
291
  uint64_t used;
292
  uint64_t list;
293
};
294
295
using NSConstantArraySyntheticFrontEnd =
296
    GenericNSArrayISyntheticFrontEnd<ConstantArray32, ConstantArray64, false>;
297
} // namespace ConstantArray
298
299
class NSArray0SyntheticFrontEnd : public SyntheticChildrenFrontEnd {
300
public:
301
  NSArray0SyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);
302
303
9
  ~NSArray0SyntheticFrontEnd() override = default;
304
305
  size_t CalculateNumChildren() override;
306
307
  lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
308
309
  bool Update() override;
310
311
  bool MightHaveChildren() override;
312
313
  size_t GetIndexOfChildWithName(ConstString name) override;
314
};
315
316
class NSArray1SyntheticFrontEnd : public SyntheticChildrenFrontEnd {
317
public:
318
  NSArray1SyntheticFrontEnd(lldb::ValueObjectSP valobj_sp);
319
320
0
  ~NSArray1SyntheticFrontEnd() override = default;
321
322
  size_t CalculateNumChildren() override;
323
324
  lldb::ValueObjectSP GetChildAtIndex(size_t idx) override;
325
326
  bool Update() override;
327
328
  bool MightHaveChildren() override;
329
330
  size_t GetIndexOfChildWithName(ConstString name) override;
331
};
332
} // namespace formatters
333
} // namespace lldb_private
334
335
bool lldb_private::formatters::NSArraySummaryProvider(
336
211
    ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
337
211
  static ConstString g_TypeHint("NSArray");
338
339
211
  ProcessSP process_sp = valobj.GetProcessSP();
340
211
  if (!process_sp)
341
0
    return false;
342
343
211
  ObjCLanguageRuntime *runtime = ObjCLanguageRuntime::Get(*process_sp);
344
345
211
  if (!runtime)
346
0
    return false;
347
348
211
  ObjCLanguageRuntime::ClassDescriptorSP descriptor(
349
211
      runtime->GetClassDescriptor(valobj));
350
351
211
  if (!descriptor || !descriptor->IsValid())
352
0
    return false;
353
354
211
  uint32_t ptr_size = process_sp->GetAddressByteSize();
355
356
211
  lldb::addr_t valobj_addr = valobj.GetValueAsUnsigned(0);
357
358
211
  if (!valobj_addr)
359
0
    return false;
360
361
211
  uint64_t value = 0;
362
363
211
  ConstString class_name(descriptor->GetClassName());
364
365
211
  static const ConstString g_NSArrayI("__NSArrayI");
366
211
  static const ConstString g_NSArrayM("__NSArrayM");
367
211
  static const ConstString g_NSArrayI_Transfer("__NSArrayI_Transfer");
368
211
  static const ConstString g_NSFrozenArrayM("__NSFrozenArrayM");
369
211
  static const ConstString g_NSArray0("__NSArray0");
370
211
  static const ConstString g_NSArray1("__NSSingleObjectArrayI");
371
211
  static const ConstString g_NSArrayCF("__NSCFArray");
372
211
  static const ConstString g_NSArrayMLegacy("__NSArrayM_Legacy");
373
211
  static const ConstString g_NSArrayMImmutable("__NSArrayM_Immutable");
374
211
  static const ConstString g_NSCallStackArray("_NSCallStackArray");
375
211
  static const ConstString g_NSConstantArray("NSConstantArray");
376
377
211
  if (class_name.IsEmpty())
378
0
    return false;
379
380
211
  if (class_name == g_NSArrayI) {
381
114
    Status error;
382
114
    value = process_sp->ReadUnsignedIntegerFromMemory(valobj_addr + ptr_size,
383
114
                                                      ptr_size, 0, error);
384
114
    if (error.Fail())
385
0
      return false;
386
114
  } else 
if (97
class_name == g_NSConstantArray97
) {
387
0
    Status error;
388
0
    value = process_sp->ReadUnsignedIntegerFromMemory(valobj_addr + ptr_size, 8,
389
0
                                                      0, error);
390
0
    if (error.Fail())
391
0
      return false;
392
97
  } else if (class_name == g_NSArrayM) {
393
58
    AppleObjCRuntime *apple_runtime =
394
58
    llvm::dyn_cast_or_null<AppleObjCRuntime>(runtime);
395
58
    Status error;
396
58
    if (apple_runtime && apple_runtime->GetFoundationVersion() >= 1437) {
397
58
      value = Foundation1437::__NSArrayMSize(*process_sp, valobj_addr, error);
398
58
    } else {
399
0
      value = process_sp->ReadUnsignedIntegerFromMemory(valobj_addr + ptr_size,
400
0
                                                        ptr_size, 0, error);
401
0
    }
402
58
    if (error.Fail())
403
0
      return false;
404
58
  } else 
if (39
class_name == g_NSArrayI_Transfer39
) {
405
0
    Status error;
406
0
    value = process_sp->ReadUnsignedIntegerFromMemory(valobj_addr + ptr_size,
407
0
                                                      ptr_size, 0, error);
408
0
    if (error.Fail())
409
0
      return false;
410
39
  } else if (class_name == g_NSFrozenArrayM) {
411
0
    Status error;
412
0
    value = Foundation1436::__NSFrozenArrayMSize(*process_sp, valobj_addr, error);
413
0
    if (error.Fail())
414
0
      return false;
415
39
  } else if (class_name == g_NSArrayMLegacy) {
416
0
    Status error;
417
0
    value = process_sp->ReadUnsignedIntegerFromMemory(valobj_addr + ptr_size,
418
0
                                                      ptr_size, 0, error);
419
0
    if (error.Fail())
420
0
      return false;
421
39
  } else if (class_name == g_NSArrayMImmutable) {
422
0
    Status error;
423
0
    value = process_sp->ReadUnsignedIntegerFromMemory(valobj_addr + ptr_size,
424
0
                                                      ptr_size, 0, error);
425
0
    if (error.Fail())
426
0
      return false;
427
39
  } else if (class_name == g_NSArray0) {
428
9
    value = 0;
429
30
  } else if (class_name == g_NSArray1) {
430
0
    value = 1;
431
30
  } else if (class_name == g_NSArrayCF || 
class_name == g_NSCallStackArray0
) {
432
    // __NSCFArray and _NSCallStackArray store the number of elements as a
433
    // pointer-sized value at offset `2 * ptr_size`.
434
30
    Status error;
435
30
    value = process_sp->ReadUnsignedIntegerFromMemory(
436
30
        valobj_addr + 2 * ptr_size, ptr_size, 0, error);
437
30
    if (error.Fail())
438
0
      return false;
439
30
  } else {
440
0
    auto &map(NSArray_Additionals::GetAdditionalSummaries());
441
0
    auto iter = map.find(class_name), end = map.end();
442
0
    if (iter != end)
443
0
      return iter->second(valobj, stream, options);
444
0
    else
445
0
      return false;
446
0
  }
447
448
211
  std::string prefix, suffix;
449
211
  if (Language *language = Language::FindPlugin(options.GetLanguage())) {
450
211
    if (!language->GetFormatterPrefixSuffix(valobj, g_TypeHint, prefix,
451
211
                                            suffix)) {
452
36
      prefix.clear();
453
36
      suffix.clear();
454
36
    }
455
211
  }
456
457
211
  stream.Printf("%s%" PRIu64 " %s%s%s", prefix.c_str(), value, "element",
458
211
                value == 1 ? 
""21
:
"s"190
, suffix.c_str());
459
211
  return true;
460
211
}
461
462
lldb_private::formatters::NSArrayMSyntheticFrontEndBase::NSArrayMSyntheticFrontEndBase(
463
    lldb::ValueObjectSP valobj_sp)
464
    : SyntheticChildrenFrontEnd(*valobj_sp), m_exe_ctx_ref(), m_ptr_size(8),
465
61
      m_id_type() {
466
61
  if (valobj_sp) {
467
61
    auto *clang_ast_context = ScratchTypeSystemClang::GetForTarget(
468
61
        *valobj_sp->GetExecutionContextRef().GetTargetSP());
469
61
    if (clang_ast_context)
470
61
      m_id_type = CompilerType(
471
61
          clang_ast_context,
472
61
          clang_ast_context->getASTContext().ObjCBuiltinIdTy.getAsOpaquePtr());
473
61
    if (valobj_sp->GetProcessSP())
474
61
      m_ptr_size = valobj_sp->GetProcessSP()->GetAddressByteSize();
475
61
  }
476
61
}
477
478
template <typename D32, typename D64>
479
lldb_private::formatters::
480
  GenericNSArrayMSyntheticFrontEnd<D32, D64>::
481
    GenericNSArrayMSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp)
482
    : NSArrayMSyntheticFrontEndBase(valobj_sp), m_data_32(nullptr),
483
61
      m_data_64(nullptr) {}
Unexecuted instantiation: NSArray.cpp:lldb_private::formatters::GenericNSArrayMSyntheticFrontEnd<lldb_private::formatters::Foundation1428::(anonymous namespace)::DataDescriptor_32, lldb_private::formatters::Foundation1428::(anonymous namespace)::DataDescriptor_64>::GenericNSArrayMSyntheticFrontEnd(std::__1::shared_ptr<lldb_private::ValueObject>)
lldb_private::formatters::GenericNSArrayMSyntheticFrontEnd<lldb_private::formatters::Foundation1437::DataDescriptor<unsigned int>, lldb_private::formatters::Foundation1437::DataDescriptor<unsigned long long> >::GenericNSArrayMSyntheticFrontEnd(std::__1::shared_ptr<lldb_private::ValueObject>)
Line
Count
Source
483
58
      m_data_64(nullptr) {}
Unexecuted instantiation: NSArray.cpp:lldb_private::formatters::GenericNSArrayMSyntheticFrontEnd<lldb_private::formatters::Foundation1010::(anonymous namespace)::DataDescriptor_32, lldb_private::formatters::Foundation1010::(anonymous namespace)::DataDescriptor_64>::GenericNSArrayMSyntheticFrontEnd(std::__1::shared_ptr<lldb_private::ValueObject>)
lldb_private::formatters::GenericNSArrayMSyntheticFrontEnd<lldb_private::formatters::CallStackArray::DataDescriptor_32, lldb_private::formatters::CallStackArray::DataDescriptor_64>::GenericNSArrayMSyntheticFrontEnd(std::__1::shared_ptr<lldb_private::ValueObject>)
Line
Count
Source
483
3
      m_data_64(nullptr) {}
484
485
size_t
486
84
lldb_private::formatters::NSArrayMSyntheticFrontEndBase::CalculateNumChildren() {
487
84
  return GetUsedCount();
488
84
}
489
490
lldb::ValueObjectSP
491
lldb_private::formatters::NSArrayMSyntheticFrontEndBase::GetChildAtIndex(
492
72
    size_t idx) {
493
72
  if (idx >= CalculateNumChildren())
494
0
    return lldb::ValueObjectSP();
495
72
  lldb::addr_t object_at_idx = GetDataAddress();
496
72
  size_t pyhs_idx = idx;
497
72
  pyhs_idx += GetOffset();
498
72
  if (GetSize() <= pyhs_idx)
499
18
    pyhs_idx -= GetSize();
500
72
  object_at_idx += (pyhs_idx * m_ptr_size);
501
72
  StreamString idx_name;
502
72
  idx_name.Printf("[%" PRIu64 "]", (uint64_t)idx);
503
72
  return CreateValueObjectFromAddress(idx_name.GetString(), object_at_idx,
504
72
                                      m_exe_ctx_ref, m_id_type);
505
72
}
506
507
template <typename D32, typename D64>
508
bool
509
lldb_private::formatters::
510
58
  GenericNSArrayMSyntheticFrontEnd<D32, D64>::Update() {
511
58
  ValueObjectSP valobj_sp = m_backend.GetSP();
512
58
  m_ptr_size = 0;
513
58
  delete m_data_32;
514
58
  m_data_32 = nullptr;
515
58
  delete m_data_64;
516
58
  m_data_64 = nullptr;
517
58
  if (!valobj_sp)
518
0
    return false;
519
58
  m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
520
58
  Status error;
521
58
  error.Clear();
522
58
  lldb::ProcessSP process_sp(valobj_sp->GetProcessSP());
523
58
  if (!process_sp)
524
0
    return false;
525
58
  m_ptr_size = process_sp->GetAddressByteSize();
526
58
  uint64_t data_location = valobj_sp->GetValueAsUnsigned(0) + m_ptr_size;
527
58
  if (m_ptr_size == 4) {
528
0
    m_data_32 = new D32();
529
0
    process_sp->ReadMemory(data_location, m_data_32, sizeof(D32),
530
0
                           error);
531
58
  } else {
532
58
    m_data_64 = new D64();
533
58
    process_sp->ReadMemory(data_location, m_data_64, sizeof(D64),
534
58
                           error);
535
58
  }
536
58
  if (error.Fail())
537
0
    return false;
538
58
  return false;
539
58
}
Unexecuted instantiation: NSArray.cpp:lldb_private::formatters::GenericNSArrayMSyntheticFrontEnd<lldb_private::formatters::Foundation1428::(anonymous namespace)::DataDescriptor_32, lldb_private::formatters::Foundation1428::(anonymous namespace)::DataDescriptor_64>::Update()
lldb_private::formatters::GenericNSArrayMSyntheticFrontEnd<lldb_private::formatters::Foundation1437::DataDescriptor<unsigned int>, lldb_private::formatters::Foundation1437::DataDescriptor<unsigned long long> >::Update()
Line
Count
Source
510
55
  GenericNSArrayMSyntheticFrontEnd<D32, D64>::Update() {
511
55
  ValueObjectSP valobj_sp = m_backend.GetSP();
512
55
  m_ptr_size = 0;
513
55
  delete m_data_32;
514
55
  m_data_32 = nullptr;
515
55
  delete m_data_64;
516
55
  m_data_64 = nullptr;
517
55
  if (!valobj_sp)
518
0
    return false;
519
55
  m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
520
55
  Status error;
521
55
  error.Clear();
522
55
  lldb::ProcessSP process_sp(valobj_sp->GetProcessSP());
523
55
  if (!process_sp)
524
0
    return false;
525
55
  m_ptr_size = process_sp->GetAddressByteSize();
526
55
  uint64_t data_location = valobj_sp->GetValueAsUnsigned(0) + m_ptr_size;
527
55
  if (m_ptr_size == 4) {
528
0
    m_data_32 = new D32();
529
0
    process_sp->ReadMemory(data_location, m_data_32, sizeof(D32),
530
0
                           error);
531
55
  } else {
532
55
    m_data_64 = new D64();
533
55
    process_sp->ReadMemory(data_location, m_data_64, sizeof(D64),
534
55
                           error);
535
55
  }
536
55
  if (error.Fail())
537
0
    return false;
538
55
  return false;
539
55
}
Unexecuted instantiation: NSArray.cpp:lldb_private::formatters::GenericNSArrayMSyntheticFrontEnd<lldb_private::formatters::Foundation1010::(anonymous namespace)::DataDescriptor_32, lldb_private::formatters::Foundation1010::(anonymous namespace)::DataDescriptor_64>::Update()
lldb_private::formatters::GenericNSArrayMSyntheticFrontEnd<lldb_private::formatters::CallStackArray::DataDescriptor_32, lldb_private::formatters::CallStackArray::DataDescriptor_64>::Update()
Line
Count
Source
510
3
  GenericNSArrayMSyntheticFrontEnd<D32, D64>::Update() {
511
3
  ValueObjectSP valobj_sp = m_backend.GetSP();
512
3
  m_ptr_size = 0;
513
3
  delete m_data_32;
514
3
  m_data_32 = nullptr;
515
3
  delete m_data_64;
516
3
  m_data_64 = nullptr;
517
3
  if (!valobj_sp)
518
0
    return false;
519
3
  m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
520
3
  Status error;
521
3
  error.Clear();
522
3
  lldb::ProcessSP process_sp(valobj_sp->GetProcessSP());
523
3
  if (!process_sp)
524
0
    return false;
525
3
  m_ptr_size = process_sp->GetAddressByteSize();
526
3
  uint64_t data_location = valobj_sp->GetValueAsUnsigned(0) + m_ptr_size;
527
3
  if (m_ptr_size == 4) {
528
0
    m_data_32 = new D32();
529
0
    process_sp->ReadMemory(data_location, m_data_32, sizeof(D32),
530
0
                           error);
531
3
  } else {
532
3
    m_data_64 = new D64();
533
3
    process_sp->ReadMemory(data_location, m_data_64, sizeof(D64),
534
3
                           error);
535
3
  }
536
3
  if (error.Fail())
537
0
    return false;
538
3
  return false;
539
3
}
540
541
bool
542
3
lldb_private::formatters::NSArrayMSyntheticFrontEndBase::MightHaveChildren() {
543
3
  return true;
544
3
}
545
546
size_t
547
lldb_private::formatters::NSArrayMSyntheticFrontEndBase::GetIndexOfChildWithName(
548
0
    ConstString name) {
549
0
  const char *item_name = name.GetCString();
550
0
  uint32_t idx = ExtractIndexFromString(item_name);
551
0
  if (idx < UINT32_MAX && idx >= CalculateNumChildren())
552
0
    return UINT32_MAX;
553
0
  return idx;
554
0
}
555
556
template <typename D32, typename D64>
557
lldb_private::formatters::
558
  GenericNSArrayMSyntheticFrontEnd<D32, D64>::
559
61
    ~GenericNSArrayMSyntheticFrontEnd<D32, D64>() {
560
61
  delete m_data_32;
561
61
  m_data_32 = nullptr;
562
61
  delete m_data_64;
563
61
  m_data_64 = nullptr;
564
61
}
Unexecuted instantiation: NSArray.cpp:lldb_private::formatters::GenericNSArrayMSyntheticFrontEnd<lldb_private::formatters::Foundation1428::(anonymous namespace)::DataDescriptor_32, lldb_private::formatters::Foundation1428::(anonymous namespace)::DataDescriptor_64>::~GenericNSArrayMSyntheticFrontEnd()
lldb_private::formatters::GenericNSArrayMSyntheticFrontEnd<lldb_private::formatters::Foundation1437::DataDescriptor<unsigned int>, lldb_private::formatters::Foundation1437::DataDescriptor<unsigned long long> >::~GenericNSArrayMSyntheticFrontEnd()
Line
Count
Source
559
58
    ~GenericNSArrayMSyntheticFrontEnd<D32, D64>() {
560
58
  delete m_data_32;
561
58
  m_data_32 = nullptr;
562
58
  delete m_data_64;
563
58
  m_data_64 = nullptr;
564
58
}
Unexecuted instantiation: NSArray.cpp:lldb_private::formatters::GenericNSArrayMSyntheticFrontEnd<lldb_private::formatters::Foundation1010::(anonymous namespace)::DataDescriptor_32, lldb_private::formatters::Foundation1010::(anonymous namespace)::DataDescriptor_64>::~GenericNSArrayMSyntheticFrontEnd()
lldb_private::formatters::GenericNSArrayMSyntheticFrontEnd<lldb_private::formatters::CallStackArray::DataDescriptor_32, lldb_private::formatters::CallStackArray::DataDescriptor_64>::~GenericNSArrayMSyntheticFrontEnd()
Line
Count
Source
559
3
    ~GenericNSArrayMSyntheticFrontEnd<D32, D64>() {
560
3
  delete m_data_32;
561
3
  m_data_32 = nullptr;
562
3
  delete m_data_64;
563
3
  m_data_64 = nullptr;
564
3
}
565
566
template <typename D32, typename D64>
567
lldb::addr_t
568
lldb_private::formatters::
569
  GenericNSArrayMSyntheticFrontEnd<D32, D64>::
570
72
    GenericNSArrayMSyntheticFrontEnd::GetDataAddress() {
571
72
  if (!m_data_32 && !m_data_64)
572
0
    return LLDB_INVALID_ADDRESS;
573
72
  return m_data_32 ? 
m_data_32->_data0
: m_data_64->_data;
574
72
}
Unexecuted instantiation: NSArray.cpp:lldb_private::formatters::GenericNSArrayMSyntheticFrontEnd<lldb_private::formatters::Foundation1428::(anonymous namespace)::DataDescriptor_32, lldb_private::formatters::Foundation1428::(anonymous namespace)::DataDescriptor_64>::GetDataAddress()
lldb_private::formatters::GenericNSArrayMSyntheticFrontEnd<lldb_private::formatters::Foundation1437::DataDescriptor<unsigned int>, lldb_private::formatters::Foundation1437::DataDescriptor<unsigned long long> >::GetDataAddress()
Line
Count
Source
570
54
    GenericNSArrayMSyntheticFrontEnd::GetDataAddress() {
571
54
  if (!m_data_32 && !m_data_64)
572
0
    return LLDB_INVALID_ADDRESS;
573
54
  return m_data_32 ? 
m_data_32->_data0
: m_data_64->_data;
574
54
}
Unexecuted instantiation: NSArray.cpp:lldb_private::formatters::GenericNSArrayMSyntheticFrontEnd<lldb_private::formatters::Foundation1010::(anonymous namespace)::DataDescriptor_32, lldb_private::formatters::Foundation1010::(anonymous namespace)::DataDescriptor_64>::GetDataAddress()
lldb_private::formatters::GenericNSArrayMSyntheticFrontEnd<lldb_private::formatters::CallStackArray::DataDescriptor_32, lldb_private::formatters::CallStackArray::DataDescriptor_64>::GetDataAddress()
Line
Count
Source
570
18
    GenericNSArrayMSyntheticFrontEnd::GetDataAddress() {
571
18
  if (!m_data_32 && !m_data_64)
572
0
    return LLDB_INVALID_ADDRESS;
573
18
  return m_data_32 ? 
m_data_32->_data0
: m_data_64->_data;
574
18
}
575
576
template <typename D32, typename D64>
577
uint64_t
578
lldb_private::formatters::
579
  GenericNSArrayMSyntheticFrontEnd<D32, D64>::
580
84
    GenericNSArrayMSyntheticFrontEnd::GetUsedCount() {
581
84
  if (!m_data_32 && !m_data_64)
582
0
    return 0;
583
84
  return m_data_32 ? 
m_data_32->_used0
: m_data_64->_used;
584
84
}
Unexecuted instantiation: NSArray.cpp:lldb_private::formatters::GenericNSArrayMSyntheticFrontEnd<lldb_private::formatters::Foundation1428::(anonymous namespace)::DataDescriptor_32, lldb_private::formatters::Foundation1428::(anonymous namespace)::DataDescriptor_64>::GetUsedCount()
lldb_private::formatters::GenericNSArrayMSyntheticFrontEnd<lldb_private::formatters::Foundation1437::DataDescriptor<unsigned int>, lldb_private::formatters::Foundation1437::DataDescriptor<unsigned long long> >::GetUsedCount()
Line
Count
Source
580
63
    GenericNSArrayMSyntheticFrontEnd::GetUsedCount() {
581
63
  if (!m_data_32 && !m_data_64)
582
0
    return 0;
583
63
  return m_data_32 ? 
m_data_32->_used0
: m_data_64->_used;
584
63
}
Unexecuted instantiation: NSArray.cpp:lldb_private::formatters::GenericNSArrayMSyntheticFrontEnd<lldb_private::formatters::Foundation1010::(anonymous namespace)::DataDescriptor_32, lldb_private::formatters::Foundation1010::(anonymous namespace)::DataDescriptor_64>::GetUsedCount()
lldb_private::formatters::GenericNSArrayMSyntheticFrontEnd<lldb_private::formatters::CallStackArray::DataDescriptor_32, lldb_private::formatters::CallStackArray::DataDescriptor_64>::GetUsedCount()
Line
Count
Source
580
21
    GenericNSArrayMSyntheticFrontEnd::GetUsedCount() {
581
21
  if (!m_data_32 && !m_data_64)
582
0
    return 0;
583
21
  return m_data_32 ? 
m_data_32->_used0
: m_data_64->_used;
584
21
}
585
586
template <typename D32, typename D64>
587
uint64_t
588
lldb_private::formatters::
589
  GenericNSArrayMSyntheticFrontEnd<D32, D64>::
590
72
    GenericNSArrayMSyntheticFrontEnd::GetOffset() {
591
72
  if (!m_data_32 && !m_data_64)
592
0
    return 0;
593
72
  return m_data_32 ? 
m_data_32->_offset0
: m_data_64->_offset;
594
72
}
Unexecuted instantiation: NSArray.cpp:lldb_private::formatters::GenericNSArrayMSyntheticFrontEnd<lldb_private::formatters::Foundation1428::(anonymous namespace)::DataDescriptor_32, lldb_private::formatters::Foundation1428::(anonymous namespace)::DataDescriptor_64>::GetOffset()
lldb_private::formatters::GenericNSArrayMSyntheticFrontEnd<lldb_private::formatters::Foundation1437::DataDescriptor<unsigned int>, lldb_private::formatters::Foundation1437::DataDescriptor<unsigned long long> >::GetOffset()
Line
Count
Source
590
54
    GenericNSArrayMSyntheticFrontEnd::GetOffset() {
591
54
  if (!m_data_32 && !m_data_64)
592
0
    return 0;
593
54
  return m_data_32 ? 
m_data_32->_offset0
: m_data_64->_offset;
594
54
}
Unexecuted instantiation: NSArray.cpp:lldb_private::formatters::GenericNSArrayMSyntheticFrontEnd<lldb_private::formatters::Foundation1010::(anonymous namespace)::DataDescriptor_32, lldb_private::formatters::Foundation1010::(anonymous namespace)::DataDescriptor_64>::GetOffset()
lldb_private::formatters::GenericNSArrayMSyntheticFrontEnd<lldb_private::formatters::CallStackArray::DataDescriptor_32, lldb_private::formatters::CallStackArray::DataDescriptor_64>::GetOffset()
Line
Count
Source
590
18
    GenericNSArrayMSyntheticFrontEnd::GetOffset() {
591
18
  if (!m_data_32 && !m_data_64)
592
0
    return 0;
593
18
  return m_data_32 ? 
m_data_32->_offset0
: m_data_64->_offset;
594
18
}
595
596
template <typename D32, typename D64>
597
uint64_t
598
lldb_private::formatters::
599
  GenericNSArrayMSyntheticFrontEnd<D32, D64>::
600
90
    GenericNSArrayMSyntheticFrontEnd::GetSize() {
601
90
  if (!m_data_32 && !m_data_64)
602
0
    return 0;
603
90
  return m_data_32 ? 
m_data_32->_size0
: m_data_64->_size;
604
90
}
Unexecuted instantiation: NSArray.cpp:lldb_private::formatters::GenericNSArrayMSyntheticFrontEnd<lldb_private::formatters::Foundation1428::(anonymous namespace)::DataDescriptor_32, lldb_private::formatters::Foundation1428::(anonymous namespace)::DataDescriptor_64>::GetSize()
lldb_private::formatters::GenericNSArrayMSyntheticFrontEnd<lldb_private::formatters::Foundation1437::DataDescriptor<unsigned int>, lldb_private::formatters::Foundation1437::DataDescriptor<unsigned long long> >::GetSize()
Line
Count
Source
600
54
    GenericNSArrayMSyntheticFrontEnd::GetSize() {
601
54
  if (!m_data_32 && !m_data_64)
602
0
    return 0;
603
54
  return m_data_32 ? 
m_data_32->_size0
: m_data_64->_size;
604
54
}
Unexecuted instantiation: NSArray.cpp:lldb_private::formatters::GenericNSArrayMSyntheticFrontEnd<lldb_private::formatters::Foundation1010::(anonymous namespace)::DataDescriptor_32, lldb_private::formatters::Foundation1010::(anonymous namespace)::DataDescriptor_64>::GetSize()
lldb_private::formatters::GenericNSArrayMSyntheticFrontEnd<lldb_private::formatters::CallStackArray::DataDescriptor_32, lldb_private::formatters::CallStackArray::DataDescriptor_64>::GetSize()
Line
Count
Source
600
36
    GenericNSArrayMSyntheticFrontEnd::GetSize() {
601
36
  if (!m_data_32 && !m_data_64)
602
0
    return 0;
603
36
  return m_data_32 ? 
m_data_32->_size0
: m_data_64->_size;
604
36
}
605
606
template <typename D32, typename D64, bool Inline>
607
lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<D32, D64, Inline>::
608
  GenericNSArrayISyntheticFrontEnd(
609
    lldb::ValueObjectSP valobj_sp)
610
    : SyntheticChildrenFrontEnd(*valobj_sp), m_exe_ctx_ref(), m_ptr_size(8),
611
96
      m_data_32(nullptr), m_data_64(nullptr) {
612
96
  if (valobj_sp) {
613
96
    CompilerType type = valobj_sp->GetCompilerType();
614
96
    if (type) {
615
96
      auto *clang_ast_context = ScratchTypeSystemClang::GetForTarget(
616
96
          *valobj_sp->GetExecutionContextRef().GetTargetSP());
617
96
      if (clang_ast_context)
618
96
        m_id_type = clang_ast_context->GetType(
619
96
            clang_ast_context->getASTContext().ObjCBuiltinIdTy);
620
96
    }
621
96
  }
622
96
}
lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<lldb_private::formatters::Foundation1436::IDD32, lldb_private::formatters::Foundation1436::IDD64, true>::GenericNSArrayISyntheticFrontEnd(std::__1::shared_ptr<lldb_private::ValueObject>)
Line
Count
Source
611
96
      m_data_32(nullptr), m_data_64(nullptr) {
612
96
  if (valobj_sp) {
613
96
    CompilerType type = valobj_sp->GetCompilerType();
614
96
    if (type) {
615
96
      auto *clang_ast_context = ScratchTypeSystemClang::GetForTarget(
616
96
          *valobj_sp->GetExecutionContextRef().GetTargetSP());
617
96
      if (clang_ast_context)
618
96
        m_id_type = clang_ast_context->GetType(
619
96
            clang_ast_context->getASTContext().ObjCBuiltinIdTy);
620
96
    }
621
96
  }
622
96
}
Unexecuted instantiation: lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<lldb_private::formatters::Foundation1300::IDD32, lldb_private::formatters::Foundation1300::IDD64, true>::GenericNSArrayISyntheticFrontEnd(std::__1::shared_ptr<lldb_private::ValueObject>)
Unexecuted instantiation: lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<lldb_private::formatters::Foundation1436::IDD32, lldb_private::formatters::Foundation1436::IDD64, false>::GenericNSArrayISyntheticFrontEnd(std::__1::shared_ptr<lldb_private::ValueObject>)
Unexecuted instantiation: lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<lldb_private::formatters::ConstantArray::ConstantArray32, lldb_private::formatters::ConstantArray::ConstantArray64, false>::GenericNSArrayISyntheticFrontEnd(std::__1::shared_ptr<lldb_private::ValueObject>)
623
624
template <typename D32, typename D64, bool Inline>
625
lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<D32, D64, Inline>::
626
96
  ~GenericNSArrayISyntheticFrontEnd<D32, D64, Inline>() {
627
96
  delete m_data_32;
628
96
  m_data_32 = nullptr;
629
96
  delete m_data_64;
630
96
  m_data_64 = nullptr;
631
96
}
lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<lldb_private::formatters::Foundation1436::IDD32, lldb_private::formatters::Foundation1436::IDD64, true>::~GenericNSArrayISyntheticFrontEnd()
Line
Count
Source
626
96
  ~GenericNSArrayISyntheticFrontEnd<D32, D64, Inline>() {
627
96
  delete m_data_32;
628
96
  m_data_32 = nullptr;
629
96
  delete m_data_64;
630
96
  m_data_64 = nullptr;
631
96
}
Unexecuted instantiation: lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<lldb_private::formatters::Foundation1300::IDD32, lldb_private::formatters::Foundation1300::IDD64, true>::~GenericNSArrayISyntheticFrontEnd()
Unexecuted instantiation: lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<lldb_private::formatters::Foundation1436::IDD32, lldb_private::formatters::Foundation1436::IDD64, false>::~GenericNSArrayISyntheticFrontEnd()
Unexecuted instantiation: lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<lldb_private::formatters::ConstantArray::ConstantArray32, lldb_private::formatters::ConstantArray::ConstantArray64, false>::~GenericNSArrayISyntheticFrontEnd()
632
633
template <typename D32, typename D64, bool Inline>
634
size_t
635
lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<D32, D64, Inline>::
636
0
  GetIndexOfChildWithName(ConstString name) {
637
0
  const char *item_name = name.GetCString();
638
0
  uint32_t idx = ExtractIndexFromString(item_name);
639
0
  if (idx < UINT32_MAX && idx >= CalculateNumChildren())
640
0
    return UINT32_MAX;
641
0
  return idx;
642
0
}
Unexecuted instantiation: lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<lldb_private::formatters::Foundation1436::IDD32, lldb_private::formatters::Foundation1436::IDD64, true>::GetIndexOfChildWithName(lldb_private::ConstString)
Unexecuted instantiation: lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<lldb_private::formatters::Foundation1300::IDD32, lldb_private::formatters::Foundation1300::IDD64, true>::GetIndexOfChildWithName(lldb_private::ConstString)
Unexecuted instantiation: lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<lldb_private::formatters::Foundation1436::IDD32, lldb_private::formatters::Foundation1436::IDD64, false>::GetIndexOfChildWithName(lldb_private::ConstString)
Unexecuted instantiation: lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<lldb_private::formatters::ConstantArray::ConstantArray32, lldb_private::formatters::ConstantArray::ConstantArray64, false>::GetIndexOfChildWithName(lldb_private::ConstString)
643
644
template <typename D32, typename D64, bool Inline>
645
size_t
646
lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<D32, D64, Inline>::
647
129
  CalculateNumChildren() {
648
129
  return m_data_32 ? 
m_data_32->used0
: m_data_64->used;
649
129
}
lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<lldb_private::formatters::Foundation1436::IDD32, lldb_private::formatters::Foundation1436::IDD64, true>::CalculateNumChildren()
Line
Count
Source
647
129
  CalculateNumChildren() {
648
129
  return m_data_32 ? 
m_data_32->used0
: m_data_64->used;
649
129
}
Unexecuted instantiation: lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<lldb_private::formatters::Foundation1300::IDD32, lldb_private::formatters::Foundation1300::IDD64, true>::CalculateNumChildren()
Unexecuted instantiation: lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<lldb_private::formatters::Foundation1436::IDD32, lldb_private::formatters::Foundation1436::IDD64, false>::CalculateNumChildren()
Unexecuted instantiation: lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<lldb_private::formatters::ConstantArray::ConstantArray32, lldb_private::formatters::ConstantArray::ConstantArray64, false>::CalculateNumChildren()
650
651
template <typename D32, typename D64, bool Inline>
652
bool
653
lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<D32, D64, Inline>::
654
93
  Update() {
655
93
  ValueObjectSP valobj_sp = m_backend.GetSP();
656
93
  m_ptr_size = 0;
657
93
  delete m_data_32;
658
93
  m_data_32 = nullptr;
659
93
  delete m_data_64;
660
93
  m_data_64 = nullptr;
661
93
  if (!valobj_sp)
662
0
    return false;
663
93
  m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
664
93
  Status error;
665
93
  error.Clear();
666
93
  lldb::ProcessSP process_sp(valobj_sp->GetProcessSP());
667
93
  if (!process_sp)
668
0
    return false;
669
93
  m_ptr_size = process_sp->GetAddressByteSize();
670
93
  uint64_t data_location = valobj_sp->GetValueAsUnsigned(0) + m_ptr_size;
671
93
  if (m_ptr_size == 4) {
672
0
    m_data_32 = new D32();
673
0
    process_sp->ReadMemory(data_location, m_data_32, sizeof(D32),
674
0
                           error);
675
93
  } else {
676
93
    m_data_64 = new D64();
677
93
    process_sp->ReadMemory(data_location, m_data_64, sizeof(D64),
678
93
                           error);
679
93
  }
680
93
  if (error.Fail())
681
0
    return false;
682
93
  return false;
683
93
}
lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<lldb_private::formatters::Foundation1436::IDD32, lldb_private::formatters::Foundation1436::IDD64, true>::Update()
Line
Count
Source
654
93
  Update() {
655
93
  ValueObjectSP valobj_sp = m_backend.GetSP();
656
93
  m_ptr_size = 0;
657
93
  delete m_data_32;
658
93
  m_data_32 = nullptr;
659
93
  delete m_data_64;
660
93
  m_data_64 = nullptr;
661
93
  if (!valobj_sp)
662
0
    return false;
663
93
  m_exe_ctx_ref = valobj_sp->GetExecutionContextRef();
664
93
  Status error;
665
93
  error.Clear();
666
93
  lldb::ProcessSP process_sp(valobj_sp->GetProcessSP());
667
93
  if (!process_sp)
668
0
    return false;
669
93
  m_ptr_size = process_sp->GetAddressByteSize();
670
93
  uint64_t data_location = valobj_sp->GetValueAsUnsigned(0) + m_ptr_size;
671
93
  if (m_ptr_size == 4) {
672
0
    m_data_32 = new D32();
673
0
    process_sp->ReadMemory(data_location, m_data_32, sizeof(D32),
674
0
                           error);
675
93
  } else {
676
93
    m_data_64 = new D64();
677
93
    process_sp->ReadMemory(data_location, m_data_64, sizeof(D64),
678
93
                           error);
679
93
  }
680
93
  if (error.Fail())
681
0
    return false;
682
93
  return false;
683
93
}
Unexecuted instantiation: lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<lldb_private::formatters::Foundation1300::IDD32, lldb_private::formatters::Foundation1300::IDD64, true>::Update()
Unexecuted instantiation: lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<lldb_private::formatters::Foundation1436::IDD32, lldb_private::formatters::Foundation1436::IDD64, false>::Update()
Unexecuted instantiation: lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<lldb_private::formatters::ConstantArray::ConstantArray32, lldb_private::formatters::ConstantArray::ConstantArray64, false>::Update()
684
685
template <typename D32, typename D64, bool Inline>
686
bool
687
lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<D32, D64, Inline>::
688
3
  MightHaveChildren() {
689
3
  return true;
690
3
}
lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<lldb_private::formatters::Foundation1436::IDD32, lldb_private::formatters::Foundation1436::IDD64, true>::MightHaveChildren()
Line
Count
Source
688
3
  MightHaveChildren() {
689
3
  return true;
690
3
}
Unexecuted instantiation: lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<lldb_private::formatters::Foundation1300::IDD32, lldb_private::formatters::Foundation1300::IDD64, true>::MightHaveChildren()
Unexecuted instantiation: lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<lldb_private::formatters::Foundation1436::IDD32, lldb_private::formatters::Foundation1436::IDD64, false>::MightHaveChildren()
Unexecuted instantiation: lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<lldb_private::formatters::ConstantArray::ConstantArray32, lldb_private::formatters::ConstantArray::ConstantArray64, false>::MightHaveChildren()
691
692
template <typename D32, typename D64, bool Inline>
693
lldb::ValueObjectSP
694
lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<D32, D64, Inline>::
695
96
  GetChildAtIndex(size_t idx) {
696
96
  if (idx >= CalculateNumChildren())
697
0
    return lldb::ValueObjectSP();
698
96
  lldb::addr_t object_at_idx;
699
96
  if (Inline) {
700
96
    object_at_idx = m_backend.GetSP()->GetValueAsUnsigned(0) + m_ptr_size;
701
96
    object_at_idx += m_ptr_size == 4 ? 
sizeof(D32)0
: sizeof(D64); // skip the data header
702
96
    object_at_idx -= m_ptr_size; // we treat the last entry in the data header as the first pointer
703
96
  } else {
704
0
    object_at_idx = m_data_32 ? m_data_32->list : m_data_64->list;
705
0
  }
706
96
  object_at_idx += (idx * m_ptr_size);
707
708
96
  ProcessSP process_sp = m_exe_ctx_ref.GetProcessSP();
709
96
  if (!process_sp)
710
0
    return lldb::ValueObjectSP();
711
96
  Status error;
712
96
  if (error.Fail())
713
0
    return lldb::ValueObjectSP();
714
96
  StreamString idx_name;
715
96
  idx_name.Printf("[%" PRIu64 "]", (uint64_t)idx);
716
96
  return CreateValueObjectFromAddress(idx_name.GetString(), object_at_idx,
717
96
                                      m_exe_ctx_ref, m_id_type);
718
96
}
lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<lldb_private::formatters::Foundation1436::IDD32, lldb_private::formatters::Foundation1436::IDD64, true>::GetChildAtIndex(unsigned long)
Line
Count
Source
695
96
  GetChildAtIndex(size_t idx) {
696
96
  if (idx >= CalculateNumChildren())
697
0
    return lldb::ValueObjectSP();
698
96
  lldb::addr_t object_at_idx;
699
96
  if (Inline) {
700
96
    object_at_idx = m_backend.GetSP()->GetValueAsUnsigned(0) + m_ptr_size;
701
96
    object_at_idx += m_ptr_size == 4 ? 
sizeof(D32)0
: sizeof(D64); // skip the data header
702
96
    object_at_idx -= m_ptr_size; // we treat the last entry in the data header as the first pointer
703
96
  } else {
704
0
    object_at_idx = m_data_32 ? m_data_32->list : m_data_64->list;
705
0
  }
706
96
  object_at_idx += (idx * m_ptr_size);
707
708
96
  ProcessSP process_sp = m_exe_ctx_ref.GetProcessSP();
709
96
  if (!process_sp)
710
0
    return lldb::ValueObjectSP();
711
96
  Status error;
712
96
  if (error.Fail())
713
0
    return lldb::ValueObjectSP();
714
96
  StreamString idx_name;
715
96
  idx_name.Printf("[%" PRIu64 "]", (uint64_t)idx);
716
96
  return CreateValueObjectFromAddress(idx_name.GetString(), object_at_idx,
717
96
                                      m_exe_ctx_ref, m_id_type);
718
96
}
Unexecuted instantiation: lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<lldb_private::formatters::Foundation1300::IDD32, lldb_private::formatters::Foundation1300::IDD64, true>::GetChildAtIndex(unsigned long)
Unexecuted instantiation: lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<lldb_private::formatters::Foundation1436::IDD32, lldb_private::formatters::Foundation1436::IDD64, false>::GetChildAtIndex(unsigned long)
Unexecuted instantiation: lldb_private::formatters::GenericNSArrayISyntheticFrontEnd<lldb_private::formatters::ConstantArray::ConstantArray32, lldb_private::formatters::ConstantArray::ConstantArray64, false>::GetChildAtIndex(unsigned long)
719
720
lldb_private::formatters::NSArray0SyntheticFrontEnd::NSArray0SyntheticFrontEnd(
721
    lldb::ValueObjectSP valobj_sp)
722
9
    : SyntheticChildrenFrontEnd(*valobj_sp) {}
723
724
size_t
725
lldb_private::formatters::NSArray0SyntheticFrontEnd::GetIndexOfChildWithName(
726
0
    ConstString name) {
727
0
  return UINT32_MAX;
728
0
}
729
730
size_t
731
3
lldb_private::formatters::NSArray0SyntheticFrontEnd::CalculateNumChildren() {
732
3
  return 0;
733
3
}
734
735
6
bool lldb_private::formatters::NSArray0SyntheticFrontEnd::Update() {
736
6
  return false;
737
6
}
738
739
3
bool lldb_private::formatters::NSArray0SyntheticFrontEnd::MightHaveChildren() {
740
3
  return false;
741
3
}
742
743
lldb::ValueObjectSP
744
lldb_private::formatters::NSArray0SyntheticFrontEnd::GetChildAtIndex(
745
0
    size_t idx) {
746
0
  return lldb::ValueObjectSP();
747
0
}
748
749
lldb_private::formatters::NSArray1SyntheticFrontEnd::NSArray1SyntheticFrontEnd(
750
    lldb::ValueObjectSP valobj_sp)
751
0
    : SyntheticChildrenFrontEnd(*valobj_sp.get()) {}
752
753
size_t
754
lldb_private::formatters::NSArray1SyntheticFrontEnd::GetIndexOfChildWithName(
755
0
    ConstString name) {
756
0
  static const ConstString g_zero("[0]");
757
758
0
  if (name == g_zero)
759
0
    return 0;
760
761
0
  return UINT32_MAX;
762
0
}
763
764
size_t
765
0
lldb_private::formatters::NSArray1SyntheticFrontEnd::CalculateNumChildren() {
766
0
  return 1;
767
0
}
768
769
0
bool lldb_private::formatters::NSArray1SyntheticFrontEnd::Update() {
770
0
  return false;
771
0
}
772
773
0
bool lldb_private::formatters::NSArray1SyntheticFrontEnd::MightHaveChildren() {
774
0
  return true;
775
0
}
776
777
lldb::ValueObjectSP
778
lldb_private::formatters::NSArray1SyntheticFrontEnd::GetChildAtIndex(
779
0
    size_t idx) {
780
0
  static const ConstString g_zero("[0]");
781
782
0
  if (idx == 0) {
783
0
    auto *clang_ast_context =
784
0
        ScratchTypeSystemClang::GetForTarget(*m_backend.GetTargetSP());
785
0
    if (clang_ast_context) {
786
0
      CompilerType id_type(
787
0
          clang_ast_context->GetBasicType(lldb::eBasicTypeObjCID));
788
0
      return m_backend.GetSyntheticChildAtOffset(
789
0
          m_backend.GetProcessSP()->GetAddressByteSize(), id_type, true,
790
0
          g_zero);
791
0
    }
792
0
  }
793
0
  return lldb::ValueObjectSP();
794
0
}
795
796
SyntheticChildrenFrontEnd *
797
lldb_private::formatters::NSArraySyntheticFrontEndCreator(
798
196
    CXXSyntheticChildren *synth, lldb::ValueObjectSP valobj_sp) {
799
196
  if (!valobj_sp)
800
0
    return nullptr;
801
802
196
  lldb::ProcessSP process_sp(valobj_sp->GetProcessSP());
803
196
  if (!process_sp)
804
0
    return nullptr;
805
196
  AppleObjCRuntime *runtime = llvm::dyn_cast_or_null<AppleObjCRuntime>(
806
196
      ObjCLanguageRuntime::Get(*process_sp));
807
196
  if (!runtime)
808
0
    return nullptr;
809
810
196
  CompilerType valobj_type(valobj_sp->GetCompilerType());
811
196
  Flags flags(valobj_type.GetTypeInfo());
812
813
196
  if (flags.IsClear(eTypeIsPointer)) {
814
0
    Status error;
815
0
    valobj_sp = valobj_sp->AddressOf(error);
816
0
    if (error.Fail() || !valobj_sp)
817
0
      return nullptr;
818
0
  }
819
820
196
  ObjCLanguageRuntime::ClassDescriptorSP descriptor(
821
196
      runtime->GetClassDescriptor(*valobj_sp));
822
823
196
  if (!descriptor || !descriptor->IsValid())
824
0
    return nullptr;
825
826
196
  ConstString class_name(descriptor->GetClassName());
827
828
196
  static const ConstString g_NSArrayI("__NSArrayI");
829
196
  static const ConstString g_NSConstantArray("NSConstantArray");
830
196
  static const ConstString g_NSArrayI_Transfer("__NSArrayI_Transfer");
831
196
  static const ConstString g_NSFrozenArrayM("__NSFrozenArrayM");
832
196
  static const ConstString g_NSArrayM("__NSArrayM");
833
196
  static const ConstString g_NSArray0("__NSArray0");
834
196
  static const ConstString g_NSArray1("__NSSingleObjectArrayI");
835
196
  static const ConstString g_NSArrayMLegacy("__NSArrayM_Legacy");
836
196
  static const ConstString g_NSArrayMImmutable("__NSArrayM_Immutable");
837
196
  static const ConstString g_NSCallStackArray("_NSCallStackArray");
838
839
196
  if (class_name.IsEmpty())
840
0
    return nullptr;
841
842
196
  if (class_name == g_NSArrayI) {
843
96
    if (runtime->GetFoundationVersion() >= 1436)
844
96
      return (new Foundation1436::NSArrayISyntheticFrontEnd(valobj_sp));
845
0
    if (runtime->GetFoundationVersion() >= 1430)
846
0
      return (new Foundation1430::NSArrayISyntheticFrontEnd(valobj_sp));
847
0
    return (new Foundation1300::NSArrayISyntheticFrontEnd(valobj_sp));
848
100
  } else if (class_name == g_NSArrayI_Transfer) {
849
0
      return (new Foundation1436::NSArrayI_TransferSyntheticFrontEnd(valobj_sp));
850
100
  } else if (class_name == g_NSConstantArray) {
851
0
    return new ConstantArray::NSConstantArraySyntheticFrontEnd(valobj_sp);
852
100
  } else if (class_name == g_NSFrozenArrayM) {
853
0
    return (new Foundation1436::NSFrozenArrayMSyntheticFrontEnd(valobj_sp));
854
100
  } else if (class_name == g_NSArray0) {
855
9
    return (new NSArray0SyntheticFrontEnd(valobj_sp));
856
91
  } else if (class_name == g_NSArray1) {
857
0
    return (new NSArray1SyntheticFrontEnd(valobj_sp));
858
91
  } else if (class_name == g_NSArrayM) {
859
58
    if (runtime->GetFoundationVersion() >= 1437)
860
58
      return (new Foundation1437::NSArrayMSyntheticFrontEnd(valobj_sp));
861
0
    if (runtime->GetFoundationVersion() >= 1428)
862
0
      return (new Foundation1428::NSArrayMSyntheticFrontEnd(valobj_sp));
863
0
    if (runtime->GetFoundationVersion() >= 1100)
864
0
      return (new Foundation1010::NSArrayMSyntheticFrontEnd(valobj_sp));
865
33
  } else if (class_name == g_NSCallStackArray) {
866
3
    return (new CallStackArray::NSCallStackArraySyntheticFrontEnd(valobj_sp));
867
30
  } else {
868
30
    auto &map(NSArray_Additionals::GetAdditionalSynthetics());
869
30
    auto iter = map.find(class_name), end = map.end();
870
30
    if (iter != end)
871
0
      return iter->second(synth, valobj_sp);
872
30
  }
873
874
30
  return nullptr;
875
196
}