Author: jmolenda Date: Wed Aug 23 17:58:14 2017 New Revision: 311622 URL: http://llvm.org/viewvc/llvm-project?rev=311622&view=rev Log: 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>
Modified: lldb/trunk/source/Host/macosx/Symbols.cpp lldb/trunk/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp Modified: lldb/trunk/source/Host/macosx/Symbols.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Symbols.cpp?rev=311622&r1=311621&r2=311622&view=diff ============================================================================== --- lldb/trunk/source/Host/macosx/Symbols.cpp (original) +++ lldb/trunk/source/Host/macosx/Symbols.cpp Wed Aug 23 17:58:14 2017 @@ -361,6 +361,7 @@ static bool GetModuleSpecInfoFromUUIDDic // 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 GetModuleSpecInfoFromUUIDDic 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 GetModuleSpecInfoFromUUIDDic 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) Modified: lldb/trunk/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp?rev=311622&r1=311621&r2=311622&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp (original) +++ lldb/trunk/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp Wed Aug 23 17:58:14 2017 @@ -220,6 +220,7 @@ SymbolVendorMacOSX::CreateInstance(const // 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 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 ->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 } 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; }); _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits