Skip to content

Commit e6d07af

Browse files
committed
[lldb] Implement CLI support for reverse-continue
This introduces the options "-F/--forward" and "-R/--reverse" to `process continue`. These only work if you're running with a gdbserver backend that supports reverse execution, such as rr. For testing we rely on the fake reverse- execution functionality in `lldbreverse.py`.
1 parent 00cb966 commit e6d07af

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

lldb/source/Commands/CommandObjectProcess.cpp

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,23 @@ class CommandObjectProcessContinue : public CommandObjectParsed {
468468
case 'b':
469469
m_run_to_bkpt_args.AppendArgument(option_arg);
470470
m_any_bkpts_specified = true;
471-
break;
471+
break;
472+
case 'F':
473+
if (m_base_direction == lldb::RunDirection::eRunReverse) {
474+
error = Status::FromErrorString(
475+
"cannot specify both 'forward' and 'reverse'");
476+
break;
477+
}
478+
m_base_direction = lldb::RunDirection::eRunForward;
479+
break;
480+
case 'R':
481+
if (m_base_direction == lldb::RunDirection::eRunForward) {
482+
error = Status::FromErrorString(
483+
"cannot specify both 'forward' and 'reverse'");
484+
break;
485+
}
486+
m_base_direction = lldb::RunDirection::eRunReverse;
487+
break;
472488
default:
473489
llvm_unreachable("Unimplemented option");
474490
}
@@ -479,6 +495,7 @@ class CommandObjectProcessContinue : public CommandObjectParsed {
479495
m_ignore = 0;
480496
m_run_to_bkpt_args.Clear();
481497
m_any_bkpts_specified = false;
498+
m_base_direction = std::nullopt;
482499
}
483500

484501
llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
@@ -488,6 +505,7 @@ class CommandObjectProcessContinue : public CommandObjectParsed {
488505
uint32_t m_ignore = 0;
489506
Args m_run_to_bkpt_args;
490507
bool m_any_bkpts_specified = false;
508+
std::optional<lldb::RunDirection> m_base_direction;
491509
};
492510

493511
void DoExecute(Args &command, CommandReturnObject &result) override {
@@ -654,6 +672,10 @@ class CommandObjectProcessContinue : public CommandObjectParsed {
654672
}
655673
}
656674

675+
if (m_options.m_base_direction.has_value()) {
676+
process->SetBaseDirection(*m_options.m_base_direction);
677+
}
678+
657679
const uint32_t iohandler_id = process->GetIOHandlerID();
658680

659681
StreamString stream;

lldb/source/Commands/Options.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,10 @@ let Command = "process continue" in {
744744
Arg<"BreakpointIDRange">, Desc<"Specify a breakpoint to continue to, temporarily "
745745
"ignoring other breakpoints. Can be specified more than once. "
746746
"The continue action will be done synchronously if this option is specified.">;
747+
def thread_continue_forward : Option<"forward", "F">, Group<3>,
748+
Desc<"Execute in forward direction">;
749+
def thread_continue_reverse : Option<"reverse", "R">, Group<3>,
750+
Desc<"Execute in forward direction">;
747751
}
748752

749753
let Command = "process detach" in {

0 commit comments

Comments
 (0)