@@ -75,8 +75,7 @@ char AppleObjCRuntimeV2::ID = 0;
75
75
76
76
static const char *g_get_dynamic_class_info_name =
77
77
" __lldb_apple_objc_v2_get_dynamic_class_info" ;
78
- // Testing using the new C++11 raw string literals. If this breaks GCC then we
79
- // will need to revert to the code above...
78
+
80
79
static const char *g_get_dynamic_class_info_body = R"(
81
80
82
81
extern "C"
@@ -176,8 +175,7 @@ extern "C"
176
175
177
176
static const char *g_get_shared_cache_class_info_name =
178
177
" __lldb_apple_objc_v2_get_shared_cache_class_info" ;
179
- // Testing using the new C++11 raw string literals. If this breaks GCC then we
180
- // will need to revert to the code above...
178
+
181
179
static const char *g_get_shared_cache_class_info_body = R"(
182
180
183
181
extern "C"
@@ -297,7 +295,7 @@ __lldb_apple_objc_v2_get_shared_cache_class_info (void *objc_opt_ro_ptr,
297
295
DEBUG_PRINTF("clsOffset == invalidEntryOffset\n");
298
296
continue; // invalid offset
299
297
}
300
-
298
+
301
299
if (class_infos && idx < max_class_infos)
302
300
{
303
301
class_infos[idx].isa = (Class)((uint8_t *)clsopt + clsOffset);
@@ -327,7 +325,7 @@ __lldb_apple_objc_v2_get_shared_cache_class_info (void *objc_opt_ro_ptr,
327
325
}
328
326
++idx;
329
327
}
330
-
328
+
331
329
const uint32_t *duplicate_count_ptr = (uint32_t *)&classOffsets[clsopt->capacity];
332
330
const uint32_t duplicate_count = *duplicate_count_ptr;
333
331
const objc_classheader_t *duplicateClassOffsets = (const objc_classheader_t *)(&duplicate_count_ptr[1]);
@@ -340,7 +338,7 @@ __lldb_apple_objc_v2_get_shared_cache_class_info (void *objc_opt_ro_ptr,
340
338
continue; // duplicate
341
339
else if (clsOffset == invalidEntryOffset)
342
340
continue; // invalid offset
343
-
341
+
344
342
if (class_infos && idx < max_class_infos)
345
343
{
346
344
class_infos[idx].isa = (Class)((uint8_t *)clsopt + clsOffset);
@@ -359,7 +357,7 @@ __lldb_apple_objc_v2_get_shared_cache_class_info (void *objc_opt_ro_ptr,
359
357
{
360
358
h = 0;
361
359
break;
362
- }
360
+ }
363
361
h = ((h << 5) + h) + c;
364
362
}
365
363
class_infos[idx].hash = h;
@@ -401,8 +399,7 @@ ExtractRuntimeGlobalSymbol(Process *process, ConstString name,
401
399
if (read_value)
402
400
return process->ReadUnsignedIntegerFromMemory (
403
401
symbol_load_addr, byte_size, default_value, error);
404
- else
405
- return symbol_load_addr;
402
+ return symbol_load_addr;
406
403
} else {
407
404
error.SetErrorString (" symbol address invalid" );
408
405
return default_value;
@@ -504,15 +501,21 @@ LanguageRuntime *AppleObjCRuntimeV2::CreateInstance(Process *process,
504
501
if (AppleObjCRuntime::GetObjCVersion (process, objc_module_sp) ==
505
502
ObjCRuntimeVersions::eAppleObjC_V2)
506
503
return new AppleObjCRuntimeV2 (process, objc_module_sp);
507
- else
508
- return nullptr ;
504
+ return nullptr ;
509
505
} else
510
506
return nullptr ;
511
507
}
512
508
513
509
static constexpr OptionDefinition g_objc_classtable_dump_options[] = {
514
- {LLDB_OPT_SET_ALL, false , " verbose" , ' v' , OptionParser::eNoArgument,
515
- nullptr , {}, 0 , eArgTypeNone,
510
+ {LLDB_OPT_SET_ALL,
511
+ false ,
512
+ " verbose" ,
513
+ ' v' ,
514
+ OptionParser::eNoArgument,
515
+ nullptr ,
516
+ {},
517
+ 0 ,
518
+ eArgTypeNone,
516
519
" Print ivar and method information in detail" }};
517
520
518
521
class CommandObjectObjC_ClassTable_Dump : public CommandObjectParsed {
@@ -554,12 +557,13 @@ class CommandObjectObjC_ClassTable_Dump : public CommandObjectParsed {
554
557
};
555
558
556
559
CommandObjectObjC_ClassTable_Dump (CommandInterpreter &interpreter)
557
- : CommandObjectParsed(
558
- interpreter, " dump" , " Dump information on Objective-C classes "
559
- " known to the current process." ,
560
- " language objc class-table dump" ,
561
- eCommandRequiresProcess | eCommandProcessMustBeLaunched |
562
- eCommandProcessMustBePaused),
560
+ : CommandObjectParsed(interpreter, " dump" ,
561
+ " Dump information on Objective-C classes "
562
+ " known to the current process." ,
563
+ " language objc class-table dump" ,
564
+ eCommandRequiresProcess |
565
+ eCommandProcessMustBeLaunched |
566
+ eCommandProcessMustBePaused),
563
567
m_options () {
564
568
CommandArgumentEntry arg;
565
569
CommandArgumentData index_arg;
@@ -661,11 +665,10 @@ class CommandObjectObjC_ClassTable_Dump : public CommandObjectParsed {
661
665
}
662
666
result.SetStatus (lldb::eReturnStatusSuccessFinishResult);
663
667
return true ;
664
- } else {
665
- result.AppendError (" current process has no Objective-C runtime loaded" );
666
- result.SetStatus (lldb::eReturnStatusFailed);
667
- return false ;
668
668
}
669
+ result.AppendError (" current process has no Objective-C runtime loaded" );
670
+ result.SetStatus (lldb::eReturnStatusFailed);
671
+ return false ;
669
672
}
670
673
671
674
CommandOptions m_options;
@@ -747,11 +750,10 @@ class CommandObjectMultiwordObjC_TaggedPointer_Info
747
750
}
748
751
result.SetStatus (lldb::eReturnStatusSuccessFinishResult);
749
752
return true ;
750
- } else {
751
- result.AppendError (" current process has no Objective-C runtime loaded" );
752
- result.SetStatus (lldb::eReturnStatusFailed);
753
- return false ;
754
753
}
754
+ result.AppendError (" current process has no Objective-C runtime loaded" );
755
+ result.SetStatus (lldb::eReturnStatusFailed);
756
+ return false ;
755
757
}
756
758
};
757
759
@@ -1220,11 +1222,9 @@ AppleObjCRuntimeV2::GetClassDescriptor(ValueObject &valobj) {
1220
1222
1221
1223
objc_class_sp = GetClassDescriptorFromISA (isa);
1222
1224
if (isa && !objc_class_sp) {
1223
- Log *log (GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS |
1224
- LIBLLDB_LOG_TYPES));
1225
+ Log *log (GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_TYPES));
1225
1226
LLDB_LOGF (log,
1226
- " 0x%" PRIx64
1227
- " : AppleObjCRuntimeV2::GetClassDescriptor() ISA was "
1227
+ " 0x%" PRIx64 " : AppleObjCRuntimeV2::GetClassDescriptor() ISA was "
1228
1228
" not in class descriptor cache 0x%" PRIx64,
1229
1229
isa_pointer, isa);
1230
1230
}
@@ -1235,28 +1235,29 @@ lldb::addr_t AppleObjCRuntimeV2::GetTaggedPointerObfuscator() {
1235
1235
if (m_tagged_pointer_obfuscator != LLDB_INVALID_ADDRESS)
1236
1236
return m_tagged_pointer_obfuscator;
1237
1237
1238
-
1239
1238
Process *process = GetProcess ();
1240
1239
ModuleSP objc_module_sp (GetObjCModule ());
1241
1240
1242
1241
if (!objc_module_sp)
1243
1242
return LLDB_INVALID_ADDRESS;
1244
1243
1245
- static ConstString g_gdb_objc_obfuscator (" objc_debug_taggedpointer_obfuscator" );
1244
+ static ConstString g_gdb_objc_obfuscator (
1245
+ " objc_debug_taggedpointer_obfuscator" );
1246
1246
1247
1247
const Symbol *symbol = objc_module_sp->FindFirstSymbolWithNameAndType (
1248
- g_gdb_objc_obfuscator, lldb::eSymbolTypeAny);
1248
+ g_gdb_objc_obfuscator, lldb::eSymbolTypeAny);
1249
1249
if (symbol) {
1250
1250
lldb::addr_t g_gdb_obj_obfuscator_ptr =
1251
- symbol->GetLoadAddress (&process->GetTarget ());
1251
+ symbol->GetLoadAddress (&process->GetTarget ());
1252
1252
1253
1253
if (g_gdb_obj_obfuscator_ptr != LLDB_INVALID_ADDRESS) {
1254
1254
Status error;
1255
- m_tagged_pointer_obfuscator = process-> ReadPointerFromMemory (
1256
- g_gdb_obj_obfuscator_ptr, error);
1255
+ m_tagged_pointer_obfuscator =
1256
+ process-> ReadPointerFromMemory ( g_gdb_obj_obfuscator_ptr, error);
1257
1257
}
1258
1258
}
1259
- // If we don't have a correct value at this point, there must be no obfuscation.
1259
+ // If we don't have a correct value at this point, there must be no
1260
+ // obfuscation.
1260
1261
if (m_tagged_pointer_obfuscator == LLDB_INVALID_ADDRESS)
1261
1262
m_tagged_pointer_obfuscator = 0 ;
1262
1263
@@ -1402,12 +1403,12 @@ AppleObjCRuntimeV2::UpdateISAToDescriptorMapDynamic(
1402
1403
arguments.GetValueAtIndex (0 )->GetScalar () = hash_table.GetTableLoadAddress ();
1403
1404
arguments.GetValueAtIndex (1 )->GetScalar () = class_infos_addr;
1404
1405
arguments.GetValueAtIndex (2 )->GetScalar () = class_infos_byte_size;
1405
-
1406
+
1406
1407
// Only dump the runtime classes from the expression evaluation if the log is
1407
1408
// verbose:
1408
1409
Log *type_log = GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES);
1409
1410
bool dump_log = type_log && type_log->GetVerbose ();
1410
-
1411
+
1411
1412
arguments.GetValueAtIndex (3 )->GetScalar () = dump_log ? 1 : 0 ;
1412
1413
1413
1414
bool success = false ;
@@ -1513,15 +1514,16 @@ uint32_t AppleObjCRuntimeV2::ParseClassInfoArray(const DataExtractor &data,
1513
1514
ClassDescriptorSP descriptor_sp (
1514
1515
new ClassDescriptorV2 (*this , isa, nullptr ));
1515
1516
1516
- // The code in g_get_shared_cache_class_info_body sets the value of the hash
1517
- // to 0 to signal a demangled symbol. We use class_getName() in that code to
1518
- // find the class name, but this returns a demangled name for Swift symbols.
1519
- // For those symbols, recompute the hash here by reading their name from the
1520
- // runtime.
1517
+ // The code in g_get_shared_cache_class_info_body sets the value of the
1518
+ // hash to 0 to signal a demangled symbol. We use class_getName() in that
1519
+ // code to find the class name, but this returns a demangled name for
1520
+ // Swift symbols. For those symbols, recompute the hash here by reading
1521
+ // their name from the runtime.
1521
1522
if (name_hash)
1522
1523
AddClass (isa, descriptor_sp, name_hash);
1523
1524
else
1524
- AddClass (isa, descriptor_sp, descriptor_sp->GetClassName ().AsCString (nullptr ));
1525
+ AddClass (isa, descriptor_sp,
1526
+ descriptor_sp->GetClassName ().AsCString (nullptr ));
1525
1527
num_parsed++;
1526
1528
if (should_log)
1527
1529
LLDB_LOGF (log,
@@ -1591,17 +1593,17 @@ AppleObjCRuntimeV2::UpdateISAToDescriptorMapSharedCache() {
1591
1593
// use that in our jitted expression. Else fall back to the old
1592
1594
// class_getName.
1593
1595
static ConstString g_class_getName_symbol_name (" class_getName" );
1594
- static ConstString g_class_getNameRaw_symbol_name (" objc_debug_class_getNameRaw" );
1596
+ static ConstString g_class_getNameRaw_symbol_name (
1597
+ " objc_debug_class_getNameRaw" );
1595
1598
ConstString class_name_getter_function_name = g_class_getName_symbol_name;
1596
1599
1597
1600
ObjCLanguageRuntime *objc_runtime = ObjCLanguageRuntime::Get (*process);
1598
1601
if (objc_runtime) {
1599
1602
for (lldb::ModuleSP mod_sp : process->GetTarget ().GetImages ().Modules ()) {
1600
1603
if (objc_runtime->IsModuleObjCLibrary (mod_sp)) {
1601
- const Symbol *symbol =
1602
- mod_sp->FindFirstSymbolWithNameAndType (g_class_getNameRaw_symbol_name,
1603
- lldb::eSymbolTypeCode);
1604
- if (symbol &&
1604
+ const Symbol *symbol = mod_sp->FindFirstSymbolWithNameAndType (
1605
+ g_class_getNameRaw_symbol_name, lldb::eSymbolTypeCode);
1606
+ if (symbol &&
1605
1607
(symbol->ValueIsAddress () || symbol->GetAddressRef ().IsValid ())) {
1606
1608
class_name_getter_function_name = g_class_getNameRaw_symbol_name;
1607
1609
}
@@ -1613,10 +1615,10 @@ AppleObjCRuntimeV2::UpdateISAToDescriptorMapSharedCache() {
1613
1615
// concatenate the two parts of our expression text. The format string
1614
1616
// has two %s's, so provide the name twice.
1615
1617
std::string shared_class_expression;
1616
- llvm::raw_string_ostream (shared_class_expression) << llvm::format (
1617
- g_shared_cache_class_name_funcptr,
1618
- class_name_getter_function_name.AsCString (),
1619
- class_name_getter_function_name.AsCString ());
1618
+ llvm::raw_string_ostream (shared_class_expression)
1619
+ << llvm::format ( g_shared_cache_class_name_funcptr,
1620
+ class_name_getter_function_name.AsCString (),
1621
+ class_name_getter_function_name.AsCString ());
1620
1622
1621
1623
shared_class_expression += g_get_shared_cache_class_info_body;
1622
1624
@@ -1684,7 +1686,7 @@ AppleObjCRuntimeV2::UpdateISAToDescriptorMapSharedCache() {
1684
1686
// verbose:
1685
1687
Log *type_log = GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES);
1686
1688
bool dump_log = type_log && type_log->GetVerbose ();
1687
-
1689
+
1688
1690
arguments.GetValueAtIndex (3 )->GetScalar () = dump_log ? 1 : 0 ;
1689
1691
1690
1692
bool success = false ;
@@ -1981,9 +1983,10 @@ lldb::addr_t AppleObjCRuntimeV2::LookupRuntimeSymbol(ConstString name) {
1981
1983
const ConstString ivar_name_cs (class_and_ivar.second );
1982
1984
const char *ivar_name_cstr = ivar_name_cs.AsCString ();
1983
1985
1984
- auto ivar_func = [&ret, ivar_name_cstr](
1985
- const char *name, const char *type, lldb::addr_t offset_addr,
1986
- uint64_t size) -> lldb::addr_t {
1986
+ auto ivar_func = [&ret,
1987
+ ivar_name_cstr](const char *name, const char *type,
1988
+ lldb::addr_t offset_addr,
1989
+ uint64_t size) -> lldb::addr_t {
1987
1990
if (!strcmp (name, ivar_name_cstr)) {
1988
1991
ret = offset_addr;
1989
1992
return true ;
@@ -2401,9 +2404,9 @@ AppleObjCRuntimeV2::TaggedPointerVendorExtended::GetClassDescriptor(
2401
2404
m_ext_cache[slot] = actual_class_descriptor_sp;
2402
2405
}
2403
2406
2404
- data_payload =
2405
- ((( uint64_t )unobfuscated << m_objc_debug_taggedpointer_ext_payload_lshift) >>
2406
- m_objc_debug_taggedpointer_ext_payload_rshift);
2407
+ data_payload = ((( uint64_t )unobfuscated
2408
+ << m_objc_debug_taggedpointer_ext_payload_lshift) >>
2409
+ m_objc_debug_taggedpointer_ext_payload_rshift);
2407
2410
2408
2411
return ClassDescriptorSP (
2409
2412
new ClassDescriptorV2Tagged (actual_class_descriptor_sp, data_payload));
@@ -2604,13 +2607,14 @@ void AppleObjCRuntimeV2::GetValuesForGlobalCFBooleans(lldb::addr_t &cf_true,
2604
2607
#pragma mark Frame recognizers
2605
2608
2606
2609
class ObjCExceptionRecognizedStackFrame : public RecognizedStackFrame {
2607
- public:
2610
+ public:
2608
2611
ObjCExceptionRecognizedStackFrame (StackFrameSP frame_sp) {
2609
2612
ThreadSP thread_sp = frame_sp->GetThread ();
2610
2613
ProcessSP process_sp = thread_sp->GetProcess ();
2611
2614
2612
2615
const lldb::ABISP &abi = process_sp->GetABI ();
2613
- if (!abi) return ;
2616
+ if (!abi)
2617
+ return ;
2614
2618
2615
2619
TypeSystemClang *clang_ast_context =
2616
2620
ScratchTypeSystemClang::GetForTarget (process_sp->GetTarget ());
@@ -2624,7 +2628,8 @@ class ObjCExceptionRecognizedStackFrame : public RecognizedStackFrame {
2624
2628
input_value.SetCompilerType (voidstar);
2625
2629
args.PushValue (input_value);
2626
2630
2627
- if (!abi->GetArgumentValues (*thread_sp, args)) return ;
2631
+ if (!abi->GetArgumentValues (*thread_sp, args))
2632
+ return ;
2628
2633
2629
2634
addr_t exception_addr = args.GetValueAtIndex (0 )->GetScalar ().ULongLong ();
2630
2635
0 commit comments