<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">I am assuming that pexpect somehow times out after 30 seconds and lets the test succeed.<div>The change you suggest seems reasonable to me.</div><div>An alternative would be to have the pexpect send the "yes" confirmation down, but I am not too worried about it right now.<br><div><br><div>
<div><div style="border-collapse: separate; border-spacing: 0px; "><i>Enrico Granata</i></div><div style="border-collapse: separate; border-spacing: 0px; ">✉ egranata@<font class="Apple-style-span" color="#ff230e"></font>.com</div><div>✆ (408) 972-7683</div></div>
</div>
<br><div><div>On Jan 25, 2013, at 11:04 AM, "Malea, Daniel" <<a href="mailto:daniel.malea@intel.com">daniel.malea@intel.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Hi Enrico,<br><br>I'm noticing at least one test-case (functionalities/embedded_interpreter) appear to hang after this commit. It looks like it's waiting for someone to answer the prompt after the "quit" command. Interestingly though, the test-case does eventually succeed, but after a 30s delay…not sure how that works, but since I'm trying to speed up testing, does the following fix look OK to you:<br><br>diff --git a/test/lldbtest.py b/test/lldbtest.py<br>index 17ad718..fbfb269 100644<br>--- a/test/lldbtest.py<br>+++ b/test/lldbtest.py<br>@@ -733,6 +733,7 @@ class Base(unittest2.TestCase):<br>             if self.child_in_script_interpreter:<br>                 self.child.sendline('quit()')<br>                 self.child.expect_exact(self.child_prompt)<br>+            self.child.sendline('settings set interpreter.prompt-on-quit false')<br>             self.child.sendline('quit')<br>             try:<br>                 self.child.expect(pexpect.EOF)<br><br><br>The idea is that before the test harness sends the "quit" command, it sets the prompt-on-quit setting to false. Since this bit of code appears to only handle tests that use the lldb subprocess (as opposed to most tests that just use the API) there's no need to clear the setting afterwards.<br><br><br>Thanks,<br>Dan<br><br>On 2013-01-17, at 4:36 PM, Enrico Granata <<a href="mailto:egranata@apple.com">egranata@apple.com</a><<a href="mailto:egranata@apple.com">mailto:egranata@apple.com</a>>> wrote:<br><br>Author: enrico<br>Date: Thu Jan 17 15:36:19 2013<br>New Revision: 172757<br><br>URL: <a href="http://llvm.org/viewvc/llvm-project?rev=172757&view=rev">http://llvm.org/viewvc/llvm-project?rev=172757&view=rev</a><br>Log:<br><<a href="rdar://problem/12786725">rdar://problem/12786725</a>><br><br>If there is any alive process being debugged, the user is asked for confirmation before quitting LLDB<br>This should prevent situations where the user mistakenly types "q" and LLDB slaughters their process without any mercy whatsoever<br>Since it can quickly get tedious, there is a new setting on the command interpreter to disable this and replicate the previous behavior<br><br><br>Modified:<br>   lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h<br>   lldb/trunk/source/Commands/CommandObjectQuit.cpp<br>   lldb/trunk/source/Commands/CommandObjectQuit.h<br>   lldb/trunk/source/Interpreter/CommandInterpreter.cpp<br><br>Modified: lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h<br>URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h?rev=172757&r1=172756&r2=172757&view=diff">http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h?rev=172757&r1=172756&r2=172757&view=diff</a><br>==============================================================================<br>--- lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h (original)<br>+++ lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h Thu Jan 17 15:36:19 2013<br>@@ -436,6 +436,9 @@<br>    bool<br>    GetExpandRegexAliases () const;<br><br>+    bool<br>+    GetPromptOnQuit () const;<br>+<br>protected:<br>    friend class Debugger;<br><br><br>Modified: lldb/trunk/source/Commands/CommandObjectQuit.cpp<br>URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectQuit.cpp?rev=172757&r1=172756&r2=172757&view=diff">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectQuit.cpp?rev=172757&r1=172756&r2=172757&view=diff</a><br>==============================================================================<br>--- lldb/trunk/source/Commands/CommandObjectQuit.cpp (original)<br>+++ lldb/trunk/source/Commands/CommandObjectQuit.cpp Thu Jan 17 15:36:19 2013<br>@@ -34,9 +34,63 @@<br>{<br>}<br><br>+// returns true if there is at least one alive process<br>+// is_a_detach will be true if all alive processes will be detached when you quit<br>+// and false if at least one process will be killed instead<br>+bool<br>+CommandObjectQuit::ShouldAskForConfirmation (bool& is_a_detach)<br>+{<br>+    if (m_interpreter.GetPromptOnQuit() == false)<br>+        return false;<br>+    bool should_prompt = false;<br>+    is_a_detach = true;<br>+    for (uint32_t debugger_idx = 0;<br>+         debugger_idx < Debugger::GetNumDebuggers();<br>+         debugger_idx++)<br>+    {<br>+        DebuggerSP debugger_sp(Debugger::GetDebuggerAtIndex(debugger_idx));<br>+        if (!debugger_sp)<br>+            continue;<br>+        const TargetList& target_list(debugger_sp->GetTargetList());<br>+        for (uint32_t target_idx = 0;<br>+             target_idx < target_list.GetNumTargets();<br>+             target_idx++)<br>+        {<br>+            TargetSP target_sp(target_list.GetTargetAtIndex(target_idx));<br>+            if (!target_sp)<br>+                continue;<br>+            ProcessSP process_sp(target_sp->GetProcessSP());<br>+            if (process_sp &&<br>+                process_sp->IsValid() &&<br>+                process_sp->IsAlive())<br>+            {<br>+                should_prompt = true;<br>+                if (process_sp->GetShouldDetach() == false)<br>+                {<br>+                    // if we need to kill at least one process, just say so and return<br>+                    is_a_detach = false;<br>+                    return should_prompt;<br>+                }<br>+            }<br>+        }<br>+    }<br>+    return should_prompt;<br>+}<br>+<br>bool<br>CommandObjectQuit::DoExecute (Args& command, CommandReturnObject &result)<br>{<br>+    bool is_a_detach = true;<br>+    if (ShouldAskForConfirmation (is_a_detach))<br>+    {<br>+        StreamString message;<br>+        message.Printf("Quitting LLDB will %s one or more processes. Do you really want to proceed", (is_a_detach ? "detach from" : "kill"));<br>+        if (!m_interpreter.Confirm(message.GetData(), true))<br>+        {<br>+            result.SetStatus(eReturnStatusFailed);<br>+            return false;<br>+        }<br>+    }<br>    m_interpreter.BroadcastEvent (CommandInterpreter::eBroadcastBitQuitCommandReceived);<br>    result.SetStatus (eReturnStatusQuit);<br>    return true;<br><br>Modified: lldb/trunk/source/Commands/CommandObjectQuit.h<br>URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectQuit.h?rev=172757&r1=172756&r2=172757&view=diff">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectQuit.h?rev=172757&r1=172756&r2=172757&view=diff</a><br>==============================================================================<br>--- lldb/trunk/source/Commands/CommandObjectQuit.h (original)<br>+++ lldb/trunk/source/Commands/CommandObjectQuit.h Thu Jan 17 15:36:19 2013<br>@@ -35,6 +35,9 @@<br>    virtual bool<br>    DoExecute (Args& args,<br>             CommandReturnObject &result);<br>+<br>+    bool<br>+    ShouldAskForConfirmation (bool& is_a_detach);<br><br>};<br><br><br>Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp<br>URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=172757&r1=172756&r2=172757&view=diff">http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=172757&r1=172756&r2=172757&view=diff</a><br>==============================================================================<br>--- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original)<br>+++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Thu Jan 17 15:36:19 2013<br>@@ -72,12 +72,14 @@<br>g_properties[] =<br>{<br>    { "expand-regex-aliases", OptionValue::eTypeBoolean, true, false, NULL, NULL, "If true, regular expression alias commands will show the expanded command that will be executed. This can be used to debug new regular expression alias commands." },<br>+    { "prompt-on-quit", OptionValue::eTypeBoolean, true, true, NULL, NULL, "If true, LLDB will prompt you before quitting if there are any live processes being debugged. If false, LLDB will quit without asking in any case." },<br>    { NULL                  , OptionValue::eTypeInvalid, true, 0    , NULL, NULL, NULL }<br>};<br><br>enum<br>{<br>-    ePropertyExpandRegexAliases = 0<br>+    ePropertyExpandRegexAliases = 0,<br>+    ePropertyPromptOnQuit = 1<br>};<br><br>ConstString &<br>@@ -121,7 +123,12 @@<br>    return m_collection_sp->GetPropertyAtIndexAsBoolean (NULL, idx, g_properties[idx].default_uint_value != 0);<br>}<br><br>-<br>+bool<br>+CommandInterpreter::GetPromptOnQuit () const<br>+{<br>+    const uint32_t idx = ePropertyPromptOnQuit;<br>+    return m_collection_sp->GetPropertyAtIndexAsBoolean (NULL, idx, g_properties[idx].default_uint_value != 0);<br>+}<br><br>void<br>CommandInterpreter::Initialize ()<br><br><br>_______________________________________________<br>lldb-commits mailing list<br><a href="mailto:lldb-commits@cs.uiuc.edu">lldb-commits@cs.uiuc.edu</a><<a href="mailto:lldb-commits@cs.uiuc.edu">mailto:lldb-commits@cs.uiuc.edu</a>><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits">http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits</a><br><br></blockquote></div><br></div></div></body></html>