diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2017-06-10 13:44:58 +0000 | 
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2017-06-10 13:44:58 +0000 | 
| commit | f1d04915a666728c241bedb36bd99aafee3ea444 (patch) | |
| tree | d63378f567f214209764be264c47c8b0814e1665 /packages/Python/lldbsuite | |
| parent | 60bb8ce74a67345b14fd540dd739254f562c605b (diff) | |
Notes
Diffstat (limited to 'packages/Python/lldbsuite')
6 files changed, 90 insertions, 4 deletions
| diff --git a/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/TestNoreturnUnwind.py b/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/TestNoreturnUnwind.py index eafe62a0e08f..d54e62887ce1 100644 --- a/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/TestNoreturnUnwind.py +++ b/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/TestNoreturnUnwind.py @@ -17,8 +17,8 @@ class NoreturnUnwind(TestBase):      mydir = TestBase.compute_mydir(__file__)      @skipIfWindows  # clang-cl does not support gcc style attributes. -    @expectedFailureAndroid(bugnumber="llvm.org/pr31192") -    @expectedFailureAll(bugnumber="llvm.org/pr31192", oslist=['linux'], compiler="gcc", archs=['arm']) +    # clang does not preserve LR in noreturn functions, making unwinding impossible +    @skipIf(compiler="clang", archs=['arm'], oslist=['linux'])      def test(self):          """Test that we can backtrace correctly with 'noreturn' functions on the stack"""          self.build() diff --git a/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/main.c b/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/main.c index 7190e38f5d8c..4f6525fbf52f 100644 --- a/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/main.c +++ b/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/main.c @@ -29,8 +29,6 @@ func_a (void)  int  main (int argc, char *argv[])  { -    sleep (2); -  	func_a ();  	return 0; diff --git a/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/module-end/TestNoReturnModuleEnd.py b/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/module-end/TestNoReturnModuleEnd.py new file mode 100644 index 000000000000..3aa6a230e8b6 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/module-end/TestNoReturnModuleEnd.py @@ -0,0 +1,53 @@ +""" +Test that we properly display the backtrace when a noreturn function happens to +be at the end of the stack. +""" + +from __future__ import print_function + +import shutil +import struct + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class TestNoreturnModuleEnd(TestBase): +    NO_DEBUG_INFO_TESTCASE = True +    mydir = TestBase.compute_mydir(__file__) + +    def setUp(self): +        super(TestNoreturnModuleEnd, self).setUp() +        self._initial_platform = lldb.DBG.GetSelectedPlatform() + +    def tearDown(self): +        lldb.DBG.SetSelectedPlatform(self._initial_platform) +        super(TestNoreturnModuleEnd, self).tearDown() + +    def test(self): +        target = self.dbg.CreateTarget("test.out") +        process = target.LoadCore("test.core") +        self.assertTrue(process.IsValid(), PROCESS_IS_VALID) +        self.assertEqual(process.GetNumThreads(), 1) + +        thread = process.GetSelectedThread() +        self.assertTrue(thread.IsValid()) + +        backtrace = [ +            ["func2", 3], +            ["func1", 8], +            ["_start", 8], +        ] +        self.assertEqual(thread.GetNumFrames(), len(backtrace)) +        for i in range(len(backtrace)): +            frame = thread.GetFrameAtIndex(i) +            self.assertTrue(frame.IsValid()) +            symbol = frame.GetSymbol() +            self.assertTrue(symbol.IsValid()) +            self.assertEqual(symbol.GetName(), backtrace[i][0]) +            function_start = symbol.GetStartAddress().GetLoadAddress(target) +            self.assertEquals(function_start + backtrace[i][1], frame.GetPC()) + +        self.dbg.DeleteTarget(target) diff --git a/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/module-end/a.s b/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/module-end/a.s new file mode 100644 index 000000000000..119465c132a9 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/module-end/a.s @@ -0,0 +1,35 @@ +# compile this with: +# as a.s -o a.o --32 && ld a.o -m elf_i386 +# generate core file with: +# ulimit -s 12 && ./a.out + +.text + +.globl func2 +.type func2, @function +func2: +  pushl %ebp +  movl  %esp, %ebp +  movl  0,    %eax +  popl  %ebp +  ret +.size func2, .-func2 + +.globl _start +.type _start, @function +_start: +  pushl %ebp +  movl  %esp, %ebp +  call  func1 +  popl  %ebp +  ret +.size _start, .-_start + +.globl func1 +.type func1, @function +func1: +  pushl %ebp +  movl  %esp, %ebp +  call  func2 +.size func1, .-func1 + diff --git a/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/module-end/test.core b/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/module-end/test.coreBinary files differ new file mode 100644 index 000000000000..6717d4ff6471 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/module-end/test.core diff --git a/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/module-end/test.out b/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/module-end/test.outBinary files differ new file mode 100755 index 000000000000..141c61ecbea3 --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/unwind/noreturn/module-end/test.out | 
