summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEnrico Granata <egranata@apple.com>2012-11-08 02:44:10 +0000
committerEnrico Granata <egranata@apple.com>2012-11-08 02:44:10 +0000
commit2ffcf43a135a522f966cf03350b65aed6c9a40f3 (patch)
tree6fd7f110c1a4d0b0013822052df707a7627d6451
parent1759848be00a5ab48ba5bccb70945b30c68da7f1 (diff)
downloadbcm5719-llvm-2ffcf43a135a522f966cf03350b65aed6c9a40f3.tar.gz
bcm5719-llvm-2ffcf43a135a522f966cf03350b65aed6c9a40f3.zip
Adding support for loading the scripting resource as part of a framework, lacking the dSYM bundle, or if the bundle has no Pythonic resources whatsoever
Solving an issue where "command script import" would fail to pick the file indicated by the user as a result of something with the same name being in an earlier position in sys.path llvm-svn: 167570
-rw-r--r--lldb/source/Interpreter/ScriptInterpreterPython.cpp2
-rw-r--r--lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp25
2 files changed, 24 insertions, 3 deletions
diff --git a/lldb/source/Interpreter/ScriptInterpreterPython.cpp b/lldb/source/Interpreter/ScriptInterpreterPython.cpp
index 87c2008e73a..11a64b6f6cd 100644
--- a/lldb/source/Interpreter/ScriptInterpreterPython.cpp
+++ b/lldb/source/Interpreter/ScriptInterpreterPython.cpp
@@ -2424,7 +2424,7 @@ ScriptInterpreterPython::LoadScriptingModule (const char* pathname,
// now make sure that Python has "directory" in the search path
StreamString command_stream;
- command_stream.Printf("if not (sys.path.__contains__('%s')):\n sys.path.append('%s');\n\n",
+ command_stream.Printf("if not (sys.path.__contains__('%s')):\n sys.path.insert(1,'%s');\n\n",
directory,
directory);
bool syspath_retval = ExecuteMultipleLines(command_stream.GetData(), ScriptInterpreter::ExecuteScriptOptions().SetEnableIO(false).SetSetLLDBGlobals(false));
diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
index a0d47b95c90..6478b2ce74b 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
@@ -55,6 +55,9 @@ PlatformDarwin::LocateExecutableScriptingResource (const ModuleSpec &module_spec
const ArchSpec *arch = module_spec.GetArchitecturePtr();
const UUID *uuid = module_spec.GetUUIDPtr();
+ const char* module_directory = exec_fspec->GetDirectory().GetCString();
+ const char* module_basename = exec_fspec->GetFileNameStrippingExtension().GetCString();
+
Timer scoped_timer (__PRETTY_FUNCTION__,
"LocateExecutableScriptingResource (file = %s, arch = %s, uuid = %p)",
exec_fspec ? exec_fspec->GetFilename().AsCString ("<NULL>") : "<NULL>",
@@ -66,17 +69,35 @@ PlatformDarwin::LocateExecutableScriptingResource (const ModuleSpec &module_spec
FileSpec script_fspec;
+ StreamString path_string;
+
if (symbol_fspec && symbol_fspec.Exists())
{
// for OSX we are going to be in .dSYM/Contents/Resources/DWARF/<basename>
// let us go to .dSYM/Contents/Resources/Python/<basename>.py and see if the file exists
- StreamString path_string;
- path_string.Printf("%s/../Python/%s.py",symbol_fspec.GetDirectory().GetCString(),module_spec.GetFileSpec().GetFileNameStrippingExtension().GetCString());
+ path_string.Printf("%s/../Python/%s.py",symbol_fspec.GetDirectory().GetCString(),module_basename);
script_fspec.SetFile(path_string.GetData(), true);
if (!script_fspec.Exists())
script_fspec.Clear();
}
+ // no symbols or symbols did not have a scripting resource
+ if (!symbol_fspec || !script_fspec)
+ {
+ path_string.Clear();
+ path_string.Printf("%s.framework",module_basename);
+ if (strstr(module_directory, path_string.GetData()))
+ {
+ // we are going to be in foo.framework/Versions/X/foo
+ path_string.Clear();
+ // let's go to foo.framework/Versions/X/Resources/Python/foo.py
+ path_string.Printf("%s/Resources/Python/%s.py",module_directory,module_basename);
+ script_fspec.SetFile(path_string.GetData(), true);
+ if (!script_fspec.Exists())
+ script_fspec.Clear();
+ }
+ }
+
return script_fspec;
}
OpenPOWER on IntegriCloud