[Lldb-commits] [lldb] 33fae08 - [lldb-dap] Forward any error from stepping. (#142652)
via lldb-commits
lldb-commits at lists.llvm.org
Tue Jun 3 15:40:03 PDT 2025
Author: Ebuka Ezike
Date: 2025-06-03T23:40:00+01:00
New Revision: 33fae0840562ae7e93dd7b4bc6dd4a41150eee01
URL: https://github.com/llvm/llvm-project/commit/33fae0840562ae7e93dd7b4bc6dd4a41150eee01
DIFF: https://github.com/llvm/llvm-project/commit/33fae0840562ae7e93dd7b4bc6dd4a41150eee01.diff
LOG: [lldb-dap] Forward any error from stepping. (#142652)
The current implementation hides any possible error from performing a
step command.
It makes it easier to know where an issue is from.
Added:
Modified:
lldb/tools/lldb-dap/Handler/NextRequestHandler.cpp
lldb/tools/lldb-dap/Handler/StepInRequestHandler.cpp
lldb/tools/lldb-dap/Handler/StepOutRequestHandler.cpp
Removed:
################################################################################
diff --git a/lldb/tools/lldb-dap/Handler/NextRequestHandler.cpp b/lldb/tools/lldb-dap/Handler/NextRequestHandler.cpp
index 3fa167686d2f9..2b48350dfba1b 100644
--- a/lldb/tools/lldb-dap/Handler/NextRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/NextRequestHandler.cpp
@@ -8,6 +8,7 @@
#include "DAP.h"
#include "EventHelper.h"
+#include "LLDBUtils.h"
#include "Protocol/ProtocolTypes.h"
#include "RequestHandler.h"
#include "llvm/Support/Error.h"
@@ -30,16 +31,21 @@ Error NextRequestHandler::Run(const NextArguments &args) const {
if (!thread.IsValid())
return make_error<DAPError>("invalid thread");
+ if (!SBDebugger::StateIsStoppedState(dap.target.GetProcess().GetState()))
+ return make_error<NotStoppedError>();
+
// Remember the thread ID that caused the resume so we can set the
// "threadCausedFocus" boolean value in the "stopped" events.
dap.focus_tid = thread.GetThreadID();
+ lldb::SBError error;
if (args.granularity == eSteppingGranularityInstruction) {
- thread.StepInstruction(/*step_over=*/true);
+ thread.StepInstruction(/*step_over=*/true, error);
} else {
- thread.StepOver(args.singleThread ? eOnlyThisThread : eOnlyDuringStepping);
+ thread.StepOver(args.singleThread ? eOnlyThisThread : eOnlyDuringStepping,
+ error);
}
- return Error::success();
+ return ToError(error);
}
} // namespace lldb_dap
diff --git a/lldb/tools/lldb-dap/Handler/StepInRequestHandler.cpp b/lldb/tools/lldb-dap/Handler/StepInRequestHandler.cpp
index 15f242a9e18ff..6742c791a5486 100644
--- a/lldb/tools/lldb-dap/Handler/StepInRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/StepInRequestHandler.cpp
@@ -8,6 +8,7 @@
#include "DAP.h"
#include "EventHelper.h"
+#include "LLDBUtils.h"
#include "Protocol/ProtocolRequests.h"
#include "Protocol/ProtocolTypes.h"
#include "RequestHandler.h"
@@ -39,9 +40,13 @@ Error StepInRequestHandler::Run(const StepInArguments &args) const {
// "threadCausedFocus" boolean value in the "stopped" events.
dap.focus_tid = thread.GetThreadID();
+ if (!SBDebugger::StateIsStoppedState(dap.target.GetProcess().GetState()))
+ return make_error<NotStoppedError>();
+
+ lldb::SBError error;
if (args.granularity == eSteppingGranularityInstruction) {
- thread.StepInstruction(/*step_over=*/false);
- return Error::success();
+ thread.StepInstruction(/*step_over=*/false, error);
+ return ToError(error);
}
std::string step_in_target;
@@ -50,8 +55,9 @@ Error StepInRequestHandler::Run(const StepInArguments &args) const {
step_in_target = it->second;
RunMode run_mode = args.singleThread ? eOnlyThisThread : eOnlyDuringStepping;
- thread.StepInto(step_in_target.c_str(), run_mode);
- return Error::success();
+ thread.StepInto(step_in_target.c_str(), LLDB_INVALID_LINE_NUMBER, error,
+ run_mode);
+ return ToError(error);
}
} // namespace lldb_dap
diff --git a/lldb/tools/lldb-dap/Handler/StepOutRequestHandler.cpp b/lldb/tools/lldb-dap/Handler/StepOutRequestHandler.cpp
index 6b98582262a68..e896e03720b6b 100644
--- a/lldb/tools/lldb-dap/Handler/StepOutRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/StepOutRequestHandler.cpp
@@ -8,6 +8,7 @@
#include "DAP.h"
#include "EventHelper.h"
+#include "LLDBUtils.h"
#include "Protocol/ProtocolRequests.h"
#include "RequestHandler.h"
#include "llvm/Support/Error.h"
@@ -32,12 +33,17 @@ Error StepOutRequestHandler::Run(const StepOutArguments &arguments) const {
if (!thread.IsValid())
return make_error<DAPError>("invalid thread");
+ if (!lldb::SBDebugger::StateIsStoppedState(
+ dap.target.GetProcess().GetState()))
+ return make_error<NotStoppedError>();
+
// Remember the thread ID that caused the resume so we can set the
// "threadCausedFocus" boolean value in the "stopped" events.
dap.focus_tid = thread.GetThreadID();
- thread.StepOut();
+ lldb::SBError error;
+ thread.StepOut(error);
- return Error::success();
+ return ToError(error);
}
} // namespace lldb_dap
More information about the lldb-commits
mailing list