summaryrefslogtreecommitdiffstats
path: root/lldb/test/functionalities/stop-hook/multiple_threads
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2015-10-28 17:43:26 +0000
committerZachary Turner <zturner@google.com>2015-10-28 17:43:26 +0000
commitc432c8f856e0bd84de980a9d9bb2d31b06fa95b1 (patch)
tree4efa528e074a6e2df782345e4cd97f5d85d038c4 /lldb/test/functionalities/stop-hook/multiple_threads
parenta8a3bd210086b50242903ed95048fe5e53897878 (diff)
downloadbcm5719-llvm-c432c8f856e0bd84de980a9d9bb2d31b06fa95b1.tar.gz
bcm5719-llvm-c432c8f856e0bd84de980a9d9bb2d31b06fa95b1.zip
Move lldb/test to lldb/packages/Python/lldbsuite/test.
This is the conclusion of an effort to get LLDB's Python code structured into a bona-fide Python package. This has a number of benefits, but most notably the ability to more easily share Python code between different but related pieces of LLDB's Python infrastructure (for example, `scripts` can now share code with `test`). llvm-svn: 251532
Diffstat (limited to 'lldb/test/functionalities/stop-hook/multiple_threads')
-rw-r--r--lldb/test/functionalities/stop-hook/multiple_threads/Makefile6
-rw-r--r--lldb/test/functionalities/stop-hook/multiple_threads/TestStopHookMultipleThreads.py76
-rw-r--r--lldb/test/functionalities/stop-hook/multiple_threads/main.cpp77
3 files changed, 0 insertions, 159 deletions
diff --git a/lldb/test/functionalities/stop-hook/multiple_threads/Makefile b/lldb/test/functionalities/stop-hook/multiple_threads/Makefile
deleted file mode 100644
index b5d93fb1166..00000000000
--- a/lldb/test/functionalities/stop-hook/multiple_threads/Makefile
+++ /dev/null
@@ -1,6 +0,0 @@
-LEVEL = ../../../make
-
-CXX_SOURCES := main.cpp
-ENABLE_STD_THREADS := YES
-
-include $(LEVEL)/Makefile.rules
diff --git a/lldb/test/functionalities/stop-hook/multiple_threads/TestStopHookMultipleThreads.py b/lldb/test/functionalities/stop-hook/multiple_threads/TestStopHookMultipleThreads.py
deleted file mode 100644
index f38f7a598fc..00000000000
--- a/lldb/test/functionalities/stop-hook/multiple_threads/TestStopHookMultipleThreads.py
+++ /dev/null
@@ -1,76 +0,0 @@
-"""
-Test that lldb stop-hook works for multiple threads.
-"""
-
-from __future__ import print_function
-
-import use_lldb_suite
-
-import os, time
-import lldb
-from lldbtest import *
-
-class StopHookForMultipleThreadsTestCase(TestBase):
-
- mydir = TestBase.compute_mydir(__file__)
-
- def setUp(self):
- # Call super's setUp().
- TestBase.setUp(self)
- # Our simple source filename.
- self.source = 'main.cpp'
- # Find the line number to break inside main().
- self.first_stop = line_number(self.source, '// Set break point at this line, and add a stop-hook.')
- self.thread_function = line_number(self.source, '// Break here to test that the stop-hook mechanism works for multiple threads.')
- # Build dictionary to have unique executable names for each test method.
- self.exe_name = self.testMethodName
- self.d = {'CXX_SOURCES': self.source, 'EXE': self.exe_name}
-
- @expectedFlakeyFreeBSD("llvm.org/pr15037")
- @expectedFlakeyLinux("llvm.org/pr15037") # stop hooks sometimes fail to fire on Linux
- @expectedFailureHostWindows("llvm.org/pr22274: need a pexpect replacement for windows")
- def test_stop_hook_multiple_threads(self):
- """Test that lldb stop-hook works for multiple threads."""
- self.build(dictionary=self.d)
- self.setTearDownCleanup(dictionary=self.d)
-
- import pexpect
- exe = os.path.join(os.getcwd(), self.exe_name)
- prompt = "(lldb) "
-
- # So that the child gets torn down after the test.
- self.child = pexpect.spawn('%s %s' % (lldbtest_config.lldbExec, self.lldbOption))
- child = self.child
- # Turn on logging for what the child sends back.
- if self.TraceOn():
- child.logfile_read = sys.stdout
-
- if lldb.remote_platform:
- child.expect_exact(prompt)
- child.sendline('platform select %s' % lldb.remote_platform.GetName())
- child.expect_exact(prompt)
- child.sendline('platform connect %s' % lldb.platform_url)
- child.expect_exact(prompt)
- child.sendline('platform settings -w %s' % lldb.remote_platform_working_dir)
-
- child.expect_exact(prompt)
- child.sendline('target create %s' % exe)
-
- # Set the breakpoint, followed by the target stop-hook commands.
- child.expect_exact(prompt)
- child.sendline('breakpoint set -f main.cpp -l %d' % self.first_stop)
- child.expect_exact(prompt)
- child.sendline('breakpoint set -f main.cpp -l %d' % self.thread_function)
- child.expect_exact(prompt)
-
- # Now run the program, expect to stop at the first breakpoint which is within the stop-hook range.
- child.sendline('run')
- child.expect_exact("Process") # 'Process 2415 launched', 'Process 2415 stopped'
- child.expect_exact(prompt)
- child.sendline('target stop-hook add -o "frame variable --show-globals g_val"')
- child.expect_exact("Stop hook") # 'Stop hook #1 added.'
- child.expect_exact(prompt)
-
- # Continue and expect to find the output emitted by the firing of our stop hook.
- child.sendline('continue')
- child.expect_exact('(uint32_t) ::g_val = ')
diff --git a/lldb/test/functionalities/stop-hook/multiple_threads/main.cpp b/lldb/test/functionalities/stop-hook/multiple_threads/main.cpp
deleted file mode 100644
index e193ae18e2c..00000000000
--- a/lldb/test/functionalities/stop-hook/multiple_threads/main.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-//===-- main.cpp ------------------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include <chrono>
-#include <cstdio>
-#include <mutex>
-#include <random>
-#include <thread>
-
-std::default_random_engine g_random_engine{std::random_device{}()};
-std::uniform_int_distribution<> g_distribution{0, 3000000};
-
-uint32_t g_val = 0;
-
-uint32_t
-access_pool (bool flag = false)
-{
- static std::mutex g_access_mutex;
- if (!flag)
- g_access_mutex.lock();
-
- uint32_t old_val = g_val;
- if (flag)
- g_val = old_val + 1;
-
- if (!flag)
- g_access_mutex.unlock();
- return g_val;
-}
-
-void
-thread_func (uint32_t thread_index)
-{
- // Break here to test that the stop-hook mechanism works for multiple threads.
- printf ("%s (thread index = %u) startng...\n", __FUNCTION__, thread_index);
-
- uint32_t count = 0;
- uint32_t val;
- while (count++ < 15)
- {
- // random micro second sleep from zero to 3 seconds
- int usec = g_distribution(g_random_engine);
- printf ("%s (thread = %u) doing a usleep (%d)...\n", __FUNCTION__, thread_index, usec);
- std::this_thread::sleep_for(std::chrono::microseconds{usec});
-
- if (count < 7)
- val = access_pool ();
- else
- val = access_pool (true);
-
- printf ("%s (thread = %u) after usleep access_pool returns %d (count=%d)...\n", __FUNCTION__, thread_index, val, count);
- }
- printf ("%s (thread index = %u) exiting...\n", __FUNCTION__, thread_index);
-}
-
-
-int main (int argc, char const *argv[])
-{
- std::thread threads[3];
-
- printf ("Before turning all three threads loose...\n"); // Set break point at this line, and add a stop-hook.
- // Create 3 threads
- for (auto &thread : threads)
- thread = std::thread{thread_func, std::distance(threads, &thread)};
-
- // Join all of our threads
- for (auto &thread : threads)
- thread.join();
-
- return 0;
-}
OpenPOWER on IntegriCloud