Skip to content

Commit 1e34af3

Browse files
Merge pull request #3674 from adrian-prantl/dyliblog
Improve logging for dynamic library loading
2 parents 0aea8ec + 6585223 commit 1e34af3

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
@@ -8299,7 +8300,7 @@ static swift::ModuleDecl *LoadOneModule(const SourceModule &module,
82998300
error.Clear();
83008301
ConstString toplevel = module.path.front();
83018302
const std::string &m_description = swift_ast_context.GetDescription();
8302-
LOG_PRINTF(LIBLLDB_LOG_EXPRESSIONS, "Importing module %s",
8303+
LOG_PRINTF(LIBLLDB_LOG_TYPES | LIBLLDB_LOG_EXPRESSIONS, "Importing module %s",
83038304
toplevel.AsCString());
83048305
swift::ModuleDecl *swift_module = nullptr;
83058306
lldb::StackFrameSP this_frame_sp(stack_frame_wp.lock());
@@ -8324,7 +8325,7 @@ static swift::ModuleDecl *LoadOneModule(const SourceModule &module,
83248325
// checked that DWARF debug info for this module actually exists
83258326
// and there is no good mechanism to do so ahead of time.
83268327
// We do know that we never load the stdlib from DWARF though.
8327-
LOG_PRINTF(LIBLLDB_LOG_EXPRESSIONS,
8328+
LOG_PRINTF(LIBLLDB_LOG_TYPES | LIBLLDB_LOG_EXPRESSIONS,
83288329
"\"Imported\" module %s via SwiftDWARFImporterDelegate "
83298330
"(no Swift AST or Clang module found)",
83308331
toplevel.AsCString());
@@ -8334,20 +8335,23 @@ static swift::ModuleDecl *LoadOneModule(const SourceModule &module,
83348335
}
83358336

83368337
if (!swift_module || !error.Success() || swift_ast_context.HasFatalErrors()) {
8337-
LOG_PRINTF(LIBLLDB_LOG_EXPRESSIONS, "Couldn't import module %s: %s",
8338-
toplevel.AsCString(), error.AsCString());
8338+
LOG_PRINTF(LIBLLDB_LOG_TYPES | LIBLLDB_LOG_EXPRESSIONS,
8339+
"Couldn't import module %s: %s", toplevel.AsCString(),
8340+
error.AsCString());
83398341

83408342
if (!swift_module || swift_ast_context.HasFatalErrors()) {
83418343
return nullptr;
83428344
}
83438345
}
83448346

8345-
if (lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)) {
8347+
if (lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_TYPES |
8348+
LIBLLDB_LOG_EXPRESSIONS)) {
83468349
StreamString ss;
83478350
for (swift::FileUnit *file_unit : swift_module->getFiles())
83488351
DescribeFileUnit(ss, file_unit);
8349-
LOG_PRINTF(LIBLLDB_LOG_EXPRESSIONS, "Imported module %s from {%s}",
8350-
module.path.front().AsCString(), ss.GetData());
8352+
LOG_PRINTF(LIBLLDB_LOG_TYPES | LIBLLDB_LOG_EXPRESSIONS,
8353+
"Imported module %s from {%s}", module.path.front().AsCString(),
8354+
ss.GetData());
83518355
}
83528356
return swift_module;
83538357
}
@@ -8415,7 +8419,7 @@ bool SwiftASTContext::CacheUserImports(SwiftASTContext &swift_ast_context,
84158419
SourceModule module_info;
84168420
ConstString module_const_str(module_name);
84178421
module_info.path.push_back(module_const_str);
8418-
LOG_PRINTF(LIBLLDB_LOG_EXPRESSIONS,
8422+
LOG_PRINTF(LIBLLDB_LOG_TYPES | LIBLLDB_LOG_EXPRESSIONS,
84198423
"Performing auto import on found module: %s.\n",
84208424
module_name.c_str());
84218425
if (!LoadOneModule(module_info, swift_ast_context, stack_frame_wp,

0 commit comments

Comments
 (0)