From bd5c8d167b7cce3290d755e29623d047c2ad8e3e Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Sun, 22 Dec 2019 16:46:01 -0800 Subject: [PATCH] [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. --- lldb/include/lldb/Interpreter/ScriptInterpreter.h | 5 +---- lldb/source/Commands/CommandObjectCommands.cpp | 7 ------- lldb/source/Interpreter/ScriptInterpreter.cpp | 8 ++++++++ lldb/test/Shell/ScriptInterpreter/None/import_module.test | 2 ++ 4 files changed, 11 insertions(+), 11 deletions(-) create mode 100644 lldb/test/Shell/ScriptInterpreter/None/import_module.test diff --git a/lldb/include/lldb/Interpreter/ScriptInterpreter.h b/lldb/include/lldb/Interpreter/ScriptInterpreter.h index b32962b..4b86694 100644 --- a/lldb/include/lldb/Interpreter/ScriptInterpreter.h +++ b/lldb/include/lldb/Interpreter/ScriptInterpreter.h @@ -459,10 +459,7 @@ public: 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 b47cc372..36d6b83 100644 --- a/lldb/source/Commands/CommandObjectCommands.cpp +++ b/lldb/source/Commands/CommandObjectCommands.cpp @@ -1426,13 +1426,6 @@ protected: }; 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 0ef8590..c7207db 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 0000000..0af7bfa --- /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. -- 2.7.4