[Lldb-commits] [lldb] 1da436a - [lldb] Return llvm::Error from breakpoint callback setters (#235964)
via lldb-commits
lldb-commits at lists.llvm.org
Mon Oct 26 16:53:32 PDT 2026
Author: Jonas Devlieghere
Date: 2026-10-26T16:53:25-07:00
New Revision: 1da436a23e613c425fc9b868fc8deb979ede47a4
URL: https://github.com/llvm/llvm-project/commit/1da436a23e613c425fc9b868fc8deb979ede47a4
DIFF: https://github.com/llvm/llvm-project/commit/1da436a23e613c425fc9b868fc8deb979ede47a4.diff
LOG: [lldb] Return llvm::Error from breakpoint callback setters (#235964)
Have ScriptInterpreter::SetBreakpointCommandCallback and
SetBreakpointCommandCallbackFunction return llvm::Error instead of
Status, converting back to SBError at the API boundary.
Requiring the error to be handled surfaces two dropped errors:
- The Python SetBreakpointCommandCallbackFunction ignored the result of
generating the callback.
- Deserializing a breakpoint reported the outer, still-empty Status
instead of the script error.
Assisted-by: Claude
Added:
Modified:
lldb/include/lldb/Interpreter/ScriptInterpreter.h
lldb/source/API/SBBreakpoint.cpp
lldb/source/API/SBBreakpointLocation.cpp
lldb/source/API/SBBreakpointName.cpp
lldb/source/Breakpoint/BreakpointOptions.cpp
lldb/source/Commands/CommandObjectBreakpointCommand.cpp
lldb/source/Interpreter/ScriptInterpreter.cpp
lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
Removed:
################################################################################
diff --git a/lldb/include/lldb/Interpreter/ScriptInterpreter.h b/lldb/include/lldb/Interpreter/ScriptInterpreter.h
index 1b8cf605bee67e..710a9db73cf173 100644
--- a/lldb/include/lldb/Interpreter/ScriptInterpreter.h
+++ b/lldb/include/lldb/Interpreter/ScriptInterpreter.h
@@ -271,33 +271,33 @@ class ScriptInterpreter : public PluginInterface {
CommandReturnObject &result);
/// Set the specified text as the callback for the breakpoint.
- Status SetBreakpointCommandCallback(
+ llvm::Error SetBreakpointCommandCallback(
std::vector<std::reference_wrapper<BreakpointOptions>> &bp_options_vec,
const char *callback_text);
- virtual Status SetBreakpointCommandCallback(BreakpointOptions &bp_options,
- const char *callback_text,
- bool is_callback) {
- return Status::FromErrorString("not implemented");
+ virtual llvm::Error
+ SetBreakpointCommandCallback(BreakpointOptions &bp_options,
+ const char *callback_text, bool is_callback) {
+ return llvm::createStringError("not implemented");
}
/// This one is for deserialization:
- virtual Status SetBreakpointCommandCallback(
+ virtual llvm::Error SetBreakpointCommandCallback(
BreakpointOptions &bp_options,
std::unique_ptr<BreakpointOptions::CommandData> &data_up) {
- return Status::FromErrorString("not implemented");
+ return llvm::createStringError("not implemented");
}
- Status SetBreakpointCommandCallbackFunction(
+ llvm::Error SetBreakpointCommandCallbackFunction(
std::vector<std::reference_wrapper<BreakpointOptions>> &bp_options_vec,
const char *function_name, StructuredData::ObjectSP extra_args_sp);
/// Set a script function as the callback for the breakpoint.
- virtual Status
+ virtual llvm::Error
SetBreakpointCommandCallbackFunction(BreakpointOptions &bp_options,
const char *function_name,
StructuredData::ObjectSP extra_args_sp) {
- return Status::FromErrorString("not implemented");
+ return llvm::createStringError("not implemented");
}
/// Set a one-liner as the callback for the watchpoint.
diff --git a/lldb/source/API/SBBreakpoint.cpp b/lldb/source/API/SBBreakpoint.cpp
index d5be88803fe0a5..e655561dc29198 100644
--- a/lldb/source/API/SBBreakpoint.cpp
+++ b/lldb/source/API/SBBreakpoint.cpp
@@ -650,18 +650,16 @@ SBError SBBreakpoint::SetScriptCallbackFunction(
BreakpointSP bkpt_sp = GetSP();
if (bkpt_sp) {
- Status error;
TargetAPIMutex api_lock = bkpt_sp->GetTarget().GetAPIMutex();
std::lock_guard<TargetAPIMutex> guard(api_lock);
BreakpointOptions &bp_options = bkpt_sp->GetOptions();
- error = bkpt_sp->GetTarget()
- .GetDebugger()
- .GetScriptInterpreter()
- ->SetBreakpointCommandCallbackFunction(bp_options,
- callback_function_name,
- extra_args.m_impl_up
- ->GetObjectSP());
- sb_error.SetError(std::move(error));
+ llvm::Error error = bkpt_sp->GetTarget()
+ .GetDebugger()
+ .GetScriptInterpreter()
+ ->SetBreakpointCommandCallbackFunction(
+ bp_options, callback_function_name,
+ extra_args.m_impl_up->GetObjectSP());
+ sb_error.SetError(Status::FromError(std::move(error)));
} else
sb_error = Status::FromErrorString("invalid breakpoint");
@@ -678,13 +676,13 @@ SBError SBBreakpoint::SetScriptCallbackBody(const char *callback_body_text) {
TargetAPIMutex api_lock = bkpt_sp->GetTarget().GetAPIMutex();
std::lock_guard<TargetAPIMutex> guard(api_lock);
BreakpointOptions &bp_options = bkpt_sp->GetOptions();
- Status error =
+ llvm::Error error =
bkpt_sp->GetTarget()
.GetDebugger()
.GetScriptInterpreter()
->SetBreakpointCommandCallback(bp_options, callback_body_text,
/*is_callback=*/false);
- sb_error.SetError(std::move(error));
+ sb_error.SetError(Status::FromError(std::move(error)));
} else
sb_error = Status::FromErrorString("invalid breakpoint");
diff --git a/lldb/source/API/SBBreakpointLocation.cpp b/lldb/source/API/SBBreakpointLocation.cpp
index 729721943ebdda..86ccbdae3bedea 100644
--- a/lldb/source/API/SBBreakpointLocation.cpp
+++ b/lldb/source/API/SBBreakpointLocation.cpp
@@ -234,23 +234,21 @@ SBError SBBreakpointLocation::SetScriptCallbackFunction(
BreakpointLocationSP loc_sp = GetSP();
if (loc_sp) {
- Status error;
TargetAPIMutex api_lock = loc_sp->GetTarget().GetAPIMutex();
std::lock_guard<TargetAPIMutex> guard(api_lock);
BreakpointOptions &bp_options = loc_sp->GetLocationOptions();
- error = loc_sp->GetBreakpoint()
- .GetTarget()
- .GetDebugger()
- .GetScriptInterpreter()
- ->SetBreakpointCommandCallbackFunction(bp_options,
- callback_function_name,
- extra_args.m_impl_up
- ->GetObjectSP());
- sb_error.SetError(std::move(error));
- } else
- sb_error = Status::FromErrorString("invalid breakpoint");
+ llvm::Error error = loc_sp->GetBreakpoint()
+ .GetTarget()
+ .GetDebugger()
+ .GetScriptInterpreter()
+ ->SetBreakpointCommandCallbackFunction(
+ bp_options, callback_function_name,
+ extra_args.m_impl_up->GetObjectSP());
+ sb_error.SetError(Status::FromError(std::move(error)));
+ } else
+ sb_error = Status::FromErrorString("invalid breakpoint");
- return sb_error;
+ return sb_error;
}
SBError
@@ -264,14 +262,14 @@ SBBreakpointLocation::SetScriptCallbackBody(const char *callback_body_text) {
TargetAPIMutex api_lock = loc_sp->GetTarget().GetAPIMutex();
std::lock_guard<TargetAPIMutex> guard(api_lock);
BreakpointOptions &bp_options = loc_sp->GetLocationOptions();
- Status error =
+ llvm::Error error =
loc_sp->GetBreakpoint()
.GetTarget()
.GetDebugger()
.GetScriptInterpreter()
->SetBreakpointCommandCallback(bp_options, callback_body_text,
/*is_callback=*/false);
- sb_error.SetError(std::move(error));
+ sb_error.SetError(Status::FromError(std::move(error)));
} else
sb_error = Status::FromErrorString("invalid breakpoint");
diff --git a/lldb/source/API/SBBreakpointName.cpp b/lldb/source/API/SBBreakpointName.cpp
index f57a0918743ea9..7fae481164a914 100644
--- a/lldb/source/API/SBBreakpointName.cpp
+++ b/lldb/source/API/SBBreakpointName.cpp
@@ -570,13 +570,13 @@ SBError SBBreakpointName::SetScriptCallbackFunction(
std::lock_guard<TargetAPIMutex> guard(api_lock);
BreakpointOptions &bp_options = bp_name->GetOptions();
- Status error = m_impl_up->GetTarget()
- ->GetDebugger()
- .GetScriptInterpreter()
- ->SetBreakpointCommandCallbackFunction(
- bp_options, callback_function_name,
- extra_args.m_impl_up->GetObjectSP());
- sb_error.SetError(std::move(error));
+ llvm::Error error = m_impl_up->GetTarget()
+ ->GetDebugger()
+ .GetScriptInterpreter()
+ ->SetBreakpointCommandCallbackFunction(
+ bp_options, callback_function_name,
+ extra_args.m_impl_up->GetObjectSP());
+ sb_error.SetError(Status::FromError(std::move(error)));
UpdateName(*bp_name);
return sb_error;
}
@@ -594,12 +594,13 @@ SBBreakpointName::SetScriptCallbackBody(const char *callback_body_text) {
std::lock_guard<TargetAPIMutex> guard(api_lock);
BreakpointOptions &bp_options = bp_name->GetOptions();
- Status error = m_impl_up->GetTarget()
- ->GetDebugger()
- .GetScriptInterpreter()
- ->SetBreakpointCommandCallback(
- bp_options, callback_body_text, /*is_callback=*/false);
- sb_error.SetError(std::move(error));
+ llvm::Error error =
+ m_impl_up->GetTarget()
+ ->GetDebugger()
+ .GetScriptInterpreter()
+ ->SetBreakpointCommandCallback(bp_options, callback_body_text,
+ /*is_callback=*/false);
+ sb_error.SetError(Status::FromError(std::move(error)));
if (!sb_error.Fail())
UpdateName(*bp_name);
diff --git a/lldb/source/Breakpoint/BreakpointOptions.cpp b/lldb/source/Breakpoint/BreakpointOptions.cpp
index cd456cd62936fb..f37c9a14a5e34a 100644
--- a/lldb/source/Breakpoint/BreakpointOptions.cpp
+++ b/lldb/source/Breakpoint/BreakpointOptions.cpp
@@ -19,6 +19,7 @@
#include "lldb/Utility/StringList.h"
#include "llvm/ADT/STLExtras.h"
+#include "llvm/Support/FormatAdapters.h"
using namespace lldb;
using namespace lldb_private;
@@ -312,12 +313,11 @@ std::unique_ptr<BreakpointOptions> BreakpointOptions::CreateFromStructuredData(
.c_str());
return nullptr;
}
- Status script_error;
- script_error =
- interp->SetBreakpointCommandCallback(*bp_options, cmd_data_up);
- if (script_error.Fail()) {
- error = Status::FromErrorStringWithFormat(
- "Error generating script callback: %s.", error.AsCString());
+ if (llvm::Error script_error =
+ interp->SetBreakpointCommandCallback(*bp_options, cmd_data_up)) {
+ error = Status::FromErrorStringWithFormatv(
+ "Error generating script callback: {0}.",
+ llvm::fmt_consume(std::move(script_error)));
return nullptr;
}
}
diff --git a/lldb/source/Commands/CommandObjectBreakpointCommand.cpp b/lldb/source/Commands/CommandObjectBreakpointCommand.cpp
index 67cdc8e2327813..f0ffad03ef6c0a 100644
--- a/lldb/source/Commands/CommandObjectBreakpointCommand.cpp
+++ b/lldb/source/Commands/CommandObjectBreakpointCommand.cpp
@@ -375,25 +375,23 @@ 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) {
- 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) {
- error = script_interp->SetBreakpointCommandCallback(
- m_bp_options_vec, m_options.m_one_liner.c_str());
- } else if (!m_func_options.GetName().empty()) {
- error = script_interp->SetBreakpointCommandCallbackFunction(
- m_bp_options_vec, m_func_options.GetName().c_str(),
- m_func_options.GetStructuredData());
- } else {
+ if (!m_options.m_use_one_liner && m_func_options.GetName().empty()) {
script_interp->CollectDataForBreakpointCommandCallback(
m_bp_options_vec, result);
// Still gathering input; the IOHandler will set the final status.
result.SetStatus(eReturnStatusStarted);
return;
}
- if (!error.Success())
+ llvm::Error error =
+ m_options.m_use_one_liner
+ ? script_interp->SetBreakpointCommandCallback(
+ m_bp_options_vec, m_options.m_one_liner.c_str())
+ : script_interp->SetBreakpointCommandCallbackFunction(
+ m_bp_options_vec, m_func_options.GetName().c_str(),
+ m_func_options.GetStructuredData());
+ if (error)
result.SetError(std::move(error));
else
result.SetStatus(eReturnStatusSuccessFinishNoResult);
diff --git a/lldb/source/Interpreter/ScriptInterpreter.cpp b/lldb/source/Interpreter/ScriptInterpreter.cpp
index a53f3b744f02ee..4f24d1b15f16a2 100644
--- a/lldb/source/Interpreter/ScriptInterpreter.cpp
+++ b/lldb/source/Interpreter/ScriptInterpreter.cpp
@@ -152,30 +152,24 @@ ScriptInterpreter::StringToExtension(llvm::StringRef string) {
.Default(eScriptedExtensionInvalid);
}
-Status ScriptInterpreter::SetBreakpointCommandCallback(
+llvm::Error ScriptInterpreter::SetBreakpointCommandCallback(
std::vector<std::reference_wrapper<BreakpointOptions>> &bp_options_vec,
const char *callback_text) {
- Status error;
- for (BreakpointOptions &bp_options : bp_options_vec) {
- error = SetBreakpointCommandCallback(bp_options, callback_text,
- /*is_callback=*/false);
- if (!error.Success())
- break;
- }
- return error;
+ for (BreakpointOptions &bp_options : bp_options_vec)
+ if (llvm::Error error = SetBreakpointCommandCallback(
+ bp_options, callback_text, /*is_callback=*/false))
+ return error;
+ return llvm::Error::success();
}
-Status ScriptInterpreter::SetBreakpointCommandCallbackFunction(
+llvm::Error ScriptInterpreter::SetBreakpointCommandCallbackFunction(
std::vector<std::reference_wrapper<BreakpointOptions>> &bp_options_vec,
const char *function_name, StructuredData::ObjectSP extra_args_sp) {
- Status error;
- for (BreakpointOptions &bp_options : bp_options_vec) {
- error = SetBreakpointCommandCallbackFunction(bp_options, function_name,
- extra_args_sp);
- if (!error.Success())
+ for (BreakpointOptions &bp_options : bp_options_vec)
+ if (llvm::Error error = SetBreakpointCommandCallbackFunction(
+ bp_options, function_name, extra_args_sp))
return error;
- }
- return error;
+ return llvm::Error::success();
}
std::unique_ptr<ScriptInterpreterLocker>
diff --git a/lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp b/lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
index 00b580bb0474f2..39f1a82e584f2e 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
@@ -116,12 +116,12 @@ class IOHandlerLuaInterpreter : public IOHandlerDelegate,
static_cast<std::vector<std::reference_wrapper<BreakpointOptions>> *>(
io_handler.GetUserData());
for (BreakpointOptions &bp_options : *bp_options_vec) {
- Status error = m_script_interpreter.SetBreakpointCommandCallback(
- bp_options, data.c_str(), /*is_callback=*/false);
- if (error.Fail()) {
+ if (llvm::Error error =
+ m_script_interpreter.SetBreakpointCommandCallback(
+ bp_options, data.c_str(), /*is_callback=*/false)) {
LockedStreamFile locked_stream =
io_handler.GetErrorStreamFileSP()->Lock();
- locked_stream << error.AsCString() << '\n';
+ locked_stream << llvm::toString(std::move(error)) << '\n';
}
}
io_handler.SetIsDone(true);
@@ -350,7 +350,7 @@ void ScriptInterpreterLua::CollectDataForWatchpointCommandCallback(
m_debugger.RunIOHandlerAsync(io_handler_sp);
}
-Status ScriptInterpreterLua::SetBreakpointCommandCallbackFunction(
+llvm::Error ScriptInterpreterLua::SetBreakpointCommandCallbackFunction(
BreakpointOptions &bp_options, const char *function_name,
StructuredData::ObjectSP extra_args_sp) {
const char *fmt_str = "return {0}(frame, bp_loc, ...)";
@@ -359,25 +359,24 @@ Status ScriptInterpreterLua::SetBreakpointCommandCallbackFunction(
extra_args_sp);
}
-Status ScriptInterpreterLua::SetBreakpointCommandCallback(
+llvm::Error ScriptInterpreterLua::SetBreakpointCommandCallback(
BreakpointOptions &bp_options, const char *command_body_text,
bool is_callback) {
return RegisterBreakpointCallback(bp_options, command_body_text, {});
}
-Status ScriptInterpreterLua::RegisterBreakpointCallback(
+llvm::Error ScriptInterpreterLua::RegisterBreakpointCallback(
BreakpointOptions &bp_options, const char *command_body_text,
StructuredData::ObjectSP extra_args_sp) {
auto data_up = std::make_unique<CommandDataLua>(extra_args_sp);
- llvm::Error err =
- m_lua_state->RegisterBreakpointCallback(data_up.get(), command_body_text);
- if (err)
- return Status::FromError(std::move(err));
+ if (llvm::Error err = m_lua_state->RegisterBreakpointCallback(
+ data_up.get(), command_body_text))
+ return err;
auto baton_sp =
std::make_shared<BreakpointOptions::CommandBaton>(std::move(data_up));
bp_options.SetCallback(ScriptInterpreterLua::BreakpointCallbackFunction,
baton_sp);
- return {};
+ return llvm::Error::success();
}
void ScriptInterpreterLua::SetWatchpointCommandCallback(
diff --git a/lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h b/lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h
index 311b90f2810880..3ba2d6bd935539 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h
+++ b/lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h
@@ -88,15 +88,15 @@ class ScriptInterpreterLua : public ScriptInterpreter {
CollectDataForWatchpointCommandCallback(WatchpointOptions *wp_options,
CommandReturnObject &result) override;
- Status SetBreakpointCommandCallback(BreakpointOptions &bp_options,
- const char *command_body_text,
- bool is_callback) override;
+ llvm::Error SetBreakpointCommandCallback(BreakpointOptions &bp_options,
+ const char *command_body_text,
+ bool is_callback) override;
void SetWatchpointCommandCallback(WatchpointOptions *wp_options,
const char *command_body_text,
bool is_callback) override;
- Status SetBreakpointCommandCallbackFunction(
+ llvm::Error SetBreakpointCommandCallbackFunction(
BreakpointOptions &bp_options, const char *function_name,
StructuredData::ObjectSP extra_args_sp) override;
@@ -104,9 +104,10 @@ class ScriptInterpreterLua : public ScriptInterpreter {
std::unique_ptr<LuaState> m_lua_state;
bool m_session_is_active = false;
- Status RegisterBreakpointCallback(BreakpointOptions &bp_options,
- const char *command_body_text,
- StructuredData::ObjectSP extra_args_sp);
+ llvm::Error
+ RegisterBreakpointCallback(BreakpointOptions &bp_options,
+ const char *command_body_text,
+ StructuredData::ObjectSP extra_args_sp);
Status RegisterWatchpointCallback(WatchpointOptions *wp_options,
const char *command_body_text,
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
index ae5bce33d5b749..a918b6a22659e5 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -1731,21 +1731,17 @@ void ScriptInterpreterPythonImpl::CollectDataForWatchpointCommandCallback(
" ", *this, wp_options);
}
-Status ScriptInterpreterPythonImpl::SetBreakpointCommandCallbackFunction(
+llvm::Error ScriptInterpreterPythonImpl::SetBreakpointCommandCallbackFunction(
BreakpointOptions &bp_options, const char *function_name,
StructuredData::ObjectSP extra_args_sp) {
- Status error;
// For now just cons up a oneliner that calls the provided function.
std::string function_signature = function_name;
llvm::Expected<unsigned> maybe_args =
GetMaxPositionalArgumentsForCallable(function_name);
- if (!maybe_args) {
- error = Status::FromErrorStringWithFormat(
- "could not get num args: %s",
- llvm::toString(maybe_args.takeError()).c_str());
- return error;
- }
+ if (!maybe_args)
+ return llvm::createStringErrorV("could not get num args: {0}",
+ llvm::fmt_consume(maybe_args.takeError()));
size_t max_args = *maybe_args;
bool uses_extra_args = false;
@@ -1753,45 +1749,39 @@ Status ScriptInterpreterPythonImpl::SetBreakpointCommandCallbackFunction(
uses_extra_args = true;
function_signature += "(frame, bp_loc, extra_args, internal_dict)";
} else if (max_args >= 3) {
- if (extra_args_sp) {
- error = Status::FromErrorStringWithFormat(
+ if (extra_args_sp)
+ return llvm::createStringError(
"cannot pass extra_args to a three argument callback");
- return error;
- }
uses_extra_args = false;
function_signature += "(frame, bp_loc, internal_dict)";
} else {
- error = Status::FromErrorStringWithFormat("expected 3 or 4 argument "
- "function, %s can only take %zu",
- function_name, max_args);
- return error;
+ return llvm::createStringErrorV(
+ "expected 3 or 4 argument function, {0} can only take {1}",
+ function_name, max_args);
}
- SetBreakpointCommandCallback(bp_options, function_signature.c_str(),
- extra_args_sp, uses_extra_args,
- /*is_callback=*/true);
- return error;
+ return SetBreakpointCommandCallback(bp_options, function_signature.c_str(),
+ extra_args_sp, uses_extra_args,
+ /*is_callback=*/true);
}
-Status ScriptInterpreterPythonImpl::SetBreakpointCommandCallback(
+llvm::Error ScriptInterpreterPythonImpl::SetBreakpointCommandCallback(
BreakpointOptions &bp_options,
std::unique_ptr<BreakpointOptions::CommandData> &cmd_data_up) {
- Status error;
- error = GenerateBreakpointCommandCallbackData(cmd_data_up->user_source,
- cmd_data_up->script_source,
- /*has_extra_args=*/false,
- /*is_callback=*/false);
- if (error.Fail()) {
- return error;
- }
+ Status error = GenerateBreakpointCommandCallbackData(
+ cmd_data_up->user_source, cmd_data_up->script_source,
+ /*has_extra_args=*/false,
+ /*is_callback=*/false);
+ if (error.Fail())
+ return error.takeError();
auto baton_sp =
std::make_shared<BreakpointOptions::CommandBaton>(std::move(cmd_data_up));
bp_options.SetCallback(
ScriptInterpreterPythonImpl::BreakpointCallbackFunction, baton_sp);
- return error;
+ return llvm::Error::success();
}
-Status ScriptInterpreterPythonImpl::SetBreakpointCommandCallback(
+llvm::Error ScriptInterpreterPythonImpl::SetBreakpointCommandCallback(
BreakpointOptions &bp_options, const char *command_body_text,
bool is_callback) {
return SetBreakpointCommandCallback(bp_options, command_body_text, {},
@@ -1799,7 +1789,7 @@ Status ScriptInterpreterPythonImpl::SetBreakpointCommandCallback(
}
// Set a Python one-liner as the callback for the breakpoint.
-Status ScriptInterpreterPythonImpl::SetBreakpointCommandCallback(
+llvm::Error ScriptInterpreterPythonImpl::SetBreakpointCommandCallback(
BreakpointOptions &bp_options, const char *command_body_text,
StructuredData::ObjectSP extra_args_sp, bool uses_extra_args,
bool is_callback) {
@@ -1813,14 +1803,13 @@ Status ScriptInterpreterPythonImpl::SetBreakpointCommandCallback(
Status error = GenerateBreakpointCommandCallbackData(
data_up->user_source, data_up->script_source, uses_extra_args,
is_callback);
- if (error.Success()) {
- auto baton_sp =
- std::make_shared<BreakpointOptions::CommandBaton>(std::move(data_up));
- bp_options.SetCallback(
- ScriptInterpreterPythonImpl::BreakpointCallbackFunction, baton_sp);
- return error;
- }
- return error;
+ if (error.Fail())
+ return error.takeError();
+ auto baton_sp =
+ std::make_shared<BreakpointOptions::CommandBaton>(std::move(data_up));
+ bp_options.SetCallback(
+ ScriptInterpreterPythonImpl::BreakpointCallbackFunction, baton_sp);
+ return llvm::Error::success();
}
// Set a Python one-liner as the callback for the watchpoint.
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
index d94ccfbbf62fed..2801fe2a36affa 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
@@ -179,23 +179,24 @@ class ScriptInterpreterPythonImpl : public ScriptInterpreterPython {
CommandReturnObject &result) override;
/// Set the callback body text into the callback for the breakpoint.
- Status SetBreakpointCommandCallback(BreakpointOptions &bp_options,
- const char *callback_body,
- bool is_callback) override;
+ llvm::Error SetBreakpointCommandCallback(BreakpointOptions &bp_options,
+ const char *callback_body,
+ bool is_callback) override;
- Status SetBreakpointCommandCallbackFunction(
+ llvm::Error SetBreakpointCommandCallbackFunction(
BreakpointOptions &bp_options, const char *function_name,
StructuredData::ObjectSP extra_args_sp) override;
/// This one is for deserialization:
- Status SetBreakpointCommandCallback(
+ llvm::Error SetBreakpointCommandCallback(
BreakpointOptions &bp_options,
std::unique_ptr<BreakpointOptions::CommandData> &data_up) override;
- Status SetBreakpointCommandCallback(BreakpointOptions &bp_options,
- const char *command_body_text,
- StructuredData::ObjectSP extra_args_sp,
- bool uses_extra_args, bool is_callback);
+ llvm::Error
+ SetBreakpointCommandCallback(BreakpointOptions &bp_options,
+ const char *command_body_text,
+ StructuredData::ObjectSP extra_args_sp,
+ bool uses_extra_args, bool is_callback);
/// Set a one-liner as the callback for the watchpoint.
void SetWatchpointCommandCallback(WatchpointOptions *wp_options,
More information about the lldb-commits
mailing list