Coverage Report

Created: 2022-01-18 06:27

/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
Line
Count
Source (jump to first uncovered line)
1
//===-- ObjCLanguage.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 <mutex>
10
11
#include "ObjCLanguage.h"
12
13
#include "Plugins/ExpressionParser/Clang/ClangUtil.h"
14
#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
15
#include "lldb/Core/PluginManager.h"
16
#include "lldb/Core/ValueObject.h"
17
#include "lldb/DataFormatters/DataVisualization.h"
18
#include "lldb/DataFormatters/FormattersHelpers.h"
19
#include "lldb/Symbol/CompilerType.h"
20
#include "lldb/Target/Target.h"
21
#include "lldb/Utility/ConstString.h"
22
#include "lldb/Utility/StreamString.h"
23
24
#include "llvm/Support/Threading.h"
25
26
#include "Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.h"
27
#include "Plugins/LanguageRuntime/ObjC/ObjCLanguageRuntime.h"
28
29
#include "CF.h"
30
#include "Cocoa.h"
31
#include "CoreMedia.h"
32
#include "NSDictionary.h"
33
#include "NSSet.h"
34
#include "NSString.h"
35
36
using namespace lldb;
37
using namespace lldb_private;
38
using namespace lldb_private::formatters;
39
40
LLDB_PLUGIN_DEFINE(ObjCLanguage)
41
42
3.47k
void ObjCLanguage::Initialize() {
43
3.47k
  PluginManager::RegisterPlugin(GetPluginNameStatic(), "Objective-C Language",
44
3.47k
                                CreateInstance);
45
3.47k
}
46
47
3.46k
void ObjCLanguage::Terminate() {
48
3.46k
  PluginManager::UnregisterPlugin(CreateInstance);
49
3.46k
}
50
51
// Static Functions
52
53
173k
Language *ObjCLanguage::CreateInstance(lldb::LanguageType language) {
54
173k
  switch (language) {
55
1.02k
  case lldb::eLanguageTypeObjC:
56
1.02k
    return new ObjCLanguage();
57
172k
  default:
58
172k
    return nullptr;
59
173k
  }
60
173k
}
61
62
97.0M
void ObjCLanguage::MethodName::Clear() {
63
97.0M
  m_full.Clear();
64
97.0M
  m_class.Clear();
65
97.0M
  m_category.Clear();
66
97.0M
  m_selector.Clear();
67
97.0M
  m_type = eTypeUnspecified;
68
97.0M
  m_category_is_valid = false;
69
97.0M
}
70
71
97.0M
bool ObjCLanguage::MethodName::SetName(llvm::StringRef name, bool strict) {
72
97.0M
  Clear();
73
97.0M
  if (name.empty())
74
0
    return IsValid(strict);
75
76
  // If "strict" is true. then the method must be specified with a '+' or '-'
77
  // at the beginning. If "strict" is false, then the '+' or '-' can be omitted
78
97.0M
  bool valid_prefix = false;
79
80
97.0M
  if (name.size() > 1 && 
(97.0M
name[0] == '+'97.0M
||
name[0] == '-'95.7M
)) {
81
9.54M
    valid_prefix = name[1] == '[';
82
9.54M
    if (name[0] == '+')
83
1.30M
      m_type = eTypeClassMethod;
84
8.24M
    else
85
8.24M
      m_type = eTypeInstanceMethod;
86
87.4M
  } else if (!strict) {
87
    // "strict" is false, the name just needs to start with '['
88
87.4M
    valid_prefix = name[0] == '[';
89
87.4M
  }
90
91
97.0M
  if (valid_prefix) {
92
9.54M
    int name_len = name.size();
93
    // Objective-C methods must have at least:
94
    //      "-[" or "+[" prefix
95
    //      One character for a class name
96
    //      One character for the space between the class name
97
    //      One character for the method name
98
    //      "]" suffix
99
9.54M
    if (name_len >= (5 + (strict ? 
1759
:
09.54M
)) && name.back() == ']') {
100
9.07M
      m_full.SetString(name);
101
9.07M
    }
102
9.54M
  }
103
97.0M
  return IsValid(strict);
104
97.0M
}
105
106
96.9M
bool ObjCLanguage::MethodName::SetName(const char *name, bool strict) {
107
96.9M
  return SetName(llvm::StringRef(name), strict);
108
96.9M
}
109
110
941k
ConstString ObjCLanguage::MethodName::GetClassName() {
111
941k
  if (!m_class) {
112
941k
    if (IsValid(false)) {
113
941k
      const char *full = m_full.GetCString();
114
941k
      const char *class_start = (full[0] == '[' ? 
full + 10
: full + 2);
115
941k
      const char *paren_pos = strchr(class_start, '(');
116
941k
      if (paren_pos) {
117
940k
        m_class.SetCStringWithLength(class_start, paren_pos - class_start);
118
940k
      } else {
119
        // No '(' was found in the full name, we can definitively say that our
120
        // category was valid (and empty).
121
746
        m_category_is_valid = true;
122
746
        const char *space_pos = strchr(full, ' ');
123
746
        if (space_pos) {
124
746
          m_class.SetCStringWithLength(class_start, space_pos - class_start);
125
746
          if (!m_class_category) {
126
            // No category in name, so we can also fill in the m_class_category
127
746
            m_class_category = m_class;
128
746
          }
129
746
        }
130
746
      }
131
941k
    }
132
941k
  }
133
941k
  return m_class;
134
941k
}
135
136
2
ConstString ObjCLanguage::MethodName::GetClassNameWithCategory() {
137
2
  if (!m_class_category) {
138
2
    if (IsValid(false)) {
139
2
      const char *full = m_full.GetCString();
140
2
      const char *class_start = (full[0] == '[' ? 
full + 10
: full + 2);
141
2
      const char *space_pos = strchr(full, ' ');
142
2
      if (space_pos) {
143
2
        m_class_category.SetCStringWithLength(class_start,
144
2
                                              space_pos - class_start);
145
        // If m_class hasn't been filled in and the class with category doesn't
146
        // contain a '(', then we can also fill in the m_class
147
2
        if (!m_class && strchr(m_class_category.GetCString(), '(') == nullptr) {
148
2
          m_class = m_class_category;
149
          // No '(' was found in the full name, we can definitively say that
150
          // our category was valid (and empty).
151
2
          m_category_is_valid = true;
152
2
        }
153
2
      }
154
2
    }
155
2
  }
156
2
  return m_class_category;
157
2
}
158
159
10.0M
ConstString ObjCLanguage::MethodName::GetSelector() {
160
10.0M
  if (!m_selector) {
161
9.07M
    if (IsValid(false)) {
162
9.07M
      const char *full = m_full.GetCString();
163
9.07M
      const char *space_pos = strchr(full, ' ');
164
9.07M
      if (space_pos) {
165
9.07M
        ++space_pos; // skip the space
166
9.07M
        m_selector.SetCStringWithLength(space_pos, m_full.GetLength() -
167
9.07M
                                                       (space_pos - full) - 1);
168
9.07M
      }
169
9.07M
    }
170
9.07M
  }
171
10.0M
  return m_selector;
172
10.0M
}
173
174
9.07M
ConstString ObjCLanguage::MethodName::GetCategory() {
175
9.07M
  if (!m_category_is_valid && 
!m_category9.07M
) {
176
9.07M
    if (IsValid(false)) {
177
9.07M
      m_category_is_valid = true;
178
9.07M
      const char *full = m_full.GetCString();
179
9.07M
      const char *class_start = (full[0] == '[' ? 
full + 16
:
full + 29.07M
);
180
9.07M
      const char *open_paren_pos = strchr(class_start, '(');
181
9.07M
      if (open_paren_pos) {
182
940k
        ++open_paren_pos; // Skip the open paren
183
940k
        const char *close_paren_pos = strchr(open_paren_pos, ')');
184
940k
        if (close_paren_pos)
185
940k
          m_category.SetCStringWithLength(open_paren_pos,
186
940k
                                          close_paren_pos - open_paren_pos);
187
940k
      }
188
9.07M
    }
189
9.07M
  }
190
9.07M
  return m_category;
191
9.07M
}
192
193
ConstString ObjCLanguage::MethodName::GetFullNameWithoutCategory(
194
9.07M
    bool empty_if_no_category) {
195
9.07M
  if (IsValid(false)) {
196
9.07M
    if (HasCategory()) {
197
940k
      StreamString strm;
198
940k
      if (m_type == eTypeClassMethod)
199
206k
        strm.PutChar('+');
200
734k
      else if (m_type == eTypeInstanceMethod)
201
734k
        strm.PutChar('-');
202
940k
      strm.Printf("[%s %s]", GetClassName().GetCString(),
203
940k
                  GetSelector().GetCString());
204
940k
      return ConstString(strm.GetString());
205
940k
    }
206
207
8.13M
    if (!empty_if_no_category) {
208
      // Just return the full name since it doesn't have a category
209
0
      return GetFullName();
210
0
    }
211
8.13M
  }
212
8.13M
  return ConstString();
213
9.07M
}
214
215
std::vector<Language::MethodNameVariant>
216
96.9M
ObjCLanguage::GetMethodNameVariants(ConstString method_name) const {
217
96.9M
  std::vector<Language::MethodNameVariant> variant_names;
218
96.9M
  ObjCLanguage::MethodName objc_method(method_name.GetCString(), false);
219
96.9M
  if (!objc_method.IsValid(false)) {
220
87.8M
    return variant_names;
221
87.8M
  }
222
223
9.07M
  variant_names.emplace_back(objc_method.GetSelector(),
224
9.07M
                             lldb::eFunctionNameTypeSelector);
225
226
9.07M
  const bool is_class_method =
227
9.07M
      objc_method.GetType() == MethodName::eTypeClassMethod;
228
9.07M
  const bool is_instance_method =
229
9.07M
      objc_method.GetType() == MethodName::eTypeInstanceMethod;
230
9.07M
  ConstString name_sans_category =
231
9.07M
      objc_method.GetFullNameWithoutCategory(/*empty_if_no_category*/ true);
232
233
9.07M
  if (is_class_method || 
is_instance_method7.83M
) {
234
9.07M
    if (name_sans_category)
235
940k
      variant_names.emplace_back(name_sans_category,
236
940k
                                 lldb::eFunctionNameTypeFull);
237
9.07M
  } else {
238
6
    StreamString strm;
239
240
6
    strm.Printf("+%s", objc_method.GetFullName().GetCString());
241
6
    variant_names.emplace_back(ConstString(strm.GetString()),
242
6
                               lldb::eFunctionNameTypeFull);
243
6
    strm.Clear();
244
245
6
    strm.Printf("-%s", objc_method.GetFullName().GetCString());
246
6
    variant_names.emplace_back(ConstString(strm.GetString()),
247
6
                               lldb::eFunctionNameTypeFull);
248
6
    strm.Clear();
249
250
6
    if (name_sans_category) {
251
0
      strm.Printf("+%s", name_sans_category.GetCString());
252
0
      variant_names.emplace_back(ConstString(strm.GetString()),
253
0
                                 lldb::eFunctionNameTypeFull);
254
0
      strm.Clear();
255
256
0
      strm.Printf("-%s", name_sans_category.GetCString());
257
0
      variant_names.emplace_back(ConstString(strm.GetString()),
258
0
                                 lldb::eFunctionNameTypeFull);
259
0
    }
260
6
  }
261
262
9.07M
  return variant_names;
263
96.9M
}
264
265
148k
bool ObjCLanguage::SymbolNameFitsToLanguage(Mangled mangled) const {
266
148k
  ConstString demangled_name = mangled.GetDemangledName();
267
148k
  if (!demangled_name)
268
45.6k
    return false;
269
102k
  return ObjCLanguage::IsPossibleObjCMethodName(demangled_name.GetCString());
270
148k
}
271
272
645
static void LoadObjCFormatters(TypeCategoryImplSP objc_category_sp) {
273
645
  if (!objc_category_sp)
274
0
    return;
275
276
645
  TypeSummaryImpl::Flags objc_flags;
277
645
  objc_flags.SetCascades(false)
278
645
      .SetSkipPointers(true)
279
645
      .SetSkipReferences(true)
280
645
      .SetDontShowChildren(true)
281
645
      .SetDontShowValue(true)
282
645
      .SetShowMembersOneLiner(false)
283
645
      .SetHideItemNames(false);
284
285
645
  lldb::TypeSummaryImplSP ObjC_BOOL_summary(new CXXFunctionSummaryFormat(
286
645
      objc_flags, lldb_private::formatters::ObjCBOOLSummaryProvider, ""));
287
645
  objc_category_sp->GetTypeSummariesContainer()->Add(ConstString("BOOL"),
288
645
                                                     ObjC_BOOL_summary);
289
645
  objc_category_sp->GetTypeSummariesContainer()->Add(ConstString("BOOL &"),
290
645
                                                     ObjC_BOOL_summary);
291
645
  objc_category_sp->GetTypeSummariesContainer()->Add(ConstString("BOOL *"),
292
645
                                                     ObjC_BOOL_summary);
293
294
  // we need to skip pointers here since we are special casing a SEL* when
295
  // retrieving its value
296
645
  objc_flags.SetSkipPointers(true);
297
645
  AddCXXSummary(objc_category_sp,
298
645
                lldb_private::formatters::ObjCSELSummaryProvider<false>,
299
645
                "SEL summary provider", ConstString("SEL"), objc_flags);
300
645
  AddCXXSummary(
301
645
      objc_category_sp, lldb_private::formatters::ObjCSELSummaryProvider<false>,
302
645
      "SEL summary provider", ConstString("struct objc_selector"), objc_flags);
303
645
  AddCXXSummary(
304
645
      objc_category_sp, lldb_private::formatters::ObjCSELSummaryProvider<false>,
305
645
      "SEL summary provider", ConstString("objc_selector"), objc_flags);
306
645
  AddCXXSummary(
307
645
      objc_category_sp, lldb_private::formatters::ObjCSELSummaryProvider<true>,
308
645
      "SEL summary provider", ConstString("objc_selector *"), objc_flags);
309
645
  AddCXXSummary(objc_category_sp,
310
645
                lldb_private::formatters::ObjCSELSummaryProvider<true>,
311
645
                "SEL summary provider", ConstString("SEL *"), objc_flags);
312
313
645
  AddCXXSummary(objc_category_sp,
314
645
                lldb_private::formatters::ObjCClassSummaryProvider,
315
645
                "Class summary provider", ConstString("Class"), objc_flags);
316
317
645
  SyntheticChildren::Flags class_synth_flags;
318
645
  class_synth_flags.SetCascades(true).SetSkipPointers(false).SetSkipReferences(
319
645
      false);
320
321
645
  AddCXXSynthetic(objc_category_sp,
322
645
                  lldb_private::formatters::ObjCClassSyntheticFrontEndCreator,
323
645
                  "Class synthetic children", ConstString("Class"),
324
645
                  class_synth_flags);
325
326
645
  objc_flags.SetSkipPointers(false);
327
645
  objc_flags.SetCascades(true);
328
645
  objc_flags.SetSkipReferences(false);
329
330
645
  AddStringSummary(objc_category_sp, "${var.__FuncPtr%A}",
331
645
                   ConstString("__block_literal_generic"), objc_flags);
332
333
645
  AddStringSummary(objc_category_sp, "${var.years} years, ${var.months} "
334
645
                                     "months, ${var.days} days, ${var.hours} "
335
645
                                     "hours, ${var.minutes} minutes "
336
645
                                     "${var.seconds} seconds",
337
645
                   ConstString("CFGregorianUnits"), objc_flags);
338
645
  AddStringSummary(objc_category_sp,
339
645
                   "location=${var.location} length=${var.length}",
340
645
                   ConstString("CFRange"), objc_flags);
341
342
645
  AddStringSummary(objc_category_sp,
343
645
                   "location=${var.location}, length=${var.length}",
344
645
                   ConstString("NSRange"), objc_flags);
345
645
  AddStringSummary(objc_category_sp, "(${var.origin}, ${var.size}), ...",
346
645
                   ConstString("NSRectArray"), objc_flags);
347
348
645
  AddOneLineSummary(objc_category_sp, ConstString("NSPoint"), objc_flags);
349
645
  AddOneLineSummary(objc_category_sp, ConstString("NSSize"), objc_flags);
350
645
  AddOneLineSummary(objc_category_sp, ConstString("NSRect"), objc_flags);
351
352
645
  AddOneLineSummary(objc_category_sp, ConstString("CGSize"), objc_flags);
353
645
  AddOneLineSummary(objc_category_sp, ConstString("CGPoint"), objc_flags);
354
645
  AddOneLineSummary(objc_category_sp, ConstString("CGRect"), objc_flags);
355
356
645
  AddStringSummary(objc_category_sp,
357
645
                   "red=${var.red} green=${var.green} blue=${var.blue}",
358
645
                   ConstString("RGBColor"), objc_flags);
359
645
  AddStringSummary(
360
645
      objc_category_sp,
361
645
      "(t=${var.top}, l=${var.left}, b=${var.bottom}, r=${var.right})",
362
645
      ConstString("Rect"), objc_flags);
363
645
  AddStringSummary(objc_category_sp, "{(v=${var.v}, h=${var.h})}",
364
645
                   ConstString("Point"), objc_flags);
365
645
  AddStringSummary(objc_category_sp,
366
645
                   "${var.month}/${var.day}/${var.year}  ${var.hour} "
367
645
                   ":${var.minute} :${var.second} dayOfWeek:${var.dayOfWeek}",
368
645
                   ConstString("DateTimeRect *"), objc_flags);
369
645
  AddStringSummary(objc_category_sp, "${var.ld.month}/${var.ld.day}/"
370
645
                                     "${var.ld.year} ${var.ld.hour} "
371
645
                                     ":${var.ld.minute} :${var.ld.second} "
372
645
                                     "dayOfWeek:${var.ld.dayOfWeek}",
373
645
                   ConstString("LongDateRect"), objc_flags);
374
645
  AddStringSummary(objc_category_sp, "(x=${var.x}, y=${var.y})",
375
645
                   ConstString("HIPoint"), objc_flags);
376
645
  AddStringSummary(objc_category_sp, "origin=${var.origin} size=${var.size}",
377
645
                   ConstString("HIRect"), objc_flags);
378
379
645
  TypeSummaryImpl::Flags appkit_flags;
380
645
  appkit_flags.SetCascades(true)
381
645
      .SetSkipPointers(false)
382
645
      .SetSkipReferences(false)
383
645
      .SetDontShowChildren(true)
384
645
      .SetDontShowValue(false)
385
645
      .SetShowMembersOneLiner(false)
386
645
      .SetHideItemNames(false);
387
388
645
  appkit_flags.SetDontShowChildren(false);
389
390
645
  AddCXXSummary(
391
645
      objc_category_sp, lldb_private::formatters::NSArraySummaryProvider,
392
645
      "NSArray summary provider", ConstString("NSArray"), appkit_flags);
393
645
  AddCXXSummary(
394
645
      objc_category_sp, lldb_private::formatters::NSArraySummaryProvider,
395
645
      "NSArray summary provider", ConstString("NSConstantArray"), appkit_flags);
396
645
  AddCXXSummary(
397
645
      objc_category_sp, lldb_private::formatters::NSArraySummaryProvider,
398
645
      "NSArray summary provider", ConstString("NSMutableArray"), appkit_flags);
399
645
  AddCXXSummary(
400
645
      objc_category_sp, lldb_private::formatters::NSArraySummaryProvider,
401
645
      "NSArray summary provider", ConstString("__NSArrayI"), appkit_flags);
402
645
  AddCXXSummary(
403
645
      objc_category_sp, lldb_private::formatters::NSArraySummaryProvider,
404
645
      "NSArray summary provider", ConstString("__NSArray0"), appkit_flags);
405
645
  AddCXXSummary(objc_category_sp,
406
645
                lldb_private::formatters::NSArraySummaryProvider,
407
645
                "NSArray summary provider",
408
645
                ConstString("__NSSingleObjectArrayI"), appkit_flags);
409
645
  AddCXXSummary(
410
645
      objc_category_sp, lldb_private::formatters::NSArraySummaryProvider,
411
645
      "NSArray summary provider", ConstString("__NSArrayM"), appkit_flags);
412
645
  AddCXXSummary(
413
645
      objc_category_sp, lldb_private::formatters::NSArraySummaryProvider,
414
645
      "NSArray summary provider", ConstString("__NSCFArray"), appkit_flags);
415
645
  AddCXXSummary(
416
645
      objc_category_sp, lldb_private::formatters::NSArraySummaryProvider,
417
645
      "NSArray summary provider", ConstString("_NSCallStackArray"), appkit_flags);
418
645
  AddCXXSummary(
419
645
      objc_category_sp, lldb_private::formatters::NSArraySummaryProvider,
420
645
      "NSArray summary provider", ConstString("CFArrayRef"), appkit_flags);
421
645
  AddCXXSummary(objc_category_sp,
422
645
                lldb_private::formatters::NSArraySummaryProvider,
423
645
                "NSArray summary provider", ConstString("CFMutableArrayRef"),
424
645
                appkit_flags);
425
426
645
  AddCXXSummary(objc_category_sp,
427
645
                lldb_private::formatters::NSDictionarySummaryProvider<false>,
428
645
                "NSDictionary summary provider", ConstString("NSDictionary"),
429
645
                appkit_flags);
430
645
  AddCXXSummary(objc_category_sp,
431
645
                lldb_private::formatters::NSDictionarySummaryProvider<false>,
432
645
                "NSDictionary summary provider",
433
645
                ConstString("NSConstantDictionary"), appkit_flags);
434
645
  AddCXXSummary(objc_category_sp,
435
645
                lldb_private::formatters::NSDictionarySummaryProvider<false>,
436
645
                "NSDictionary summary provider",
437
645
                ConstString("NSMutableDictionary"), appkit_flags);
438
645
  AddCXXSummary(objc_category_sp,
439
645
                lldb_private::formatters::NSDictionarySummaryProvider<false>,
440
645
                "NSDictionary summary provider",
441
645
                ConstString("__NSCFDictionary"), appkit_flags);
442
645
  AddCXXSummary(objc_category_sp,
443
645
                lldb_private::formatters::NSDictionarySummaryProvider<false>,
444
645
                "NSDictionary summary provider", ConstString("__NSDictionaryI"),
445
645
                appkit_flags);
446
645
  AddCXXSummary(objc_category_sp,
447
645
                lldb_private::formatters::NSDictionarySummaryProvider<false>,
448
645
                "NSDictionary summary provider",
449
645
                ConstString("__NSSingleEntryDictionaryI"), appkit_flags);
450
645
  AddCXXSummary(objc_category_sp,
451
645
                lldb_private::formatters::NSDictionarySummaryProvider<false>,
452
645
                "NSDictionary summary provider", ConstString("__NSDictionaryM"),
453
645
                appkit_flags);
454
645
  AddCXXSummary(objc_category_sp,
455
645
                lldb_private::formatters::NSDictionarySummaryProvider<true>,
456
645
                "NSDictionary summary provider", ConstString("CFDictionaryRef"),
457
645
                appkit_flags);
458
645
  AddCXXSummary(objc_category_sp,
459
645
                lldb_private::formatters::NSDictionarySummaryProvider<true>,
460
645
                "NSDictionary summary provider", ConstString("__CFDictionary"),
461
645
                appkit_flags);
462
645
  AddCXXSummary(objc_category_sp,
463
645
                lldb_private::formatters::NSDictionarySummaryProvider<true>,
464
645
                "NSDictionary summary provider",
465
645
                ConstString("CFMutableDictionaryRef"), appkit_flags);
466
467
645
  AddCXXSummary(objc_category_sp,
468
645
                lldb_private::formatters::NSSetSummaryProvider<false>,
469
645
                "NSSet summary", ConstString("NSSet"), appkit_flags);
470
645
  AddCXXSummary(
471
645
      objc_category_sp, lldb_private::formatters::NSSetSummaryProvider<false>,
472
645
      "NSMutableSet summary", ConstString("NSMutableSet"), appkit_flags);
473
645
  AddCXXSummary(objc_category_sp,
474
645
                lldb_private::formatters::NSSetSummaryProvider<true>,
475
645
                "CFSetRef summary", ConstString("CFSetRef"), appkit_flags);
476
645
  AddCXXSummary(
477
645
      objc_category_sp, lldb_private::formatters::NSSetSummaryProvider<true>,
478
645
      "CFMutableSetRef summary", ConstString("CFMutableSetRef"), appkit_flags);
479
645
  AddCXXSummary(objc_category_sp,
480
645
                lldb_private::formatters::NSSetSummaryProvider<false>,
481
645
                "__NSCFSet summary", ConstString("__NSCFSet"), appkit_flags);
482
645
  AddCXXSummary(objc_category_sp,
483
645
                lldb_private::formatters::NSSetSummaryProvider<false>,
484
645
                "__CFSet summary", ConstString("__CFSet"), appkit_flags);
485
645
  AddCXXSummary(objc_category_sp,
486
645
                lldb_private::formatters::NSSetSummaryProvider<false>,
487
645
                "__NSSetI summary", ConstString("__NSSetI"), appkit_flags);
488
645
  AddCXXSummary(objc_category_sp,
489
645
                lldb_private::formatters::NSSetSummaryProvider<false>,
490
645
                "__NSSetM summary", ConstString("__NSSetM"), appkit_flags);
491
645
  AddCXXSummary(
492
645
      objc_category_sp, lldb_private::formatters::NSSetSummaryProvider<false>,
493
645
      "NSCountedSet summary", ConstString("NSCountedSet"), appkit_flags);
494
645
  AddCXXSummary(
495
645
      objc_category_sp, lldb_private::formatters::NSSetSummaryProvider<false>,
496
645
      "NSMutableSet summary", ConstString("NSMutableSet"), appkit_flags);
497
645
  AddCXXSummary(
498
645
      objc_category_sp, lldb_private::formatters::NSSetSummaryProvider<false>,
499
645
      "NSOrderedSet summary", ConstString("NSOrderedSet"), appkit_flags);
500
645
  AddCXXSummary(
501
645
      objc_category_sp, lldb_private::formatters::NSSetSummaryProvider<false>,
502
645
      "__NSOrderedSetI summary", ConstString("__NSOrderedSetI"), appkit_flags);
503
645
  AddCXXSummary(
504
645
      objc_category_sp, lldb_private::formatters::NSSetSummaryProvider<false>,
505
645
      "__NSOrderedSetM summary", ConstString("__NSOrderedSetM"), appkit_flags);
506
507
645
  AddCXXSummary(
508
645
      objc_category_sp, lldb_private::formatters::NSError_SummaryProvider,
509
645
      "NSError summary provider", ConstString("NSError"), appkit_flags);
510
645
  AddCXXSummary(
511
645
      objc_category_sp, lldb_private::formatters::NSException_SummaryProvider,
512
645
      "NSException summary provider", ConstString("NSException"), appkit_flags);
513
514
  // AddSummary(appkit_category_sp, "${var.key%@} -> ${var.value%@}",
515
  // ConstString("$_lldb_typegen_nspair"), appkit_flags);
516
517
645
  appkit_flags.SetDontShowChildren(true);
518
519
645
  AddCXXSynthetic(objc_category_sp,
520
645
                  lldb_private::formatters::NSArraySyntheticFrontEndCreator,
521
645
                  "NSArray synthetic children", ConstString("__NSArrayM"),
522
645
                  ScriptedSyntheticChildren::Flags());
523
645
  AddCXXSynthetic(objc_category_sp,
524
645
                  lldb_private::formatters::NSArraySyntheticFrontEndCreator,
525
645
                  "NSArray synthetic children", ConstString("__NSArrayI"),
526
645
                  ScriptedSyntheticChildren::Flags());
527
645
  AddCXXSynthetic(objc_category_sp,
528
645
                  lldb_private::formatters::NSArraySyntheticFrontEndCreator,
529
645
                  "NSArray synthetic children", ConstString("__NSArray0"),
530
645
                  ScriptedSyntheticChildren::Flags());
531
645
  AddCXXSynthetic(objc_category_sp,
532
645
                  lldb_private::formatters::NSArraySyntheticFrontEndCreator,
533
645
                  "NSArray synthetic children",
534
645
                  ConstString("__NSSingleObjectArrayI"),
535
645
                  ScriptedSyntheticChildren::Flags());
536
645
  AddCXXSynthetic(objc_category_sp,
537
645
                  lldb_private::formatters::NSArraySyntheticFrontEndCreator,
538
645
                  "NSArray synthetic children", ConstString("NSArray"),
539
645
                  ScriptedSyntheticChildren::Flags());
540
645
  AddCXXSynthetic(objc_category_sp,
541
645
                  lldb_private::formatters::NSArraySyntheticFrontEndCreator,
542
645
                  "NSArray synthetic children", ConstString("NSConstantArray"),
543
645
                  ScriptedSyntheticChildren::Flags());
544
645
  AddCXXSynthetic(objc_category_sp,
545
645
                  lldb_private::formatters::NSArraySyntheticFrontEndCreator,
546
645
                  "NSArray synthetic children", ConstString("NSMutableArray"),
547
645
                  ScriptedSyntheticChildren::Flags());
548
645
  AddCXXSynthetic(objc_category_sp,
549
645
                  lldb_private::formatters::NSArraySyntheticFrontEndCreator,
550
645
                  "NSArray synthetic children", ConstString("__NSCFArray"),
551
645
                  ScriptedSyntheticChildren::Flags());
552
645
  AddCXXSynthetic(objc_category_sp,
553
645
                  lldb_private::formatters::NSArraySyntheticFrontEndCreator,
554
645
                  "NSArray synthetic children", ConstString("_NSCallStackArray"),
555
645
                  ScriptedSyntheticChildren::Flags());
556
645
  AddCXXSynthetic(objc_category_sp,
557
645
                  lldb_private::formatters::NSArraySyntheticFrontEndCreator,
558
645
                  "NSArray synthetic children",
559
645
                  ConstString("CFMutableArrayRef"),
560
645
                  ScriptedSyntheticChildren::Flags());
561
645
  AddCXXSynthetic(objc_category_sp,
562
645
                  lldb_private::formatters::NSArraySyntheticFrontEndCreator,
563
645
                  "NSArray synthetic children", ConstString("CFArrayRef"),
564
645
                  ScriptedSyntheticChildren::Flags());
565
566
645
  AddCXXSynthetic(
567
645
      objc_category_sp,
568
645
      lldb_private::formatters::NSDictionarySyntheticFrontEndCreator,
569
645
      "NSDictionary synthetic children", ConstString("__NSDictionaryM"),
570
645
      ScriptedSyntheticChildren::Flags());
571
645
  AddCXXSynthetic(
572
645
      objc_category_sp,
573
645
      lldb_private::formatters::NSDictionarySyntheticFrontEndCreator,
574
645
      "NSDictionary synthetic children", ConstString("NSConstantDictionary"),
575
645
      ScriptedSyntheticChildren::Flags());
576
645
  AddCXXSynthetic(
577
645
      objc_category_sp,
578
645
      lldb_private::formatters::NSDictionarySyntheticFrontEndCreator,
579
645
      "NSDictionary synthetic children", ConstString("__NSDictionaryI"),
580
645
      ScriptedSyntheticChildren::Flags());
581
645
  AddCXXSynthetic(
582
645
      objc_category_sp,
583
645
      lldb_private::formatters::NSDictionarySyntheticFrontEndCreator,
584
645
      "NSDictionary synthetic children",
585
645
      ConstString("__NSSingleEntryDictionaryI"),
586
645
      ScriptedSyntheticChildren::Flags());
587
645
  AddCXXSynthetic(
588
645
      objc_category_sp,
589
645
      lldb_private::formatters::NSDictionarySyntheticFrontEndCreator,
590
645
      "NSDictionary synthetic children", ConstString("__NSCFDictionary"),
591
645
      ScriptedSyntheticChildren::Flags());
592
645
  AddCXXSynthetic(
593
645
      objc_category_sp,
594
645
      lldb_private::formatters::NSDictionarySyntheticFrontEndCreator,
595
645
      "NSDictionary synthetic children", ConstString("NSDictionary"),
596
645
      ScriptedSyntheticChildren::Flags());
597
645
  AddCXXSynthetic(
598
645
      objc_category_sp,
599
645
      lldb_private::formatters::NSDictionarySyntheticFrontEndCreator,
600
645
      "NSDictionary synthetic children", ConstString("NSMutableDictionary"),
601
645
      ScriptedSyntheticChildren::Flags());
602
645
  AddCXXSynthetic(
603
645
      objc_category_sp,
604
645
      lldb_private::formatters::NSDictionarySyntheticFrontEndCreator,
605
645
      "NSDictionary synthetic children", ConstString("CFDictionaryRef"),
606
645
      ScriptedSyntheticChildren::Flags());
607
645
  AddCXXSynthetic(
608
645
      objc_category_sp,
609
645
      lldb_private::formatters::NSDictionarySyntheticFrontEndCreator,
610
645
      "NSDictionary synthetic children", ConstString("CFMutableDictionaryRef"),
611
645
      ScriptedSyntheticChildren::Flags());
612
645
  AddCXXSynthetic(
613
645
      objc_category_sp,
614
645
      lldb_private::formatters::NSDictionarySyntheticFrontEndCreator,
615
645
      "NSDictionary synthetic children", ConstString("__CFDictionary"),
616
645
      ScriptedSyntheticChildren::Flags());
617
618
645
  AddCXXSynthetic(objc_category_sp,
619
645
                  lldb_private::formatters::NSErrorSyntheticFrontEndCreator,
620
645
                  "NSError synthetic children", ConstString("NSError"),
621
645
                  ScriptedSyntheticChildren::Flags());
622
645
  AddCXXSynthetic(objc_category_sp,
623
645
                  lldb_private::formatters::NSExceptionSyntheticFrontEndCreator,
624
645
                  "NSException synthetic children", ConstString("NSException"),
625
645
                  ScriptedSyntheticChildren::Flags());
626
627
645
  AddCXXSynthetic(objc_category_sp,
628
645
                  lldb_private::formatters::NSSetSyntheticFrontEndCreator,
629
645
                  "NSSet synthetic children", ConstString("NSSet"),
630
645
                  ScriptedSyntheticChildren::Flags());
631
645
  AddCXXSynthetic(objc_category_sp,
632
645
                  lldb_private::formatters::NSSetSyntheticFrontEndCreator,
633
645
                  "__NSSetI synthetic children", ConstString("__NSSetI"),
634
645
                  ScriptedSyntheticChildren::Flags());
635
645
  AddCXXSynthetic(objc_category_sp,
636
645
                  lldb_private::formatters::NSSetSyntheticFrontEndCreator,
637
645
                  "__NSSetM synthetic children", ConstString("__NSSetM"),
638
645
                  ScriptedSyntheticChildren::Flags());
639
645
  AddCXXSynthetic(objc_category_sp,
640
645
                  lldb_private::formatters::NSSetSyntheticFrontEndCreator,
641
645
                  "__NSCFSet synthetic children", ConstString("__NSCFSet"),
642
645
                  ScriptedSyntheticChildren::Flags());
643
645
  AddCXXSynthetic(objc_category_sp,
644
645
                  lldb_private::formatters::NSSetSyntheticFrontEndCreator,
645
645
                  "CFSetRef synthetic children", ConstString("CFSetRef"),
646
645
                  ScriptedSyntheticChildren::Flags());
647
648
645
  AddCXXSynthetic(
649
645
      objc_category_sp, lldb_private::formatters::NSSetSyntheticFrontEndCreator,
650
645
      "NSMutableSet synthetic children", ConstString("NSMutableSet"),
651
645
      ScriptedSyntheticChildren::Flags());
652
645
  AddCXXSynthetic(
653
645
      objc_category_sp, lldb_private::formatters::NSSetSyntheticFrontEndCreator,
654
645
      "NSOrderedSet synthetic children", ConstString("NSOrderedSet"),
655
645
      ScriptedSyntheticChildren::Flags());
656
645
  AddCXXSynthetic(
657
645
      objc_category_sp, lldb_private::formatters::NSSetSyntheticFrontEndCreator,
658
645
      "__NSOrderedSetI synthetic children", ConstString("__NSOrderedSetI"),
659
645
      ScriptedSyntheticChildren::Flags());
660
645
  AddCXXSynthetic(
661
645
      objc_category_sp, lldb_private::formatters::NSSetSyntheticFrontEndCreator,
662
645
      "__NSOrderedSetM synthetic children", ConstString("__NSOrderedSetM"),
663
645
      ScriptedSyntheticChildren::Flags());
664
645
  AddCXXSynthetic(objc_category_sp,
665
645
                  lldb_private::formatters::NSSetSyntheticFrontEndCreator,
666
645
                  "__CFSet synthetic children", ConstString("__CFSet"),
667
645
                  ScriptedSyntheticChildren::Flags());
668
669
645
  AddCXXSynthetic(objc_category_sp,
670
645
                  lldb_private::formatters::NSIndexPathSyntheticFrontEndCreator,
671
645
                  "NSIndexPath synthetic children", ConstString("NSIndexPath"),
672
645
                  ScriptedSyntheticChildren::Flags());
673
674
645
  AddCXXSummary(
675
645
      objc_category_sp, lldb_private::formatters::CFBagSummaryProvider,
676
645
      "CFBag summary provider", ConstString("CFBagRef"), appkit_flags);
677
645
  AddCXXSummary(objc_category_sp,
678
645
                lldb_private::formatters::CFBagSummaryProvider,
679
645
                "CFBag summary provider", ConstString("__CFBag"), appkit_flags);
680
645
  AddCXXSummary(objc_category_sp,
681
645
                lldb_private::formatters::CFBagSummaryProvider,
682
645
                "CFBag summary provider", ConstString("const struct __CFBag"),
683
645
                appkit_flags);
684
645
  AddCXXSummary(
685
645
      objc_category_sp, lldb_private::formatters::CFBagSummaryProvider,
686
645
      "CFBag summary provider", ConstString("CFMutableBagRef"), appkit_flags);
687
688
645
  AddCXXSummary(objc_category_sp,
689
645
                lldb_private::formatters::CFBinaryHeapSummaryProvider,
690
645
                "CFBinaryHeap summary provider", ConstString("CFBinaryHeapRef"),
691
645
                appkit_flags);
692
645
  AddCXXSummary(objc_category_sp,
693
645
                lldb_private::formatters::CFBinaryHeapSummaryProvider,
694
645
                "CFBinaryHeap summary provider", ConstString("__CFBinaryHeap"),
695
645
                appkit_flags);
696
697
645
  AddCXXSummary(
698
645
      objc_category_sp, lldb_private::formatters::NSStringSummaryProvider,
699
645
      "NSString summary provider", ConstString("NSString"), appkit_flags);
700
645
  AddCXXSummary(
701
645
      objc_category_sp, lldb_private::formatters::NSStringSummaryProvider,
702
645
      "NSString summary provider", ConstString("CFStringRef"), appkit_flags);
703
645
  AddCXXSummary(
704
645
      objc_category_sp, lldb_private::formatters::NSStringSummaryProvider,
705
645
      "NSString summary provider", ConstString("__CFString"), appkit_flags);
706
645
  AddCXXSummary(objc_category_sp,
707
645
                lldb_private::formatters::NSStringSummaryProvider,
708
645
                "NSString summary provider", ConstString("CFMutableStringRef"),
709
645
                appkit_flags);
710
645
  AddCXXSummary(objc_category_sp,
711
645
                lldb_private::formatters::NSStringSummaryProvider,
712
645
                "NSString summary provider", ConstString("NSMutableString"),
713
645
                appkit_flags);
714
645
  AddCXXSummary(objc_category_sp,
715
645
                lldb_private::formatters::NSStringSummaryProvider,
716
645
                "NSString summary provider",
717
645
                ConstString("__NSCFConstantString"), appkit_flags);
718
645
  AddCXXSummary(
719
645
      objc_category_sp, lldb_private::formatters::NSStringSummaryProvider,
720
645
      "NSString summary provider", ConstString("__NSCFString"), appkit_flags);
721
645
  AddCXXSummary(objc_category_sp,
722
645
                lldb_private::formatters::NSStringSummaryProvider,
723
645
                "NSString summary provider", ConstString("NSCFConstantString"),
724
645
                appkit_flags);
725
645
  AddCXXSummary(
726
645
      objc_category_sp, lldb_private::formatters::NSStringSummaryProvider,
727
645
      "NSString summary provider", ConstString("NSCFString"), appkit_flags);
728
645
  AddCXXSummary(
729
645
      objc_category_sp, lldb_private::formatters::NSStringSummaryProvider,
730
645
      "NSString summary provider", ConstString("NSPathStore2"), appkit_flags);
731
645
  AddCXXSummary(objc_category_sp,
732
645
                lldb_private::formatters::NSStringSummaryProvider,
733
645
                "NSString summary provider",
734
645
                ConstString("NSTaggedPointerString"), appkit_flags);
735
736
645
  AddCXXSummary(objc_category_sp,
737
645
                lldb_private::formatters::NSAttributedStringSummaryProvider,
738
645
                "NSAttributedString summary provider",
739
645
                ConstString("NSAttributedString"), appkit_flags);
740
645
  AddCXXSummary(
741
645
      objc_category_sp,
742
645
      lldb_private::formatters::NSMutableAttributedStringSummaryProvider,
743
645
      "NSMutableAttributedString summary provider",
744
645
      ConstString("NSMutableAttributedString"), appkit_flags);
745
645
  AddCXXSummary(
746
645
      objc_category_sp,
747
645
      lldb_private::formatters::NSMutableAttributedStringSummaryProvider,
748
645
      "NSMutableAttributedString summary provider",
749
645
      ConstString("NSConcreteMutableAttributedString"), appkit_flags);
750
751
645
  AddCXXSummary(
752
645
      objc_category_sp, lldb_private::formatters::NSBundleSummaryProvider,
753
645
      "NSBundle summary provider", ConstString("NSBundle"), appkit_flags);
754
755
645
  AddCXXSummary(objc_category_sp,
756
645
                lldb_private::formatters::NSDataSummaryProvider<false>,
757
645
                "NSData summary provider", ConstString("NSData"), appkit_flags);
758
645
  AddCXXSummary(
759
645
      objc_category_sp, lldb_private::formatters::NSDataSummaryProvider<false>,
760
645
      "NSData summary provider", ConstString("_NSInlineData"), appkit_flags);
761
645
  AddCXXSummary(
762
645
      objc_category_sp, lldb_private::formatters::NSDataSummaryProvider<false>,
763
645
      "NSData summary provider", ConstString("NSConcreteData"), appkit_flags);
764
645
  AddCXXSummary(objc_category_sp,
765
645
                lldb_private::formatters::NSDataSummaryProvider<false>,
766
645
                "NSData summary provider", ConstString("NSConcreteMutableData"),
767
645
                appkit_flags);
768
645
  AddCXXSummary(
769
645
      objc_category_sp, lldb_private::formatters::NSDataSummaryProvider<false>,
770
645
      "NSData summary provider", ConstString("NSMutableData"), appkit_flags);
771
645
  AddCXXSummary(
772
645
      objc_category_sp, lldb_private::formatters::NSDataSummaryProvider<false>,
773
645
      "NSData summary provider", ConstString("__NSCFData"), appkit_flags);
774
645
  AddCXXSummary(
775
645
      objc_category_sp, lldb_private::formatters::NSDataSummaryProvider<true>,
776
645
      "NSData summary provider", ConstString("CFDataRef"), appkit_flags);
777
645
  AddCXXSummary(
778
645
      objc_category_sp, lldb_private::formatters::NSDataSummaryProvider<true>,
779
645
      "NSData summary provider", ConstString("CFMutableDataRef"), appkit_flags);
780
781
645
  AddCXXSummary(
782
645
      objc_category_sp, lldb_private::formatters::NSMachPortSummaryProvider,
783
645
      "NSMachPort summary provider", ConstString("NSMachPort"), appkit_flags);
784
785
645
  AddCXXSummary(objc_category_sp,
786
645
                lldb_private::formatters::NSNotificationSummaryProvider,
787
645
                "NSNotification summary provider",
788
645
                ConstString("NSNotification"), appkit_flags);
789
645
  AddCXXSummary(objc_category_sp,
790
645
                lldb_private::formatters::NSNotificationSummaryProvider,
791
645
                "NSNotification summary provider",
792
645
                ConstString("NSConcreteNotification"), appkit_flags);
793
794
645
  AddCXXSummary(
795
645
      objc_category_sp, lldb_private::formatters::NSNumberSummaryProvider,
796
645
      "NSNumber summary provider", ConstString("NSNumber"), appkit_flags);
797
645
  AddCXXSummary(objc_category_sp,
798
645
                lldb_private::formatters::NSNumberSummaryProvider,
799
645
                "NSNumber summary provider",
800
645
                ConstString("NSConstantIntegerNumber"), appkit_flags);
801
645
  AddCXXSummary(objc_category_sp,
802
645
                lldb_private::formatters::NSNumberSummaryProvider,
803
645
                "NSNumber summary provider",
804
645
                ConstString("NSConstantDoubleNumber"), appkit_flags);
805
645
  AddCXXSummary(objc_category_sp,
806
645
                lldb_private::formatters::NSNumberSummaryProvider,
807
645
                "NSNumber summary provider",
808
645
                ConstString("NSConstantFloatNumber"), appkit_flags);
809
645
  AddCXXSummary(
810
645
      objc_category_sp, lldb_private::formatters::NSNumberSummaryProvider,
811
645
      "CFNumberRef summary provider", ConstString("CFNumberRef"), appkit_flags);
812
645
  AddCXXSummary(
813
645
      objc_category_sp, lldb_private::formatters::NSNumberSummaryProvider,
814
645
      "NSNumber summary provider", ConstString("__NSCFBoolean"), appkit_flags);
815
645
  AddCXXSummary(
816
645
      objc_category_sp, lldb_private::formatters::NSNumberSummaryProvider,
817
645
      "NSNumber summary provider", ConstString("__NSCFNumber"), appkit_flags);
818
645
  AddCXXSummary(
819
645
      objc_category_sp, lldb_private::formatters::NSNumberSummaryProvider,
820
645
      "NSNumber summary provider", ConstString("NSCFBoolean"), appkit_flags);
821
645
  AddCXXSummary(
822
645
      objc_category_sp, lldb_private::formatters::NSNumberSummaryProvider,
823
645
      "NSNumber summary provider", ConstString("NSCFNumber"), appkit_flags);
824
645
  AddCXXSummary(objc_category_sp,
825
645
                lldb_private::formatters::NSNumberSummaryProvider,
826
645
                "NSDecimalNumber summary provider",
827
645
                ConstString("NSDecimalNumber"), appkit_flags);
828
829
645
  AddCXXSummary(objc_category_sp,
830
645
                lldb_private::formatters::NSURLSummaryProvider,
831
645
                "NSURL summary provider", ConstString("NSURL"), appkit_flags);
832
645
  AddCXXSummary(
833
645
      objc_category_sp, lldb_private::formatters::NSURLSummaryProvider,
834
645
      "NSURL summary provider", ConstString("CFURLRef"), appkit_flags);
835
836
645
  AddCXXSummary(objc_category_sp,
837
645
                lldb_private::formatters::NSDateSummaryProvider,
838
645
                "NSDate summary provider", ConstString("NSDate"), appkit_flags);
839
645
  AddCXXSummary(
840
645
      objc_category_sp, lldb_private::formatters::NSDateSummaryProvider,
841
645
      "NSDate summary provider", ConstString("__NSDate"), appkit_flags);
842
645
  AddCXXSummary(
843
645
      objc_category_sp, lldb_private::formatters::NSDateSummaryProvider,
844
645
      "NSDate summary provider", ConstString("__NSTaggedDate"), appkit_flags);
845
645
  AddCXXSummary(
846
645
      objc_category_sp, lldb_private::formatters::NSDateSummaryProvider,
847
645
      "NSDate summary provider", ConstString("NSCalendarDate"), appkit_flags);
848
849
645
  AddCXXSummary(
850
645
      objc_category_sp, lldb_private::formatters::NSTimeZoneSummaryProvider,
851
645
      "NSTimeZone summary provider", ConstString("NSTimeZone"), appkit_flags);
852
645
  AddCXXSummary(objc_category_sp,
853
645
                lldb_private::formatters::NSTimeZoneSummaryProvider,
854
645
                "NSTimeZone summary provider", ConstString("CFTimeZoneRef"),
855
645
                appkit_flags);
856
645
  AddCXXSummary(
857
645
      objc_category_sp, lldb_private::formatters::NSTimeZoneSummaryProvider,
858
645
      "NSTimeZone summary provider", ConstString("__NSTimeZone"), appkit_flags);
859
860
  // CFAbsoluteTime is actually a double rather than a pointer to an object we
861
  // do not care about the numeric value, since it is probably meaningless to
862
  // users
863
645
  appkit_flags.SetDontShowValue(true);
864
645
  AddCXXSummary(objc_category_sp,
865
645
                lldb_private::formatters::CFAbsoluteTimeSummaryProvider,
866
645
                "CFAbsoluteTime summary provider",
867
645
                ConstString("CFAbsoluteTime"), appkit_flags);
868
645
  appkit_flags.SetDontShowValue(false);
869
870
645
  AddCXXSummary(
871
645
      objc_category_sp, lldb_private::formatters::NSIndexSetSummaryProvider,
872
645
      "NSIndexSet summary provider", ConstString("NSIndexSet"), appkit_flags);
873
645
  AddCXXSummary(objc_category_sp,
874
645
                lldb_private::formatters::NSIndexSetSummaryProvider,
875
645
                "NSIndexSet summary provider", ConstString("NSMutableIndexSet"),
876
645
                appkit_flags);
877
878
645
  AddStringSummary(objc_category_sp,
879
645
                   "@\"${var.month%d}/${var.day%d}/${var.year%d} "
880
645
                   "${var.hour%d}:${var.minute%d}:${var.second}\"",
881
645
                   ConstString("CFGregorianDate"), appkit_flags);
882
883
645
  AddCXXSummary(objc_category_sp,
884
645
                lldb_private::formatters::CFBitVectorSummaryProvider,
885
645
                "CFBitVector summary provider", ConstString("CFBitVectorRef"),
886
645
                appkit_flags);
887
645
  AddCXXSummary(objc_category_sp,
888
645
                lldb_private::formatters::CFBitVectorSummaryProvider,
889
645
                "CFBitVector summary provider",
890
645
                ConstString("CFMutableBitVectorRef"), appkit_flags);
891
645
  AddCXXSummary(objc_category_sp,
892
645
                lldb_private::formatters::CFBitVectorSummaryProvider,
893
645
                "CFBitVector summary provider", ConstString("__CFBitVector"),
894
645
                appkit_flags);
895
645
  AddCXXSummary(objc_category_sp,
896
645
                lldb_private::formatters::CFBitVectorSummaryProvider,
897
645
                "CFBitVector summary provider",
898
645
                ConstString("__CFMutableBitVector"), appkit_flags);
899
645
}
900
901
645
static void LoadCoreMediaFormatters(TypeCategoryImplSP objc_category_sp) {
902
645
  if (!objc_category_sp)
903
0
    return;
904
905
645
  TypeSummaryImpl::Flags cm_flags;
906
645
  cm_flags.SetCascades(true)
907
645
      .SetDontShowChildren(false)
908
645
      .SetDontShowValue(false)
909
645
      .SetHideItemNames(false)
910
645
      .SetShowMembersOneLiner(false)
911
645
      .SetSkipPointers(false)
912
645
      .SetSkipReferences(false);
913
914
645
  AddCXXSummary(objc_category_sp,
915
645
                lldb_private::formatters::CMTimeSummaryProvider,
916
645
                "CMTime summary provider", ConstString("CMTime"), cm_flags);
917
645
}
918
919
645
lldb::TypeCategoryImplSP ObjCLanguage::GetFormatters() {
920
645
  static llvm::once_flag g_initialize;
921
645
  static TypeCategoryImplSP g_category;
922
923
645
  llvm::call_once(g_initialize, [this]() -> void {
924
645
    DataVisualization::Categories::GetCategory(ConstString(GetPluginName()),
925
645
                                               g_category);
926
645
    if (g_category) {
927
645
      LoadCoreMediaFormatters(g_category);
928
645
      LoadObjCFormatters(g_category);
929
645
    }
930
645
  });
931
645
  return g_category;
932
645
}
933
934
std::vector<ConstString>
935
ObjCLanguage::GetPossibleFormattersMatches(ValueObject &valobj,
936
39.2k
                                           lldb::DynamicValueType use_dynamic) {
937
39.2k
  std::vector<ConstString> result;
938
939
39.2k
  if (use_dynamic == lldb::eNoDynamicValues)
940
36.9k
    return result;
941
942
2.29k
  CompilerType compiler_type(valobj.GetCompilerType());
943
944
2.29k
  const bool check_cpp = false;
945
2.29k
  const bool check_objc = true;
946
2.29k
  bool canBeObjCDynamic =
947
2.29k
      compiler_type.IsPossibleDynamicType(nullptr, check_cpp, check_objc);
948
949
2.29k
  if (canBeObjCDynamic && 
ClangUtil::IsClangType(compiler_type)2.01k
) {
950
2.01k
    do {
951
2.01k
      lldb::ProcessSP process_sp = valobj.GetProcessSP();
952
2.01k
      if (!process_sp)
953
12
        break;
954
2.00k
      ObjCLanguageRuntime *runtime = ObjCLanguageRuntime::Get(*process_sp);
955
2.00k
      if (runtime == nullptr)
956
0
        break;
957
2.00k
      ObjCLanguageRuntime::ClassDescriptorSP objc_class_sp(
958
2.00k
          runtime->GetClassDescriptor(valobj));
959
2.00k
      if (!objc_class_sp)
960
52
        break;
961
1.94k
      if (ConstString name = objc_class_sp->GetClassName())
962
1.94k
        result.push_back(name);
963
1.94k
    } while (false);
964
2.01k
  }
965
966
0
  return result;
967
39.2k
}
968
969
24
std::unique_ptr<Language::TypeScavenger> ObjCLanguage::GetTypeScavenger() {
970
24
  class ObjCScavengerResult : public Language::TypeScavenger::Result {
971
24
  public:
972
24
    ObjCScavengerResult(CompilerType type)
973
24
        : Language::TypeScavenger::Result(), m_compiler_type(type) 
{}12
974
975
24
    bool IsValid() override { return m_compiler_type.IsValid(); }
976
977
24
    bool DumpToStream(Stream &stream, bool print_help_if_available) override {
978
12
      if (IsValid()) {
979
12
        m_compiler_type.DumpTypeDescription(&stream);
980
12
        stream.EOL();
981
12
        return true;
982
12
      }
983
0
      return false;
984
12
    }
985
986
24
  private:
987
24
    CompilerType m_compiler_type;
988
24
  };
989
990
24
  class ObjCRuntimeScavenger : public Language::TypeScavenger {
991
24
  protected:
992
24
    bool Find_Impl(ExecutionContextScope *exe_scope, const char *key,
993
24
                   ResultSet &results) override {
994
21
      bool result = false;
995
996
21
      if (auto *process = exe_scope->CalculateProcess().get()) {
997
18
        if (auto *objc_runtime = ObjCLanguageRuntime::Get(*process)) {
998
18
          if (auto *decl_vendor = objc_runtime->GetDeclVendor()) {
999
18
            ConstString name(key);
1000
18
            for (const CompilerType &type :
1001
18
                 decl_vendor->FindTypes(name, /*max_matches*/ UINT32_MAX)) {
1002
9
              result = true;
1003
9
              std::unique_ptr<Language::TypeScavenger::Result> result(
1004
9
                  new ObjCScavengerResult(type));
1005
9
              results.insert(std::move(result));
1006
9
            }
1007
18
          }
1008
18
        }
1009
18
      }
1010
1011
21
      return result;
1012
21
    }
1013
1014
24
    friend class lldb_private::ObjCLanguage;
1015
24
  };
1016
1017
24
  class ObjCModulesScavenger : public Language::TypeScavenger {
1018
24
  protected:
1019
24
    bool Find_Impl(ExecutionContextScope *exe_scope, const char *key,
1020
24
                   ResultSet &results) override {
1021
24
      bool result = false;
1022
1023
24
      if (auto *target = exe_scope->CalculateTarget().get()) {
1024
24
        auto *persistent_vars = llvm::cast<ClangPersistentVariables>(
1025
24
            target->GetPersistentExpressionStateForLanguage(
1026
24
                lldb::eLanguageTypeC));
1027
24
        if (std::shared_ptr<ClangModulesDeclVendor> clang_modules_decl_vendor =
1028
24
                persistent_vars->GetClangModulesDeclVendor()) {
1029
21
          ConstString key_cs(key);
1030
21
          auto types = clang_modules_decl_vendor->FindTypes(
1031
21
              key_cs, /*max_matches*/ UINT32_MAX);
1032
21
          if (!types.empty()) {
1033
3
            result = true;
1034
3
            std::unique_ptr<Language::TypeScavenger::Result> result(
1035
3
                new ObjCScavengerResult(types.front()));
1036
3
            results.insert(std::move(result));
1037
3
          }
1038
21
        }
1039
24
      }
1040
1041
24
      return result;
1042
24
    }
1043
1044
24
    friend class lldb_private::ObjCLanguage;
1045
24
  };
1046
  
1047
24
  class ObjCDebugInfoScavenger : public Language::ImageListTypeScavenger {
1048
24
  public:
1049
24
    CompilerType AdjustForInclusion(CompilerType &candidate) override {
1050
3
      LanguageType lang_type(candidate.GetMinimumLanguage());
1051
3
      if (!Language::LanguageIsObjC(lang_type))
1052
0
        return CompilerType();
1053
3
      if (candidate.IsTypedefType())
1054
0
        return candidate.GetTypedefedType();
1055
3
      return candidate;
1056
3
    }
1057
24
  };
1058
1059
24
  return std::unique_ptr<TypeScavenger>(
1060
24
      new Language::EitherTypeScavenger<ObjCModulesScavenger,
1061
24
                                        ObjCRuntimeScavenger,
1062
24
                                        ObjCDebugInfoScavenger>());
1063
24
}
1064
1065
bool ObjCLanguage::GetFormatterPrefixSuffix(ValueObject &valobj,
1066
                                            ConstString type_hint,
1067
                                            std::string &prefix,
1068
2.29k
                                            std::string &suffix) {
1069
2.29k
  static ConstString g_CFBag("CFBag");
1070
2.29k
  static ConstString g_CFBinaryHeap("CFBinaryHeap");
1071
1072
2.29k
  static ConstString g_NSNumberChar("NSNumber:char");
1073
2.29k
  static ConstString g_NSNumberShort("NSNumber:short");
1074
2.29k
  static ConstString g_NSNumberInt("NSNumber:int");
1075
2.29k
  static ConstString g_NSNumberLong("NSNumber:long");
1076
2.29k
  static ConstString g_NSNumberInt128("NSNumber:int128_t");
1077
2.29k
  static ConstString g_NSNumberFloat("NSNumber:float");
1078
2.29k
  static ConstString g_NSNumberDouble("NSNumber:double");
1079
1080
2.29k
  static ConstString g_NSData("NSData");
1081
2.29k
  static ConstString g_NSArray("NSArray");
1082
2.29k
  static ConstString g_NSString("NSString");
1083
2.29k
  static ConstString g_NSStringStar("NSString*");
1084
1085
2.29k
  if (type_hint.IsEmpty())
1086
0
    return false;
1087
1088
2.29k
  prefix.clear();
1089
2.29k
  suffix.clear();
1090
1091
2.29k
  if (type_hint == g_CFBag || type_hint == g_CFBinaryHeap) {
1092
15
    prefix = "@";
1093
15
    return true;
1094
15
  }
1095
1096
2.27k
  if (type_hint == g_NSNumberChar) {
1097
33
    prefix = "(char)";
1098
33
    return true;
1099
33
  }
1100
2.24k
  if (type_hint == g_NSNumberShort) {
1101
21
    prefix = "(short)";
1102
21
    return true;
1103
21
  }
1104
2.22k
  if (type_hint == g_NSNumberInt) {
1105
261
    prefix = "(int)";
1106
261
    return true;
1107
261
  }
1108
1.96k
  if (type_hint == g_NSNumberLong) {
1109
66
    prefix = "(long)";
1110
66
    return true;
1111
66
  }
1112
1.89k
  if (type_hint == g_NSNumberInt128) {
1113
33
    prefix = "(int128_t)";
1114
33
    return true;
1115
33
  }
1116
1.86k
  if (type_hint == g_NSNumberFloat) {
1117
33
    prefix = "(float)";
1118
33
    return true;
1119
33
  }
1120
1.83k
  if (type_hint == g_NSNumberDouble) {
1121
78
    prefix = "(double)";
1122
78
    return true;
1123
78
  }
1124
1125
1.75k
  if (type_hint == g_NSData || type_hint == g_NSArray) {
1126
175
    prefix = "@\"";
1127
175
    suffix = "\"";
1128
175
    return true;
1129
175
  }
1130
1131
1.57k
  if (type_hint == g_NSString || 
type_hint == g_NSStringStar303
) {
1132
1.27k
    prefix = "@";
1133
1.27k
    return true;
1134
1.27k
  }
1135
1136
303
  return false;
1137
1.57k
}
1138
1139
3.75k
bool ObjCLanguage::IsNilReference(ValueObject &valobj) {
1140
3.75k
  const uint32_t mask = eTypeIsObjC | eTypeIsPointer;
1141
3.75k
  bool isObjCpointer =
1142
3.75k
      (((valobj.GetCompilerType().GetTypeInfo(nullptr)) & mask) == mask);
1143
3.75k
  if (!isObjCpointer)
1144
545
    return false;
1145
3.20k
  bool canReadValue = true;
1146
3.20k
  bool isZero = valobj.GetValueAsUnsigned(0, &canReadValue) == 0;
1147
3.20k
  return canReadValue && 
isZero3.17k
;
1148
3.75k
}
1149
1150
1.26k
bool ObjCLanguage::IsSourceFile(llvm::StringRef file_path) const {
1151
1.26k
  const auto suffixes = {".h", ".m", ".M"};
1152
2.63k
  for (auto suffix : suffixes) {
1153
2.63k
    if (file_path.endswith_insensitive(suffix))
1154
1.14k
      return true;
1155
2.63k
  }
1156
115
  return false;
1157
1.26k
}