[AppleObjCRuntimeV2] Force lazily allocated class names to be resolved.

Fixes a couple of tests on new versions of the Obj-C runtime.
This commit is contained in:
Davide Italiano 2020-03-20 13:42:21 -07:00
parent 40fc80a023
commit 6385c2ab8f
2 changed files with 34 additions and 2 deletions

View File

@ -1175,6 +1175,28 @@ AppleObjCRuntimeV2::GetClassDescriptorFromISA(ObjCISA isa) {
return class_descriptor_sp;
}
static std::pair<bool, ConstString> ObjCGetClassNameRaw(
AppleObjCRuntime::ObjCISA isa,
Process *process) {
StreamString expr_string;
std::string input = std::to_string(isa);
expr_string.Printf("(const char *)objc_debug_class_getNameRaw(%s)",
input.c_str());
ValueObjectSP result_sp;
EvaluateExpressionOptions eval_options;
eval_options.SetLanguage(lldb::eLanguageTypeObjC);
eval_options.SetResultIsInternal(true);
eval_options.SetGenerateDebugInfo(true);
eval_options.SetTimeout(process->GetUtilityExpressionTimeout());
auto eval_result = process->GetTarget().EvaluateExpression(
expr_string.GetData(),
process->GetThreadList().GetSelectedThread()->GetSelectedFrame().get(),
result_sp, eval_options);
ConstString type_name(result_sp->GetSummaryAsCString());
return std::make_pair(eval_result == eExpressionCompleted, type_name);
}
ObjCLanguageRuntime::ClassDescriptorSP
AppleObjCRuntimeV2::GetClassDescriptor(ValueObject &valobj) {
ClassDescriptorSP objc_class_sp;
@ -1210,7 +1232,10 @@ AppleObjCRuntimeV2::GetClassDescriptor(ValueObject &valobj) {
return objc_class_sp;
objc_class_sp = GetClassDescriptorFromISA(isa);
if (isa && !objc_class_sp) {
if (objc_class_sp)
return objc_class_sp;
else {
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS |
LIBLLDB_LOG_TYPES));
LLDB_LOGF(log,
@ -1219,6 +1244,13 @@ AppleObjCRuntimeV2::GetClassDescriptor(ValueObject &valobj) {
"not in class descriptor cache 0x%" PRIx64,
isa_pointer, isa);
}
ClassDescriptorSP descriptor_sp(new ClassDescriptorV2(*this, isa, nullptr));
auto resolved = ObjCGetClassNameRaw(isa, process);
if (resolved.first == true) {
AddClass(isa, descriptor_sp, resolved.second.AsCString());
objc_class_sp = descriptor_sp;
}
return objc_class_sp;
}

View File

@ -51,7 +51,7 @@ run
thread step-over
# Stepping inside of the stop hook range
# CHECK: (lldb) thread step-over
# CHECK-NEXT: (void *) $1 = 0x
# CHECK-NEXT: (void *) $2 = 0x
# CHECK: ->{{.*}} // We should stop here after stepping.
process continue