@@ -1176,6 +1176,28 @@ AppleObjCRuntimeV2::GetClassDescriptorFromISA(ObjCISA isa) {
1176
1176
return class_descriptor_sp;
1177
1177
}
1178
1178
1179
+ static std::pair<bool , ConstString> ObjCGetClassNameRaw (
1180
+ AppleObjCRuntime::ObjCISA isa,
1181
+ Process *process) {
1182
+ StreamString expr_string;
1183
+ std::string input = std::to_string (isa);
1184
+ expr_string.Printf (" (const char *)objc_debug_class_getNameRaw(%s)" ,
1185
+ input.c_str ());
1186
+
1187
+ ValueObjectSP result_sp;
1188
+ EvaluateExpressionOptions eval_options;
1189
+ eval_options.SetLanguage (lldb::eLanguageTypeObjC);
1190
+ eval_options.SetResultIsInternal (true );
1191
+ eval_options.SetGenerateDebugInfo (true );
1192
+ eval_options.SetTimeout (process->GetUtilityExpressionTimeout ());
1193
+ auto eval_result = process->GetTarget ().EvaluateExpression (
1194
+ expr_string.GetData (),
1195
+ process->GetThreadList ().GetSelectedThread ()->GetSelectedFrame ().get (),
1196
+ result_sp, eval_options);
1197
+ ConstString type_name (result_sp->GetSummaryAsCString ());
1198
+ return std::make_pair (eval_result == eExpressionCompleted, type_name);
1199
+ }
1200
+
1179
1201
ObjCLanguageRuntime::ClassDescriptorSP
1180
1202
AppleObjCRuntimeV2::GetClassDescriptor (ValueObject &valobj) {
1181
1203
ClassDescriptorSP objc_class_sp;
@@ -1192,32 +1214,43 @@ AppleObjCRuntimeV2::GetClassDescriptor(ValueObject &valobj) {
1192
1214
// if we get an invalid VO (which might still happen when playing around with
1193
1215
// pointers returned by the expression parser, don't consider this a valid
1194
1216
// ObjC object)
1195
- if (valobj.GetCompilerType ().IsValid ()) {
1196
- addr_t isa_pointer = valobj.GetPointerValue ();
1217
+ if (!valobj.GetCompilerType ().IsValid ())
1218
+ return objc_class_sp;
1219
+ addr_t isa_pointer = valobj.GetPointerValue ();
1197
1220
1198
- // tagged pointer
1199
- if (IsTaggedPointer (isa_pointer)) {
1200
- return m_tagged_pointer_vendor_up->GetClassDescriptor (isa_pointer);
1201
- } else {
1202
- ExecutionContext exe_ctx (valobj.GetExecutionContextRef ());
1221
+ // tagged pointer
1222
+ if (IsTaggedPointer (isa_pointer))
1223
+ return m_tagged_pointer_vendor_up->GetClassDescriptor (isa_pointer);
1224
+ ExecutionContext exe_ctx (valobj.GetExecutionContextRef ());
1203
1225
1204
- Process *process = exe_ctx.GetProcessPtr ();
1205
- if (process) {
1206
- Status error;
1207
- ObjCISA isa = process->ReadPointerFromMemory (isa_pointer, error);
1208
- if (isa != LLDB_INVALID_ADDRESS) {
1209
- objc_class_sp = GetClassDescriptorFromISA (isa);
1210
- if (isa && !objc_class_sp) {
1211
- Log *log (GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS));
1212
- LLDB_LOGF (log,
1213
- " 0x%" PRIx64
1214
- " : AppleObjCRuntimeV2::GetClassDescriptor() ISA was "
1215
- " not in class descriptor cache 0x%" PRIx64,
1216
- isa_pointer, isa);
1217
- }
1218
- }
1219
- }
1220
- }
1226
+ Process *process = exe_ctx.GetProcessPtr ();
1227
+ if (!process)
1228
+ return objc_class_sp;
1229
+
1230
+ Status error;
1231
+ ObjCISA isa = process->ReadPointerFromMemory (isa_pointer, error);
1232
+ if (isa == LLDB_INVALID_ADDRESS)
1233
+ return objc_class_sp;
1234
+
1235
+ objc_class_sp = GetClassDescriptorFromISA (isa);
1236
+
1237
+ if (objc_class_sp)
1238
+ return objc_class_sp;
1239
+ else {
1240
+ Log *log (GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS |
1241
+ LIBLLDB_LOG_TYPES));
1242
+ LLDB_LOGF (log,
1243
+ " 0x%" PRIx64
1244
+ " : AppleObjCRuntimeV2::GetClassDescriptor() ISA was "
1245
+ " not in class descriptor cache 0x%" PRIx64,
1246
+ isa_pointer, isa);
1247
+ }
1248
+
1249
+ ClassDescriptorSP descriptor_sp (new ClassDescriptorV2 (*this , isa, nullptr ));
1250
+ auto resolved = ObjCGetClassNameRaw (isa, process);
1251
+ if (resolved.first == true ) {
1252
+ AddClass (isa, descriptor_sp, resolved.second .AsCString ());
1253
+ objc_class_sp = descriptor_sp;
1221
1254
}
1222
1255
return objc_class_sp;
1223
1256
}
0 commit comments