@@ -185,6 +185,20 @@ std::recursive_mutex g_log_mutex;
185
185
} \
186
186
} while (0 )
187
187
188
+ #define SWIFT_LOG_PRINTF (FMT, ...) \
189
+ LOG_PRINTF_IMPL (LIBLLDB_LOG_TYPES, false , FMT, ##__VA_ARGS__); \
190
+ SWIFT_LOG_PRINTF_IMPL (FMT, ##__VA_ARGS__)
191
+ #define SWIFT_LOG_PRINTF_IMPL (FMT, ...) \
192
+ do { \
193
+ if (Log *log = lldb_private::GetSwiftHealthLog ()) { \
194
+ std::lock_guard<std::recursive_mutex> locker (g_log_mutex); \
195
+ /* The format string is optimized for code size, not speed. */ \
196
+ log->Printf (" %s::%s%s" FMT, m_description.c_str (), \
197
+ IsLambda (__FUNCTION__) ? " " : __FUNCTION__, \
198
+ (FMT && FMT[0 ] == ' (' ) ? " " : " () -- " , ##__VA_ARGS__); \
199
+ } \
200
+ } while (0 )
201
+
188
202
using namespace lldb ;
189
203
using namespace lldb_private ;
190
204
@@ -5078,65 +5092,61 @@ void SwiftASTContext::ClearModuleDependentCaches() {
5078
5092
void SwiftASTContext::LogConfiguration () {
5079
5093
// It makes no sense to call VALID_OR_RETURN here. We specifically
5080
5094
// want the logs in the error case!
5081
- Log *log (lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_TYPES));
5082
- if (!log)
5083
- return ;
5084
-
5085
- LOG_PRINTF (LIBLLDB_LOG_TYPES,
5086
- " (SwiftASTContext*)%p:" , static_cast <void *>(this ));
5095
+ SWIFT_LOG_PRINTF (" (SwiftASTContext*)%p:" , static_cast <void *>(this ));
5087
5096
5088
5097
if (!m_ast_context_ap) {
5089
- log-> Printf (" (no AST context)" );
5098
+ SWIFT_LOG_PRINTF (" (no AST context)" );
5090
5099
return ;
5091
5100
}
5092
5101
5093
- log->Printf (" Architecture : %s" ,
5094
- m_ast_context_ap->LangOpts .Target .getTriple ().c_str ());
5095
- log->Printf (" SDK path : %s" ,
5096
- m_ast_context_ap->SearchPathOpts .SDKPath .c_str ());
5097
- log->Printf (" Runtime resource path : %s" ,
5098
- m_ast_context_ap->SearchPathOpts .RuntimeResourcePath .c_str ());
5099
- log->Printf (" Runtime library paths : (%llu items)" ,
5100
- (unsigned long long )
5101
- m_ast_context_ap->SearchPathOpts .RuntimeLibraryPaths .size ());
5102
+ SWIFT_LOG_PRINTF (" Architecture : %s" ,
5103
+ m_ast_context_ap->LangOpts .Target .getTriple ().c_str ());
5104
+ SWIFT_LOG_PRINTF (" SDK path : %s" ,
5105
+ m_ast_context_ap->SearchPathOpts .SDKPath .c_str ());
5106
+ SWIFT_LOG_PRINTF (
5107
+ " Runtime resource path : %s" ,
5108
+ m_ast_context_ap->SearchPathOpts .RuntimeResourcePath .c_str ());
5109
+ SWIFT_LOG_PRINTF (" Runtime library paths : (%llu items)" ,
5110
+ (unsigned long long )m_ast_context_ap->SearchPathOpts
5111
+ .RuntimeLibraryPaths .size ());
5102
5112
5103
5113
for (const auto &runtime_library_path :
5104
5114
m_ast_context_ap->SearchPathOpts .RuntimeLibraryPaths ) {
5105
- log-> Printf (" %s" , runtime_library_path.c_str ());
5115
+ SWIFT_LOG_PRINTF (" %s" , runtime_library_path.c_str ());
5106
5116
}
5107
5117
5108
- log-> Printf (" Runtime library import paths : (%llu items)" ,
5109
- (unsigned long long )m_ast_context_ap->SearchPathOpts
5110
- .RuntimeLibraryImportPaths .size ());
5118
+ SWIFT_LOG_PRINTF (" Runtime library import paths : (%llu items)" ,
5119
+ (unsigned long long )m_ast_context_ap->SearchPathOpts
5120
+ .RuntimeLibraryImportPaths .size ());
5111
5121
5112
5122
for (const auto &runtime_import_path :
5113
5123
m_ast_context_ap->SearchPathOpts .RuntimeLibraryImportPaths ) {
5114
- log-> Printf (" %s" , runtime_import_path.c_str ());
5124
+ SWIFT_LOG_PRINTF (" %s" , runtime_import_path.c_str ());
5115
5125
}
5116
5126
5117
- log-> Printf (" Framework search paths : (%llu items)" ,
5118
- (unsigned long long )
5119
- m_ast_context_ap-> SearchPathOpts .FrameworkSearchPaths .size ());
5127
+ SWIFT_LOG_PRINTF (" Framework search paths : (%llu items)" ,
5128
+ (unsigned long long )m_ast_context_ap-> SearchPathOpts
5129
+ .FrameworkSearchPaths .size ());
5120
5130
for (const auto &framework_search_path :
5121
5131
m_ast_context_ap->SearchPathOpts .FrameworkSearchPaths ) {
5122
- log-> Printf (" %s" , framework_search_path.Path .c_str ());
5132
+ SWIFT_LOG_PRINTF (" %s" , framework_search_path.Path .c_str ());
5123
5133
}
5124
5134
5125
- log-> Printf (" Import search paths : (%llu items)" ,
5126
- (unsigned long long )
5127
- m_ast_context_ap-> SearchPathOpts .ImportSearchPaths .size ());
5135
+ SWIFT_LOG_PRINTF (" Import search paths : (%llu items)" ,
5136
+ (unsigned long long )m_ast_context_ap-> SearchPathOpts
5137
+ .ImportSearchPaths .size ());
5128
5138
for (std::string &import_search_path :
5129
5139
m_ast_context_ap->SearchPathOpts .ImportSearchPaths ) {
5130
- log-> Printf (" %s" , import_search_path.c_str ());
5140
+ SWIFT_LOG_PRINTF (" %s" , import_search_path.c_str ());
5131
5141
}
5132
5142
5133
5143
swift::ClangImporterOptions &clang_importer_options =
5134
5144
GetClangImporterOptions ();
5135
5145
5136
- log-> Printf (" Extra clang arguments : (%llu items)" ,
5137
- (unsigned long long )clang_importer_options.ExtraArgs .size ());
5146
+ SWIFT_LOG_PRINTF (" Extra clang arguments : (%llu items)" ,
5147
+ (unsigned long long )clang_importer_options.ExtraArgs .size ());
5138
5148
for (std::string &extra_arg : clang_importer_options.ExtraArgs ) {
5139
- log-> Printf (" %s" , extra_arg.c_str ());
5149
+ SWIFT_LOG_PRINTF (" %s" , extra_arg.c_str ());
5140
5150
}
5141
5151
}
5142
5152
0 commit comments