summaryrefslogtreecommitdiffstats
path: root/lldb/test/Shell
diff options
context:
space:
mode:
authorJim Ingham <jingham@apple.com>2019-12-20 11:00:11 -0800
committerJim Ingham <jingham@apple.com>2019-12-20 11:02:24 -0800
commit2a42a5a2f4144cd99812ad0d230480f94a1d1c92 (patch)
treed4b33c08279563782d568724e1b8f77152c61cd5 /lldb/test/Shell
parent42f9d0c0bee32a1a48a45c039988d27115f30da9 (diff)
downloadbcm5719-llvm-2a42a5a2f4144cd99812ad0d230480f94a1d1c92.tar.gz
bcm5719-llvm-2a42a5a2f4144cd99812ad0d230480f94a1d1c92.zip
In 'thread step-out' command, only insert a breakpoint in executable memory.
Previously, if the current function had a nonstandard stack layout/ABI, and had a valid data pointer in the location where the return address is usually located, data corruption would occur when the breakpoint was written. This could lead to an incorrectly reported crash or silent corruption of the program's state. Now, if the above check fails, the command safely aborts. Differential Revision: https://reviews.llvm.org/D71372
Diffstat (limited to 'lldb/test/Shell')
-rw-r--r--lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s20
-rw-r--r--lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test17
2 files changed, 37 insertions, 0 deletions
diff --git a/lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s b/lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s
new file mode 100644
index 00000000000..d18ea24fba4
--- /dev/null
+++ b/lldb/test/Shell/Unwind/Inputs/thread-step-out-ret-addr-check.s
@@ -0,0 +1,20 @@
+ .text
+ .globl asm_main
+asm_main:
+ sub $0x8, %rsp
+ movq $0, (%rsp)
+ push %rsp
+ jmp _nonstandard_stub
+
+# Takes a single pointer argument via the stack, which is nonstandard for x64.
+# Executing 'thread step-out' here will initially attempt to write a
+# breakpoint to that stack address, but should fail because of the executable
+# memory check.
+_nonstandard_stub:
+ mov (%rsp), %rdi
+ mov (%rdi), %rsi
+ add $1, %rsi
+ mov %rsi, (%rdi)
+
+ add $0x10, %rsp
+ ret
diff --git a/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test b/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
new file mode 100644
index 00000000000..96490faa2de
--- /dev/null
+++ b/lldb/test/Shell/Unwind/thread-step-out-ret-addr-check.test
@@ -0,0 +1,17 @@
+# Test that `thread step-out` fails when the "return address"
+# points to non-executable memory.
+
+# REQUIRES: target-x86_64, native
+
+# RUN: %clang_host %p/Inputs/call-asm.c %p/Inputs/thread-step-out-ret-addr-check.s -o %t
+# RUN: %lldb %t -s %s -b 2>&1 | FileCheck %s
+
+breakpoint set -n nonstandard_stub
+# CHECK: Breakpoint 1: where = {{.*}}`nonstandard_stub
+
+process launch
+# CHECK: stop reason = breakpoint 1.1
+
+thread step-out
+# CHECK: Could not create return address breakpoint.
+# CHECK: Return address (0x{{[a-f0-9]*}}) did not point to executable memory.
OpenPOWER on IntegriCloud