Reapply "[lldb] Implement basic support for reverse-continue (#125242)" (again) by labath · Pull Request #128156 · llvm/llvm-project (original) (raw)

@llvm/pr-subscribers-lldb

Author: Pavel Labath (labath)

Changes

This reverts commit 87b7f63, reapplying
7e66cf7 with a small (and probably temporary)
change to generate more debug info to help with diagnosing buildbot issues.


Patch is 86.67 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/128156.diff

40 Files Affected:

diff --git a/lldb/include/lldb/API/SBProcess.h b/lldb/include/lldb/API/SBProcess.h index 1624e02070b1b..882b8bd837131 100644 --- a/lldb/include/lldb/API/SBProcess.h +++ b/lldb/include/lldb/API/SBProcess.h @@ -159,6 +159,7 @@ class LLDB_API SBProcess { lldb::SBError Destroy();

lldb::SBError Continue();

diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h index c3622a29bc772..2e827d4c5cb74 100644 --- a/lldb/include/lldb/Target/Process.h +++ b/lldb/include/lldb/Target/Process.h @@ -1089,6 +1089,13 @@ class Process : public std::enable_shared_from_this, /// Returns an error object. virtual Status WillResume() { return Status(); }

@@ -2677,6 +2688,18 @@ void PruneThreadPlans(); const AddressRange &range, size_t alignment, Status &error);

@@ -3076,6 +3099,7 @@ void PruneThreadPlans(); ThreadList m_extended_thread_list; ///< Constituent for extended threads that may be /// generated, cleared on natural stops

public: // Constructors and Destructors @@ -154,6 +155,12 @@ class StopInfo : public std::enable_shared_from_this { static lldb::StopInfoSP CreateStopReasonProcessorTrace(Thread &thread, const char *description);

diff --git a/lldb/include/lldb/Target/Thread.h b/lldb/include/lldb/Target/Thread.h index 1d1e3dcfc1dc6..6ede7fa301a82 100644 --- a/lldb/include/lldb/Target/Thread.h +++ b/lldb/include/lldb/Target/Thread.h @@ -201,14 +201,13 @@ class Thread : public std::enable_shared_from_this, /// The User resume state for this thread. lldb::StateType GetResumeState() const { return m_resume_state; }

diff --git a/lldb/include/lldb/Target/ThreadList.h b/lldb/include/lldb/Target/ThreadList.h index bca01f5fe2083..c108962003598 100644 --- a/lldb/include/lldb/Target/ThreadList.h +++ b/lldb/include/lldb/Target/ThreadList.h @@ -113,6 +113,10 @@ class ThreadList : public ThreadCollection { /// If a thread can "resume" without having to resume the target, it /// will return false for WillResume, and then the process will not be /// restarted.

diff --git a/lldb/include/lldb/Target/ThreadPlan.h b/lldb/include/lldb/Target/ThreadPlan.h index d6da484f4fc13..a7bac8cc5ecf6 100644 --- a/lldb/include/lldb/Target/ThreadPlan.h +++ b/lldb/include/lldb/Target/ThreadPlan.h @@ -283,6 +283,15 @@ namespace lldb_private { // report_run_vote argument to the constructor works like report_stop_vote, and // is a way for a plan to instruct a sub-plan on how to respond to // ShouldReportStop. +// +// Reverse execution: +// +// Every thread plan has an associated RunDirection (forward or backward). +// For ThreadPlanBase, this direction is the Process's base direction. +// Whenever we resume the target, we need to ensure that the topmost thread +// plans for each runnable thread all agree on their direction. This is +// ensured in ThreadList::WillResume(), which chooses a direction and then +// discards thread plans incompatible with that direction.

class ThreadPlan : public std::enable_shared_from_this, public UserID { @@ -497,6 +506,10 @@ class ThreadPlan : public std::enable_shared_from_this,

virtual lldb::StateType GetPlanRunState() = 0;

+/// Execution directions +enum RunDirection { eRunForward, eRunReverse }; + /// Byte ordering definitions. enum ByteOrder { eByteOrderInvalid = 0, @@ -254,6 +257,9 @@ enum StopReason { eStopReasonVFork, eStopReasonVForkDone, eStopReasonInterrupt, ///< Thread requested interrupt

/// Command Return Status Types. diff --git a/lldb/packages/Python/lldbsuite/test/gdbclientutils.py b/lldb/packages/Python/lldbsuite/test/gdbclientutils.py index 4b782b3b470fe..753de22b9cfee 100644 --- a/lldb/packages/Python/lldbsuite/test/gdbclientutils.py +++ b/lldb/packages/Python/lldbsuite/test/gdbclientutils.py @@ -516,8 +516,9 @@ def start(self): self._thread.start()

 def stop(self):

diff --git a/lldb/packages/Python/lldbsuite/test/lldbgdbproxy.py b/lldb/packages/Python/lldbsuite/test/lldbgdbproxy.py new file mode 100644 index 0000000000000..e41f89e2443a4 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/lldbgdbproxy.py @@ -0,0 +1,177 @@ +import logging +import os +import os.path +import random + +import lldb +from lldbsuite.test.lldbtest import * +from lldbsuite.test.gdbclientutils import * +import lldbgdbserverutils +from lldbsuite.support import seven + + +class GDBProxyTestBase(TestBase):

diff --git a/lldb/packages/Python/lldbsuite/test/lldbreverse.py b/lldb/packages/Python/lldbsuite/test/lldbreverse.py new file mode 100644 index 0000000000000..a42cc7cac15d3 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/lldbreverse.py @@ -0,0 +1,541 @@ +import os +import os.path +import lldb +from lldbsuite.test.lldbtest import * +from lldbsuite.test.gdbclientutils import * +from lldbsuite.test.lldbgdbproxy import * +import lldbgdbserverutils +import re + + +class ThreadSnapshot:

[truncated]