diff options
author | Jonas Devlieghere <jonas@devlieghere.com> | 2019-12-21 22:20:03 -0800 |
---|---|---|
committer | Jonas Devlieghere <jonas@devlieghere.com> | 2019-12-21 22:32:13 -0800 |
commit | 68cb7d85423c19a61c5d6afbc8e004a345a28856 (patch) | |
tree | 5714210b5f1021624c5bc636615f473e420ae4f8 /lldb/source/Commands/CommandObjectWatchpointCommand.cpp | |
parent | acdda1344a0e1b45bd3ba7feb0e8cd398bee0179 (diff) | |
download | bcm5719-llvm-68cb7d85423c19a61c5d6afbc8e004a345a28856.tar.gz bcm5719-llvm-68cb7d85423c19a61c5d6afbc8e004a345a28856.zip |
[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.
Diffstat (limited to 'lldb/source/Commands/CommandObjectWatchpointCommand.cpp')
-rw-r--r-- | lldb/source/Commands/CommandObjectWatchpointCommand.cpp | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/lldb/source/Commands/CommandObjectWatchpointCommand.cpp b/lldb/source/Commands/CommandObjectWatchpointCommand.cpp index 237c4e28638..4cc74e77ed4 100644 --- a/lldb/source/Commands/CommandObjectWatchpointCommand.cpp +++ b/lldb/source/Commands/CommandObjectWatchpointCommand.cpp @@ -37,6 +37,11 @@ static constexpr OptionEnumValueElement g_script_option_enumeration[] = { "Commands are in the Python language.", }, { + eScriptLanguageLua, + "lua", + "Commands are in the Python language.", + }, + { eSortOrderByName, "default-script", "Commands are in the default scripting language.", @@ -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 @@ protected: 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 @@ protected: // 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 @@ protected: 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. |