summaryrefslogtreecommitdiffstats
path: root/lldb/test/Shell/Register/Inputs/x86-64-gp-write.cpp
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2019-10-09 19:22:02 +0000
committerJonas Devlieghere <jonas@devlieghere.com>2019-10-09 19:22:02 +0000
commit87aa9c9e4d41ed881453e2fab85b3d25f648bb55 (patch)
tree63efe79832bf3de4f63e4e81c62e73923947b882 /lldb/test/Shell/Register/Inputs/x86-64-gp-write.cpp
parentfd18e94697c987d5f24e25aa4e27adaffff3cce4 (diff)
downloadbcm5719-llvm-87aa9c9e4d41ed881453e2fab85b3d25f648bb55.tar.gz
bcm5719-llvm-87aa9c9e4d41ed881453e2fab85b3d25f648bb55.zip
Re-land "[test] Split LLDB tests into API, Shell & Unit"
The original patch got reverted because it broke `check-lldb` on a clean build. This fixes that. llvm-svn: 374201
Diffstat (limited to 'lldb/test/Shell/Register/Inputs/x86-64-gp-write.cpp')
-rw-r--r--lldb/test/Shell/Register/Inputs/x86-64-gp-write.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/lldb/test/Shell/Register/Inputs/x86-64-gp-write.cpp b/lldb/test/Shell/Register/Inputs/x86-64-gp-write.cpp
new file mode 100644
index 00000000000..fd579c031a3
--- /dev/null
+++ b/lldb/test/Shell/Register/Inputs/x86-64-gp-write.cpp
@@ -0,0 +1,45 @@
+#include <cinttypes>
+#include <cstdint>
+#include <cstdio>
+
+int main() {
+ constexpr uint64_t fill = 0x0F0F0F0F0F0F0F0F;
+
+ uint64_t rax, rbx, rcx, rdx, rsp, rbp, rsi, rdi;
+
+ asm volatile(
+ // save rsp & rbp
+ "movq %%rsp, %4\n\t"
+ "movq %%rbp, %5\n\t"
+ "\n\t"
+ "movq %8, %%rax\n\t"
+ "movq %8, %%rbx\n\t"
+ "movq %8, %%rcx\n\t"
+ "movq %8, %%rdx\n\t"
+ "movq %8, %%rsp\n\t"
+ "movq %8, %%rbp\n\t"
+ "movq %8, %%rsi\n\t"
+ "movq %8, %%rdi\n\t"
+ "\n\t"
+ "int3\n\t"
+ "\n\t"
+ // swap saved & current rsp & rbp
+ "xchgq %%rsp, %4\n\t"
+ "xchgq %%rbp, %5\n\t"
+ : "=a"(rax), "=b"(rbx), "=c"(rcx), "=d"(rdx), "=r"(rsp), "=r"(rbp),
+ "=S"(rsi), "=D"(rdi)
+ : "g"(fill)
+ :
+ );
+
+ printf("rax = 0x%016" PRIx64 "\n", rax);
+ printf("rbx = 0x%016" PRIx64 "\n", rbx);
+ printf("rcx = 0x%016" PRIx64 "\n", rcx);
+ printf("rdx = 0x%016" PRIx64 "\n", rdx);
+ printf("rsp = 0x%016" PRIx64 "\n", rsp);
+ printf("rbp = 0x%016" PRIx64 "\n", rbp);
+ printf("rsi = 0x%016" PRIx64 "\n", rsi);
+ printf("rdi = 0x%016" PRIx64 "\n", rdi);
+
+ return 0;
+}
OpenPOWER on IntegriCloud