Skip to content

[lldb] Handle CFTimeZoneRef in NSTimeZoneSummaryProvider #8035

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions lldb/source/Plugins/Language/ObjC/Cocoa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,29 @@ bool lldb_private::formatters::NSTimeZoneSummaryProvider(
return true;
}
} else if (class_name == "_NSSwiftTimeZone") {
llvm::ArrayRef<llvm::StringRef> identifier_path = {"timeZone", "_timeZone",
"some", "identifier"};
if (auto identifier_sp = valobj.GetChildAtNamePath(identifier_path)) {
// CFTimeZoneRef is declared as follows:
// typedef const struct CF_BRIDGED_TYPE(NSTimeZone) __CFTimeZone *
// CFTimeZoneRef;
// From the available debug info, this appears to lldb as pointer to an
// opaque type, not an ObjC object. As a result, lldb does not correctly
// determine the correct dynamic type (because it doesn't try ObjC). With no
// dynamic type, this summary provider cannot access the inner `identifier`
// property.
//
// The fix here is to explicitly cast the value as `id`, and get the dynamic
// value from there.
ValueObjectSP dyn_valobj_sp;
if (valobj.GetTypeName() == "CFTimeZoneRef") {
auto id_type =
valobj.GetCompilerType().GetBasicTypeFromAST(lldb::eBasicTypeObjCID);
dyn_valobj_sp = valobj.Cast(id_type)->GetDynamicValue(
DynamicValueType::eDynamicDontRunTarget);
}

ValueObject &time_zone = dyn_valobj_sp ? *dyn_valobj_sp : valobj;
llvm::ArrayRef<llvm::StringRef> identifier_path = {
"some", "timeZone", "_timeZone", "some", "identifier"};
if (auto identifier_sp = time_zone.GetChildAtNamePath(identifier_path)) {
std::string desc;
if (identifier_sp->GetSummaryAsCString(desc, options)) {
stream.PutCString(desc);
Expand Down