return 0
}
+# With a libc with probes, all tests should pass.
+#
+# Without probes, we can still set a break on longjmp, but getting the longjmp
+# target may not work, in the following cases:
+# - gdbarch_get_longjmp_target_p (gdbarch) == 0: not implemented.
+# - gdbarch_get_longjmp_target (gdbarch) == 0: for instance on amd64 if
+# tdep->jb_pc_offset == -1.
+# - gdbarch_get_longjmp_target (gdbarch) != 0: if we have a glibc with
+# pointer mangling ( https://sourceware.org/glibc/wiki/PointerEncryption )
+# then we retrieve a mangled longjmp target that needs to be demangled.
+# For instance on amd64 with target board unix/-m32.
+#
+# Pointer demangling is currently not implemented for any target.
+# For the amd64 case, this would require copying for instance this:
+# 48 c1 ca 11 ror $0x11,%rdx
+# 64 48 33 14 25 30 00 xor %fs:0x30,%rdx
+# into a scratch space, save the register set, set %rdx to the mangled
+# longjmp target, displaced-step through the two insn and read the
+# demangled longjmp target from %rdx, and restore the register set.
+#
+# The failure mode in the first two cases is that the next degrades into a
+# continue. The failure mode in the latter case is a failure to set a
+# breakpoint (matched by re_cannot_insert_bp) and a stop in longjmp.
+#
+# We detect the different failure modes and kfail these.
+
+set have_longjmp_probe 0
+gdb_test_multiple "info probes stap libc ^longjmp$" "" {
+ -re -wrap "No probes matched\\." {
+ pass $gdb_test_name
+ }
+ -re -wrap "\r\nstap\[ \t\]+libc\[ \t\]+longjmp\[ \t\]+.*" {
+ pass $gdb_test_name
+ set have_longjmp_probe 1
+ }
+}
+
set bp_miss_step_1 [gdb_get_line_number "miss_step_1"]
set bp_miss_step_2 [gdb_get_line_number "miss_step_2"]
set bp_start_test_2 [gdb_get_line_number "patt2"]
set bp_start_test_3 [gdb_get_line_number "patt3"]
+set re_cannot_insert_bp \
+ [multi_line \
+ "Warning:" \
+ "Cannot insert breakpoint $decimal\\." \
+ "Cannot access memory at address $hex"]
+
#
# Pattern 1 - simple longjmp.
#
gdb_test "next" "miss_step_1.*" "next into safety net"
}
-re "miss_step_1.*$gdb_prompt $" {
- fail $msg
+ if { $have_longjmp_probe } {
+ fail $gdb_test_name
+ } else {
+ kfail $gdb_test_name "gdb/26967"
+ }
+ }
+ -re -wrap "\r\n$re_cannot_insert_bp\r\n.*" {
+ if { $have_longjmp_probe } {
+ fail $gdb_test_name
+ } else {
+ kfail $gdb_test_name "gdb/26967"
+ }
}
}
}
gdb_test "next" "miss_step_2.*" "next into safety net"
}
-re "miss_step_2.*$gdb_prompt $" {
- fail $msg
+ if { $have_longjmp_probe } {
+ fail $gdb_test_name
+ } else {
+ kfail $gdb_test_name "gdb/26967"
+ }
+ }
+ -re -wrap "\r\n$re_cannot_insert_bp\r\n.*" {
+ if { $have_longjmp_probe } {
+ fail $gdb_test_name
+ } else {
+ kfail $gdb_test_name "gdb/26967"
+ }
}
}
}
gdb_test "continue" "patt3.*" "continue to breakpoint at pattern start"
}
- gdb_test "next" "longjmp caught.*" "next over pattern"
+ gdb_test_multiple "next" "next over pattern" {
+ -re -wrap "longjmp caught.*" {
+ pass $gdb_test_name
+ }
+ -re -wrap "\r\n$re_cannot_insert_bp\r\n.*" {
+ if { $have_longjmp_probe } {
+ fail $gdb_test_name
+ } else {
+ kfail $gdb_test_name "gdb/26967"
+ }
+ }
+ }
}