Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFC] [gdb/testsuite] Add xfail in gdb.base/hbreak.exp
@ 2024-07-17 15:10 Tom de Vries
  2024-07-17 15:14 ` Luis Machado
  0 siblings, 1 reply; 15+ messages in thread
From: Tom de Vries @ 2024-07-17 15:10 UTC (permalink / raw)
  To: gdb-patches; +Cc: Luis Machado

On an aarch64-linux system with 32-bit userland running in a chroot, and using
target board unix/mthumb I get:
...
(gdb) hbreak hbreak.c:27^M
Hardware assisted breakpoint 2 at 0x4004e2: file hbreak.c, line 27.^M
(gdb) PASS: gdb.base/hbreak.exp: hbreak
continue^M
Continuing.^M
Unexpected error setting breakpoint: Invalid argument.^M
(gdb) FAIL: gdb.base/hbreak.exp: continue to break-at-exit after hbreak
...
due to this call in arm_linux_nat_target::low_prepare_to_resume:
...
          if (ptrace (PTRACE_SETHBPREGS, pid,
              (PTRACE_TYPE_ARG3) ((i << 1) + 1), &bpts[i].address) < 0)
            perror_with_name (_("Unexpected error setting breakpoint"));
...

This problem does not happen if instead we use a 4-byte aligned address.

I'm not sure if this is simply unsupported or if there's a kernel bug of some
sort, but I don't see what gdb can do about this.

Tentatively mark this as xfail.

Tested on aarch64-linux.
---
 gdb/testsuite/gdb.base/hbreak.exp | 40 ++++++++++++++++++++++++++-----
 1 file changed, 34 insertions(+), 6 deletions(-)

diff --git a/gdb/testsuite/gdb.base/hbreak.exp b/gdb/testsuite/gdb.base/hbreak.exp
index 73a3e2afb67..b140257a23e 100644
--- a/gdb/testsuite/gdb.base/hbreak.exp
+++ b/gdb/testsuite/gdb.base/hbreak.exp
@@ -27,10 +27,38 @@ if ![runto_main] {
 
 set breakline [gdb_get_line_number "break-at-exit"]
 
-gdb_test "hbreak ${srcfile}:${breakline}" \
-	 "Hardware assisted breakpoint \[0-9\]+ at 0x\[0-9a-f\]+: file .*${srcfile}, line ${breakline}\\." \
-	 "hbreak"
+set re_loc "file \[^\r\n\]*$srcfile, line $breakline"
+set re_dot [string_to_regexp .]
 
-gdb_test "continue" \
-	 "Continuing\\.\[ \r\n\]+Breakpoint \[0-9\]+, .*break-at-exit.*" \
-	 "continue to break-at-exit after hbreak"
+set addr 0x0
+gdb_test_multiple "hbreak ${srcfile}:${breakline}" "hbreak" {
+    -re -wrap "Hardware assisted breakpoint $decimal at ($hex): $re_loc$re_dot" {
+	set addr $expect_out(1,string)
+	pass $gdb_test_name
+    }
+}
+
+set have_xfail 0
+if { [istarget arm*-*-*] } {
+    # When running 32-bit userland on aarch64 kernel, thumb instructions that
+    # are not 4-byte aligned may not be supported for setting a hardware
+    # breakpoint on.
+    set have_xfail [expr ($addr & 0x2) == 2]
+}
+
+set re_xfail \
+    [string_to_regexp \
+	 "Unexpected error setting breakpoint: Invalid argument."]
+
+gdb_test_multiple "continue" "continue to break-at-exit after hbreak" {
+    -re -wrap "Continuing\\.\[ \r\n\]+Breakpoint \[0-9\]+, .*break-at-exit.*" {
+	pass $gdb_test_name
+    }
+    -re -wrap $re_xfail {
+	if { $have_xfail } {
+	    xfail $gdb_test_name
+	} else {
+	    fail $gdb_test_name
+	}
+    }
+}

base-commit: 0ed152c5c6b3c72fc505b331ed77e08b438d643a
-- 
2.35.3


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2024-07-26 15:47 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-17 15:10 [RFC] [gdb/testsuite] Add xfail in gdb.base/hbreak.exp Tom de Vries
2024-07-17 15:14 ` Luis Machado
2024-07-23 10:02   ` Luis Machado
2024-07-24  5:25     ` Tom de Vries
2024-07-24  6:53       ` Luis Machado
2024-07-24  9:28         ` Tom de Vries
2024-07-24 10:45           ` Luis Machado
2024-07-24 11:56             ` Tom de Vries
2024-07-24 22:59               ` Luis Machado
2024-07-25 13:52                 ` Tom de Vries
2024-07-25 15:22                   ` Luis Machado
2024-07-26  6:28                     ` Tom de Vries
2024-07-26  6:30                       ` Luis Machado
2024-07-26 10:01                         ` Tom de Vries
2024-07-26 15:46                           ` Luis Machado

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox