[Lldb-commits] [PATCH] D91264: [lldb] [test] Add a minimal test for x86 dbreg reading

Michał Górny via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Nov 11 07:38:06 PST 2020


mgorny created this revision.
mgorny added reviewers: labath, krytarowski, emaste.
Herald added a subscriber: pengfei.
mgorny requested review of this revision.

Add a test verifying that after the 'watchpoint' command, new values
of x86 debug registers can be read back correctly.  The primary purpose
of this test is to catch broken DRn reading and help debugging it.


https://reviews.llvm.org/D91264

Files:
  lldb/test/Shell/Register/Inputs/x86-db-read.cpp
  lldb/test/Shell/Register/x86-db-read.test


Index: lldb/test/Shell/Register/x86-db-read.test
===================================================================
--- /dev/null
+++ lldb/test/Shell/Register/x86-db-read.test
@@ -0,0 +1,35 @@
+# XFAIL: system-windows
+# REQUIRES: native && (target-x86 || target-x86_64) && can-set-dbregs
+# RUN: %clangxx_host -g %p/Inputs/x86-db-read.cpp -o %t
+# RUN: %lldb -b -s %s %t | FileCheck %s
+process launch
+# CHECK: Process {{[0-9]+}} stopped
+
+watchpoint set variable -w write g_8w
+# CHECK: Watchpoint created: Watchpoint 1: addr = 0x{{[0-9a-f]*}} size = 1 state = enabled type = w
+watchpoint set variable -w read_write g_16rw
+# CHECK: Watchpoint created: Watchpoint 2: addr = 0x{{[0-9a-f]*}} size = 2 state = enabled type = rw
+watchpoint set variable -w write g_32w
+# CHECK: Watchpoint created: Watchpoint 3: addr = 0x{{[0-9a-f]*}} size = 4 state = enabled type = w
+watchpoint set variable -w read_write g_32rw
+# CHECK: Watchpoint created: Watchpoint 4: addr = 0x{{[0-9a-f]*}} size = 4 state = enabled type = rw
+
+print &g_8w
+# CHECK: (uint8_t *) $0 = [[VAR8W:0x[0-9a-f]*]]
+print &g_16rw
+# CHECK: (uint16_t *) $1 = [[VAR16RW:0x[0-9a-f]*]]
+print &g_32w
+# CHECK: (uint32_t *) $2 = [[VAR32W:0x[0-9a-f]*]]
+print &g_32rw
+# CHECK: (uint32_t *) $3 = [[VAR64RW:0x[0-9a-f]*]]
+
+register read --all
+# CHECK-DAG: dr0 = [[VAR8W]]
+# CHECK-DAG: dr1 = [[VAR16RW]]
+# CHECK-DAG: dr2 = [[VAR32W]]
+# CHECK-DAG: dr3 = [[VAR64RW]]
+# CHECK-DAG: dr6 = 0x{{(00000000)?}}ffff0ff0
+# CHECK-DAG: dr7 = 0x{{(00000000)?}}fd7104aa
+
+process continue
+# CHECK: Process {{[0-9]+}} exited with status = 0
Index: lldb/test/Shell/Register/Inputs/x86-db-read.cpp
===================================================================
--- /dev/null
+++ lldb/test/Shell/Register/Inputs/x86-db-read.cpp
@@ -0,0 +1,12 @@
+#include <cstdint>
+#include <csignal>
+
+uint8_t g_8w;
+uint16_t g_16rw;
+uint32_t g_32w;
+uint32_t g_32rw;
+
+int main() {
+  ::raise(SIGSTOP);
+  return 0;
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D91264.304519.patch
Type: text/x-patch
Size: 1964 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20201111/785bca57/attachment.bin>


More information about the lldb-commits mailing list