Skip to content

Commit 33fae08

Browse files
authored
[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.
1 parent cb56e15 commit 33fae08

File tree

3 files changed

+27
-9
lines changed

3 files changed

+27
-9
lines changed

lldb/tools/lldb-dap/Handler/NextRequestHandler.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include "DAP.h"
1010
#include "EventHelper.h"
11+
#include "LLDBUtils.h"
1112
#include "Protocol/ProtocolTypes.h"
1213
#include "RequestHandler.h"
1314
#include "llvm/Support/Error.h"
@@ -30,16 +31,21 @@ Error NextRequestHandler::Run(const NextArguments &args) const {
3031
if (!thread.IsValid())
3132
return make_error<DAPError>("invalid thread");
3233

34+
if (!SBDebugger::StateIsStoppedState(dap.target.GetProcess().GetState()))
35+
return make_error<NotStoppedError>();
36+
3337
// Remember the thread ID that caused the resume so we can set the
3438
// "threadCausedFocus" boolean value in the "stopped" events.
3539
dap.focus_tid = thread.GetThreadID();
40+
lldb::SBError error;
3641
if (args.granularity == eSteppingGranularityInstruction) {
37-
thread.StepInstruction(/*step_over=*/true);
42+
thread.StepInstruction(/*step_over=*/true, error);
3843
} else {
39-
thread.StepOver(args.singleThread ? eOnlyThisThread : eOnlyDuringStepping);
44+
thread.StepOver(args.singleThread ? eOnlyThisThread : eOnlyDuringStepping,
45+
error);
4046
}
4147

42-
return Error::success();
48+
return ToError(error);
4349
}
4450

4551
} // namespace lldb_dap

lldb/tools/lldb-dap/Handler/StepInRequestHandler.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include "DAP.h"
1010
#include "EventHelper.h"
11+
#include "LLDBUtils.h"
1112
#include "Protocol/ProtocolRequests.h"
1213
#include "Protocol/ProtocolTypes.h"
1314
#include "RequestHandler.h"
@@ -39,9 +40,13 @@ Error StepInRequestHandler::Run(const StepInArguments &args) const {
3940
// "threadCausedFocus" boolean value in the "stopped" events.
4041
dap.focus_tid = thread.GetThreadID();
4142

43+
if (!SBDebugger::StateIsStoppedState(dap.target.GetProcess().GetState()))
44+
return make_error<NotStoppedError>();
45+
46+
lldb::SBError error;
4247
if (args.granularity == eSteppingGranularityInstruction) {
43-
thread.StepInstruction(/*step_over=*/false);
44-
return Error::success();
48+
thread.StepInstruction(/*step_over=*/false, error);
49+
return ToError(error);
4550
}
4651

4752
std::string step_in_target;
@@ -50,8 +55,9 @@ Error StepInRequestHandler::Run(const StepInArguments &args) const {
5055
step_in_target = it->second;
5156

5257
RunMode run_mode = args.singleThread ? eOnlyThisThread : eOnlyDuringStepping;
53-
thread.StepInto(step_in_target.c_str(), run_mode);
54-
return Error::success();
58+
thread.StepInto(step_in_target.c_str(), LLDB_INVALID_LINE_NUMBER, error,
59+
run_mode);
60+
return ToError(error);
5561
}
5662

5763
} // namespace lldb_dap

lldb/tools/lldb-dap/Handler/StepOutRequestHandler.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include "DAP.h"
1010
#include "EventHelper.h"
11+
#include "LLDBUtils.h"
1112
#include "Protocol/ProtocolRequests.h"
1213
#include "RequestHandler.h"
1314
#include "llvm/Support/Error.h"
@@ -32,12 +33,17 @@ Error StepOutRequestHandler::Run(const StepOutArguments &arguments) const {
3233
if (!thread.IsValid())
3334
return make_error<DAPError>("invalid thread");
3435

36+
if (!lldb::SBDebugger::StateIsStoppedState(
37+
dap.target.GetProcess().GetState()))
38+
return make_error<NotStoppedError>();
39+
3540
// Remember the thread ID that caused the resume so we can set the
3641
// "threadCausedFocus" boolean value in the "stopped" events.
3742
dap.focus_tid = thread.GetThreadID();
38-
thread.StepOut();
43+
lldb::SBError error;
44+
thread.StepOut(error);
3945

40-
return Error::success();
46+
return ToError(error);
4147
}
4248

4349
} // namespace lldb_dap

0 commit comments

Comments
 (0)