diff options
author | dim <dim@FreeBSD.org> | 2016-01-13 20:06:56 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2016-01-13 20:06:56 +0000 |
commit | 8553c19974a5ab5f815b9e64f7bfe9899924726b (patch) | |
tree | 2b6dc7dcb4a6380cb331aded15f5a81c0038e194 /packages/Python/lldbsuite/test/functionalities | |
parent | 78b9749c0a4ea980a8b934645da6ae98fcc665e8 (diff) | |
download | FreeBSD-src-8553c19974a5ab5f815b9e64f7bfe9899924726b.zip FreeBSD-src-8553c19974a5ab5f815b9e64f7bfe9899924726b.tar.gz |
Vendor import of lldb trunk r257626:
https://llvm.org/svn/llvm-project/lldb/trunk@257626
Diffstat (limited to 'packages/Python/lldbsuite/test/functionalities')
19 files changed, 132 insertions, 126 deletions
diff --git a/packages/Python/lldbsuite/test/functionalities/attach_resume/main.cpp b/packages/Python/lldbsuite/test/functionalities/attach_resume/main.cpp index 7cf3602..82aad70 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 0000000..b09a579 --- /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 0000000..b32c970 --- /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 0000000..5f93632 --- /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 b7562c4..f30733d 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 69e977e..950b021 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 3bdf6ec..023f6f3 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 5388850..1dda59a 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 eb6476b..295d4a1 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 8021fea..46ffacc 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 c730c62..7e986bb 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 876dd08..1565157 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 8434458..d8f06e5 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 be49a21..768e2fe 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 623c659..4938ec5 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 b4a0b7a..68c96a0 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 a419500..c0a311f 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 dd18a64..f51da36 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 6bdac70..9301a6f 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.""" |