diff --git a/lldb/source/Commands/CommandObjectBreakpointCommand.cpp b/lldb/source/Commands/CommandObjectBreakpointCommand.cpp --- a/lldb/source/Commands/CommandObjectBreakpointCommand.cpp +++ b/lldb/source/Commands/CommandObjectBreakpointCommand.cpp @@ -414,22 +414,23 @@ // to set or collect command callback. Otherwise, call the methods // associated with this object. if (m_options.m_use_script_language) { + Status error; 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) { - script_interp->SetBreakpointCommandCallback( + error = script_interp->SetBreakpointCommandCallback( m_bp_options_vec, m_options.m_one_liner.c_str()); } else if (!m_func_options.GetName().empty()) { - Status error = script_interp->SetBreakpointCommandCallbackFunction( + error = script_interp->SetBreakpointCommandCallbackFunction( m_bp_options_vec, m_func_options.GetName().c_str(), m_func_options.GetStructuredData()); - if (!error.Success()) - result.SetError(error); } else { script_interp->CollectDataForBreakpointCommandCallback( m_bp_options_vec, result); } + if (!error.Success()) + result.SetError(error); } else { // Special handling for one-liner specified inline. if (m_options.m_use_one_liner) diff --git a/lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp b/lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp --- a/lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Lua/Lua.cpp @@ -86,7 +86,7 @@ std::string func_str = llvm::formatv(fmt_str, body).str(); if (luaL_dostring(m_lua_state, func_str.c_str()) != LUA_OK) { llvm::Error e = llvm::make_error( - llvm::formatv("{0}\n", lua_tostring(m_lua_state, -1)), + llvm::formatv("{0}", lua_tostring(m_lua_state, -1)), llvm::inconvertibleErrorCode()); // Pop error message from the stack. lua_pop(m_lua_state, 2); diff --git a/lldb/test/Shell/ScriptInterpreter/Lua/fail_breakpoint_oneline.test b/lldb/test/Shell/ScriptInterpreter/Lua/fail_breakpoint_oneline.test new file mode 100644 --- /dev/null +++ b/lldb/test/Shell/ScriptInterpreter/Lua/fail_breakpoint_oneline.test @@ -0,0 +1,5 @@ +# REQUIRES: lua +# RUN: %lldb -s %s --script-language lua 2>&1 | FileCheck %s +b main +breakpoint command add -s lua -o '1234_foo' +# CHECK: error: {{.*}} unexpected symbol near '1234' diff --git a/lldb/test/Shell/ScriptInterpreter/Python/fail_breakpoint_oneline.test b/lldb/test/Shell/ScriptInterpreter/Python/fail_breakpoint_oneline.test new file mode 100644 --- /dev/null +++ b/lldb/test/Shell/ScriptInterpreter/Python/fail_breakpoint_oneline.test @@ -0,0 +1,7 @@ +# REQUIRES: python +# UNSUPPORTED: lldb-repro +# +# RUN: cat %s | %lldb --script-language python 2>&1 | FileCheck %s +b main +breakpoint command add -s python -o "1234_foo" +# CHECK: error: SyntaxError({{.*}})