diff options
author | Raphael Isemann <teemperor@gmail.com> | 2019-09-01 09:12:37 +0000 |
---|---|---|
committer | Raphael Isemann <teemperor@gmail.com> | 2019-09-01 09:12:37 +0000 |
commit | 29872606d220420d53fde7cc5e3bea15f8da62e7 (patch) | |
tree | 47d7a82ccea48a6dd10a2d8ecb6b3c3127724131 /lldb/packages/Python/lldbsuite/test/commands/process/attach-resume | |
parent | adfdcb9c2652aeee585b9005fd6c67be06af8ea9 (diff) | |
download | bcm5719-llvm-29872606d220420d53fde7cc5e3bea15f8da62e7.tar.gz bcm5719-llvm-29872606d220420d53fde7cc5e3bea15f8da62e7.zip |
[lldb] Restructure test folders to match LLDB command hierarchy
Summary:
As discussed on lldb-dev, this patch moves some LLDB tests into a hierarchy that more closely
resembles the commands we use in the LLDB interpreter. This patch should only move tests
that use the command interpreter and shouldn't touch any tests that primarily test the SB API.
Reviewers: #lldb, jfb, JDevlieghere
Reviewed By: #lldb, JDevlieghere
Subscribers: dexonsmith, arphaman, JDevlieghere, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D67033
llvm-svn: 370605
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/commands/process/attach-resume')
3 files changed, 135 insertions, 0 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/commands/process/attach-resume/Makefile b/lldb/packages/Python/lldbsuite/test/commands/process/attach-resume/Makefile new file mode 100644 index 00000000000..13d40a13b3e --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/process/attach-resume/Makefile @@ -0,0 +1,7 @@ +LEVEL = ../../make + +CXX_SOURCES := main.cpp +ENABLE_THREADS := YES +EXE := AttachResume + +include $(LEVEL)/Makefile.rules diff --git a/lldb/packages/Python/lldbsuite/test/commands/process/attach-resume/TestAttachResume.py b/lldb/packages/Python/lldbsuite/test/commands/process/attach-resume/TestAttachResume.py new file mode 100644 index 00000000000..2c402e6a31a --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/process/attach-resume/TestAttachResume.py @@ -0,0 +1,93 @@ +""" +Test process attach/resume. +""" + +from __future__ import print_function + + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + +exe_name = "AttachResume" # Must match Makefile + + +class AttachResumeTestCase(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + @skipIfRemote + @expectedFailureAll(oslist=['freebsd'], bugnumber='llvm.org/pr19310') + @expectedFailureNetBSD + @skipIfWindows # llvm.org/pr24778, llvm.org/pr21753 + def test_attach_continue_interrupt_detach(self): + """Test attach/continue/interrupt/detach""" + self.build() + self.process_attach_continue_interrupt_detach() + + def process_attach_continue_interrupt_detach(self): + """Test attach/continue/interrupt/detach""" + + exe = self.getBuildArtifact(exe_name) + + popen = self.spawnSubprocess(exe) + self.addTearDownHook(self.cleanupSubprocesses) + + self.runCmd("process attach -p " + str(popen.pid)) + + self.setAsync(True) + listener = self.dbg.GetListener() + process = self.dbg.GetSelectedTarget().GetProcess() + + self.runCmd("c") + lldbutil.expect_state_changes( + self, listener, process, [ + lldb.eStateRunning]) + + self.runCmd("process interrupt") + lldbutil.expect_state_changes( + self, listener, process, [ + lldb.eStateStopped]) + + # be sure to continue/interrupt/continue (r204504) + self.runCmd("c") + lldbutil.expect_state_changes( + self, listener, process, [ + lldb.eStateRunning]) + + self.runCmd("process interrupt") + lldbutil.expect_state_changes( + self, listener, process, [ + lldb.eStateStopped]) + + # Second interrupt should have no effect. + self.expect( + "process interrupt", + patterns=["Process is not running"], + error=True) + + # check that this breakpoint is auto-cleared on detach (r204752) + self.runCmd("br set -f main.cpp -l %u" % + (line_number('main.cpp', '// Set breakpoint here'))) + + self.runCmd("c") + lldbutil.expect_state_changes( + self, listener, process, [ + lldb.eStateRunning, lldb.eStateStopped]) + self.expect('br list', 'Breakpoint not hit', + substrs=['hit count = 1']) + + # Make sure the breakpoint is not hit again. + self.expect("expr debugger_flag = false", substrs=[" = false"]) + + self.runCmd("c") + lldbutil.expect_state_changes( + self, listener, process, [ + lldb.eStateRunning]) + + # make sure to detach while in running state (r204759) + self.runCmd("detach") + lldbutil.expect_state_changes( + self, listener, process, [ + lldb.eStateDetached]) diff --git a/lldb/packages/Python/lldbsuite/test/commands/process/attach-resume/main.cpp b/lldb/packages/Python/lldbsuite/test/commands/process/attach-resume/main.cpp new file mode 100644 index 00000000000..82aad70eed5 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/commands/process/attach-resume/main.cpp @@ -0,0 +1,35 @@ +#include <stdio.h> +#include <fcntl.h> + +#include <chrono> +#include <thread> + +volatile bool debugger_flag = true; // The debugger will flip this to false + +void *start(void *data) +{ + int i; + size_t idx = (size_t)data; + for (i=0; i<30; i++) + { + if ( idx == 0 && debugger_flag) + std::this_thread::sleep_for(std::chrono::microseconds(1)); // Set breakpoint here + std::this_thread::sleep_for(std::chrono::seconds(1)); + } + return 0; +} + +int main(int argc, char const *argv[]) +{ + lldb_enable_attach(); + + static const size_t nthreads = 16; + std::thread threads[nthreads]; + size_t i; + + for (i=0; i<nthreads; i++) + threads[i] = std::move(std::thread(start, (void*)i)); + + for (i=0; i<nthreads; i++) + threads[i].join(); +} |