[Lldb-commits] [lldb] 1728dec - [lldb/Lua] Recognize "quit" as a way to exit the script interpreter.

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Mon Jun 22 09:27:19 PDT 2020


Author: Jonas Devlieghere
Date: 2020-06-22T09:27:12-07:00
New Revision: 1728dec255a5336303b301e26ec22eca2000b593

URL: https://github.com/llvm/llvm-project/commit/1728dec255a5336303b301e26ec22eca2000b593
DIFF: https://github.com/llvm/llvm-project/commit/1728dec255a5336303b301e26ec22eca2000b593.diff

LOG: [lldb/Lua] Recognize "quit" as a way to exit the script interpreter.

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.

Differential revision: https://reviews.llvm.org/D82272

Added: 
    lldb/test/Shell/ScriptInterpreter/Lua/quit.test

Modified: 
    lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp b/lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
index cbd639417990..f8fd8ff94aa3 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.cpp
@@ -39,6 +39,11 @@ class IOHandlerLuaInterpreter : public IOHandlerDelegate,
 
   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));
     }

diff  --git a/lldb/test/Shell/ScriptInterpreter/Lua/quit.test b/lldb/test/Shell/ScriptInterpreter/Lua/quit.test
new file mode 100644
index 000000000000..e47c66c5a10a
--- /dev/null
+++ b/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


        


More information about the lldb-commits mailing list