Author: Jonas Devlieghere Date: 2019-12-21T22:32:13-08:00 New Revision: 68cb7d85423c19a61c5d6afbc8e004a345a28856
URL: https://github.com/llvm/llvm-project/commit/68cb7d85423c19a61c5d6afbc8e004a345a28856 DIFF: https://github.com/llvm/llvm-project/commit/68cb7d85423c19a61c5d6afbc8e004a345a28856.diff LOG: [lldb/Commands] Honor the scripting language passed (2/2) This ensures that watchpoint command honors the scripting language passed with `-s`. Currently the argument ignores the actual language and only uses it to differentiate between lldb and script commands. Added: Modified: lldb/source/Commands/CommandObjectWatchpointCommand.cpp Removed: ################################################################################ diff --git a/lldb/source/Commands/CommandObjectWatchpointCommand.cpp b/lldb/source/Commands/CommandObjectWatchpointCommand.cpp index 237c4e28638c..4cc74e77ed4d 100644 --- a/lldb/source/Commands/CommandObjectWatchpointCommand.cpp +++ b/lldb/source/Commands/CommandObjectWatchpointCommand.cpp @@ -36,6 +36,11 @@ static constexpr OptionEnumValueElement g_script_option_enumeration[] = { "python", "Commands are in the Python language.", }, + { + eScriptLanguageLua, + "lua", + "Commands are in the Python language.", + }, { eSortOrderByName, "default-script", @@ -331,8 +336,16 @@ are no syntax errors may indicate that a function was declared but never called. option_arg, GetDefinitions()[option_idx].enum_values, eScriptLanguageNone, error); - m_use_script_language = (m_script_language == eScriptLanguagePython || - m_script_language == eScriptLanguageDefault); + switch (m_script_language) { + case eScriptLanguagePython: + case eScriptLanguageLua: + m_use_script_language = true; + break; + case eScriptLanguageNone: + case eScriptLanguageUnknown: + m_use_script_language = false; + break; + } break; case 'e': { @@ -347,7 +360,6 @@ are no syntax errors may indicate that a function was declared but never called. case 'F': m_use_one_liner = false; - m_use_script_language = true; m_function_name.assign(option_arg); break; @@ -398,12 +410,11 @@ are no syntax errors may indicate that a function was declared but never called. return false; } - if (!m_options.m_use_script_language && - !m_options.m_function_name.empty()) { - result.AppendError("need to enable scripting to have a function run as a " - "watchpoint command"); - result.SetStatus(eReturnStatusFailed); - return false; + if (!m_options.m_function_name.empty()) { + if (!m_options.m_use_script_language) { + m_options.m_script_language = GetDebugger().GetScriptLanguage(); + m_options.m_use_script_language = true; + } } std::vector<uint32_t> valid_wp_ids; @@ -433,9 +444,11 @@ are no syntax errors may indicate that a function was declared but never called. // to set or collect command callback. Otherwise, call the methods // associated with this object. if (m_options.m_use_script_language) { + ScriptInterpreter *script_interp = GetDebugger().GetScriptInterpreter( + /*can_create=*/true, m_options.m_script_language); // Special handling for one-liner specified inline. if (m_options.m_use_one_liner) { - GetDebugger().GetScriptInterpreter()->SetWatchpointCommandCallback( + script_interp->SetWatchpointCommandCallback( wp_options, m_options.m_one_liner.c_str()); } // Special handling for using a Python function by name instead of @@ -445,12 +458,11 @@ are no syntax errors may indicate that a function was declared but never called. else if (!m_options.m_function_name.empty()) { std::string oneliner(m_options.m_function_name); oneliner += "(frame, wp, internal_dict)"; - GetDebugger().GetScriptInterpreter()->SetWatchpointCommandCallback( + script_interp->SetWatchpointCommandCallback( wp_options, oneliner.c_str()); } else { - GetDebugger() - .GetScriptInterpreter() - ->CollectDataForWatchpointCommandCallback(wp_options, result); + script_interp->CollectDataForWatchpointCommandCallback(wp_options, + result); } } else { // Special handling for one-liner specified inline. _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits