mgorny created this revision.
mgorny added reviewers: labath, krytarowski.

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.


https://reviews.llvm.org/D61210

Files:
  lldb/lit/Register/Inputs/x86-64-gp-read.cpp
  lldb/lit/Register/Inputs/x86-gp-read.cpp
  lldb/lit/Register/x86-64-gp-read.test
  lldb/lit/Register/x86-gp-read.test

Index: lldb/lit/Register/x86-gp-read.test
===================================================================
--- /dev/null
+++ lldb/lit/Register/x86-gp-read.test
@@ -0,0 +1,31 @@
+# XFAIL: system-windows
+# REQUIRES: native && target-x86
+# RUN: %clangxx %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
Index: lldb/lit/Register/x86-64-gp-read.test
===================================================================
--- /dev/null
+++ lldb/lit/Register/x86-64-gp-read.test
@@ -0,0 +1,39 @@
+# XFAIL: system-windows
+# REQUIRES: native && target-x86_64
+# RUN: %clangxx %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
Index: lldb/lit/Register/Inputs/x86-gp-read.cpp
===================================================================
--- /dev/null
+++ lldb/lit/Register/Inputs/x86-gp-read.cpp
@@ -0,0 +1,31 @@
+#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(
+    "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"
+    :
+    : "i"(eax), "i"(ebx), "i"(ecx), "i"(edx), "i"(esp), "i"(ebp), "i"(esi),
+      "i"(edi)
+    : "%eax", "%ebx", "%ecx", "%edx", "%esp", "%ebp", "%esi", "%edi"
+  );
+
+  return 0;
+}
Index: lldb/lit/Register/Inputs/x86-64-gp-read.cpp
===================================================================
--- /dev/null
+++ lldb/lit/Register/Inputs/x86-64-gp-read.cpp
@@ -0,0 +1,31 @@
+#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(
+    "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"
+    :
+    : "i"(rax), "i"(rbx), "i"(rcx), "i"(rdx), "i"(rsp), "i"(rbp), "i"(rsi),
+      "i"(rdi)
+    : "%rax", "%rbx", "%rcx", "%rdx", "%rsp", "%rbp", "%rsi", "%rdi"
+  );
+
+  return 0;
+}
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to