[PATCH] D11003: Tolerate DWARF compile unit without filename.
Greg Clayton
clayborg at gmail.com
Tue Jul 7 11:16:31 PDT 2015
clayborg requested changes to this revision.
This revision now requires changes to proceed.
Just create the compile unit first with an empty file spec, and then afterward, use CompileUnit::GetSupportFiles() so that we don't parse the line table files and throw them away. The exact code you need is in the inline comments. This way we won't end up parsing the support files once in SymbolFileDWARF::ParseCompileUnit() and then again in SymbolFileDWARF::ParseCompileUnitSupportFiles() when the lldb_private::CompileUnit parses them.
================
Comment at: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:991-1009
@@ -990,3 +990,21 @@
cu_file_spec.SetFile(remapped_file, false);
-
+ }
+ else
+ {
+ // If there is no filename in the compilation unit,
+ // use the first filename from the debug line table.
+ const char *cu_comp_dir{cu_die->GetAttributeValueAsString(this, dwarf_cu, DW_AT_comp_dir, nullptr)};
+ cu_comp_dir = removeHostnameFromPathname(cu_comp_dir);
+ dw_offset_t stmt_list = cu_die->GetAttributeValueAsUnsigned(this, dwarf_cu, DW_AT_stmt_list, DW_INVALID_OFFSET);
+ FileSpecList support_files;
+ if (stmt_list != DW_INVALID_OFFSET &&
+ DWARFDebugLine::ParseSupportFiles(module_sp, get_debug_line_data(), cu_comp_dir, stmt_list, support_files) &&
+ support_files.GetSize() > 0)
+ {
+ cu_file_spec = support_files.GetFileSpecAtIndex(0);
+ }
+ // ParseSupportFiles already prepended cu_comp_dir and remapped the file.
+ }
+ if (cu_file_spec)
+ {
LanguageType cu_language = DWARFCompileUnit::LanguageTypeFromDWARF(cu_die->GetAttributeValueAsUnsigned(this, dwarf_cu, DW_AT_language, 0));
----------------
remove this
================
Comment at: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:1017
@@ -998,3 +1016,3 @@
cu_language));
if (cu_sp)
{
----------------
inside this if statement, adddo the following:
```
if (cu_sp)
{
// If we just created a compile unit with an invalid file spec, try and get the
// first entry in the supports files from the line table as that should be the
// compile unit.
if (!cu_file_spec)
{
cu_file_spec = cu_sp->GetSupportFiles().GetFileSpecAtIndex(0);
if (cu_file_spec)
(FileSpec &)(*cu_sp) = cu_file_spec;
}
```
http://reviews.llvm.org/D11003
More information about the llvm-commits
mailing list