Skip to content

Commit 838142a

Browse files
Merge pull request #8186 from adrian-prantl/log-objfile
Improve logging.
2 parents cd1082e + 438950f commit 838142a

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

lldb/source/Plugins/LanguageRuntime/Swift/SwiftLanguageRuntime.cpp

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -476,13 +476,10 @@ static bool HasReflectionInfo(ObjectFile *obj_file) {
476476
StringRef reflstr =
477477
obj_file_format_up->getSectionName(swift::ReflectionSectionKind::reflstr);
478478

479-
bool hasReflectionSection = false;
480-
hasReflectionSection |= findSectionInObject(field_md);
481-
hasReflectionSection |= findSectionInObject(assocty);
482-
hasReflectionSection |= findSectionInObject(builtin);
483-
hasReflectionSection |= findSectionInObject(capture);
484-
hasReflectionSection |= findSectionInObject(typeref);
485-
hasReflectionSection |= findSectionInObject(reflstr);
479+
bool hasReflectionSection =
480+
findSectionInObject(field_md) || findSectionInObject(assocty) ||
481+
findSectionInObject(builtin) || findSectionInObject(capture) ||
482+
findSectionInObject(typeref) || findSectionInObject(reflstr);
486483
return hasReflectionSection;
487484
}
488485

@@ -888,14 +885,18 @@ bool SwiftLanguageRuntimeImpl::AddModuleToReflectionContext(
888885

889886
if (load_ptr == 0 || load_ptr == LLDB_INVALID_ADDRESS) {
890887
if (obj_file->GetType() != ObjectFile::eTypeJIT)
891-
if (Log *log = GetLog(LLDBLog::Types))
892-
log->Printf("%s: failed to get start address for %s.", __FUNCTION__,
893-
obj_file->GetFileSpec().GetFilename().GetCString());
888+
LLDB_LOG(GetLog(LLDBLog::Types),
889+
"{0}: failed to get start address for \"{1}\".", __FUNCTION__,
890+
module_sp->GetObjectName()
891+
? module_sp->GetObjectName()
892+
: obj_file->GetFileSpec().GetFilename());
894893
return false;
895894
}
896895
bool found = HasReflectionInfo(obj_file);
897-
LLDB_LOGF(GetLog(LLDBLog::Types), "%s reflection metadata in \"%s\"",
898-
found ? "Adding" : "No", obj_file->GetFileSpec().GetPath().c_str());
896+
LLDB_LOG(GetLog(LLDBLog::Types), "{0} reflection metadata in \"{1}\"",
897+
found ? "Adding" : "No",
898+
module_sp->GetObjectName() ? module_sp->GetObjectName()
899+
: obj_file->GetFileSpec().GetFilename());
899900
if (!found)
900901
return true;
901902

@@ -925,8 +926,14 @@ bool SwiftLanguageRuntimeImpl::AddModuleToReflectionContext(
925926
likely_module_names);
926927
}
927928

928-
if (info_id)
929-
if (auto *swift_metadata_cache = GetSwiftMetadataCache())
929+
if (!info_id) {
930+
LLDB_LOG(GetLog(LLDBLog::Types),
931+
"Error while loading reflection metadata in \"{0}\"",
932+
module_sp->GetObjectName());
933+
return false;
934+
}
935+
936+
if (auto *swift_metadata_cache = GetSwiftMetadataCache())
930937
swift_metadata_cache->registerModuleWithReflectionInfoID(module_sp,
931938
*info_id);
932939

0 commit comments

Comments
 (0)