@@ -1694,6 +1694,14 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(lldb::LanguageType language,
1694
1694
m_description,
1695
1695
target ? target->GetArchitecture ().GetTriple () : triple,
1696
1696
target)));
1697
+ bool suppress_config_log = false ;
1698
+ auto defer_log = llvm::make_scope_exit ([swift_ast_sp, &suppress_config_log] {
1699
+ // To avoid spamming the log with useless info, we don't log the
1700
+ // configuration if everything went fine and the current module
1701
+ // doesn't have any Swift contents (i.e., the shared cache dylibs).
1702
+ if (!suppress_config_log)
1703
+ swift_ast_sp->LogConfiguration ();
1704
+ });
1697
1705
1698
1706
// This is a module AST context, mark it as such.
1699
1707
swift_ast_sp->m_is_scratch_context = false ;
@@ -1706,9 +1714,7 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(lldb::LanguageType language,
1706
1714
1707
1715
bool set_triple = false ;
1708
1716
bool found_swift_modules = false ;
1709
-
1710
1717
SymbolFile *sym_file = module .GetSymbolFile ();
1711
-
1712
1718
std::string target_triple;
1713
1719
1714
1720
if (sym_file) {
@@ -1831,15 +1837,17 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(lldb::LanguageType language,
1831
1837
1832
1838
std::vector<std::string> module_names;
1833
1839
swift_ast_sp->RegisterSectionModules (module , module_names);
1834
- if (module_names.size ()) {
1840
+ if (!module_names.size ()) {
1841
+ // This dylib has no Swift contents; logging the configuration is pointless.
1842
+ suppress_config_log = true ;
1843
+ } else {
1835
1844
swift_ast_sp->ValidateSectionModules (module , module_names);
1836
1845
if (lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES)) {
1837
1846
std::lock_guard<std::recursive_mutex> locker (g_log_mutex);
1838
1847
LOG_PRINTF (LIBLLDB_LOG_TYPES, " ((Module*)%p, \" %s\" ) = %p" ,
1839
1848
static_cast <void *>(&module ),
1840
1849
module .GetFileSpec ().GetFilename ().AsCString (" <anonymous>" ),
1841
1850
static_cast <void *>(swift_ast_sp.get ()));
1842
- swift_ast_sp->LogConfiguration ();
1843
1851
}
1844
1852
}
1845
1853
@@ -1926,6 +1934,8 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(lldb::LanguageType language,
1926
1934
// detect if we have a iOS simulator.
1927
1935
std::shared_ptr<SwiftASTContextForExpressions> swift_ast_sp (
1928
1936
new SwiftASTContextForExpressions (m_description, target));
1937
+ auto defer_log = llvm::make_scope_exit (
1938
+ [swift_ast_sp] { swift_ast_sp->LogConfiguration (); });
1929
1939
1930
1940
LOG_PRINTF (LIBLLDB_LOG_TYPES, " (Target)" );
1931
1941
@@ -2280,7 +2290,6 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(lldb::LanguageType language,
2280
2290
LOG_PRINTF (LIBLLDB_LOG_TYPES, " ((Target*)%p) = %p" ,
2281
2291
static_cast <void *>(&target),
2282
2292
static_cast <void *>(swift_ast_sp.get ()));
2283
- swift_ast_sp->LogConfiguration ();
2284
2293
2285
2294
if (swift_ast_sp->HasFatalErrors ()) {
2286
2295
logError (swift_ast_sp->GetFatalErrors ().AsCString ());
@@ -4929,8 +4938,8 @@ void SwiftASTContext::ClearModuleDependentCaches() {
4929
4938
}
4930
4939
4931
4940
void SwiftASTContext::LogConfiguration () {
4932
- VALID_OR_RETURN_VOID ();
4933
-
4941
+ // It makes no sense to call VALID_OR_RETURN here. We specifically
4942
+ // want the logs in the error case!
4934
4943
Log *log (lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
4935
4944
if (!log)
4936
4945
return ;
0 commit comments