When parsing the DBGSourcePathRemapping plist entries

in a dSYM, and it's a version 2 DBGSourcePathRemapping,
in addition to the build/source paths specified, add 
build/source paths with the last two filename components
removed.  This more generic remapping can sometimes
help lldb to find the correct source file in complex
projects.
<rdar://problem/33973545> 

llvm-svn: 311622
This commit is contained in:
Jason Molenda 2017-08-24 00:58:14 +00:00
parent 8d15bbb019
commit c064881a36
2 changed files with 39 additions and 1 deletions

View File

@ -361,6 +361,7 @@ static bool GetModuleSpecInfoFromUUIDDictionary(CFDictionaryRef uuid_dict,
// If we see DBGVersion with a value of 2 or higher, this is a new style
// DBGSourcePathRemapping dictionary
bool new_style_source_remapping_dictionary = false;
bool do_truncate_remapping_names = false;
std::string original_DBGSourcePath_value = DBGSourcePath;
cf_str = (CFStringRef)CFDictionaryGetValue((CFDictionaryRef)uuid_dict,
CFSTR("DBGVersion"));
@ -372,6 +373,9 @@ static bool GetModuleSpecInfoFromUUIDDictionary(CFDictionaryRef uuid_dict,
if (version_number > 1) {
new_style_source_remapping_dictionary = true;
}
if (version_number == 2) {
do_truncate_remapping_names = true;
}
}
}
@ -409,9 +413,24 @@ static bool GetModuleSpecInfoFromUUIDDictionary(CFDictionaryRef uuid_dict,
FileSpec resolved_source_path(DBGSourcePath.c_str(), true);
DBGSourcePath = resolved_source_path.GetPath();
}
// With version 2 of DBGSourcePathRemapping, we can chop off the
// last two filename parts from the source remapping and get a
// more general source remapping that still works. Add this as
// another option in addition to the full source path remap.
module_spec.GetSourceMappingList().Append(
ConstString(DBGBuildSourcePath.c_str()),
ConstString(DBGSourcePath.c_str()), true);
if (do_truncate_remapping_names) {
FileSpec build_path(DBGBuildSourcePath.c_str(), false);
FileSpec source_path(DBGSourcePath.c_str(), false);
build_path.RemoveLastPathComponent();
build_path.RemoveLastPathComponent();
source_path.RemoveLastPathComponent();
source_path.RemoveLastPathComponent();
module_spec.GetSourceMappingList().Append(
ConstString(build_path.GetPath().c_str()),
ConstString(source_path.GetPath().c_str()), true);
}
}
}
if (keys)

View File

@ -220,6 +220,7 @@ SymbolVendorMacOSX::CreateInstance(const lldb::ModuleSP &module_sp,
// the original
// gloal DBGSourcePath string.
bool new_style_source_remapping_dictionary = false;
bool do_truncate_remapping_names = false;
std::string original_DBGSourcePath_value =
DBGSourcePath;
if (plist_sp->GetAsDictionary()->HasKey("DBGVersion")) {
@ -233,6 +234,9 @@ SymbolVendorMacOSX::CreateInstance(const lldb::ModuleSP &module_sp,
if (version_number > 1) {
new_style_source_remapping_dictionary = true;
}
if (version_number == 2) {
do_truncate_remapping_names = true;
}
}
}
@ -242,7 +246,7 @@ SymbolVendorMacOSX::CreateInstance(const lldb::ModuleSP &module_sp,
->GetAsDictionary();
remappings_dict->ForEach(
[&module_sp, new_style_source_remapping_dictionary,
original_DBGSourcePath_value](
original_DBGSourcePath_value, do_truncate_remapping_names](
ConstString key,
StructuredData::Object *object) -> bool {
if (object && object->GetAsString()) {
@ -264,6 +268,21 @@ SymbolVendorMacOSX::CreateInstance(const lldb::ModuleSP &module_sp,
}
module_sp->GetSourceMappingList().Append(
key, ConstString(DBGSourcePath), true);
// With version 2 of DBGSourcePathRemapping, we can chop off the
// last two filename parts from the source remapping and get a
// more general source remapping that still works. Add this as
// another option in addition to the full source path remap.
if (do_truncate_remapping_names) {
FileSpec build_path(key.AsCString(), false);
FileSpec source_path(DBGSourcePath.c_str(), false);
build_path.RemoveLastPathComponent();
build_path.RemoveLastPathComponent();
source_path.RemoveLastPathComponent();
source_path.RemoveLastPathComponent();
module_sp->GetSourceMappingList().Append(
ConstString(build_path.GetPath().c_str()),
ConstString(source_path.GetPath().c_str()), true);
}
}
return true;
});