[Lldb-commits] [lldb] [lldb] Implement CLI support for reverse-continue (PR #132783)
Robert O'Callahan via lldb-commits
lldb-commits at lists.llvm.org
Mon Mar 24 10:15:32 PDT 2025
https://github.com/rocallahan created https://github.com/llvm/llvm-project/pull/132783
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`.
>From e6d07af9dba86a9a46938fe83e3518134ab9fc6a Mon Sep 17 00:00:00 2001
From: Robert O'Callahan <rocallahan at google.com>
Date: Fri, 19 Jul 2024 22:48:14 +1200
Subject: [PATCH] [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`.
---
lldb/source/Commands/CommandObjectProcess.cpp | 24 ++++++++++++++++++-
lldb/source/Commands/Options.td | 4 ++++
2 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp
index 654dfa83ea444..aaa9ffeeea447 100644
--- a/lldb/source/Commands/CommandObjectProcess.cpp
+++ b/lldb/source/Commands/CommandObjectProcess.cpp
@@ -468,7 +468,23 @@ class CommandObjectProcessContinue : public CommandObjectParsed {
case 'b':
m_run_to_bkpt_args.AppendArgument(option_arg);
m_any_bkpts_specified = true;
- break;
+ break;
+ case 'F':
+ if (m_base_direction == lldb::RunDirection::eRunReverse) {
+ error = Status::FromErrorString(
+ "cannot specify both 'forward' and 'reverse'");
+ break;
+ }
+ m_base_direction = lldb::RunDirection::eRunForward;
+ break;
+ case 'R':
+ if (m_base_direction == lldb::RunDirection::eRunForward) {
+ error = Status::FromErrorString(
+ "cannot specify both 'forward' and 'reverse'");
+ break;
+ }
+ m_base_direction = lldb::RunDirection::eRunReverse;
+ break;
default:
llvm_unreachable("Unimplemented option");
}
@@ -479,6 +495,7 @@ class CommandObjectProcessContinue : public CommandObjectParsed {
m_ignore = 0;
m_run_to_bkpt_args.Clear();
m_any_bkpts_specified = false;
+ m_base_direction = std::nullopt;
}
llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
@@ -488,6 +505,7 @@ class CommandObjectProcessContinue : public CommandObjectParsed {
uint32_t m_ignore = 0;
Args m_run_to_bkpt_args;
bool m_any_bkpts_specified = false;
+ std::optional<lldb::RunDirection> m_base_direction;
};
void DoExecute(Args &command, CommandReturnObject &result) override {
@@ -654,6 +672,10 @@ class CommandObjectProcessContinue : public CommandObjectParsed {
}
}
+ if (m_options.m_base_direction.has_value()) {
+ process->SetBaseDirection(*m_options.m_base_direction);
+ }
+
const uint32_t iohandler_id = process->GetIOHandlerID();
StreamString stream;
diff --git a/lldb/source/Commands/Options.td b/lldb/source/Commands/Options.td
index cc579d767eb06..b18a2e4be0b72 100644
--- a/lldb/source/Commands/Options.td
+++ b/lldb/source/Commands/Options.td
@@ -744,6 +744,10 @@ let Command = "process continue" in {
Arg<"BreakpointIDRange">, Desc<"Specify a breakpoint to continue to, temporarily "
"ignoring other breakpoints. Can be specified more than once. "
"The continue action will be done synchronously if this option is specified.">;
+ def thread_continue_forward : Option<"forward", "F">, Group<3>,
+ Desc<"Execute in forward direction">;
+ def thread_continue_reverse : Option<"reverse", "R">, Group<3>,
+ Desc<"Execute in forward direction">;
}
let Command = "process detach" in {
More information about the lldb-commits
mailing list