diff options
author | Zachary Turner <zturner@google.com> | 2015-10-28 17:43:26 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2015-10-28 17:43:26 +0000 |
commit | c432c8f856e0bd84de980a9d9bb2d31b06fa95b1 (patch) | |
tree | 4efa528e074a6e2df782345e4cd97f5d85d038c4 /lldb/packages/Python/lldbsuite/test/tools/lldb-server/inferior-crash | |
parent | a8a3bd210086b50242903ed95048fe5e53897878 (diff) | |
download | bcm5719-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/packages/Python/lldbsuite/test/tools/lldb-server/inferior-crash')
4 files changed, 129 insertions, 0 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/inferior-crash/Makefile b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/inferior-crash/Makefile new file mode 100644 index 00000000000..a47e2797fd8 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/inferior-crash/Makefile @@ -0,0 +1,8 @@ +LEVEL = ../../../make + +CFLAGS_EXTRAS += -D__STDC_LIMIT_MACROS -D__STDC_FORMAT_MACROS -std=c++11 +# LD_EXTRAS := -lpthread +CXX_SOURCES := main.cpp +MAKE_DSYM :=NO + +include $(LEVEL)/Makefile.rules diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/inferior-crash/TestGdbRemoteAbort.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/inferior-crash/TestGdbRemoteAbort.py new file mode 100644 index 00000000000..1f00a7d3594 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/inferior-crash/TestGdbRemoteAbort.py @@ -0,0 +1,42 @@ +from __future__ import print_function + +import use_lldb_suite + +import gdbremote_testcase +import signal +from lldbtest import * + +class TestGdbRemoteAbort(gdbremote_testcase.GdbRemoteTestCaseBase): + mydir = TestBase.compute_mydir(__file__) + + def inferior_abort_received(self): + procs = self.prep_debug_monitor_and_inferior(inferior_args=["abort"]) + self.assertIsNotNone(procs) + + self.test_sequence.add_log_lines([ + "read packet: $vCont;c#a8", + {"direction":"send", "regex":r"^\$T([0-9a-fA-F]{2}).*#[0-9a-fA-F]{2}$", "capture":{ 1:"hex_exit_code"} }, + ], True) + + context = self.expect_gdbremote_sequence() + self.assertIsNotNone(context) + + hex_exit_code = context.get("hex_exit_code") + self.assertIsNotNone(hex_exit_code) + self.assertEqual(int(hex_exit_code, 16), + lldbutil.get_signal_number('SIGABRT')) + + @debugserver_test + def test_inferior_abort_received_debugserver(self): + self.init_debugserver_test() + self.build() + self.inferior_abort_received() + + @llgs_test + # std::abort() on <= API 16 raises SIGSEGV - b.android.com/179836 + @expectedFailureAndroid(api_levels=list(range(16 + 1))) + def test_inferior_abort_received_llgs(self): + self.init_llgs_test() + self.build() + self.inferior_abort_received() + diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/inferior-crash/TestGdbRemoteSegFault.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/inferior-crash/TestGdbRemoteSegFault.py new file mode 100644 index 00000000000..7b3186b9a7c --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/inferior-crash/TestGdbRemoteSegFault.py @@ -0,0 +1,40 @@ +from __future__ import print_function + +import use_lldb_suite + +import gdbremote_testcase +import signal +from lldbtest import * + +class TestGdbRemoteSegFault(gdbremote_testcase.GdbRemoteTestCaseBase): + mydir = TestBase.compute_mydir(__file__) + + GDB_REMOTE_STOP_CODE_BAD_ACCESS = 0x91 + + def inferior_seg_fault_received(self, expected_signo): + procs = self.prep_debug_monitor_and_inferior(inferior_args=["segfault"]) + self.assertIsNotNone(procs) + + self.test_sequence.add_log_lines([ + "read packet: $vCont;c#a8", + {"direction":"send", "regex":r"^\$T([0-9a-fA-F]{2}).*#[0-9a-fA-F]{2}$", "capture":{ 1:"hex_exit_code"} }, + ], True) + + context = self.expect_gdbremote_sequence() + self.assertIsNotNone(context) + + hex_exit_code = context.get("hex_exit_code") + self.assertIsNotNone(hex_exit_code) + self.assertEqual(int(hex_exit_code, 16), expected_signo) + + @debugserver_test + def test_inferior_seg_fault_received_debugserver(self): + self.init_debugserver_test() + self.build() + self.inferior_seg_fault_received(self.GDB_REMOTE_STOP_CODE_BAD_ACCESS) + + @llgs_test + def test_inferior_seg_fault_received_llgs(self): + self.init_llgs_test() + self.build() + self.inferior_seg_fault_received(lldbutil.get_signal_number('SIGSEGV')) diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/inferior-crash/main.cpp b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/inferior-crash/main.cpp new file mode 100644 index 00000000000..69d60071aa4 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/inferior-crash/main.cpp @@ -0,0 +1,39 @@ +#include <cstdlib> +#include <cstring> +#include <iostream> + +namespace +{ + const char *const SEGFAULT_COMMAND = "segfault"; + const char *const ABORT_COMMAND = "abort"; +} + +int main (int argc, char **argv) +{ + if (argc < 2) + { + std::cout << "expected at least one command provided on the command line" << std::endl; + } + + // Process command line args. + for (int i = 1; i < argc; ++i) + { + const char *const command = argv[i]; + if (std::strstr (command, SEGFAULT_COMMAND)) + { + // Perform a null pointer access. + int *const null_int_ptr = nullptr; + *null_int_ptr = 0xDEAD; + } + else if (std::strstr (command, ABORT_COMMAND)) + { + std::abort(); + } + else + { + std::cout << "Unsupported command: " << command << std::endl; + } + } + + return 0; +} |