[Lldb-commits] [PATCH] D82272: [lldb/Lua] Recognize "quit" as a way to exit the interactive script interpreter.

Jonas Devlieghere via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Sun Jun 21 01:01:48 PDT 2020


JDevlieghere created this revision.
JDevlieghere added reviewers: labath, LLDB.

Add a way to quit the interactive script interpreter from a shell tests. Currently, the only way (that I know) to exit the interactive Lua interpreter is to send a EOF with CTRL-D. I noticed that the embedded Python script interpreter accepts `quit` (while the regular python interpreter doesn't). I've added a special case to the Lua interpreter to do the same.


Repository:
  rLLDB LLDB

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));
     }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82272.272291.patch
Type: text/x-patch
Size: 1081 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20200621/211b967c/attachment.bin>


More information about the lldb-commits mailing list