[lldb] [lit] Introduce tests for reading x86 general purpose registers

Introduce tests for reading the eight x86 general purpose registers,
i.e. RAX/RBX/RCX/RDX/RBP/RSP/RSI/RDI and their shorter counterparts.
The test comes in separate 32-bit and 64-bit variant, targeting
appropriate processors.

While technically the 32-bit test could run on amd64, it would be
redundant to the 64-bit version, so just run one of them on each arch.

Differential Revision: https://reviews.llvm.org/D61210

llvm-svn: 359438
This commit is contained in:
Michal Gorny 2019-04-29 11:37:58 +00:00
parent c570b2a2e5
commit d25710f5a0
4 changed files with 156 additions and 0 deletions

View File

@ -0,0 +1,40 @@
#include <cstdint>
int main() {
constexpr uint64_t rax = 0x0102030405060708;
constexpr uint64_t rbx = 0x1112131415161718;
constexpr uint64_t rcx = 0x2122232425262728;
constexpr uint64_t rdx = 0x3132333435363738;
constexpr uint64_t rsp = 0x4142434445464748;
constexpr uint64_t rbp = 0x5152535455565758;
constexpr uint64_t rsi = 0x6162636465666768;
constexpr uint64_t rdi = 0x7172737475767778;
asm volatile(
// save rsp & rbp
"movq %%rsp, %%r8\n\t"
"movq %%rbp, %%r9\n\t"
"\n\t"
"movq %0, %%rax\n\t"
"movq %1, %%rbx\n\t"
"movq %2, %%rcx\n\t"
"movq %3, %%rdx\n\t"
"movq %4, %%rsp\n\t"
"movq %5, %%rbp\n\t"
"movq %6, %%rsi\n\t"
"movq %7, %%rdi\n\t"
"\n\t"
"int3\n\t"
"\n\t"
// restore rsp & rbp
"movq %%r8, %%rsp\n\t"
"movq %%r9, %%rbp"
:
: "i"(rax), "i"(rbx), "i"(rcx), "i"(rdx), "i"(rsp), "i"(rbp), "i"(rsi),
"i"(rdi)
: "%rax", "%rbx", "%rcx", "%rdx", "%rsp", "%rbp", "%rsi", "%rdi", "%r8",
"%r9"
);
return 0;
}

View File

@ -0,0 +1,40 @@
#include <cstdint>
int main() {
constexpr uint32_t eax = 0x05060708;
constexpr uint32_t ebx = 0x15161718;
constexpr uint32_t ecx = 0x25262728;
constexpr uint32_t edx = 0x35363738;
constexpr uint32_t esp = 0x45464748;
constexpr uint32_t ebp = 0x55565758;
constexpr uint32_t esi = 0x65666768;
constexpr uint32_t edi = 0x75767778;
asm volatile(
// save esp & ebp
"movd %%esp, %%mm0\n\t"
"movd %%ebp, %%mm1\n\t"
"\n\t"
"movl %0, %%eax\n\t"
"movl %1, %%ebx\n\t"
"movl %2, %%ecx\n\t"
"movl %3, %%edx\n\t"
"movl %4, %%esp\n\t"
"movl %5, %%ebp\n\t"
"movl %6, %%esi\n\t"
"movl %7, %%edi\n\t"
"\n\t"
"int3\n\t"
"\n\t"
// restore esp & ebp
"movd %%mm0, %%esp\n\t"
"movd %%mm1, %%ebp\n\t"
:
: "i"(eax), "i"(ebx), "i"(ecx), "i"(edx), "i"(esp), "i"(ebp), "i"(esi),
"i"(edi)
: "%eax", "%ebx", "%ecx", "%edx", "%esp", "%ebp", "%esi", "%edi", "%mm0",
"%mm1"
);
return 0;
}

View File

@ -0,0 +1,42 @@
# XFAIL: system-windows
# REQUIRES: native && target-x86_64
# RUN: %clangxx -fomit-frame-pointer %p/Inputs/x86-64-gp-read.cpp -o %t
# RUN: %lldb -b -s %s %t | FileCheck %s
process launch
register read --all
# CHECK-DAG: rax = 0x0102030405060708
# CHECK-DAG: rbx = 0x1112131415161718
# CHECK-DAG: rcx = 0x2122232425262728
# CHECK-DAG: rdx = 0x3132333435363738
# CHECK-DAG: rdi = 0x7172737475767778
# CHECK-DAG: rsi = 0x6162636465666768
# CHECK-DAG: rbp = 0x5152535455565758
# CHECK-DAG: rsp = 0x4142434445464748
# CHECK-DAG: eax = 0x05060708
# CHECK-DAG: ebx = 0x15161718
# CHECK-DAG: ecx = 0x25262728
# CHECK-DAG: edx = 0x35363738
# CHECK-DAG: edi = 0x75767778
# CHECK-DAG: esi = 0x65666768
# CHECK-DAG: ebp = 0x55565758
# CHECK-DAG: esp = 0x45464748
# CHECK-DAG: ax = 0x0708
# CHECK-DAG: bx = 0x1718
# CHECK-DAG: cx = 0x2728
# CHECK-DAG: dx = 0x3738
# CHECK-DAG: di = 0x7778
# CHECK-DAG: si = 0x6768
# CHECK-DAG: bp = 0x5758
# CHECK-DAG: sp = 0x4748
# CHECK-DAG: ah = 0x07
# CHECK-DAG: bh = 0x17
# CHECK-DAG: ch = 0x27
# CHECK-DAG: dh = 0x37
# CHECK-DAG: al = 0x08
# CHECK-DAG: bl = 0x18
# CHECK-DAG: cl = 0x28
# CHECK-DAG: dl = 0x38
process continue
# CHECK: Process {{[0-9]+}} exited with status = 0

View File

@ -0,0 +1,34 @@
# XFAIL: system-windows
# REQUIRES: native && target-x86
# RUN: %clangxx -fomit-frame-pointer %p/Inputs/x86-gp-read.cpp -o %t
# RUN: %lldb -b -s %s %t | FileCheck %s
process launch
register read --all
# CHECK-DAG: eax = 0x05060708
# CHECK-DAG: ebx = 0x15161718
# CHECK-DAG: ecx = 0x25262728
# CHECK-DAG: edx = 0x35363738
# CHECK-DAG: edi = 0x75767778
# CHECK-DAG: esi = 0x65666768
# CHECK-DAG: ebp = 0x55565758
# CHECK-DAG: esp = 0x45464748
# CHECK-DAG: ax = 0x0708
# CHECK-DAG: bx = 0x1718
# CHECK-DAG: cx = 0x2728
# CHECK-DAG: dx = 0x3738
# CHECK-DAG: di = 0x7778
# CHECK-DAG: si = 0x6768
# CHECK-DAG: bp = 0x5758
# CHECK-DAG: sp = 0x4748
# CHECK-DAG: ah = 0x07
# CHECK-DAG: bh = 0x17
# CHECK-DAG: ch = 0x27
# CHECK-DAG: dh = 0x37
# CHECK-DAG: al = 0x08
# CHECK-DAG: bl = 0x18
# CHECK-DAG: cl = 0x28
# CHECK-DAG: dl = 0x38
process continue
# CHECK: Process {{[0-9]+}} exited with status = 0