diff options
author | 2020-08-03 14:33:06 +0000 | |
---|---|---|
committer | 2020-08-03 14:33:06 +0000 | |
commit | 061da546b983eb767bad15e67af1174fb0bcf31c (patch) | |
tree | 83c78b820819d70aa40c36d90447978b300078c5 /gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/unwind/ehframe | |
parent | Import LLVM 10.0.0 release including clang, lld and lldb. (diff) | |
download | wireguard-openbsd-061da546b983eb767bad15e67af1174fb0bcf31c.tar.xz wireguard-openbsd-061da546b983eb767bad15e67af1174fb0bcf31c.zip |
Import LLVM 10.0.0 release including clang, lld and lldb.
ok hackroom
tested by plenty
Diffstat (limited to 'gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/unwind/ehframe')
3 files changed, 112 insertions, 0 deletions
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/Makefile new file mode 100644 index 00000000000..493ea3f7f68 --- /dev/null +++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/Makefile @@ -0,0 +1,5 @@ +C_SOURCES := main.c + +CFLAGS ?= -g -fomit-frame-pointer + +include Makefile.rules diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/TestEhFrameUnwind.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/TestEhFrameUnwind.py new file mode 100644 index 00000000000..905543ff769 --- /dev/null +++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/TestEhFrameUnwind.py @@ -0,0 +1,49 @@ +""" +Test that we can backtrace correctly from Non ABI functions on the stack +""" + + + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class EHFrameBasedUnwind(TestBase): + mydir = TestBase.compute_mydir(__file__) + + @skipUnlessPlatform(['linux']) + @skipIf(archs=["aarch64", "arm", "i386", "i686"]) + def test(self): + """Test that we can backtrace correctly from Non ABI functions on the stack""" + self.build() + self.setTearDownCleanup() + + exe = self.getBuildArtifact("a.out") + target = self.dbg.CreateTarget(exe) + + self.assertTrue(target, VALID_TARGET) + + lldbutil.run_break_set_by_symbol(self, "func") + + process = target.LaunchSimple( + ["abc", "xyz"], None, self.get_process_working_directory()) + + if not process: + self.fail("SBTarget.Launch() failed") + + if process.GetState() != lldb.eStateStopped: + self.fail("Process should be in the 'stopped' state, " + "instead the actual state is: '%s'" % + lldbutil.state_type_to_str(process.GetState())) + + stacktraces = lldbutil.print_stacktraces(process, string_buffer=True) + self.expect(stacktraces, exe=False, + substrs=['(int)argc=3']) + + self.runCmd("thread step-inst") + + stacktraces = lldbutil.print_stacktraces(process, string_buffer=True) + self.expect(stacktraces, exe=False, + substrs=['(int)argc=3']) diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/main.c b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/main.c new file mode 100644 index 00000000000..46de1efe626 --- /dev/null +++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/functionalities/unwind/ehframe/main.c @@ -0,0 +1,58 @@ +void func() { + +#ifdef __powerpc64__ + __asm__ ( + "mflr 0;" + "std 0,16(1);" + "addi 1,1,-24;" + "mr 31,1;" + ".cfi_def_cfa_offset 24;" + "addi 0,0,0;" + "addi 1,1,24;" + "ld 0,16(1);" + ".cfi_def_cfa_offset 0;" + ); +#elif !defined __mips__ + __asm__ ( + "pushq $0x10;" + ".cfi_def_cfa_offset 16;" + "jmp label;" + "movq $0x48, %rax;" +"label: subq $0x38, %rax;" + "movq $0x48, %rcx;" + "movq $0x48, %rdx;" + "movq $0x48, %rax;" + "popq %rax;" + ); +#elif __mips64 + __asm__ ( + "daddiu $sp,$sp,-16;" + ".cfi_def_cfa_offset 16;" + "sd $ra,8($sp);" + ".cfi_offset 31, -8;" + "daddiu $ra,$zero,0;" + "ld $ra,8($sp);" + "daddiu $sp, $sp,16;" + ".cfi_restore 31;" + ".cfi_def_cfa_offset 0;" + ); +#else + // For MIPS32 + __asm__ ( + "addiu $sp,$sp,-8;" + ".cfi_def_cfa_offset 8;" + "sw $ra,4($sp);" + ".cfi_offset 31, -4;" + "addiu $ra,$zero,0;" + "lw $ra,4($sp);" + "addiu $sp,$sp,8;" + ".cfi_restore 31;" + ".cfi_def_cfa_offset 0;" + ); +#endif +} + +int main(int argc, char const *argv[]) +{ + func(); +} |