[Lldb-commits] [lldb] [lldb] Implement basic support for reverse-continue (PR #112079)

Robert O'Callahan via lldb-commits lldb-commits at lists.llvm.org
Sat Dec 14 03:24:38 PST 2024


================
@@ -608,19 +594,49 @@ bool ThreadList::WillResume() {
   }
 
   bool need_to_resume = true;
+  Log *log(GetLog(LLDBLog::Process | LLDBLog::Step));
 
   if (run_me_only_list.GetSize(false) == 0) {
+    *direction = m_process.GetBaseDirection();
+    // We've determined the direction so now we can determine which
+    // threads need to step over breakpoints.
+    for (pos = m_threads.begin(); pos != end; ++pos) {
+      if ((*pos)->GetResumeState() != eStateSuspended &&
+          (!wants_solo_run || (*pos)->GetCurrentPlan()->StopOthers())) {
+        if ((*pos)->IsOperatingSystemPluginThread() &&
+            !(*pos)->GetBackingThread())
+          continue;
+        if ((*pos)->StepOverBreakpointIfNeeded(*direction)) {
+          run_me_only_list.AddThread(*pos);
+          break;
+        }
+      }
+    }
+  } // else we'll set *direction to the direction of the chosen thread later
+  if (run_me_only_list.GetSize(false) == 0) {
+    // *direction has been set to m_process.GetBaseDirection().
     // Everybody runs as they wish:
     for (pos = m_threads.begin(); pos != end; ++pos) {
       ThreadSP thread_sp(*pos);
       StateType run_state;
-      if (thread_sp->GetResumeState() != eStateSuspended)
+      if (thread_sp->GetResumeState() != eStateSuspended) {
         run_state = thread_sp->GetCurrentPlan()->RunState();
-      else
+      } else {
         run_state = eStateSuspended;
+      }
       if (!thread_sp->ShouldResume(run_state))
         need_to_resume = false;
     }
+    if (need_to_resume) {
+      for (pos = m_threads.begin(); pos != end; ++pos) {
+        ThreadSP thread_sp(*pos);
+        while (thread_sp->GetCurrentPlan()->GetDirection() != *direction) {
+          // This can't pop the base plan because its direction is
+          // m_process.GetBaseDirection() i.e. *direction.
+          thread_sp->PopPlan();
----------------
rocallahan wrote:

Good point, fixed.

https://github.com/llvm/llvm-project/pull/112079


More information about the lldb-commits mailing list