summaryrefslogtreecommitdiffstats
path: root/packages/Python/lldbsuite/test/tools/lldb-server/inferior-crash
diff options
context:
space:
mode:
Diffstat (limited to 'packages/Python/lldbsuite/test/tools/lldb-server/inferior-crash')
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/inferior-crash/Makefile8
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/inferior-crash/TestGdbRemoteAbort.py42
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/inferior-crash/TestGdbRemoteSegFault.py40
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/inferior-crash/main.cpp39
4 files changed, 129 insertions, 0 deletions
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/inferior-crash/Makefile b/packages/Python/lldbsuite/test/tools/lldb-server/inferior-crash/Makefile
new file mode 100644
index 0000000..a47e279
--- /dev/null
+++ b/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/packages/Python/lldbsuite/test/tools/lldb-server/inferior-crash/TestGdbRemoteAbort.py b/packages/Python/lldbsuite/test/tools/lldb-server/inferior-crash/TestGdbRemoteAbort.py
new file mode 100644
index 0000000..d134332
--- /dev/null
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/inferior-crash/TestGdbRemoteAbort.py
@@ -0,0 +1,42 @@
+from __future__ import print_function
+
+
+
+import gdbremote_testcase
+import signal
+from lldbsuite.test.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/packages/Python/lldbsuite/test/tools/lldb-server/inferior-crash/TestGdbRemoteSegFault.py b/packages/Python/lldbsuite/test/tools/lldb-server/inferior-crash/TestGdbRemoteSegFault.py
new file mode 100644
index 0000000..6618d8f
--- /dev/null
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/inferior-crash/TestGdbRemoteSegFault.py
@@ -0,0 +1,40 @@
+from __future__ import print_function
+
+
+
+import gdbremote_testcase
+import signal
+from lldbsuite.test.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/packages/Python/lldbsuite/test/tools/lldb-server/inferior-crash/main.cpp b/packages/Python/lldbsuite/test/tools/lldb-server/inferior-crash/main.cpp
new file mode 100644
index 0000000..69d6007
--- /dev/null
+++ b/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;
+}
OpenPOWER on IntegriCloud