aboutsummaryrefslogtreecommitdiff
path: root/packages/Python
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2016-01-13 20:06:56 +0000
committerDimitry Andric <dim@FreeBSD.org>2016-01-13 20:06:56 +0000
commit7fed546d1996271dabc7cf71d4d033125c4da4ee (patch)
tree2b6dc7dcb4a6380cb331aded15f5a81c0038e194 /packages/Python
parent9e6d35490a6542f9c97607f93c2ef8ca8e03cbcc (diff)
downloadsrc-7fed546d1996271dabc7cf71d4d033125c4da4ee.tar.gz
src-7fed546d1996271dabc7cf71d4d033125c4da4ee.zip
Vendor import of lldb trunk r257626:vendor/lldb/lldb-trunk-r257626
Notes
Notes: svn path=/vendor/lldb/dist/; revision=293848 svn path=/vendor/lldb/lldb-trunk-r257626/; revision=293849; tag=vendor/lldb/lldb-trunk-r257626
Diffstat (limited to 'packages/Python')
-rw-r--r--packages/Python/lldbsuite/test/README-TestSuite7
-rw-r--r--packages/Python/lldbsuite/test/api/multithreaded/TestMultithreaded.py2
-rw-r--r--packages/Python/lldbsuite/test/dosep.py5
-rw-r--r--packages/Python/lldbsuite/test/driver/batch_mode/TestBatchMode.py105
-rw-r--r--packages/Python/lldbsuite/test/driver/batch_mode/main.c28
-rw-r--r--packages/Python/lldbsuite/test/functionalities/attach_resume/main.cpp17
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/debugbreak/Makefile5
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/debugbreak/TestDebugBreak.py51
-rw-r--r--packages/Python/lldbsuite/test/functionalities/breakpoint/debugbreak/main.c29
-rw-r--r--packages/Python/lldbsuite/test/functionalities/data-formatter/language_category_updates/TestDataFormatterLanguageCategoryUpdates.py1
-rw-r--r--packages/Python/lldbsuite/test/functionalities/inferior-assert/TestInferiorAssert.py4
-rw-r--r--packages/Python/lldbsuite/test/functionalities/inline-stepping/TestInlineStepping.py1
-rw-r--r--packages/Python/lldbsuite/test/functionalities/postmortem/minidump/TestMiniDump.py6
-rw-r--r--packages/Python/lldbsuite/test/functionalities/postmortem/minidump/fizzbuzz.cpp62
-rw-r--r--packages/Python/lldbsuite/test/functionalities/process_attach/main.cpp19
-rw-r--r--packages/Python/lldbsuite/test/functionalities/process_group/main.c17
-rw-r--r--packages/Python/lldbsuite/test/functionalities/register/main.cpp17
-rw-r--r--packages/Python/lldbsuite/test/functionalities/thread/create_after_attach/main.cpp19
-rw-r--r--packages/Python/lldbsuite/test/functionalities/thread/jump/TestThreadJump.py4
-rw-r--r--packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py1
-rw-r--r--packages/Python/lldbsuite/test/functionalities/thread/thread_specific_break_plus_condition/TestThreadSpecificBpPlusCondition.py1
-rw-r--r--packages/Python/lldbsuite/test/functionalities/unwind/noreturn/TestNoreturnUnwind.py2
-rw-r--r--packages/Python/lldbsuite/test/functionalities/watchpoint/step_over_watchpoint/TestStepOverWatchpoint.py1
-rw-r--r--packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_set_command/TestWatchLocationWithWatchSet.py1
-rw-r--r--packages/Python/lldbsuite/test/lang/objc/global_ptrs/Makefile6
-rw-r--r--packages/Python/lldbsuite/test/lang/objc/global_ptrs/TestGlobalObjects.py53
-rw-r--r--packages/Python/lldbsuite/test/lang/objc/global_ptrs/main.m11
-rw-r--r--packages/Python/lldbsuite/test/lldbinline.py8
-rw-r--r--packages/Python/lldbsuite/test/lldbtest.py7
-rw-r--r--packages/Python/lldbsuite/test/make/test_common.h63
-rw-r--r--packages/Python/lldbsuite/test/python_api/disassemble-raw-data/TestDisassembleRawData.py24
-rw-r--r--packages/Python/lldbsuite/test/python_api/event/TestEvents.py4
-rw-r--r--packages/Python/lldbsuite/test/python_api/hello_world/main.c23
-rw-r--r--packages/Python/lldbsuite/test/python_api/module_section/TestModuleAndSection.py2
-rw-r--r--packages/Python/lldbsuite/test/python_api/value/change_values/TestChangeValueAPI.py1
-rw-r--r--packages/Python/lldbsuite/test/python_api/value/linked_list/TestValueAPILinkedList.py2
-rw-r--r--packages/Python/lldbsuite/test/test_categories.py3
-rw-r--r--packages/Python/lldbsuite/test/tools/lldb-server/main.cpp15
38 files changed, 411 insertions, 216 deletions
diff --git a/packages/Python/lldbsuite/test/README-TestSuite b/packages/Python/lldbsuite/test/README-TestSuite
index 6df4d7bd7be7..70e4c91b8894 100644
--- a/packages/Python/lldbsuite/test/README-TestSuite
+++ b/packages/Python/lldbsuite/test/README-TestSuite
@@ -157,3 +157,10 @@ o Writing test cases:
then use SBInterpreter::HandleCommand to run the command. You get the full result text
from the command in the command return object, and all the part where you are driving the
debugger to the point you want to test will be more robust.
+
+o Attaching in test cases:
+
+ If you need to attach to inferiors in your tests, you must make sure the inferior calls
+ lldb_enable_attach(), before the debugger attempts to attach. This function performs any
+ platform-specific processing needed to enable attaching to this process (e.g., on Linux, we
+ execute prctl(PR_SET_TRACER) syscall to disable protections present in some Linux systems).
diff --git a/packages/Python/lldbsuite/test/api/multithreaded/TestMultithreaded.py b/packages/Python/lldbsuite/test/api/multithreaded/TestMultithreaded.py
index 0b405091ebd1..9963cf23a8c6 100644
--- a/packages/Python/lldbsuite/test/api/multithreaded/TestMultithreaded.py
+++ b/packages/Python/lldbsuite/test/api/multithreaded/TestMultithreaded.py
@@ -51,7 +51,7 @@ class SBBreakpointCallbackCase(TestBase):
@skipIfNoSBHeaders
@skipIfWindows # clang-cl does not support throw or catch (llvm.org/pr24538)
@expectedFlakeyFreeBSD
- @expectedFlakeyLinux
+ @expectedFailureLinux
def test_sb_api_listener_resume(self):
""" Test that a process can be resumed from a non-main thread. """
self.build_and_test('driver.cpp listener_test.cpp test_listener_resume.cpp',
diff --git a/packages/Python/lldbsuite/test/dosep.py b/packages/Python/lldbsuite/test/dosep.py
index 51275d55c178..87a410fa090f 100644
--- a/packages/Python/lldbsuite/test/dosep.py
+++ b/packages/Python/lldbsuite/test/dosep.py
@@ -1149,11 +1149,6 @@ def getExpectedTimeouts(platform_name):
"TestExitDuringStep.py",
"TestHelloWorld.py",
}
- if host.startswith("win32"):
- expected_timeout |= {
- "TestEvents.py",
- "TestThreadStates.py",
- }
elif target.startswith("freebsd"):
expected_timeout |= {
"TestBreakpointConditions.py",
diff --git a/packages/Python/lldbsuite/test/driver/batch_mode/TestBatchMode.py b/packages/Python/lldbsuite/test/driver/batch_mode/TestBatchMode.py
index b5ff88c3bba1..0a9edd2755c9 100644
--- a/packages/Python/lldbsuite/test/driver/batch_mode/TestBatchMode.py
+++ b/packages/Python/lldbsuite/test/driver/batch_mode/TestBatchMode.py
@@ -14,21 +14,12 @@ class DriverBatchModeTest (TestBase):
mydir = TestBase.compute_mydir(__file__)
- @skipIfRemote # test not remote-ready llvm.org/pr24813
- @expectedFlakeyFreeBSD("llvm.org/pr25172 fails rarely on the buildbot")
- @expectedFlakeyLinux("llvm.org/pr25172")
- @expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows")
- def test_driver_batch_mode(self):
- """Test that the lldb driver's batch mode works correctly."""
- self.build()
- self.setTearDownCleanup()
- self.batch_mode()
-
def setUp(self):
# Call super's setUp().
TestBase.setUp(self)
# Our simple source filename.
self.source = 'main.c'
+ self.victim = None
def expect_string (self, string):
import pexpect
@@ -40,12 +31,20 @@ class DriverBatchModeTest (TestBase):
except pexpect.TIMEOUT:
self.fail ("Timed out waiting for '%s'"%(string))
- def batch_mode (self):
+ @skipIfRemote # test not remote-ready llvm.org/pr24813
+ @expectedFlakeyFreeBSD("llvm.org/pr25172 fails rarely on the buildbot")
+ @expectedFlakeyLinux("llvm.org/pr25172")
+ @expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows")
+ def test_batch_mode_run_crash (self):
+ """Test that the lldb driver's batch mode works correctly."""
+ self.build()
+ self.setTearDownCleanup()
+
import pexpect
exe = os.path.join(os.getcwd(), "a.out")
prompt = "(lldb) "
- # First time through, pass CRASH so the process will crash and stop in batch mode.
+ # Pass CRASH so the process will crash and stop in batch mode.
run_commands = ' -b -o "break set -n main" -o "run" -o "continue" -k "frame var touch_me_not"'
self.child = pexpect.spawn('%s %s %s %s -- CRASH' % (lldbtest_config.lldbExec, self.lldbOption, run_commands, exe))
child = self.child
@@ -68,7 +67,21 @@ class DriverBatchModeTest (TestBase):
self.deletePexpectChild()
- # Now do it again, and see make sure if we don't crash, we quit:
+
+ @skipIfRemote # test not remote-ready llvm.org/pr24813
+ @expectedFlakeyFreeBSD("llvm.org/pr25172 fails rarely on the buildbot")
+ @expectedFlakeyLinux("llvm.org/pr25172")
+ @expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows")
+ def test_batch_mode_run_exit (self):
+ """Test that the lldb driver's batch mode works correctly."""
+ self.build()
+ self.setTearDownCleanup()
+
+ import pexpect
+ exe = os.path.join(os.getcwd(), "a.out")
+ prompt = "(lldb) "
+
+ # Now do it again, and make sure if we don't crash, we quit:
run_commands = ' -b -o "break set -n main" -o "run" -o "continue" '
self.child = pexpect.spawn('%s %s %s %s -- NOCRASH' % (lldbtest_config.lldbExec, self.lldbOption, run_commands, exe))
child = self.child
@@ -87,3 +100,69 @@ class DriverBatchModeTest (TestBase):
index = self.child.expect([pexpect.EOF, pexpect.TIMEOUT])
self.assertTrue(index == 0, "lldb didn't close on successful batch completion.")
+ def closeVictim(self):
+ if self.victim != None:
+ self.victim.close()
+ self.victim = None
+
+ @skipIfRemote # test not remote-ready llvm.org/pr24813
+ @expectedFlakeyFreeBSD("llvm.org/pr25172 fails rarely on the buildbot")
+ @expectedFlakeyLinux("llvm.org/pr25172")
+ @expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows")
+ def test_batch_mode_attach_exit (self):
+ """Test that the lldb driver's batch mode works correctly."""
+ self.build()
+ self.setTearDownCleanup()
+
+ import pexpect
+ exe = os.path.join(os.getcwd(), "a.out")
+ prompt = "(lldb) "
+
+ # Finally, start up the process by hand, attach to it, and wait for its completion.
+ # Attach is funny, since it looks like it stops with a signal on most Unixen so
+ # care must be taken not to treat that as a reason to exit batch mode.
+
+ # Start up the process by hand and wait for it to get to the wait loop.
+
+ self.victim = pexpect.spawn('%s WAIT' %(exe))
+ if self.victim == None:
+ self.fail("Could not spawn ", exe, ".")
+
+ self.addTearDownHook (self.closeVictim)
+
+ if self.TraceOn():
+ self.victim.logfile_read = sys.stdout
+
+ self.victim.expect("PID: ([0-9]+) END")
+ if self.victim.match == None:
+ self.fail("Couldn't get the target PID.")
+
+ victim_pid = int(self.victim.match.group(1))
+
+ self.victim.expect("Waiting")
+
+ run_commands = ' -b -o "process attach -p %d" -o "breakpoint set --file %s -p \'Stop here to unset keep_waiting\' -N keep_waiting" -o "continue" -o "break delete keep_waiting" -o "expr keep_waiting = 0" -o "continue" ' % (victim_pid, self.source)
+ self.child = pexpect.spawn('%s %s %s %s' % (lldbtest_config.lldbExec, self.lldbOption, run_commands, exe))
+
+ child = self.child
+ # Turn on logging for what the child sends back.
+ if self.TraceOn():
+ child.logfile_read = sys.stdout
+
+ # We should see the "run":
+ self.expect_string ("attach")
+
+ self.expect_string(prompt + "continue")
+
+ self.expect_string(prompt + "continue")
+
+ # Then we should see the process exit:
+ self.expect_string ("Process %d exited with status"%(victim_pid))
+
+ victim_index = self.victim.expect([pexpect.EOF, pexpect.TIMEOUT])
+ self.assertTrue(victim_index == 0, "Victim didn't really exit.")
+
+ index = self.child.expect([pexpect.EOF, pexpect.TIMEOUT])
+ self.assertTrue(index == 0, "lldb didn't close on successful batch completion.")
+
+
diff --git a/packages/Python/lldbsuite/test/driver/batch_mode/main.c b/packages/Python/lldbsuite/test/driver/batch_mode/main.c
index 418160eaa36d..c85a0f272d2c 100644
--- a/packages/Python/lldbsuite/test/driver/batch_mode/main.c
+++ b/packages/Python/lldbsuite/test/driver/batch_mode/main.c
@@ -1,10 +1,36 @@
#include <stdio.h>
#include <string.h>
+#include <unistd.h>
int
main (int argc, char **argv)
{
- if (argc >= 2 && strcmp (argv[1], "CRASH") == 0)
+ lldb_enable_attach();
+
+ int do_crash = 0;
+ int do_wait = 0;
+
+ int idx;
+ for (idx = 1; idx < argc; idx++)
+ {
+ if (strcmp(argv[idx], "CRASH") == 0)
+ do_crash = 1;
+ if (strcmp(argv[idx], "WAIT") == 0)
+ do_wait = 1;
+ }
+ printf("PID: %d END\n", getpid());
+
+ if (do_wait)
+ {
+ int keep_waiting = 1;
+ while (keep_waiting)
+ {
+ printf ("Waiting\n");
+ sleep(1); // Stop here to unset keep_waiting
+ }
+ }
+
+ if (do_crash)
{
char *touch_me_not = (char *) 0;
printf ("About to crash.\n");
diff --git a/packages/Python/lldbsuite/test/functionalities/attach_resume/main.cpp b/packages/Python/lldbsuite/test/functionalities/attach_resume/main.cpp
index 7cf360258546..82aad70eed56 100644
--- a/packages/Python/lldbsuite/test/functionalities/attach_resume/main.cpp
+++ b/packages/Python/lldbsuite/test/functionalities/attach_resume/main.cpp
@@ -4,10 +4,6 @@
#include <chrono>
#include <thread>
-#if defined(__linux__)
-#include <sys/prctl.h>
-#endif
-
volatile bool debugger_flag = true; // The debugger will flip this to false
void *start(void *data)
@@ -25,18 +21,7 @@ void *start(void *data)
int main(int argc, char const *argv[])
{
-#if defined(__linux__)
- // Immediately enable any ptracer so that we can allow the stub attach
- // operation to succeed. Some Linux kernels are locked down so that
- // only an ancestor process can be a ptracer of a process. This disables that
- // restriction. Without it, attach-related stub tests will fail.
-#if defined(PR_SET_PTRACER) && defined(PR_SET_PTRACER_ANY)
- // For now we execute on best effort basis. If this fails for
- // some reason, so be it.
- const int prctl_result = prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY, 0, 0, 0);
- static_cast<void> (prctl_result);
-#endif
-#endif
+ lldb_enable_attach();
static const size_t nthreads = 16;
std::thread threads[nthreads];
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/debugbreak/Makefile b/packages/Python/lldbsuite/test/functionalities/breakpoint/debugbreak/Makefile
new file mode 100644
index 000000000000..b09a579159d4
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/debugbreak/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../../make
+
+C_SOURCES := main.c
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/debugbreak/TestDebugBreak.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/debugbreak/TestDebugBreak.py
new file mode 100644
index 000000000000..b32c970301c9
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/debugbreak/TestDebugBreak.py
@@ -0,0 +1,51 @@
+"""
+Test embedded breakpoints, like `asm int 3;` in x86 or or `__debugbreak` on Windows.
+"""
+
+from __future__ import print_function
+
+import os
+import lldb
+from lldbsuite.test.lldbtest import *
+import lldbsuite.test.lldbutil as lldbutil
+
+class DebugBreakTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ @skipIf(archs=not_in(["i386", "i686"]))
+ @no_debug_info_test
+ def test_asm_int_3(self):
+ """Test that intrinsics like `__debugbreak();` and `asm {"int3"}` are treated like breakpoints."""
+ self.build()
+ exe = os.path.join(os.getcwd(), "a.out")
+
+ # Run the program.
+ target = self.dbg.CreateTarget(exe)
+ process = target.LaunchSimple(None, None, self.get_process_working_directory())
+
+ # We've hit the first stop, so grab the frame.
+ self.assertEqual(process.GetState(), lldb.eStateStopped)
+ thread = process.GetThreadAtIndex(0)
+ frame = thread.GetFrameAtIndex(0)
+
+ # We should be in funciton 'bar'.
+ self.assertTrue(frame.IsValid())
+ function_name = frame.GetFunctionName()
+ self.assertTrue('bar' in function_name)
+
+ # We should be able to evaluate the parameter foo.
+ value = frame.EvaluateExpression('*foo')
+ self.assertEqual(value.GetValueAsSigned(), 42)
+
+ # The counter should be 1 at the first stop and increase by 2 for each
+ # subsequent stop.
+ counter = 1
+ while counter < 20:
+ value = frame.EvaluateExpression('count')
+ self.assertEqual(value.GetValueAsSigned(), counter)
+ counter += 2
+ process.Continue()
+
+ # The inferior should exit after the last iteration.
+ self.assertEqual(process.GetState(), lldb.eStateExited)
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/debugbreak/main.c b/packages/Python/lldbsuite/test/functionalities/breakpoint/debugbreak/main.c
new file mode 100644
index 000000000000..5f936327e4ea
--- /dev/null
+++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/debugbreak/main.c
@@ -0,0 +1,29 @@
+#ifdef _MSC_VER
+#include <intrin.h>
+#define BREAKPOINT_INTRINSIC() __debugbreak()
+#else
+#define BREAKPOINT_INTRINSIC() __asm__ __volatile__ ("int3")
+#endif
+
+int
+bar(int const *foo)
+{
+ int count = 0, i = 0;
+ for (; i < 10; ++i)
+ {
+ count += 1;
+ BREAKPOINT_INTRINSIC();
+ count += 1;
+ }
+ return *foo;
+}
+
+int
+main(int argc, char **argv)
+{
+ int foo = 42;
+ bar(&foo);
+ return 0;
+}
+
+
diff --git a/packages/Python/lldbsuite/test/functionalities/data-formatter/language_category_updates/TestDataFormatterLanguageCategoryUpdates.py b/packages/Python/lldbsuite/test/functionalities/data-formatter/language_category_updates/TestDataFormatterLanguageCategoryUpdates.py
index b7562c4336a6..f30733d2d81a 100644
--- a/packages/Python/lldbsuite/test/functionalities/data-formatter/language_category_updates/TestDataFormatterLanguageCategoryUpdates.py
+++ b/packages/Python/lldbsuite/test/functionalities/data-formatter/language_category_updates/TestDataFormatterLanguageCategoryUpdates.py
@@ -21,7 +21,6 @@ class LanguageCategoryUpdatesTestCase(TestBase):
# Find the line number to break at.
self.line = line_number('main.cpp', '// break here')
- @expectedFailureWindows("llvm.org/pr24462") # Data formatters have problems on Windows
def test_with_run_command(self):
"""Test that LLDB correctly cleans caches when language categories change."""
# This is the function to remove the custom formats in order to have a
diff --git a/packages/Python/lldbsuite/test/functionalities/inferior-assert/TestInferiorAssert.py b/packages/Python/lldbsuite/test/functionalities/inferior-assert/TestInferiorAssert.py
index 69e977e6343f..950b021b69ce 100644
--- a/packages/Python/lldbsuite/test/functionalities/inferior-assert/TestInferiorAssert.py
+++ b/packages/Python/lldbsuite/test/functionalities/inferior-assert/TestInferiorAssert.py
@@ -16,6 +16,7 @@ class AssertingInferiorTestCase(TestBase):
@expectedFailureWindows("llvm.org/pr21793: need to implement support for detecting assertion / abort on Windows")
@expectedFailurei386("llvm.org/pr25338")
+ @expectedFailureLinux("llvm.org/pr25338", archs=['arm', 'i386'])
def test_inferior_asserting(self):
"""Test that lldb reliably catches the inferior asserting (command)."""
self.build()
@@ -30,6 +31,7 @@ class AssertingInferiorTestCase(TestBase):
@expectedFailureWindows("llvm.org/pr21793: need to implement support for detecting assertion / abort on Windows")
@expectedFailurei386("llvm.org/pr25338")
+ @expectedFailureLinux("llvm.org/pr25338", archs=['arm', 'i386'])
def test_inferior_asserting_disassemble(self):
"""Test that lldb reliably disassembles frames after asserting (command)."""
self.build()
@@ -44,6 +46,7 @@ class AssertingInferiorTestCase(TestBase):
@expectedFailureWindows("llvm.org/pr21793: need to implement support for detecting assertion / abort on Windows")
@expectedFailurei386("llvm.org/pr25338")
+ @expectedFailureLinux("llvm.org/pr25338", archs=['arm', 'i386'])
def test_inferior_asserting_expr(self):
"""Test that the lldb expression interpreter can read from the inferior after asserting (command)."""
self.build()
@@ -51,6 +54,7 @@ class AssertingInferiorTestCase(TestBase):
@expectedFailureWindows("llvm.org/pr21793: need to implement support for detecting assertion / abort on Windows")
@expectedFailurei386("llvm.org/pr25338")
+ @expectedFailureLinux("llvm.org/pr25338", archs=['arm', 'i386'])
def test_inferior_asserting_step(self):
"""Test that lldb functions correctly after stepping through a call to assert()."""
self.build()
diff --git a/packages/Python/lldbsuite/test/functionalities/inline-stepping/TestInlineStepping.py b/packages/Python/lldbsuite/test/functionalities/inline-stepping/TestInlineStepping.py
index 3bdf6ec70e34..023f6f31e395 100644
--- a/packages/Python/lldbsuite/test/functionalities/inline-stepping/TestInlineStepping.py
+++ b/packages/Python/lldbsuite/test/functionalities/inline-stepping/TestInlineStepping.py
@@ -16,7 +16,6 @@ class TestInlineStepping(TestBase):
@add_test_categories(['pyapi'])
@expectedFailureFreeBSD('llvm.org/pr17214')
@expectedFailureIcc # Not really a bug. ICC combines two inlined functions.
- @expectedFailureWindows("llvm.org/pr24778")
# failed 1/365 dosep runs, (i386-clang), TestInlineStepping.py:237 failed to stop at first breakpoint in main
@expectedFailureAll(oslist=["linux"], archs=["i386"])
def test_with_python_api(self):
diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/TestMiniDump.py b/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/TestMiniDump.py
index 53888502a3aa..1dda59ac374b 100644
--- a/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/TestMiniDump.py
+++ b/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/TestMiniDump.py
@@ -3,7 +3,7 @@ Test basics of mini dump debugging.
"""
from __future__ import print_function
-
+from six import iteritems
import lldb
@@ -83,8 +83,8 @@ class MiniDumpTestCase(TestBase):
thread = process.GetThreadAtIndex(0)
expected_stack = { 0: 'bar', 1: 'foo', 2: 'main' }
- self.assertEqual(thread.GetNumFrames(), len(expected_stack))
- for index, name in expected_stack.iteritems():
+ self.assertGreaterEqual(thread.GetNumFrames(), len(expected_stack))
+ for index, name in iteritems(expected_stack):
frame = thread.GetFrameAtIndex(index)
self.assertTrue(frame.IsValid())
function_name = frame.GetFunctionName()
diff --git a/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/fizzbuzz.cpp b/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/fizzbuzz.cpp
index eb6476bfd9a9..295d4a1f24db 100644
--- a/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/fizzbuzz.cpp
+++ b/packages/Python/lldbsuite/test/functionalities/postmortem/minidump/fizzbuzz.cpp
@@ -1,31 +1,31 @@
-// A sample program for getting minidumps on Windows.
-
-#include <iostream>
-
-bool
-fizz(int x)
-{
- return x % 3 == 0;
-}
-
-bool
-buzz(int x)
-{
- return x % 5 == 0;
-}
-
-int
-main()
-{
- int *buggy = 0;
-
- for (int i = 1; i <= 100; ++i)
- {
- if (fizz(i)) std::cout << "fizz";
- if (buzz(i)) std::cout << "buzz";
- if (!fizz(i) && !buzz(i)) std::cout << i;
- std::cout << '\n';
- }
-
- return *buggy;
-}
+// A sample program for getting minidumps on Windows.
+
+#include <iostream>
+
+bool
+fizz(int x)
+{
+ return x % 3 == 0;
+}
+
+bool
+buzz(int x)
+{
+ return x % 5 == 0;
+}
+
+int
+main()
+{
+ int *buggy = 0;
+
+ for (int i = 1; i <= 100; ++i)
+ {
+ if (fizz(i)) std::cout << "fizz";
+ if (buzz(i)) std::cout << "buzz";
+ if (!fizz(i) && !buzz(i)) std::cout << i;
+ std::cout << '\n';
+ }
+
+ return *buggy;
+}
diff --git a/packages/Python/lldbsuite/test/functionalities/process_attach/main.cpp b/packages/Python/lldbsuite/test/functionalities/process_attach/main.cpp
index 8021feac5c71..46ffacc0a840 100644
--- a/packages/Python/lldbsuite/test/functionalities/process_attach/main.cpp
+++ b/packages/Python/lldbsuite/test/functionalities/process_attach/main.cpp
@@ -1,28 +1,11 @@
#include <stdio.h>
-#if defined(__linux__)
-#include <sys/prctl.h>
-#endif
-
#include <chrono>
#include <thread>
int main(int argc, char const *argv[]) {
int temp;
-#if defined(__linux__)
- // Immediately enable any ptracer so that we can allow the stub attach
- // operation to succeed. Some Linux kernels are locked down so that
- // only an ancestor process can be a ptracer of a process. This disables that
- // restriction. Without it, attach-related stub tests will fail.
-#if defined(PR_SET_PTRACER) && defined(PR_SET_PTRACER_ANY)
- int prctl_result;
-
- // For now we execute on best effort basis. If this fails for
- // some reason, so be it.
- prctl_result = prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY, 0, 0, 0);
- (void) prctl_result;
-#endif
-#endif
+ lldb_enable_attach();
// Waiting to be attached by the debugger.
temp = 0;
diff --git a/packages/Python/lldbsuite/test/functionalities/process_group/main.c b/packages/Python/lldbsuite/test/functionalities/process_group/main.c
index c730c629e8b0..7e986bbac65d 100644
--- a/packages/Python/lldbsuite/test/functionalities/process_group/main.c
+++ b/packages/Python/lldbsuite/test/functionalities/process_group/main.c
@@ -2,10 +2,6 @@
#include <unistd.h>
#include <sys/wait.h>
-#if defined(__linux__)
-#include <sys/prctl.h>
-#endif
-
volatile int release_child_flag = 0;
int main(int argc, char const *argv[])
@@ -61,18 +57,7 @@ int main(int argc, char const *argv[])
}
else
{ // child
-#if defined(__linux__)
- // Immediately enable any ptracer so that we can allow the stub attach
- // operation to succeed. Some Linux kernels are locked down so that
- // only an ancestor process can be a ptracer of a process. This disables that
- // restriction. Without it, attach-related stub tests will fail.
-#if defined(PR_SET_PTRACER) && defined(PR_SET_PTRACER_ANY)
- // For now we execute on best effort basis. If this fails for
- // some reason, so be it.
- const int prctl_result = prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY, 0, 0, 0);
- (void) prctl_result;
-#endif
-#endif
+ lldb_enable_attach();
while (! release_child_flag) // Wait for debugger to attach
sleep(1);
diff --git a/packages/Python/lldbsuite/test/functionalities/register/main.cpp b/packages/Python/lldbsuite/test/functionalities/register/main.cpp
index 876dd0833e54..156515768ddb 100644
--- a/packages/Python/lldbsuite/test/functionalities/register/main.cpp
+++ b/packages/Python/lldbsuite/test/functionalities/register/main.cpp
@@ -8,10 +8,6 @@
//===----------------------------------------------------------------------===//
#include <stdio.h>
-#if defined(__linux__)
-#include <sys/prctl.h>
-#endif
-
#include <chrono>
#include <thread>
@@ -19,18 +15,7 @@ long double outermost_return_long_double (long double my_long_double);
int main (int argc, char const *argv[])
{
-#if defined(__linux__)
- // Immediately enable any ptracer so that we can allow the stub attach
- // operation to succeed. Some Linux kernels are locked down so that
- // only an ancestor process can be a ptracer of a process. This disables that
- // restriction. Without it, attach-related stub tests will fail.
-#if defined(PR_SET_PTRACER) && defined(PR_SET_PTRACER_ANY)
- // For now we execute on best effort basis. If this fails for
- // some reason, so be it.
- const int prctl_result = prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY, 0, 0, 0);
- static_cast<void> (prctl_result);
-#endif
-#endif
+ lldb_enable_attach();
char my_string[] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 0};
double my_double = 1234.5678;
diff --git a/packages/Python/lldbsuite/test/functionalities/thread/create_after_attach/main.cpp b/packages/Python/lldbsuite/test/functionalities/thread/create_after_attach/main.cpp
index 8434458f0648..d8f06e55a2dd 100644
--- a/packages/Python/lldbsuite/test/functionalities/thread/create_after_attach/main.cpp
+++ b/packages/Python/lldbsuite/test/functionalities/thread/create_after_attach/main.cpp
@@ -4,10 +4,6 @@
using std::chrono::microseconds;
-#if defined(__linux__)
-#include <sys/prctl.h>
-#endif
-
volatile int g_thread_2_continuing = 0;
void *
@@ -42,20 +38,7 @@ thread_2_func (void *input)
int main(int argc, char const *argv[])
{
-#if defined(__linux__)
- // Immediately enable any ptracer so that we can allow the stub attach
- // operation to succeed. Some Linux kernels are locked down so that
- // only an ancestor process can be a ptracer of a process. This disables that
- // restriction. Without it, attach-related stub tests will fail.
-#if defined(PR_SET_PTRACER) && defined(PR_SET_PTRACER_ANY)
- int prctl_result;
-
- // For now we execute on best effort basis. If this fails for
- // some reason, so be it.
- prctl_result = prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY, 0, 0, 0);
- (void) prctl_result;
-#endif
-#endif
+ lldb_enable_attach();
// Create a new thread
std::thread thread_1(thread_1_func, nullptr);
diff --git a/packages/Python/lldbsuite/test/functionalities/thread/jump/TestThreadJump.py b/packages/Python/lldbsuite/test/functionalities/thread/jump/TestThreadJump.py
index be49a210f0f0..768e2fe4f87a 100644
--- a/packages/Python/lldbsuite/test/functionalities/thread/jump/TestThreadJump.py
+++ b/packages/Python/lldbsuite/test/functionalities/thread/jump/TestThreadJump.py
@@ -33,9 +33,7 @@ class ThreadJumpTestCase(TestBase):
# The stop reason of the thread should be breakpoint 1.
self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT + " 1",
- substrs = ['stopped',
- '* thread #1',
- 'stop reason = breakpoint 1'])
+ substrs=['stopped', 'main.cpp:{}'.format(self.mark3), 'stop reason = breakpoint 1'])
self.do_min_test(self.mark3, self.mark1, "i", "4"); # Try the int path, force it to return 'a'
self.do_min_test(self.mark3, self.mark2, "i", "5"); # Try the int path, force it to return 'b'
diff --git a/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py b/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py
index 623c659ffa5c..4938ec50453e 100644
--- a/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py
+++ b/packages/Python/lldbsuite/test/functionalities/thread/state/TestThreadStates.py
@@ -19,7 +19,6 @@ class ThreadStateTestCase(TestBase):
@expectedFailureDarwin("rdar://15367566")
@expectedFailureFreeBSD('llvm.org/pr15824')
@expectedFailureLinux("llvm.org/pr15824") # thread states not properly maintained
- @expectedFailureWindows("llvm.org/pr24668") # Breakpoints not resolved correctly
def test_state_after_breakpoint(self):
"""Test thread state after breakpoint."""
self.build(dictionary=self.getBuildFlags(use_cpp11=False))
diff --git a/packages/Python/lldbsuite/test/functionalities/thread/thread_specific_break_plus_condition/TestThreadSpecificBpPlusCondition.py b/packages/Python/lldbsuite/test/functionalities/thread/thread_specific_break_plus_condition/TestThreadSpecificBpPlusCondition.py
index b4a0b7a5dd4e..68c96a0fba75 100644
--- a/packages/Python/lldbsuite/test/functionalities/thread/thread_specific_break_plus_condition/TestThreadSpecificBpPlusCondition.py
+++ b/packages/Python/lldbsuite/test/functionalities/thread/thread_specific_break_plus_condition/TestThreadSpecificBpPlusCondition.py
@@ -20,7 +20,6 @@ class ThreadSpecificBreakPlusConditionTestCase(TestBase):
@skipIfFreeBSD # test frequently times out or hangs
@expectedFailureFreeBSD('llvm.org/pr18522') # hits break in another thread in testrun
@add_test_categories(['pyapi'])
- @expectedFailureWindows # Thread specific breakpoints cause the inferior to crash.
@expectedFlakeyLinux # this test fails 6/100 dosep runs
def test_python(self):
"""Test that we obey thread conditioned breakpoints."""
diff --git a/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/TestNoreturnUnwind.py b/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/TestNoreturnUnwind.py
index a419500f7a17..c0a311f7ac9e 100644
--- a/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/TestNoreturnUnwind.py
+++ b/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/TestNoreturnUnwind.py
@@ -14,7 +14,7 @@ import lldbsuite.test.lldbutil as lldbutil
class NoreturnUnwind(TestBase):
mydir = TestBase.compute_mydir(__file__)
- @expectedFailurei386 #xfail to get buildbot green, failing config: i386 binary running on ubuntu 14.04 x86_64
+ @expectedFailurei386("llvm.org/pr25338")
@skipIfWindows # clang-cl does not support gcc style attributes.
def test (self):
"""Test that we can backtrace correctly with 'noreturn' functions on the stack"""
diff --git a/packages/Python/lldbsuite/test/functionalities/watchpoint/step_over_watchpoint/TestStepOverWatchpoint.py b/packages/Python/lldbsuite/test/functionalities/watchpoint/step_over_watchpoint/TestStepOverWatchpoint.py
index dd18a6482066..f51da36b72d7 100644
--- a/packages/Python/lldbsuite/test/functionalities/watchpoint/step_over_watchpoint/TestStepOverWatchpoint.py
+++ b/packages/Python/lldbsuite/test/functionalities/watchpoint/step_over_watchpoint/TestStepOverWatchpoint.py
@@ -17,6 +17,7 @@ class TestStepOverWatchpoint(TestBase):
return ['basic_process']
@expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported
+ @expectedFailureLinux(bugnumber="llvm.org/pr26031", archs=['arm'])
@expectedFailureWindows("llvm.org/pr24446")
def test(self):
"""Test stepping over watchpoints."""
diff --git a/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_set_command/TestWatchLocationWithWatchSet.py b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_set_command/TestWatchLocationWithWatchSet.py
index 6bdac7024847..9301a6f9fd00 100644
--- a/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_set_command/TestWatchLocationWithWatchSet.py
+++ b/packages/Python/lldbsuite/test/functionalities/watchpoint/watchpoint_set_command/TestWatchLocationWithWatchSet.py
@@ -27,6 +27,7 @@ class WatchLocationUsingWatchpointSetTestCase(TestBase):
# Build dictionary to have unique executable names for each test method.
@expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported
+ @expectedFailureLinux(bugnumber="llvm.org/pr26031", archs=['arm'])
@expectedFailureWindows("llvm.org/pr24446") # WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows
def test_watchlocation_using_watchpoint_set(self):
"""Test watching a location with 'watchpoint set expression -w write -s size' option."""
diff --git a/packages/Python/lldbsuite/test/lang/objc/global_ptrs/Makefile b/packages/Python/lldbsuite/test/lang/objc/global_ptrs/Makefile
new file mode 100644
index 000000000000..a1608fe5a664
--- /dev/null
+++ b/packages/Python/lldbsuite/test/lang/objc/global_ptrs/Makefile
@@ -0,0 +1,6 @@
+LEVEL = ../../../make
+
+OBJC_SOURCES := main.m
+LDFLAGS = $(CFLAGS) -lobjc -framework Foundation
+
+include $(LEVEL)/Makefile.rules
diff --git a/packages/Python/lldbsuite/test/lang/objc/global_ptrs/TestGlobalObjects.py b/packages/Python/lldbsuite/test/lang/objc/global_ptrs/TestGlobalObjects.py
new file mode 100644
index 000000000000..c4c581b9240f
--- /dev/null
+++ b/packages/Python/lldbsuite/test/lang/objc/global_ptrs/TestGlobalObjects.py
@@ -0,0 +1,53 @@
+"""Test that a global ObjC object found before the process is started updates correctly."""
+
+from __future__ import print_function
+
+
+
+import os, time
+import lldb
+import lldbsuite.test.lldbutil as lldbutil
+from lldbsuite.test.lldbtest import *
+
+class TestObjCGlobalVar(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def setUp(self):
+ # Call super's setUp().
+ TestBase.setUp(self)
+ self.main_source = lldb.SBFileSpec("main.m")
+
+ @skipUnlessDarwin
+ @add_test_categories(['pyapi'])
+ def test_with_python_api(self):
+ """Test that a global ObjC object found before the process is started updates correctly."""
+ self.build()
+ exe = os.path.join(os.getcwd(), "a.out")
+
+ target = self.dbg.CreateTarget(exe)
+ self.assertTrue(target, VALID_TARGET)
+
+ bkpt = target.BreakpointCreateBySourceRegex ('NSLog', self.main_source)
+ self.assertTrue(bkpt, VALID_BREAKPOINT)
+
+ # Before we launch, make an SBValue for our global object pointer:
+ g_obj_ptr = target.FindFirstGlobalVariable("g_obj_ptr")
+ self.assertTrue(g_obj_ptr.GetError().Success(), "Made the g_obj_ptr")
+ self.assertTrue(g_obj_ptr.GetValueAsUnsigned(10) == 0, "g_obj_ptr is initially null")
+
+ # Now launch the process, and do not stop at entry point.
+ process = target.LaunchSimple (None, None, self.get_process_working_directory())
+
+ self.assertTrue(process, PROCESS_IS_VALID)
+
+ # The stop reason of the thread should be breakpoint.
+ threads = lldbutil.get_threads_stopped_at_breakpoint (process, bkpt)
+ if len(threads) != 1:
+ self.fail ("Failed to stop at breakpoint 1.")
+
+ thread = threads[0]
+
+ dyn_value = g_obj_ptr.GetDynamicValue(lldb.eDynamicCanRunTarget)
+ self.assertTrue(dyn_value.GetError().Success(), "Dynamic value is valid")
+ self.assertTrue(dyn_value.GetObjectDescription() == "Some NSString")
diff --git a/packages/Python/lldbsuite/test/lang/objc/global_ptrs/main.m b/packages/Python/lldbsuite/test/lang/objc/global_ptrs/main.m
new file mode 100644
index 000000000000..977a984e06e0
--- /dev/null
+++ b/packages/Python/lldbsuite/test/lang/objc/global_ptrs/main.m
@@ -0,0 +1,11 @@
+#import <Foundation/Foundation.h>
+
+id g_obj_ptr = nil;
+
+int
+main()
+{
+ g_obj_ptr = @"Some NSString";
+ NSLog(@"My string was %@.", g_obj_ptr);
+ return 0;
+}
diff --git a/packages/Python/lldbsuite/test/lldbinline.py b/packages/Python/lldbsuite/test/lldbinline.py
index 691a3fba6dc2..abde6e790ded 100644
--- a/packages/Python/lldbsuite/test/lldbinline.py
+++ b/packages/Python/lldbsuite/test/lldbinline.py
@@ -3,7 +3,6 @@ from __future__ import absolute_import
# System modules
import os
-import sys
# Third-party modules
@@ -23,6 +22,7 @@ def source_type(filename):
'.mm' : 'OBJCXX_SOURCES'
}.get(extension, None)
+
class CommandParser:
def __init__(self):
self.breakpoints = []
@@ -34,7 +34,7 @@ class CommandParser:
new_breakpoint = True
if len(parts) == 2:
- command = parts[1].strip() # take off whitespace
+ command = parts[1].strip() # take off whitespace
new_breakpoint = parts[0].strip() != ""
return (command, new_breakpoint)
@@ -85,7 +85,7 @@ class InlineTest(TestBase):
return "-N dwarf %s" % (self.mydir)
else:
return "-N dsym %s" % (self.mydir)
-
+
def BuildMakefile(self):
if os.path.exists("Makefile"):
return
@@ -116,11 +116,11 @@ class InlineTest(TestBase):
if ('CXX_SOURCES' in list(categories.keys())):
makefile.write("CXXFLAGS += -std=c++11\n")
+ makefile.write("\ncleanup:\n\trm -f Makefile *.d\n\n")
makefile.write("include $(LEVEL)/Makefile.rules\n")
makefile.flush()
makefile.close()
-
@skipUnlessDarwin
def __test_with_dsym(self):
self.using_dsym = True
diff --git a/packages/Python/lldbsuite/test/lldbtest.py b/packages/Python/lldbsuite/test/lldbtest.py
index 43d02c521d18..3ad6d29a1d7a 100644
--- a/packages/Python/lldbsuite/test/lldbtest.py
+++ b/packages/Python/lldbsuite/test/lldbtest.py
@@ -696,10 +696,11 @@ def expectedFailurei386(bugnumber=None):
def expectedFailurex86_64(bugnumber=None):
return expectedFailureArch('x86_64', bugnumber)
-def expectedFailureOS(oslist, bugnumber=None, compilers=None, debug_info=None):
+def expectedFailureOS(oslist, bugnumber=None, compilers=None, debug_info=None, archs=None):
def fn(self):
return (self.getPlatform() in oslist and
self.expectedCompiler(compilers) and
+ (archs is None or self.getArchitecture() in archs) and
(debug_info is None or self.debug_info in debug_info))
return expectedFailure(fn, bugnumber)
@@ -716,8 +717,8 @@ def expectedFailureDarwin(bugnumber=None, compilers=None, debug_info=None):
def expectedFailureFreeBSD(bugnumber=None, compilers=None, debug_info=None):
return expectedFailureOS(['freebsd'], bugnumber, compilers, debug_info=debug_info)
-def expectedFailureLinux(bugnumber=None, compilers=None, debug_info=None):
- return expectedFailureOS(['linux'], bugnumber, compilers, debug_info=debug_info)
+def expectedFailureLinux(bugnumber=None, compilers=None, debug_info=None, archs=None):
+ return expectedFailureOS(['linux'], bugnumber, compilers, debug_info=debug_info, archs=archs)
def expectedFailureNetBSD(bugnumber=None, compilers=None, debug_info=None):
return expectedFailureOS(['netbsd'], bugnumber, compilers, debug_info=debug_info)
diff --git a/packages/Python/lldbsuite/test/make/test_common.h b/packages/Python/lldbsuite/test/make/test_common.h
index 6f819706366e..a1ed364574e3 100644
--- a/packages/Python/lldbsuite/test/make/test_common.h
+++ b/packages/Python/lldbsuite/test/make/test_common.h
@@ -1,19 +1,44 @@
-// This header is included in all the test programs (C and C++) and provides a
-// hook for dealing with platform-specifics.
-#if defined(_WIN32) || defined(_WIN64)
-#ifdef COMPILING_LLDB_TEST_DLL
-#define LLDB_TEST_API __declspec(dllexport)
-#else
-#define LLDB_TEST_API __declspec(dllimport)
-#endif
-#else
-#define LLDB_TEST_API
-#endif
-
-#if defined(__cplusplus) && defined(_MSC_VER) && (_HAS_EXCEPTIONS == 0)
-// Compiling MSVC libraries with _HAS_EXCEPTIONS=0, eliminates most but not all
-// calls to __uncaught_exception. Unfortunately, it does seem to eliminate
-// the delcaration of __uncaught_excpeiton. Including <eh.h> ensures that it is
-// declared. This may not be necessary after MSVC 12.
-#include <eh.h>
-#endif
+// This header is included in all the test programs (C and C++) and provides a
+// hook for dealing with platform-specifics.
+#if defined(_WIN32) || defined(_WIN64)
+#ifdef COMPILING_LLDB_TEST_DLL
+#define LLDB_TEST_API __declspec(dllexport)
+#else
+#define LLDB_TEST_API __declspec(dllimport)
+#endif
+#else
+#define LLDB_TEST_API
+#endif
+
+#if defined(__cplusplus) && defined(_MSC_VER) && (_HAS_EXCEPTIONS == 0)
+// Compiling MSVC libraries with _HAS_EXCEPTIONS=0, eliminates most but not all
+// calls to __uncaught_exception. Unfortunately, it does seem to eliminate
+// the delcaration of __uncaught_excpeiton. Including <eh.h> ensures that it is
+// declared. This may not be necessary after MSVC 12.
+#include <eh.h>
+#endif
+
+
+// On some systems (e.g., some versions of linux) it is not possible to attach to a process
+// without it giving us special permissions. This defines the lldb_enable_attach macro, which
+// should perform any such actions, if needed by the platform. This is a macro instead of a
+// function to avoid the need for complex linking of the test programs.
+#if defined(__linux__)
+#include <sys/prctl.h>
+
+#if defined(PR_SET_PTRACER) && defined(PR_SET_PTRACER_ANY)
+// For now we execute on best effort basis. If this fails for some reason, so be it.
+#define lldb_enable_attach() \
+ do \
+ { \
+ const int prctl_result = prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY, 0, 0, 0); \
+ (void)prctl_result; \
+ } while (0)
+
+#endif
+
+#else // not linux
+
+#define lldb_enable_attach()
+
+#endif
diff --git a/packages/Python/lldbsuite/test/python_api/disassemble-raw-data/TestDisassembleRawData.py b/packages/Python/lldbsuite/test/python_api/disassemble-raw-data/TestDisassembleRawData.py
index 20333abc57af..31ba44928794 100644
--- a/packages/Python/lldbsuite/test/python_api/disassemble-raw-data/TestDisassembleRawData.py
+++ b/packages/Python/lldbsuite/test/python_api/disassemble-raw-data/TestDisassembleRawData.py
@@ -21,11 +21,18 @@ class DisassembleRawDataTestCase(TestBase):
def test_disassemble_raw_data(self):
"""Test disassembling raw bytes with the API."""
# Create a target from the debugger.
- target = self.dbg.CreateTargetWithFileAndTargetTriple ("", "x86_64")
+ arch = self.getArchitecture()
+ if re.match("mips*el",arch):
+ target = self.dbg.CreateTargetWithFileAndTargetTriple ("", "mipsel")
+ raw_bytes = bytearray([0x21,0xf0, 0xa0, 0x03])
+ elif re.match("mips",arch):
+ target = self.dbg.CreateTargetWithFileAndTargetTriple ("", "mips")
+ raw_bytes = bytearray([0x03,0xa0, 0xf0, 0x21])
+ else:
+ target = self.dbg.CreateTargetWithFileAndTargetTriple ("", "x86_64")
+ raw_bytes = bytearray([0x48, 0x89, 0xe5])
+
self.assertTrue(target, VALID_TARGET)
-
- raw_bytes = bytearray([0x48, 0x89, 0xe5])
-
insts = target.GetInstructions(lldb.SBAddress(0, target), raw_bytes)
inst = insts.GetInstructionAtIndex(0)
@@ -34,6 +41,9 @@ class DisassembleRawDataTestCase(TestBase):
print()
print("Raw bytes: ", [hex(x) for x in raw_bytes])
print("Disassembled%s" % str(inst))
-
- self.assertTrue (inst.GetMnemonic(target) == "movq")
- self.assertTrue (inst.GetOperands(target) == '%' + "rsp, " + '%' + "rbp")
+ if re.match("mips",arch):
+ self.assertTrue (inst.GetMnemonic(target) == "move")
+ self.assertTrue (inst.GetOperands(target) == '$' + "fp, " + '$' + "sp")
+ else:
+ self.assertTrue (inst.GetMnemonic(target) == "movq")
+ self.assertTrue (inst.GetOperands(target) == '%' + "rsp, " + '%' + "rbp")
diff --git a/packages/Python/lldbsuite/test/python_api/event/TestEvents.py b/packages/Python/lldbsuite/test/python_api/event/TestEvents.py
index 0a1a0dfda7d2..51c924b2aff1 100644
--- a/packages/Python/lldbsuite/test/python_api/event/TestEvents.py
+++ b/packages/Python/lldbsuite/test/python_api/event/TestEvents.py
@@ -13,6 +13,7 @@ import lldbsuite.test.lldbutil as lldbutil
from lldbsuite.test.lldbtest import *
@skipIfDarwin # llvm.org/pr25924, sometimes generating SIGSEGV
+@skipIfLinux # llvm.org/pr25924, sometimes generating SIGSEGV
class EventAPITestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
@@ -25,7 +26,6 @@ class EventAPITestCase(TestBase):
@add_test_categories(['pyapi'])
@expectedFailureLinux("llvm.org/pr23730") # Flaky, fails ~1/10 cases
- @skipIfLinux # skip to avoid crashes
def test_listen_for_and_print_event(self):
"""Exercise SBEvent API."""
self.build()
@@ -176,7 +176,7 @@ class EventAPITestCase(TestBase):
@skipIfFreeBSD # llvm.org/pr21325
@add_test_categories(['pyapi'])
- @expectedFlakeyLinux("llvm.org/pr23617") # Flaky, fails ~1/10 cases
+ @expectedFailureLinux("llvm.org/pr23617") # Flaky, fails ~1/10 cases
@expectedFailureWindows("llvm.org/pr24778")
def test_add_listener_to_broadcaster(self):
"""Exercise some SBBroadcaster APIs."""
diff --git a/packages/Python/lldbsuite/test/python_api/hello_world/main.c b/packages/Python/lldbsuite/test/python_api/hello_world/main.c
index 31a041ede741..1b942d0db159 100644
--- a/packages/Python/lldbsuite/test/python_api/hello_world/main.c
+++ b/packages/Python/lldbsuite/test/python_api/hello_world/main.c
@@ -1,25 +1,8 @@
#include <stdio.h>
-#if defined(__linux__)
-#include <sys/prctl.h>
-#endif
-
-int main(int argc, char const *argv[]) {
-
-#if defined(__linux__)
- // Immediately enable any ptracer so that we can allow the stub attach
- // operation to succeed. Some Linux kernels are locked down so that
- // only an ancestor process can be a ptracer of a process. This disables that
- // restriction. Without it, attach-related stub tests will fail.
-#if defined(PR_SET_PTRACER) && defined(PR_SET_PTRACER_ANY)
- int prctl_result;
-
- // For now we execute on best effort basis. If this fails for
- // some reason, so be it.
- prctl_result = prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY, 0, 0, 0);
- (void) prctl_result;
-#endif
-#endif
+int main(int argc, char const *argv[])
+{
+ lldb_enable_attach();
printf("Hello world.\n"); // Set break point at this line.
if (argc == 1)
diff --git a/packages/Python/lldbsuite/test/python_api/module_section/TestModuleAndSection.py b/packages/Python/lldbsuite/test/python_api/module_section/TestModuleAndSection.py
index bc97d432406f..2de026c54eef 100644
--- a/packages/Python/lldbsuite/test/python_api/module_section/TestModuleAndSection.py
+++ b/packages/Python/lldbsuite/test/python_api/module_section/TestModuleAndSection.py
@@ -16,6 +16,8 @@ class ModuleAndSectionAPIsTestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
+ # Py3 asserts due to a bug in SWIG. A fix for this was upstreamed into SWIG 3.0.8.
+ @skipIf(py_version=['>=', (3,0)], swig_version=['<', (3,0,8)])
@add_test_categories(['pyapi'])
def test_module_and_section(self):
"""Test module and section APIs."""
diff --git a/packages/Python/lldbsuite/test/python_api/value/change_values/TestChangeValueAPI.py b/packages/Python/lldbsuite/test/python_api/value/change_values/TestChangeValueAPI.py
index 77aefe05be46..f8ad97277f05 100644
--- a/packages/Python/lldbsuite/test/python_api/value/change_values/TestChangeValueAPI.py
+++ b/packages/Python/lldbsuite/test/python_api/value/change_values/TestChangeValueAPI.py
@@ -28,6 +28,7 @@ class ChangeValueAPITestCase(TestBase):
@expectedFailureWindows("llvm.org/pr24772")
@add_test_categories(['pyapi'])
+ @expectedFlakeyLinux("llvm.org/pr25652")
def test_change_value(self):
"""Exercise the SBValue::SetValueFromCString API."""
d = {'EXE': self.exe_name}
diff --git a/packages/Python/lldbsuite/test/python_api/value/linked_list/TestValueAPILinkedList.py b/packages/Python/lldbsuite/test/python_api/value/linked_list/TestValueAPILinkedList.py
index 22d7e7ebf7e8..8b60be97bdc2 100644
--- a/packages/Python/lldbsuite/test/python_api/value/linked_list/TestValueAPILinkedList.py
+++ b/packages/Python/lldbsuite/test/python_api/value/linked_list/TestValueAPILinkedList.py
@@ -25,6 +25,8 @@ class ValueAsLinkedListTestCase(TestBase):
# Find the line number to break at.
self.line = line_number('main.cpp', '// Break at this line')
+ # Py3 asserts due to a bug in SWIG. A fix for this was upstreamed into SWIG 3.0.8.
+ @skipIf(py_version=['>=', (3,0)], swig_version=['<', (3,0,8)])
@add_test_categories(['pyapi'])
def test(self):
"""Exercise SBValue API linked_list_iter."""
diff --git a/packages/Python/lldbsuite/test/test_categories.py b/packages/Python/lldbsuite/test/test_categories.py
index e3e446091050..72b7afdf7241 100644
--- a/packages/Python/lldbsuite/test/test_categories.py
+++ b/packages/Python/lldbsuite/test/test_categories.py
@@ -44,7 +44,8 @@ def unique_string_match(yourentry, list):
def is_supported_on_platform(category, platform):
if category == "dwo":
- return platform in ["linux", "freebsd", "windows"]
+ # -gsplit-dwarf is not implemented by clang on Windows.
+ return platform in ["linux", "freebsd"]
elif category == "dsym":
return platform in ["darwin", "macosx", "ios"]
return True
diff --git a/packages/Python/lldbsuite/test/tools/lldb-server/main.cpp b/packages/Python/lldbsuite/test/tools/lldb-server/main.cpp
index c65b22571596..b97c6ebc18e3 100644
--- a/packages/Python/lldbsuite/test/tools/lldb-server/main.cpp
+++ b/packages/Python/lldbsuite/test/tools/lldb-server/main.cpp
@@ -20,10 +20,6 @@ int pthread_threadid_np(pthread_t,__uint64_t*);
#include <sys/syscall.h>
#endif
-#if defined(__linux__)
-#include <sys/prctl.h>
-#endif
-
static const char *const RETVAL_PREFIX = "retval:";
static const char *const SLEEP_PREFIX = "sleep:";
static const char *const STDERR_PREFIX = "stderr:";
@@ -210,16 +206,7 @@ thread_func (void *arg)
int main (int argc, char **argv)
{
-#if defined(__linux__)
- // Immediately enable any ptracer so that we can allow the stub attach
- // operation to succeed. Some Linux kernels are locked down so that
- // only an ancestor can be a ptracer of a process. This disables that
- // restriction. Without it, attach-related stub tests will fail.
-#if defined(PR_SET_PTRACER) && defined(PR_SET_PTRACER_ANY)
- const int prctl_result = prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY, 0, 0, 0);
- static_cast<void> (prctl_result);
-#endif
-#endif
+ lldb_enable_attach();
std::vector<pthread_t> threads;
std::unique_ptr<uint8_t[]> heap_array_up;