Skip to content

Commit 4be640f

Browse files
authored
Merge pull request #482 from adrian-prantl/logging
Suppress logging of empty module summaries (NFC)
2 parents 6bfee9d + b0fd0bd commit 4be640f

File tree

3 files changed

+21
-19
lines changed

3 files changed

+21
-19
lines changed

lldb/include/lldb/Symbol/SwiftASTContext.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,8 @@ class SwiftASTContext : public TypeSystem {
250250
void LoadModule(swift::ModuleDecl *swift_module, Process &process,
251251
Status &error);
252252

253-
bool RegisterSectionModules(Module &module,
253+
/// Collect Swift modules in the .swift_ast section of \p module.
254+
void RegisterSectionModules(Module &module,
254255
std::vector<std::string> &module_names);
255256

256257
void ValidateSectionModules(Module &module, // this is used to print errors

lldb/source/Symbol/SwiftASTContext.cpp

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1791,15 +1791,16 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(lldb::LanguageType language,
17911791

17921792
std::vector<std::string> module_names;
17931793
swift_ast_sp->RegisterSectionModules(module, module_names);
1794-
swift_ast_sp->ValidateSectionModules(module, module_names);
1795-
1796-
if (lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_TYPES)) {
1797-
std::lock_guard<std::recursive_mutex> locker(g_log_mutex);
1798-
LOG_PRINTF(LIBLLDB_LOG_TYPES, "((Module*)%p, \"%s\") = %p",
1799-
static_cast<void *>(&module),
1800-
module.GetFileSpec().GetFilename().AsCString("<anonymous>"),
1801-
static_cast<void *>(swift_ast_sp.get()));
1802-
swift_ast_sp->LogConfiguration();
1794+
if (module_names.size()) {
1795+
swift_ast_sp->ValidateSectionModules(module, module_names);
1796+
if (lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_TYPES)) {
1797+
std::lock_guard<std::recursive_mutex> locker(g_log_mutex);
1798+
LOG_PRINTF(LIBLLDB_LOG_TYPES, "((Module*)%p, \"%s\") = %p",
1799+
static_cast<void *>(&module),
1800+
module.GetFileSpec().GetFilename().AsCString("<anonymous>"),
1801+
static_cast<void *>(swift_ast_sp.get()));
1802+
swift_ast_sp->LogConfiguration();
1803+
}
18031804
}
18041805
return swift_ast_sp;
18051806
}
@@ -4224,18 +4225,18 @@ static std::string GetBriefModuleName(Module &module) {
42244225
return ss.GetString().str();
42254226
}
42264227

4227-
bool SwiftASTContext::RegisterSectionModules(
4228+
void SwiftASTContext::RegisterSectionModules(
42284229
Module &module, std::vector<std::string> &module_names) {
4229-
VALID_OR_RETURN(false);
4230+
VALID_OR_RETURN_VOID();
42304231

42314232
swift::MemoryBufferSerializedModuleLoader *loader =
42324233
GetMemoryBufferModuleLoader();
42334234
if (!loader)
4234-
return false;
4235+
return;
42354236

42364237
SectionList *section_list = module.GetSectionList();
42374238
if (!section_list)
4238-
return false;
4239+
return;
42394240

42404241
SectionSP section_sp(
42414242
section_list->FindSectionByType(eSectionTypeSwiftModules, true));
@@ -4250,12 +4251,12 @@ bool SwiftASTContext::RegisterSectionModules(
42504251
if (swift::parseASTSection(*loader, section_data_ref, llvm_modules)) {
42514252
for (auto module_name : llvm_modules)
42524253
module_names.push_back(module_name);
4253-
return true;
4254+
return;
42544255
}
42554256
}
42564257
} else {
42574258
if (m_ast_file_data_map.find(&module) != m_ast_file_data_map.end())
4258-
return true;
4259+
return;
42594260

42604261
// Grab all the AST blobs from the symbol vendor.
42614262
auto ast_file_datas = module.GetASTData(eLanguageTypeSwift);
@@ -4301,10 +4302,10 @@ bool SwiftASTContext::RegisterSectionModules(
43014302
}
43024303
if (!ast_file_datas.empty() && (parse_fail_count == 0)) {
43034304
// We found AST data entries and we successfully parsed all of them.
4304-
return true;
4305+
return;
43054306
}
43064307
}
4307-
return false;
4308+
return;
43084309
}
43094310

43104311
void SwiftASTContext::ValidateSectionModules(

lldb/source/Target/SwiftLanguageRuntime.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1878,7 +1878,7 @@ bool SwiftLanguageRuntime::GetDynamicTypeAndAddress_Protocol(
18781878
}
18791879

18801880
if (log)
1881-
log->Printf("existential address is %llu", existential_address);
1881+
log->Printf("existential address is 0x%llx", existential_address);
18821882

18831883
if (!existential_address || existential_address == LLDB_INVALID_ADDRESS)
18841884
return false;

0 commit comments

Comments
 (0)