Skip to content

Commit

Permalink
[lldb] [test] Add a minimal test for x86 dbreg reading
Browse files Browse the repository at this point in the history
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.

Differential Revision: https://reviews.llvm.org/D91264
  • Loading branch information
mgorny committed Nov 12, 2020
1 parent a8bfee2 commit f37834c
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
12 changes: 12 additions & 0 deletions 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;
}
36 changes: 36 additions & 0 deletions lldb/test/Shell/Register/x86-db-read.test
@@ -0,0 +1,36 @@
# Debug registers are currently printed only on FreeBSD.
# REQUIRES: system-freebsd
# REQUIRES: native && (target-x86 || target-x86_64) && dbregs-set
# 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

0 comments on commit f37834c

Please sign in to comment.