summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/source/Commands/CommandObjectCommands.cpp4
-rw-r--r--lldb/source/Core/Module.cpp2
-rw-r--r--lldb/source/Interpreter/ScriptInterpreterPython.cpp5
-rw-r--r--lldb/test/functionalities/command_script/import/TestImport.py8
4 files changed, 10 insertions, 9 deletions
diff --git a/lldb/source/Commands/CommandObjectCommands.cpp b/lldb/source/Commands/CommandObjectCommands.cpp
index 278fdc0c876..5964eacce55 100644
--- a/lldb/source/Commands/CommandObjectCommands.cpp
+++ b/lldb/source/Commands/CommandObjectCommands.cpp
@@ -1355,7 +1355,7 @@ protected:
void
OptionParsingStarting ()
{
- m_allow_reload = false;
+ m_allow_reload = true;
}
const OptionDefinition*
@@ -1426,7 +1426,7 @@ protected:
OptionDefinition
CommandObjectCommandsScriptImport::CommandOptions::g_option_table[] =
{
- { LLDB_OPT_SET_1, false, "allow-reload", 'r', no_argument, NULL, 0, eArgTypeNone, "Allow the script to be loaded even if it was already loaded before (for Python, the __lldb_init_module function will be called again, but the module will not be reloaded from disk)."},
+ { LLDB_OPT_SET_1, false, "allow-reload", 'r', no_argument, NULL, 0, eArgTypeNone, "Allow the script to be loaded even if it was already loaded before. This argument exists for backwards compatibility, but reloading is always allowed, whether you specify it or not."},
{ 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
};
diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp
index 0967ef7100d..d8420ab8af1 100644
--- a/lldb/source/Core/Module.cpp
+++ b/lldb/source/Core/Module.cpp
@@ -1287,7 +1287,7 @@ Module::LoadScriptingResourceInTarget (Target *target, Error& error, Stream* fee
}
StreamString scripting_stream;
scripting_fspec.Dump(&scripting_stream);
- const bool can_reload = false;
+ const bool can_reload = true;
const bool init_lldb_globals = false;
bool did_load = script_interpreter->LoadScriptingModule(scripting_stream.GetData(), can_reload, init_lldb_globals, error);
if (!did_load)
diff --git a/lldb/source/Interpreter/ScriptInterpreterPython.cpp b/lldb/source/Interpreter/ScriptInterpreterPython.cpp
index b54ef1ca901..da80e0ce0e8 100644
--- a/lldb/source/Interpreter/ScriptInterpreterPython.cpp
+++ b/lldb/source/Interpreter/ScriptInterpreterPython.cpp
@@ -2672,7 +2672,10 @@ ScriptInterpreterPython::LoadScriptingModule (const char* pathname,
// now actually do the import
command_stream.Clear();
- command_stream.Printf("import %s",basename.c_str());
+ if (was_imported)
+ command_stream.Printf("reload(%s)",basename.c_str());
+ else
+ command_stream.Printf("import %s",basename.c_str());
bool import_retval = ExecuteMultipleLines(command_stream.GetData(), ScriptInterpreter::ExecuteScriptOptions().SetEnableIO(false).SetSetLLDBGlobals(false).SetMaskoutErrors(false));
PyObject* py_error = PyErr_Occurred(); // per Python docs: "you do not need to Py_DECREF()" the return of this function
diff --git a/lldb/test/functionalities/command_script/import/TestImport.py b/lldb/test/functionalities/command_script/import/TestImport.py
index 2356fcee850..2f0121bd73d 100644
--- a/lldb/test/functionalities/command_script/import/TestImport.py
+++ b/lldb/test/functionalities/command_script/import/TestImport.py
@@ -45,17 +45,15 @@ class ImportTestCase(TestBase):
error=True, startstr='error: module importing failed')
self.expect("command script import ./nosuchfolder/",
error=True, startstr='error: module importing failed')
- self.expect("command script import ./foo/foo.py",
- error=True, startstr='error: module importing failed')
+ self.expect("command script import ./foo/foo.py", error=False)
self.runCmd("command script import --allow-reload ./thepackage")
self.expect("TPcommandA",substrs=["hello world A"])
self.expect("TPcommandB",substrs=["hello world B"])
self.runCmd("script import dummymodule")
- self.expect("command script import ./dummymodule.py",
- error=True, startstr='error: module importing failed')
- self.runCmd("command script import --allow-reload ./dummymodule.py")
+ self.expect("command script import ./dummymodule.py", error=False)
+ self.expect("command script import --allow-reload ./dummymodule.py", error=False)
self.runCmd("command script add -f foo.foo_function foocmd")
self.runCmd("command script add -f foobar.foo_function foobarcmd")
OpenPOWER on IntegriCloud