<rdar://problem/12973809>
Fixed an issue with the auto loading of script resources in debug info files. Any platform can add support for this, and on MacOSX we allow dSYM files to contain python modules that get automatically loaded when a dSYM file is associated with an executable or shared library.
The modifications will now:
- Let the module locate the symbol file naturally instead of using a function that only works in certain cases. This helps us to locate the script resources as long as the dSYM file can be found.
- Don't try and do any of this if the script interpreter has scripting disabled.
- Allow more than one scripting resource to be found in a symbol file by returning the list
- Load the scripting resources when a symbol file is added via the "target symbols add" command.
- Be smarter about matching the dSYM mach-o file to an existing executable in the target images by stripping extensions on the symfile basname if needed.
git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@172275 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Commands/CommandObjectTarget.cpp b/source/Commands/CommandObjectTarget.cpp
index 1a6f3be..badea45 100644
--- a/source/Commands/CommandObjectTarget.cpp
+++ b/source/Commands/CommandObjectTarget.cpp
@@ -4272,7 +4272,24 @@
// current target, so we need to find that module in the
// target
ModuleList matching_module_list;
- const size_t num_matches = target->GetImages().FindModules (module_spec, matching_module_list);
+ size_t num_matches = target->GetImages().FindModules (module_spec, matching_module_list);
+ while (num_matches == 0)
+ {
+ ConstString filename_no_extension(module_spec.GetFileSpec().GetFileNameStrippingExtension());
+ // Empty string returned, lets bail
+ if (!filename_no_extension)
+ break;
+
+ // Check if there was no extension to strip and the basename is the same
+ if (filename_no_extension == module_spec.GetFileSpec().GetFilename())
+ break;
+
+ // Replace basename with one less extension
+ module_spec.GetFileSpec().GetFilename() = filename_no_extension;
+
+ num_matches = target->GetImages().FindModules (module_spec, matching_module_list);
+ }
+
if (num_matches > 1)
{
result.AppendErrorWithFormat ("multiple modules match symbol file '%s', use the --uuid option to resolve the ambiguity.\n", symfile_path);
@@ -4309,6 +4326,12 @@
ModuleList module_list;
module_list.Append (module_sp);
target->ModulesDidLoad (module_list);
+
+ // Make sure we load any scripting resources that may be embedded
+ // in the debug info files in case the platform supports that.
+ Error error;
+ module_sp->LoadScriptingResourceInTarget (target, error);
+
flush = true;
result.SetStatus (eReturnStatusSuccessFinishResult);
return true;
@@ -4317,7 +4340,6 @@
}
// Clear the symbol file spec if anything went wrong
module_sp->SetSymbolFileFileSpec (FileSpec());
-
}
if (module_spec.GetUUID().IsValid())