JDevlieghere created this revision.
JDevlieghere added reviewers: jingham, labath, teemperor.
Herald added a project: LLDB.

Replaying a reproducer in asynchronous mode never makes sense. This patch 
disables asynchronous mode during replay.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D65547

Files:
  lldb/lit/Reproducer/TestSynchronous.test
  lldb/source/Interpreter/CommandInterpreter.cpp


Index: lldb/source/Interpreter/CommandInterpreter.cpp
===================================================================
--- lldb/source/Interpreter/CommandInterpreter.cpp
+++ lldb/source/Interpreter/CommandInterpreter.cpp
@@ -109,7 +109,7 @@
       Properties(OptionValuePropertiesSP(
           new OptionValueProperties(ConstString("interpreter")))),
       IOHandlerDelegate(IOHandlerDelegate::Completion::LLDBCommand),
-      m_debugger(debugger), m_synchronous_execution(synchronous_execution),
+      m_debugger(debugger), m_synchronous_execution(true),
       m_skip_lldbinit_files(false), m_skip_app_init_files(false),
       m_command_io_handler_sp(), m_comment_char('#'),
       m_batch_command_mode(false), m_truncation_warning(eNoTruncation),
@@ -118,6 +118,7 @@
   SetEventName(eBroadcastBitThreadShouldExit, "thread-should-exit");
   SetEventName(eBroadcastBitResetPrompt, "reset-prompt");
   SetEventName(eBroadcastBitQuitCommandReceived, "quit");
+  SetSynchronous(synchronous_execution);
   CheckInWithManager();
   m_collection_sp->Initialize(g_interpreter_properties);
 }
@@ -2504,6 +2505,9 @@
 bool CommandInterpreter::GetSynchronous() { return m_synchronous_execution; }
 
 void CommandInterpreter::SetSynchronous(bool value) {
+  // Asynchronous mode is not supported with reproducers.
+  if (repro::Reproducer::Instance().GetLoader())
+    return;
   m_synchronous_execution = value;
 }
 
Index: lldb/lit/Reproducer/TestSynchronous.test
===================================================================
--- /dev/null
+++ lldb/lit/Reproducer/TestSynchronous.test
@@ -0,0 +1,13 @@
+# Ensure that replay happens in synchronous mode.
+
+# RUN: rm -rf %t.repro
+# RUN: %lldb -x -b --capture --capture-path %t.repro -o 'script 
lldb.debugger.SetAsync(True)' -o 'script lldb.debugger.GetAsync()' -o 
'reproducer generate' | FileCheck %s --check-prefix CAPTURE
+# RUN: %lldb --replay %t.repro | FileCheck %s --check-prefix REPLAY
+
+# CAPTURE: script lldb.debugger.SetAsync(True)
+# CAPTURE-NEXT: script lldb.debugger.GetAsync()
+# CAPTURE-NEXT: True
+
+# REPLAY: script lldb.debugger.SetAsync(True)
+# REPLAY-NEXT: script lldb.debugger.GetAsync()
+# REPLAY-NEXT: False


Index: lldb/source/Interpreter/CommandInterpreter.cpp
===================================================================
--- lldb/source/Interpreter/CommandInterpreter.cpp
+++ lldb/source/Interpreter/CommandInterpreter.cpp
@@ -109,7 +109,7 @@
       Properties(OptionValuePropertiesSP(
           new OptionValueProperties(ConstString("interpreter")))),
       IOHandlerDelegate(IOHandlerDelegate::Completion::LLDBCommand),
-      m_debugger(debugger), m_synchronous_execution(synchronous_execution),
+      m_debugger(debugger), m_synchronous_execution(true),
       m_skip_lldbinit_files(false), m_skip_app_init_files(false),
       m_command_io_handler_sp(), m_comment_char('#'),
       m_batch_command_mode(false), m_truncation_warning(eNoTruncation),
@@ -118,6 +118,7 @@
   SetEventName(eBroadcastBitThreadShouldExit, "thread-should-exit");
   SetEventName(eBroadcastBitResetPrompt, "reset-prompt");
   SetEventName(eBroadcastBitQuitCommandReceived, "quit");
+  SetSynchronous(synchronous_execution);
   CheckInWithManager();
   m_collection_sp->Initialize(g_interpreter_properties);
 }
@@ -2504,6 +2505,9 @@
 bool CommandInterpreter::GetSynchronous() { return m_synchronous_execution; }
 
 void CommandInterpreter::SetSynchronous(bool value) {
+  // Asynchronous mode is not supported with reproducers.
+  if (repro::Reproducer::Instance().GetLoader())
+    return;
   m_synchronous_execution = value;
 }
 
Index: lldb/lit/Reproducer/TestSynchronous.test
===================================================================
--- /dev/null
+++ lldb/lit/Reproducer/TestSynchronous.test
@@ -0,0 +1,13 @@
+# Ensure that replay happens in synchronous mode.
+
+# RUN: rm -rf %t.repro
+# RUN: %lldb -x -b --capture --capture-path %t.repro -o 'script lldb.debugger.SetAsync(True)' -o 'script lldb.debugger.GetAsync()' -o 'reproducer generate' | FileCheck %s --check-prefix CAPTURE
+# RUN: %lldb --replay %t.repro | FileCheck %s --check-prefix REPLAY
+
+# CAPTURE: script lldb.debugger.SetAsync(True)
+# CAPTURE-NEXT: script lldb.debugger.GetAsync()
+# CAPTURE-NEXT: True
+
+# REPLAY: script lldb.debugger.SetAsync(True)
+# REPLAY-NEXT: script lldb.debugger.GetAsync()
+# REPLAY-NEXT: False
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to