Misc module/dwarf logging improvements

This change improves the logging for the lldb.module category to note a few interesting cases:

1. Local object file found, but specs not matching
2. Local object file not found, using a placeholder module

The handling and logging for the cases wehre we fail to load compressed dwarf
symbols is also improved.

Differential Revision: https://reviews.llvm.org/D50274

llvm-svn: 339161
This commit is contained in:
Leonard Mosescu 2018-08-07 18:00:30 +00:00
parent 57e6dd7222
commit 9ba51579fb
5 changed files with 33 additions and 19 deletions

View File

@ -28,5 +28,4 @@ Sections:
# CHECK-NEXT: Type: regular # CHECK-NEXT: Type: regular
# CHECK-NEXT: VM size: 0 # CHECK-NEXT: VM size: 0
# CHECK-NEXT: File size: 8 # CHECK-NEXT: File size: 8
# CHECK-NEXT: Data: # CHECK-NEXT: Data: ()
# CHECK-NEXT: DEADBEEF BAADF00D

View File

@ -162,9 +162,13 @@ Module::Module(const ModuleSpec &module_spec)
// fill any ivars in so we don't accidentally grab the wrong file later since // fill any ivars in so we don't accidentally grab the wrong file later since
// they don't match... // they don't match...
ModuleSpec matching_module_spec; ModuleSpec matching_module_spec;
if (modules_specs.FindMatchingModuleSpec(module_spec, matching_module_spec) == if (!modules_specs.FindMatchingModuleSpec(module_spec,
0) matching_module_spec)) {
if (log) {
log->Printf("Found local object file but the specs didn't match");
}
return; return;
}
if (module_spec.GetFileSpec()) if (module_spec.GetFileSpec())
m_mod_time = FileSystem::GetModificationTime(module_spec.GetFileSpec()); m_mod_time = FileSystem::GetModificationTime(module_spec.GetFileSpec());

View File

@ -3385,8 +3385,6 @@ size_t ObjectFileELF::ReadSectionData(Section *section,
if (section->GetObjectFile() != this) if (section->GetObjectFile() != this)
return section->GetObjectFile()->ReadSectionData(section, section_data); return section->GetObjectFile()->ReadSectionData(section, section_data);
Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_MODULES);
size_t result = ObjectFile::ReadSectionData(section, section_data); size_t result = ObjectFile::ReadSectionData(section, section_data);
if (result == 0 || !section->Test(SHF_COMPRESSED)) if (result == 0 || !section->Test(SHF_COMPRESSED))
return result; return result;
@ -3397,20 +3395,27 @@ size_t ObjectFileELF::ReadSectionData(Section *section,
size_t(section_data.GetByteSize())}, size_t(section_data.GetByteSize())},
GetByteOrder() == eByteOrderLittle, GetAddressByteSize() == 8); GetByteOrder() == eByteOrderLittle, GetAddressByteSize() == 8);
if (!Decompressor) { if (!Decompressor) {
LLDB_LOG_ERROR(log, Decompressor.takeError(), GetModule()->ReportWarning(
"Unable to initialize decompressor for section {0}", "Unable to initialize decompressor for section '%s': %s",
section->GetName()); section->GetName().GetCString(),
return result; llvm::toString(Decompressor.takeError()).c_str());
section_data.Clear();
return 0;
} }
auto buffer_sp = auto buffer_sp =
std::make_shared<DataBufferHeap>(Decompressor->getDecompressedSize(), 0); std::make_shared<DataBufferHeap>(Decompressor->getDecompressedSize(), 0);
if (auto Error = Decompressor->decompress( if (auto error = Decompressor->decompress(
{reinterpret_cast<char *>(buffer_sp->GetBytes()), {reinterpret_cast<char *>(buffer_sp->GetBytes()),
size_t(buffer_sp->GetByteSize())})) { size_t(buffer_sp->GetByteSize())})) {
LLDB_LOG_ERROR(log, std::move(Error), "Decompression of section {0} failed", GetModule()->ReportWarning(
section->GetName()); "Decompression of section '%s' failed: %s",
return result; section->GetName().GetCString(),
llvm::toString(std::move(error)).c_str());
section_data.Clear();
return 0;
} }
section_data.SetData(buffer_sp); section_data.SetData(buffer_sp);
return buffer_sp->GetByteSize(); return buffer_sp->GetByteSize();
} }

View File

@ -365,6 +365,12 @@ void ProcessMinidump::ReadModuleList() {
// This enables most LLDB functionality involving address-to-module // This enables most LLDB functionality involving address-to-module
// translations (ex. identifing the module for a stack frame PC) and // translations (ex. identifing the module for a stack frame PC) and
// modules/sections commands (ex. target modules list, ...) // modules/sections commands (ex. target modules list, ...)
if (log) {
log->Printf("Unable to locate the matching object file, creating a "
"placeholder module for: %s",
name.getValue().c_str());
}
auto placeholder_module = auto placeholder_module =
std::make_shared<PlaceholderModule>(module_spec); std::make_shared<PlaceholderModule>(module_spec);
placeholder_module->CreateImageSection(module, GetTarget()); placeholder_module->CreateImageSection(module, GetTarget());

View File

@ -5842,7 +5842,7 @@ void Process::ModulesDidLoad(ModuleList &module_list) {
// that loaded. // that loaded.
// Iterate over a copy of this language runtime list in case the language // Iterate over a copy of this language runtime list in case the language
// runtime ModulesDidLoad somehow causes the language riuntime to be // runtime ModulesDidLoad somehow causes the language runtime to be
// unloaded. // unloaded.
LanguageRuntimeCollection language_runtimes(m_language_runtimes); LanguageRuntimeCollection language_runtimes(m_language_runtimes);
for (const auto &pair : language_runtimes) { for (const auto &pair : language_runtimes) {