<div dir="ltr">Different shells have different quoting rules, so unfortunately something like this:<div><br></div><div><div># RUN: %lldb -b -s %s -O 'target create %t' -O 'target stop-hook add -n b -o "expr ptr"' </div></div><div><br></div><div>is non-portable.  For example, on Windows all single quotes are converted to double quotes before running, so this is effectively:</div><div>lldb.EXE</div><div>  -S lit-lldb-init</div><div>  -b</div><div>  -s stop-hook.test</div><div>  -O "target create stop-hook.test.tmp"</div><div>  -O "target stop-hook add -n b -o expr"          // expr gets concatenated to the previous quoted string since there is no space separating expr and the closing quote from the previous arg.</div><div>  ptr<br></div><div><br></div><div>If we're going to be writing more of these kinds of tests (and I think we should!), I think we need to agree that we should not be using -O, instead we should source the commands from a file.</div><div><br></div><div>I'll prepare a patch that converts these two tests to do just that and add you as a reviewer.</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Fri, Nov 16, 2018 at 3:09 PM Frederic Riss via lldb-commits <<a href="mailto:lldb-commits@lists.llvm.org">lldb-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: friss<br>
Date: Fri Nov 16 15:07:28 2018<br>
New Revision: 347109<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=347109&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=347109&view=rev</a><br>
Log:<br>
Rewrite stop-hook tests as a couple of FileCheck tests<br>
<br>
Those tests were using pexpect and being flaky on some of ours bots.<br>
This patch reimplmeents the tests usinf FileCheck, and it also<br>
extends the test coverage to a few more stop-hook options.<br>
<br>
Added:<br>
    lldb/trunk/lit/ExecControl/<br>
    lldb/trunk/lit/ExecControl/StopHook/<br>
    lldb/trunk/lit/ExecControl/StopHook/Inputs/<br>
    lldb/trunk/lit/ExecControl/StopHook/Inputs/stop-hook-threads.cpp<br>
      - copied, changed from r347104, lldb/trunk/packages/Python/lldbsuite/test/functionalities/stop-hook/multiple_threads/main.cpp<br>
    lldb/trunk/lit/ExecControl/StopHook/Inputs/stop-hook.c<br>
      - copied, changed from r347104, lldb/trunk/packages/Python/lldbsuite/test/functionalities/stop-hook/main.cpp<br>
    lldb/trunk/lit/ExecControl/StopHook/stop-hook-threads.test<br>
    lldb/trunk/lit/ExecControl/StopHook/stop-hook.test<br>
Removed:<br>
    lldb/trunk/packages/Python/lldbsuite/test/functionalities/stop-hook/Makefile<br>
    lldb/trunk/packages/Python/lldbsuite/test/functionalities/stop-hook/TestStopHookCmd.py<br>
    lldb/trunk/packages/Python/lldbsuite/test/functionalities/stop-hook/TestStopHookMechanism.py<br>
    lldb/trunk/packages/Python/lldbsuite/test/functionalities/stop-hook/main.cpp<br>
    lldb/trunk/packages/Python/lldbsuite/test/functionalities/stop-hook/multiple_threads/Makefile<br>
    lldb/trunk/packages/Python/lldbsuite/test/functionalities/stop-hook/multiple_threads/TestStopHookMultipleThreads.py<br>
    lldb/trunk/packages/Python/lldbsuite/test/functionalities/stop-hook/multiple_threads/main.cpp<br>
<br>
Copied: lldb/trunk/lit/ExecControl/StopHook/Inputs/stop-hook-threads.cpp (from r347104, lldb/trunk/packages/Python/lldbsuite/test/functionalities/stop-hook/multiple_threads/main.cpp)<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/ExecControl/StopHook/Inputs/stop-hook-threads.cpp?p2=lldb/trunk/lit/ExecControl/StopHook/Inputs/stop-hook-threads.cpp&p1=lldb/trunk/packages/Python/lldbsuite/test/functionalities/stop-hook/multiple_threads/main.cpp&r1=347104&r2=347109&rev=347109&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/ExecControl/StopHook/Inputs/stop-hook-threads.cpp?p2=lldb/trunk/lit/ExecControl/StopHook/Inputs/stop-hook-threads.cpp&p1=lldb/trunk/packages/Python/lldbsuite/test/functionalities/stop-hook/multiple_threads/main.cpp&r1=347104&r2=347109&rev=347109&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/stop-hook/multiple_threads/main.cpp (original)<br>
+++ lldb/trunk/lit/ExecControl/StopHook/Inputs/stop-hook-threads.cpp Fri Nov 16 15:07:28 2018<br>
@@ -14,7 +14,7 @@<br>
 #include <thread><br>
<br>
 std::default_random_engine g_random_engine{std::random_device{}()};<br>
-std::uniform_int_distribution<> g_distribution{0, 3000000};<br>
+std::uniform_int_distribution<> g_distribution{0, 3000};<br>
<br>
 uint32_t g_val = 0;<br>
<br>
@@ -42,14 +42,14 @@ thread_func (uint32_t thread_index)<br>
<br>
     uint32_t count = 0;<br>
     uint32_t val;<br>
-    while (count++ < 15)<br>
+    while (count++ < 4)<br>
     {<br>
-        // random micro second sleep from zero to 3 seconds<br>
+        // random micro second sleep from zero to .3 seconds<br>
         int usec = g_distribution(g_random_engine);<br>
         printf ("%s (thread = %u) doing a usleep (%d)...\n", __FUNCTION__, thread_index, usec);<br>
-        std::this_thread::sleep_for(std::chrono::microseconds{usec});<br>
+        std::this_thread::sleep_for(std::chrono::microseconds{usec}); // Set break point at this line<br>
<br>
-        if (count < 7)<br>
+        if (count < 2)<br>
             val = access_pool ();<br>
         else<br>
             val = access_pool (true);<br>
@@ -64,7 +64,6 @@ int main (int argc, char const *argv[])<br>
 {<br>
     std::thread threads[3];<br>
<br>
-    printf ("Before turning all three threads loose...\n"); // Set break point at this line, and add a stop-hook.<br>
     // Create 3 threads<br>
     for (auto &thread : threads)<br>
         thread = std::thread{thread_func, std::distance(threads, &thread)};<br>
<br>
Copied: lldb/trunk/lit/ExecControl/StopHook/Inputs/stop-hook.c (from r347104, lldb/trunk/packages/Python/lldbsuite/test/functionalities/stop-hook/main.cpp)<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/ExecControl/StopHook/Inputs/stop-hook.c?p2=lldb/trunk/lit/ExecControl/StopHook/Inputs/stop-hook.c&p1=lldb/trunk/packages/Python/lldbsuite/test/functionalities/stop-hook/main.cpp&r1=347104&r2=347109&rev=347109&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/ExecControl/StopHook/Inputs/stop-hook.c?p2=lldb/trunk/lit/ExecControl/StopHook/Inputs/stop-hook.c&p1=lldb/trunk/packages/Python/lldbsuite/test/functionalities/stop-hook/main.cpp&r1=347104&r2=347109&rev=347109&view=diff</a><br>
==============================================================================<br>
    (empty)<br>
<br>
Added: lldb/trunk/lit/ExecControl/StopHook/stop-hook-threads.test<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/ExecControl/StopHook/stop-hook-threads.test?rev=347109&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/ExecControl/StopHook/stop-hook-threads.test?rev=347109&view=auto</a><br>
==============================================================================<br>
--- lldb/trunk/lit/ExecControl/StopHook/stop-hook-threads.test (added)<br>
+++ lldb/trunk/lit/ExecControl/StopHook/stop-hook-threads.test Fri Nov 16 15:07:28 2018<br>
@@ -0,0 +1,44 @@<br>
+# RUN: %cxx %p/Inputs/stop-hook-threads.cpp -g -o %t<br>
+# RUN: %lldb -b -s %s -O 'target create %t' \<br>
+# RUN:     -O 'break set -f stop-hook-threads.cpp -p "Break here to test that the stop-hook"' \<br>
+# RUN:     -O run \<br>
+# RUN:     -O 'target stop-hook add' \<br>
+# RUN:            -O "frame variable --show-globals g_val" \<br>
+# RUN:            -O "thread list" \<br>
+# RUN:            -O continue \<br>
+# RUN:            -O DONE \<br>
+# RUN:     | FileCheck --check-prefix=CHECK --check-prefix=CHECK-NO-FILTER %s<br>
+# RUN: %lldb -b -s %s \<br>
+# RUN:     -O 'target create %t' \<br>
+# RUN:     -O 'break set -f stop-hook-threads.cpp -p "Break here to test that the stop-hook"' \<br>
+# RUN:     -O run \<br>
+# RUN:     -O 'target stop-hook add -x 2 -o "frame variable thread_index"' \<br>
+# RUN:     -O 'target stop-hook add -o continue' \<br>
+# RUN:     | FileCheck --check-prefix=CHECK --check-prefix=CHECK-FILTER %s<br>
+<br>
+thread list<br>
+break set -f stop-hook-threads.cpp -p "Set break point at this line"<br>
+target stop-hook list<br>
+<br>
+# CHECK: Hook: 1<br>
+# CHECK-NEXT:  State: enabled<br>
+# CHECK-FILTER-NEXT:  Thread<br>
+# CHECK-FILTER-NEXT:  index: 2<br>
+# CHECK-NEXT:  Commands: <br>
+# CHECK-NEXT:    frame variable<br>
+<br>
+# CHECK-FILTER: Hook: 2<br>
+# CHECK-FILTER-NEXT:  State: enabled<br>
+# CHECK-FILTER-NEXT:  Commands: <br>
+# CHECK-FILTER-NEXT:    continue<br>
+<br>
+# Get the threads going<br>
+continue<br>
+<br>
+# When we filter per thread, we expect exactly 4 identical "frame var" results<br>
+# CHECK-FILTER: (uint32_t) thread_index = [[THREAD_INDEX:[0-9]*]]<br>
+# CHECK-FILTER-COUNT-3: (uint32_t) thread_index = [[THREAD_INDEX]]<br>
+# CHECK-FILTER-NOT: thread_index<br>
+<br>
+# When we don't filter, we expect to count 12 stopped threads in the thread list output<br>
+# CHECK-NO-FILTER-COUNT-12: at stop-hook-threads.cpp{{.*}} stop reason = breakpoint<br>
\ No newline at end of file<br>
<br>
Added: lldb/trunk/lit/ExecControl/StopHook/stop-hook.test<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/ExecControl/StopHook/stop-hook.test?rev=347109&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/ExecControl/StopHook/stop-hook.test?rev=347109&view=auto</a><br>
==============================================================================<br>
--- lldb/trunk/lit/ExecControl/StopHook/stop-hook.test (added)<br>
+++ lldb/trunk/lit/ExecControl/StopHook/stop-hook.test Fri Nov 16 15:07:28 2018<br>
@@ -0,0 +1,71 @@<br>
+# RUN: %cc %p/Inputs/stop-hook.c -g -o %t<br>
+# Test setting stop-hook per-function<br>
+# RUN: %lldb -b -s %s -O 'target create %t' -O 'target stop-hook add -n b -o "expr ptr"' \<br>
+# RUN:      | FileCheck --check-prefix=CHECK --check-prefix=CHECK-FUNC %s<br>
+# Test setting stop-hook per-line range<br>
+# RUN: %lldb -b -s %s -O 'target create %t' -O 'target stop-hook add -f stop-hook.c -l 30 -e 34 -o "expr ptr"'  | FileCheck %s<br>
+# Test setting stop-hook with multi-line expression<br>
+# RUN: %lldb -b -s %s -O 'target create %t' -O 'target stop-hook add -f stop-hook.c -l 30 -e 34' -O 'expr ptr' -O DONE | FileCheck %s<br>
+<br>
+break set -f stop-hook.c -p "// Set breakpoint here to test target stop-hook"<br>
+break set -f stop-hook.c -p "// Another breakpoint which is outside of the stop-hook range"<br>
+target stop-hook list<br>
+<br>
+# CHECK: Hook: 1<br>
+# CHECK-NEXT:  State: enabled<br>
+# CHECK-NEXT:  Specifier:<br>
+# CHECK-FUNC-NEXT:    Function: b.<br>
+# CHECK-NEXT:  Commands: <br>
+# CHECK-NEXT:    expr ptr<br>
+<br>
+target stop-hook disable<br>
+<br>
+target stop-hook list<br>
+# CHECK: Hook: 1<br>
+# CHECK-NEXT:  State: disabled<br>
+# CHECK-NEXT:  Specifier:<br>
+# CHECK-FUNC-NEXT:    Function: b.<br>
+# CHECK-NEXT:  Commands: <br>
+# CHECK-NEXT:    expr ptr<br>
+<br>
+target stop-hook enable<br>
+<br>
+target stop-hook list<br>
+# CHECK: Hook: 1<br>
+# CHECK-NEXT:  State: enabled<br>
+# CHECK-NEXT:  Specifier:<br>
+# CHECK-FUNC-NEXT:    Function: b.<br>
+# CHECK-NEXT:  Commands: <br>
+# CHECK-NEXT:    expr ptr<br>
+<br>
+run<br>
+# Stopping inside of the stop hook range<br>
+# CHECK: (lldb) run<br>
+# CHECK-NEXT: (void *) $0 = 0x<br>
+<br>
+thread step-over<br>
+# Stepping inside of the stop hook range<br>
+# CHECK: (lldb) thread step-over<br>
+# CHECK-NEXT: (void *) $1 = 0x<br>
+# CHECK: ->{{.*}} // We should stop here after stepping.<br>
+<br>
+process continue<br>
+# Stopping outside of the stop hook range<br>
+# CHECK: (lldb) process continue<br>
+# CHECK-NOT: (void *)<br>
+# CHECK: ->{{.*}} // Another breakpoint which is outside of the stop-hook range.<br>
+<br>
+thread step-over<br>
+# Stepping inside of the stop hook range<br>
+# CHECK: (lldb) thread step-over<br>
+# CHECK-NOT: (void *)<br>
+<br>
+settings set auto-confirm true<br>
+target stop-hook delete<br>
+<br>
+target stop-hook list<br>
+# CHECK: (lldb) target stop-hook list<br>
+# CHECK-NOT: Hook: 1<br>
+# CHECK: No stop hooks<br>
+# CHECK-NOT: Hook: 1<br>
+<br>
<br>
Removed: lldb/trunk/packages/Python/lldbsuite/test/functionalities/stop-hook/Makefile<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/stop-hook/Makefile?rev=347108&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/stop-hook/Makefile?rev=347108&view=auto</a><br>
==============================================================================<br>
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/stop-hook/Makefile (original)<br>
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/stop-hook/Makefile (removed)<br>
@@ -1,5 +0,0 @@<br>
-LEVEL = ../../make<br>
-<br>
-CXX_SOURCES := main.cpp<br>
-<br>
-include $(LEVEL)/Makefile.rules<br>
<br>
Removed: lldb/trunk/packages/Python/lldbsuite/test/functionalities/stop-hook/TestStopHookCmd.py<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/stop-hook/TestStopHookCmd.py?rev=347108&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/stop-hook/TestStopHookCmd.py?rev=347108&view=auto</a><br>
==============================================================================<br>
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/stop-hook/TestStopHookCmd.py (original)<br>
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/stop-hook/TestStopHookCmd.py (removed)<br>
@@ -1,77 +0,0 @@<br>
-"""<br>
-Test lldb target stop-hook command.<br>
-"""<br>
-<br>
-from __future__ import print_function<br>
-<br>
-<br>
-import os<br>
-import lldb<br>
-from lldbsuite.test.decorators import *<br>
-from lldbsuite.test.lldbtest import *<br>
-from lldbsuite.test import lldbutil<br>
-<br>
-<br>
-class StopHookCmdTestCase(TestBase):<br>
-<br>
-    mydir = TestBase.compute_mydir(__file__)<br>
-<br>
-    def setUp(self):<br>
-        # Call super's setUp().<br>
-        TestBase.setUp(self)<br>
-        # Find the line numbers inside main.cpp.<br>
-        self.begl = line_number(<br>
-            'main.cpp',<br>
-            '// Set breakpoint here to test target stop-hook.')<br>
-        self.endl = line_number(<br>
-            'main.cpp',<br>
-            '// End of the line range for which stop-hook is to be run.')<br>
-        self.line = line_number(<br>
-            'main.cpp',<br>
-            '// Another breakpoint which is outside of the stop-hook range.')<br>
-<br>
-    @no_debug_info_test<br>
-    def test_not_crashing_if_no_target(self):<br>
-        """target stop-hook list should not crash if no target has been set."""<br>
-        self.runCmd("target stop-hook list", check=False)<br>
-<br>
-    def test(self):<br>
-        """Test a sequence of target stop-hook commands."""<br>
-        self.build()<br>
-        exe = self.getBuildArtifact("a.out")<br>
-        self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)<br>
-<br>
-        lldbutil.run_break_set_by_file_and_line(<br>
-            self, "main.cpp", self.begl, num_expected_locations=1, loc_exact=True)<br>
-<br>
-        lldbutil.run_break_set_by_file_and_line(<br>
-            self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)<br>
-<br>
-        self.runCmd(<br>
-            "target stop-hook add -f main.cpp -l %d -e %d -o 'expr ptr'" %<br>
-            (self.begl, self.endl))<br>
-<br>
-        self.expect('target stop-hook list', 'Stop Hook added successfully',<br>
-                    substrs=['State: enabled',<br>
-                             'expr ptr'])<br>
-<br>
-        self.runCmd('target stop-hook disable')<br>
-<br>
-        self.expect('target stop-hook list', 'Stop Hook disabled successfully',<br>
-                    substrs=['State: disabled',<br>
-                             'expr ptr'])<br>
-<br>
-        self.runCmd('target stop-hook enable')<br>
-<br>
-        self.expect('target stop-hook list', 'Stop Hook enabled successfully',<br>
-                    substrs=['State: enabled',<br>
-                             'expr ptr'])<br>
-<br>
-        self.runCmd("settings set auto-confirm true")<br>
-        self.addTearDownHook(<br>
-            lambda: self.runCmd("settings clear auto-confirm"))<br>
-<br>
-        self.runCmd('target stop-hook delete')<br>
-<br>
-        self.expect('target stop-hook list', 'Stop Hook deleted successfully',<br>
-                    substrs=['No stop hooks.'])<br>
<br>
Removed: lldb/trunk/packages/Python/lldbsuite/test/functionalities/stop-hook/TestStopHookMechanism.py<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/stop-hook/TestStopHookMechanism.py?rev=347108&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/stop-hook/TestStopHookMechanism.py?rev=347108&view=auto</a><br>
==============================================================================<br>
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/stop-hook/TestStopHookMechanism.py (original)<br>
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/stop-hook/TestStopHookMechanism.py (removed)<br>
@@ -1,128 +0,0 @@<br>
-"""<br>
-Test lldb target stop-hook mechanism to see whether it fires off correctly .<br>
-"""<br>
-<br>
-from __future__ import print_function<br>
-<br>
-<br>
-import os<br>
-import lldb<br>
-from lldbsuite.test.decorators import *<br>
-from lldbsuite.test.lldbtest import *<br>
-from lldbsuite.test import configuration<br>
-from lldbsuite.test import lldbutil<br>
-<br>
-<br>
-class StopHookMechanismTestCase(TestBase):<br>
-<br>
-    mydir = TestBase.compute_mydir(__file__)<br>
-<br>
-    def setUp(self):<br>
-        # Call super's setUp().<br>
-        TestBase.setUp(self)<br>
-        # Find the line numbers inside main.cpp.<br>
-        self.begl = line_number(<br>
-            'main.cpp',<br>
-            '// Set breakpoint here to test target stop-hook.')<br>
-        self.endl = line_number(<br>
-            'main.cpp',<br>
-            '// End of the line range for which stop-hook is to be run.')<br>
-        self.correct_step_line = line_number(<br>
-            'main.cpp', '// We should stop here after stepping.')<br>
-        self.line = line_number(<br>
-            'main.cpp',<br>
-            '// Another breakpoint which is outside of the stop-hook range.')<br>
-<br>
-    @skipIfFreeBSD  # <a href="http://llvm.org/pr15037" rel="noreferrer" target="_blank">llvm.org/pr15037</a><br>
-    # stop-hooks sometimes fail to fire on Linux<br>
-    @expectedFlakeyLinux('<a href="http://llvm.org/pr15037" rel="noreferrer" target="_blank">llvm.org/pr15037</a>')<br>
-    @expectedFailureAll(<br>
-        hostoslist=["windows"],<br>
-        bugnumber="<a href="http://llvm.org/pr22274" rel="noreferrer" target="_blank">llvm.org/pr22274</a>: need a pexpect replacement for windows")<br>
-    @skipIf(oslist=['ios', 'watchos', 'tvos', 'bridgeos'], archs=['armv7', 'armv7k'])  # <rdar://problem/34582291> problem with armv7 and step-over and stop-hook firing on ios etc systems<br>
-    def test(self):<br>
-        """Test the stop-hook mechanism."""<br>
-        self.build()<br>
-<br>
-        import pexpect<br>
-        exe = self.getBuildArtifact("a.out")<br>
-        prompt = "(lldb) "<br>
-        add_prompt = "Enter your stop hook command(s).  Type 'DONE' to end."<br>
-        add_prompt1 = "> "<br>
-<br>
-        # So that the child gets torn down after the test.<br>
-        self.child = pexpect.spawn('%s %s' %<br>
-                                   (lldbtest_config.lldbExec, self.lldbOption))<br>
-        child = self.child<br>
-        # Turn on logging for what the child sends back.<br>
-        if self.TraceOn():<br>
-            child.logfile_read = sys.stdout<br>
-<br>
-        if lldb.remote_platform:<br>
-            child.expect_exact(prompt)<br>
-            child.sendline(<br>
-                'platform select %s' %<br>
-                lldb.remote_platform.GetName())<br>
-            child.expect_exact(prompt)<br>
-            child.sendline(<br>
-                'platform connect %s' %<br>
-                configuration.lldb_platform_url)<br>
-            child.expect_exact(prompt)<br>
-            child.sendline(<br>
-                'platform settings -w %s' %<br>
-                configuration.lldb_platform_working_dir)<br>
-<br>
-        child.expect_exact(prompt)<br>
-        child.sendline('target create %s' % exe)<br>
-<br>
-        # Set the breakpoint, followed by the target stop-hook commands.<br>
-        child.expect_exact(prompt)<br>
-        child.sendline('breakpoint set -f main.cpp -l %d' % self.begl)<br>
-        child.expect_exact(prompt)<br>
-        child.sendline('breakpoint set -f main.cpp -l %d' % self.line)<br>
-        child.expect_exact(prompt)<br>
-        child.sendline(<br>
-            'target stop-hook add -f main.cpp -l %d -e %d' %<br>
-            (self.begl, self.endl))<br>
-        child.expect_exact(add_prompt)<br>
-        child.expect_exact(add_prompt1)<br>
-        child.sendline('expr ptr')<br>
-        child.expect_exact(add_prompt1)<br>
-        child.sendline('DONE')<br>
-        child.expect_exact(prompt)<br>
-        child.sendline('target stop-hook list')<br>
-<br>
-        # Now run the program, expect to stop at the first breakpoint which is<br>
-        # within the stop-hook range.<br>
-        child.expect_exact(prompt)<br>
-        child.sendline('run')<br>
-        # Make sure we see the stop hook text from the stop of the process from<br>
-        # the run hitting the first breakpoint<br>
-        child.expect_exact('(void *) $')<br>
-        child.expect_exact(prompt)<br>
-        child.sendline('thread step-over')<br>
-        # Expecting to find the output emitted by the firing of our stop hook.<br>
-        child.expect_exact('(void *) $')<br>
-        # This is orthogonal to the main stop hook test, but this example shows a bug in<br>
-        # CLANG where the line table entry for the "return -1" actually includes some code<br>
-        # from the other branch of the if/else, so we incorrectly stop at the "return -1" line.<br>
-        # I fixed that in lldb and I'm sticking in a test here because I don't want to have to<br>
-        # make up a whole nother test case for it.<br>
-        child.sendline('frame info')<br>
-        at_line = 'at main.cpp:%d' % (self.correct_step_line)<br>
-        print('expecting "%s"' % at_line)<br>
-        child.expect_exact(at_line)<br>
-<br>
-        # Now continue the inferior, we'll stop at another breakpoint which is<br>
-        # outside the stop-hook range.<br>
-        child.sendline('process continue')<br>
-        child.expect_exact(<br>
-            '// Another breakpoint which is outside of the stop-hook range.')<br>
-        # self.DebugPExpect(child)<br>
-        child.sendline('thread step-over')<br>
-        child.expect_exact(<br>
-            '// Another breakpoint which is outside of the stop-hook range.')<br>
-        # self.DebugPExpect(child)<br>
-        # Verify that the 'Stop Hooks' mechanism is NOT BEING fired off.<br>
-        self.expect(child.before, exe=False, matching=False,<br>
-                    substrs=['(void *) $'])<br>
<br>
Removed: lldb/trunk/packages/Python/lldbsuite/test/functionalities/stop-hook/main.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/stop-hook/main.cpp?rev=347108&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/stop-hook/main.cpp?rev=347108&view=auto</a><br>
==============================================================================<br>
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/stop-hook/main.cpp (original)<br>
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/stop-hook/main.cpp (removed)<br>
@@ -1,54 +0,0 @@<br>
-//===-- main.c --------------------------------------------------*- C++ -*-===//<br>
-//<br>
-//                     The LLVM Compiler Infrastructure<br>
-//<br>
-// This file is distributed under the University of Illinois Open Source<br>
-// License. See LICENSE.TXT for details.<br>
-//<br>
-//===----------------------------------------------------------------------===//<br>
-#include <stdio.h><br>
-#include <stdlib.h><br>
-<br>
-int a(int);<br>
-int b(int);<br>
-int c(int);<br>
-<br>
-int a(int val)<br>
-{<br>
-    if (val <= 1)<br>
-        return b(val);<br>
-    else if (val >= 3)<br>
-        return c(val);<br>
-<br>
-    return val;<br>
-}<br>
-<br>
-int b(int val)<br>
-{<br>
-    int rc = c(val);<br>
-    void *ptr = malloc(1024);<br>
-    if (!ptr)  // Set breakpoint here to test target stop-hook.<br>
-        return -1;<br>
-    else<br>
-        printf("ptr=%p\n", ptr); // We should stop here after stepping.<br>
-    return rc; // End of the line range for which stop-hook is to be run.<br>
-}<br>
-<br>
-int c(int val)<br>
-{<br>
-    return val + 3;<br>
-}<br>
-<br>
-int main (int argc, char const *argv[])<br>
-{<br>
-    int A1 = a(1);<br>
-    printf("a(1) returns %d\n", A1);<br>
-    <br>
-    int C2 = c(2); // Another breakpoint which is outside of the stop-hook range.<br>
-    printf("c(2) returns %d\n", C2);<br>
-    <br>
-    int A3 = a(3);<br>
-    printf("a(3) returns %d\n", A3);<br>
-    <br>
-    return 0;<br>
-}<br>
<br>
Removed: lldb/trunk/packages/Python/lldbsuite/test/functionalities/stop-hook/multiple_threads/Makefile<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/stop-hook/multiple_threads/Makefile?rev=347108&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/stop-hook/multiple_threads/Makefile?rev=347108&view=auto</a><br>
==============================================================================<br>
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/stop-hook/multiple_threads/Makefile (original)<br>
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/stop-hook/multiple_threads/Makefile (removed)<br>
@@ -1,6 +0,0 @@<br>
-LEVEL = ../../../make<br>
-<br>
-CXX_SOURCES := main.cpp<br>
-ENABLE_THREADS := YES<br>
-<br>
-include $(LEVEL)/Makefile.rules<br>
<br>
Removed: lldb/trunk/packages/Python/lldbsuite/test/functionalities/stop-hook/multiple_threads/TestStopHookMultipleThreads.py<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/stop-hook/multiple_threads/TestStopHookMultipleThreads.py?rev=347108&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/stop-hook/multiple_threads/TestStopHookMultipleThreads.py?rev=347108&view=auto</a><br>
==============================================================================<br>
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/stop-hook/multiple_threads/TestStopHookMultipleThreads.py (original)<br>
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/stop-hook/multiple_threads/TestStopHookMultipleThreads.py (removed)<br>
@@ -1,100 +0,0 @@<br>
-"""<br>
-Test that lldb stop-hook works for multiple threads.<br>
-"""<br>
-<br>
-from __future__ import print_function<br>
-<br>
-<br>
-import os<br>
-import time<br>
-import lldb<br>
-from lldbsuite.test.decorators import *<br>
-from lldbsuite.test.lldbtest import *<br>
-from lldbsuite.test import configuration<br>
-from lldbsuite.test import lldbutil<br>
-<br>
-<br>
-class StopHookForMultipleThreadsTestCase(TestBase):<br>
-<br>
-    mydir = TestBase.compute_mydir(__file__)<br>
-<br>
-    def setUp(self):<br>
-        # Call super's setUp().<br>
-        TestBase.setUp(self)<br>
-        # Our simple source filename.<br>
-        self.source = 'main.cpp'<br>
-        # Find the line number to break inside main().<br>
-        self.first_stop = line_number(<br>
-            self.source, '// Set break point at this line, and add a stop-hook.')<br>
-        self.thread_function = line_number(<br>
-            self.source,<br>
-            '// Break here to test that the stop-hook mechanism works for multiple threads.')<br>
-        # Build dictionary to have unique executable names for each test<br>
-        # method.<br>
-        self.exe_name = self.testMethodName<br>
-        self.d = {'CXX_SOURCES': self.source, 'EXE': self.exe_name}<br>
-<br>
-    @expectedFlakeyFreeBSD("<a href="http://llvm.org/pr15037" rel="noreferrer" target="_blank">llvm.org/pr15037</a>")<br>
-    # stop hooks sometimes fail to fire on Linux<br>
-    @expectedFlakeyLinux("<a href="http://llvm.org/pr15037" rel="noreferrer" target="_blank">llvm.org/pr15037</a>")<br>
-    @expectedFailureAll(<br>
-        hostoslist=["windows"],<br>
-        bugnumber="<a href="http://llvm.org/pr22274" rel="noreferrer" target="_blank">llvm.org/pr22274</a>: need a pexpect replacement for windows")<br>
-    def test_stop_hook_multiple_threads(self):<br>
-        """Test that lldb stop-hook works for multiple threads."""<br>
-        self.build(dictionary=self.d)<br>
-        self.setTearDownCleanup(dictionary=self.d)<br>
-<br>
-        import pexpect<br>
-        exe = self.getBuildArtifact(self.exe_name)<br>
-        prompt = "(lldb) "<br>
-<br>
-        # So that the child gets torn down after the test.<br>
-        self.child = pexpect.spawn('%s %s' %<br>
-                                   (lldbtest_config.lldbExec, self.lldbOption))<br>
-        child = self.child<br>
-        # Turn on logging for what the child sends back.<br>
-        if self.TraceOn():<br>
-            child.logfile_read = sys.stdout<br>
-<br>
-        if lldb.remote_platform:<br>
-            child.expect_exact(prompt)<br>
-            child.sendline(<br>
-                'platform select %s' %<br>
-                lldb.remote_platform.GetName())<br>
-            child.expect_exact(prompt)<br>
-            child.sendline(<br>
-                'platform connect %s' %<br>
-                configuration.lldb_platform_url)<br>
-            child.expect_exact(prompt)<br>
-            child.sendline(<br>
-                'platform settings -w %s' %<br>
-                configuration.lldb_platform_working_dir)<br>
-<br>
-        child.expect_exact(prompt)<br>
-        child.sendline('target create %s' % exe)<br>
-<br>
-        # Set the breakpoint, followed by the target stop-hook commands.<br>
-        child.expect_exact(prompt)<br>
-        child.sendline('breakpoint set -f main.cpp -l %d' % self.first_stop)<br>
-        child.expect_exact(prompt)<br>
-        child.sendline(<br>
-            'breakpoint set -f main.cpp -l %d' %<br>
-            self.thread_function)<br>
-        child.expect_exact(prompt)<br>
-<br>
-        # Now run the program, expect to stop at the first breakpoint which is<br>
-        # within the stop-hook range.<br>
-        child.sendline('run')<br>
-        # 'Process 2415 launched', 'Process 2415 stopped'<br>
-        child.expect_exact("Process")<br>
-        child.expect_exact(prompt)<br>
-        child.sendline(<br>
-            'target stop-hook add -o "frame variable --show-globals g_val"')<br>
-        child.expect_exact("Stop hook")  # 'Stop hook #1 added.'<br>
-        child.expect_exact(prompt)<br>
-<br>
-        # Continue and expect to find the output emitted by the firing of our<br>
-        # stop hook.<br>
-        child.sendline('continue')<br>
-        child.expect_exact('(uint32_t) ::g_val = ')<br>
<br>
Removed: lldb/trunk/packages/Python/lldbsuite/test/functionalities/stop-hook/multiple_threads/main.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/stop-hook/multiple_threads/main.cpp?rev=347108&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/stop-hook/multiple_threads/main.cpp?rev=347108&view=auto</a><br>
==============================================================================<br>
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/stop-hook/multiple_threads/main.cpp (original)<br>
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/stop-hook/multiple_threads/main.cpp (removed)<br>
@@ -1,77 +0,0 @@<br>
-//===-- main.cpp ------------------------------------------------*- C++ -*-===//<br>
-//<br>
-//                     The LLVM Compiler Infrastructure<br>
-//<br>
-// This file is distributed under the University of Illinois Open Source<br>
-// License. See LICENSE.TXT for details.<br>
-//<br>
-//===----------------------------------------------------------------------===//<br>
-<br>
-#include <chrono><br>
-#include <cstdio><br>
-#include <mutex><br>
-#include <random><br>
-#include <thread><br>
-<br>
-std::default_random_engine g_random_engine{std::random_device{}()};<br>
-std::uniform_int_distribution<> g_distribution{0, 3000000};<br>
-<br>
-uint32_t g_val = 0;<br>
-<br>
-uint32_t<br>
-access_pool (bool flag = false)<br>
-{<br>
-    static std::mutex g_access_mutex;<br>
-    if (!flag)<br>
-        g_access_mutex.lock();<br>
-<br>
-    uint32_t old_val = g_val;<br>
-    if (flag)<br>
-        g_val = old_val + 1;<br>
-<br>
-    if (!flag)<br>
-        g_access_mutex.unlock();<br>
-    return g_val;<br>
-}<br>
-<br>
-void<br>
-thread_func (uint32_t thread_index)<br>
-{<br>
-    // Break here to test that the stop-hook mechanism works for multiple threads.<br>
-    printf ("%s (thread index = %u) startng...\n", __FUNCTION__, thread_index);<br>
-<br>
-    uint32_t count = 0;<br>
-    uint32_t val;<br>
-    while (count++ < 15)<br>
-    {<br>
-        // random micro second sleep from zero to 3 seconds<br>
-        int usec = g_distribution(g_random_engine);<br>
-        printf ("%s (thread = %u) doing a usleep (%d)...\n", __FUNCTION__, thread_index, usec);<br>
-        std::this_thread::sleep_for(std::chrono::microseconds{usec});<br>
-<br>
-        if (count < 7)<br>
-            val = access_pool ();<br>
-        else<br>
-            val = access_pool (true);<br>
-<br>
-        printf ("%s (thread = %u) after usleep access_pool returns %d (count=%d)...\n", __FUNCTION__, thread_index, val, count);<br>
-    }<br>
-    printf ("%s (thread index = %u) exiting...\n", __FUNCTION__, thread_index);<br>
-}<br>
-<br>
-<br>
-int main (int argc, char const *argv[])<br>
-{<br>
-    std::thread threads[3];<br>
-<br>
-    printf ("Before turning all three threads loose...\n"); // Set break point at this line, and add a stop-hook.<br>
-    // Create 3 threads<br>
-    for (auto &thread : threads)<br>
-        thread = std::thread{thread_func, std::distance(threads, &thread)};<br>
-<br>
-    // Join all of our threads<br>
-    for (auto &thread : threads)<br>
-        thread.join();<br>
-<br>
-    return 0;<br>
-}<br>
<br>
<br>
_______________________________________________<br>
lldb-commits mailing list<br>
<a href="mailto:lldb-commits@lists.llvm.org" target="_blank">lldb-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits</a><br>
</blockquote></div>