This revision was automatically updated to reflect the committed changes.
Closed by commit rG1728dec255a5: [lldb/Lua] Recognize "quit" as a way 
to exit the script interpreter. (authored by JDevlieghere).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82272/new/

https://reviews.llvm.org/D82272

Files:
  lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
  lldb/test/Shell/ScriptInterpreter/Lua/quit.test


Index: lldb/test/Shell/ScriptInterpreter/Lua/quit.test
===================================================================
--- /dev/null
+++ lldb/test/Shell/ScriptInterpreter/Lua/quit.test
@@ -0,0 +1,10 @@
+# REQUIRES: lua
+# UNSUPPORTED: lldb-repro
+#
+# RUN: cat %s | %lldb --script-language lua 2>&1 | FileCheck %s
+script
+print(95000 + 126)
+quit
+target list
+# CHECK: 95126
+# CHECK: No targets
Index: lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
===================================================================
--- lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
@@ -39,6 +39,11 @@
 
   void IOHandlerInputComplete(IOHandler &io_handler,
                               std::string &data) override {
+    if (llvm::StringRef(data).rtrim() == "quit") {
+      io_handler.SetIsDone(true);
+      return;
+    }
+
     if (llvm::Error error = m_script_interpreter.GetLua().Run(data)) {
       *GetOutputStreamFileSP() << llvm::toString(std::move(error));
     }


Index: lldb/test/Shell/ScriptInterpreter/Lua/quit.test
===================================================================
--- /dev/null
+++ lldb/test/Shell/ScriptInterpreter/Lua/quit.test
@@ -0,0 +1,10 @@
+# REQUIRES: lua
+# UNSUPPORTED: lldb-repro
+#
+# RUN: cat %s | %lldb --script-language lua 2>&1 | FileCheck %s
+script
+print(95000 + 126)
+quit
+target list
+# CHECK: 95126
+# CHECK: No targets
Index: lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
===================================================================
--- lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
@@ -39,6 +39,11 @@
 
   void IOHandlerInputComplete(IOHandler &io_handler,
                               std::string &data) override {
+    if (llvm::StringRef(data).rtrim() == "quit") {
+      io_handler.SetIsDone(true);
+      return;
+    }
+
     if (llvm::Error error = m_script_interpreter.GetLua().Run(data)) {
       *GetOutputStreamFileSP() << llvm::toString(std::move(error));
     }
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to