Skip to content

Commit 6585223

Browse files
committed
Improve logging for dynamic library loading
1 parent 9057c80 commit 6585223

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,10 @@ std::recursive_mutex g_log_mutex;
169169

170170
/// Similar to LLDB_LOG, but with richer contextual information.
171171
#define LOG_PRINTF(CHANNEL, FMT, ...) \
172-
LOG_PRINTF_IMPL(lldb_private::GetLogIfAllCategoriesSet(CHANNEL), false, FMT, \
172+
LOG_PRINTF_IMPL(lldb_private::GetLogIfAnyCategoriesSet(CHANNEL), false, FMT, \
173173
##__VA_ARGS__)
174174
#define LOG_VERBOSE_PRINTF(CHANNEL, FMT, ...) \
175-
LOG_PRINTF_IMPL(lldb_private::GetLogIfAllCategoriesSet(CHANNEL), true, FMT, \
175+
LOG_PRINTF_IMPL(lldb_private::GetLogIfAnyCategoriesSet(CHANNEL), true, FMT, \
176176
##__VA_ARGS__)
177177
#define LOG_PRINTF_IMPL(CHANNEL, VERBOSE, FMT, ...) \
178178
do { \
@@ -3844,13 +3844,14 @@ void SwiftASTContext::LoadModule(swift::ModuleDecl *swift_module,
38443844
return;
38453845

38463846
swift::LibraryKind library_kind = link_lib.getKind();
3847-
3848-
LOG_PRINTF(LIBLLDB_LOG_TYPES, "Loading link library \"%s\" of kind: %d.",
3849-
library_name.c_str(), library_kind);
3847+
LOG_PRINTF(LIBLLDB_LOG_TYPES | LIBLLDB_LOG_EXPRESSIONS,
3848+
"Loading linked %s \"%s\".",
3849+
library_kind == swift::LibraryKind::Framework ? "framework"
3850+
: "library",
3851+
library_name.c_str());
38503852

38513853
switch (library_kind) {
38523854
case swift::LibraryKind::Framework: {
3853-
38543855
// First make sure the library isn't already loaded. Since this
38553856
// is a framework, we make sure the file name and the framework
38563857
// name are the same, and that we are contained in
@@ -8295,7 +8296,7 @@ static swift::ModuleDecl *LoadOneModule(const SourceModule &module,
82958296
error.Clear();
82968297
ConstString toplevel = module.path.front();
82978298
const std::string &m_description = swift_ast_context.GetDescription();
8298-
LOG_PRINTF(LIBLLDB_LOG_EXPRESSIONS, "Importing module %s",
8299+
LOG_PRINTF(LIBLLDB_LOG_TYPES | LIBLLDB_LOG_EXPRESSIONS, "Importing module %s",
82998300
toplevel.AsCString());
83008301
swift::ModuleDecl *swift_module = nullptr;
83018302
lldb::StackFrameSP this_frame_sp(stack_frame_wp.lock());
@@ -8320,7 +8321,7 @@ static swift::ModuleDecl *LoadOneModule(const SourceModule &module,
83208321
// checked that DWARF debug info for this module actually exists
83218322
// and there is no good mechanism to do so ahead of time.
83228323
// We do know that we never load the stdlib from DWARF though.
8323-
LOG_PRINTF(LIBLLDB_LOG_EXPRESSIONS,
8324+
LOG_PRINTF(LIBLLDB_LOG_TYPES | LIBLLDB_LOG_EXPRESSIONS,
83248325
"\"Imported\" module %s via SwiftDWARFImporterDelegate "
83258326
"(no Swift AST or Clang module found)",
83268327
toplevel.AsCString());
@@ -8330,20 +8331,23 @@ static swift::ModuleDecl *LoadOneModule(const SourceModule &module,
83308331
}
83318332

83328333
if (!swift_module || !error.Success() || swift_ast_context.HasFatalErrors()) {
8333-
LOG_PRINTF(LIBLLDB_LOG_EXPRESSIONS, "Couldn't import module %s: %s",
8334-
toplevel.AsCString(), error.AsCString());
8334+
LOG_PRINTF(LIBLLDB_LOG_TYPES | LIBLLDB_LOG_EXPRESSIONS,
8335+
"Couldn't import module %s: %s", toplevel.AsCString(),
8336+
error.AsCString());
83358337

83368338
if (!swift_module || swift_ast_context.HasFatalErrors()) {
83378339
return nullptr;
83388340
}
83398341
}
83408342

8341-
if (lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)) {
8343+
if (lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_TYPES |
8344+
LIBLLDB_LOG_EXPRESSIONS)) {
83428345
StreamString ss;
83438346
for (swift::FileUnit *file_unit : swift_module->getFiles())
83448347
DescribeFileUnit(ss, file_unit);
8345-
LOG_PRINTF(LIBLLDB_LOG_EXPRESSIONS, "Imported module %s from {%s}",
8346-
module.path.front().AsCString(), ss.GetData());
8348+
LOG_PRINTF(LIBLLDB_LOG_TYPES | LIBLLDB_LOG_EXPRESSIONS,
8349+
"Imported module %s from {%s}", module.path.front().AsCString(),
8350+
ss.GetData());
83478351
}
83488352
return swift_module;
83498353
}
@@ -8411,7 +8415,7 @@ bool SwiftASTContext::CacheUserImports(SwiftASTContext &swift_ast_context,
84118415
SourceModule module_info;
84128416
ConstString module_const_str(module_name);
84138417
module_info.path.push_back(module_const_str);
8414-
LOG_PRINTF(LIBLLDB_LOG_EXPRESSIONS,
8418+
LOG_PRINTF(LIBLLDB_LOG_TYPES | LIBLLDB_LOG_EXPRESSIONS,
84158419
"Performing auto import on found module: %s.\n",
84168420
module_name.c_str());
84178421
if (!LoadOneModule(module_info, swift_ast_context, stack_frame_wp,

0 commit comments

Comments
 (0)