Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp =================================================================== --- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -972,39 +972,26 @@ const DWARFDebugInfoEntry * cu_die = dwarf_cu->GetCompileUnitDIEOnly (); if (cu_die) { - const char * cu_die_name = cu_die->GetName(this, dwarf_cu); - const char * cu_comp_dir = cu_die->GetAttributeValueAsString(this, dwarf_cu, DW_AT_comp_dir, NULL); - LanguageType cu_language = (LanguageType)cu_die->GetAttributeValueAsUnsigned(this, dwarf_cu, DW_AT_language, 0); - if (cu_die_name) + FileSpec cu_file_spec{ cu_die->GetName(this, dwarf_cu), false }; + if (cu_file_spec) { - std::string ramapped_file; - FileSpec cu_file_spec; - - if (cu_die_name[0] == '/' || cu_comp_dir == NULL || cu_comp_dir[0] == '\0') - { - // If we have a full path to the compile unit, we don't need to resolve - // the file. This can be expensive e.g. when the source files are NFS mounted. - if (module_sp->RemapSourceFile(cu_die_name, ramapped_file)) - cu_file_spec.SetFile (ramapped_file.c_str(), false); - else - cu_file_spec.SetFile (cu_die_name, false); - } - else + FileSpec cu_comp_dir{cu_die->GetAttributeValueAsString(this, dwarf_cu, DW_AT_comp_dir, NULL), false}; + LanguageType cu_language = (LanguageType)cu_die->GetAttributeValueAsUnsigned(this, dwarf_cu, DW_AT_language, 0); + // If we have a full path to the compile unit, we don't need to resolve + // the file. This can be expensive e.g. when the source files are NFS mounted. + if (cu_file_spec.IsRelativeToCurrentWorkingDirectory() && cu_comp_dir) { // DWARF2/3 suggests the form hostname:pathname for compilation directory. // Remove the host part if present. - cu_comp_dir = removeHostnameFromPathname(cu_comp_dir); - std::string fullpath(cu_comp_dir); - - if (*fullpath.rbegin() != '/') - fullpath += '/'; - fullpath += cu_die_name; - if (module_sp->RemapSourceFile (fullpath.c_str(), ramapped_file)) - cu_file_spec.SetFile (ramapped_file.c_str(), false); - else - cu_file_spec.SetFile (fullpath.c_str(), false); + const char *cu_die_name = cu_file_spec.GetCString(); + cu_file_spec.SetFile(removeHostnameFromPathname(cu_comp_dir.GetCString()), false); + cu_file_spec.AppendPathComponent(cu_die_name); } + std::string ramapped_file; + if (module_sp->RemapSourceFile(cu_file_spec.GetCString(), ramapped_file)) + cu_file_spec.SetFile(ramapped_file.c_str(), false); + cu_sp.reset(new CompileUnit (module_sp, dwarf_cu, cu_file_spec,