Author: Jonas Devlieghere Date: 2019-12-22T16:47:28-08:00 New Revision: bd5c8d167b7cce3290d755e29623d047c2ad8e3e
URL: https://github.com/llvm/llvm-project/commit/bd5c8d167b7cce3290d755e29623d047c2ad8e3e DIFF: https://github.com/llvm/llvm-project/commit/bd5c8d167b7cce3290d755e29623d047c2ad8e3e.diff LOG: [lldb/ScriptInterpreter] Unify error message for command script import Rather than checking for Python explicitly, let the script interpreter handle things and print an error if the functionality is not supported. Added: lldb/test/Shell/ScriptInterpreter/None/import_module.test Modified: lldb/include/lldb/Interpreter/ScriptInterpreter.h lldb/source/Commands/CommandObjectCommands.cpp lldb/source/Interpreter/ScriptInterpreter.cpp Removed: ################################################################################ diff --git a/lldb/include/lldb/Interpreter/ScriptInterpreter.h b/lldb/include/lldb/Interpreter/ScriptInterpreter.h index b32962b80355..4b866949514d 100644 --- a/lldb/include/lldb/Interpreter/ScriptInterpreter.h +++ b/lldb/include/lldb/Interpreter/ScriptInterpreter.h @@ -459,10 +459,7 @@ class ScriptInterpreter : public PluginInterface { virtual bool LoadScriptingModule(const char *filename, bool can_reload, bool init_session, lldb_private::Status &error, - StructuredData::ObjectSP *module_sp = nullptr) { - error.SetErrorString("loading unimplemented"); - return false; - } + StructuredData::ObjectSP *module_sp = nullptr); virtual bool IsReservedWord(const char *word) { return false; } diff --git a/lldb/source/Commands/CommandObjectCommands.cpp b/lldb/source/Commands/CommandObjectCommands.cpp index b47cc372b4c1..36d6b83d1156 100644 --- a/lldb/source/Commands/CommandObjectCommands.cpp +++ b/lldb/source/Commands/CommandObjectCommands.cpp @@ -1426,13 +1426,6 @@ class CommandObjectCommandsScriptImport : public CommandObjectParsed { }; bool DoExecute(Args &command, CommandReturnObject &result) override { - if (GetDebugger().GetScriptLanguage() != lldb::eScriptLanguagePython) { - result.AppendError("only scripting language supported for module " - "importing is currently Python"); - result.SetStatus(eReturnStatusFailed); - return false; - } - if (command.empty()) { result.AppendError("command script import needs one or more arguments"); result.SetStatus(eReturnStatusFailed); diff --git a/lldb/source/Interpreter/ScriptInterpreter.cpp b/lldb/source/Interpreter/ScriptInterpreter.cpp index 0ef859061ab1..c7207db5523d 100644 --- a/lldb/source/Interpreter/ScriptInterpreter.cpp +++ b/lldb/source/Interpreter/ScriptInterpreter.cpp @@ -42,6 +42,14 @@ void ScriptInterpreter::CollectDataForWatchpointCommandCallback( "This script interpreter does not support watchpoint callbacks."); } +bool ScriptInterpreter::LoadScriptingModule( + const char *filename, bool can_reload, bool init_session, + lldb_private::Status &error, StructuredData::ObjectSP *module_sp) { + error.SetErrorString( + "This script interpreter does not support importing modules."); + return false; +} + std::string ScriptInterpreter::LanguageToString(lldb::ScriptLanguage language) { switch (language) { case eScriptLanguageNone: diff --git a/lldb/test/Shell/ScriptInterpreter/None/import_module.test b/lldb/test/Shell/ScriptInterpreter/None/import_module.test new file mode 100644 index 000000000000..0af7bfaf24f4 --- /dev/null +++ b/lldb/test/Shell/ScriptInterpreter/None/import_module.test @@ -0,0 +1,2 @@ +# RUN: %lldb --script-language none -o 'command script import %t' 2>&1 | FileCheck %s +# CHECK: error: module importing failed: This script interpreter does not support importing modules. _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits