[v2,gdb/testsuite] Add PR gdb/26967 KFAIL in two more test-cases

Message ID 20240320091128.16646-1-tdevries@suse.de
State Committed
Headers
Series [v2,gdb/testsuite] Add PR gdb/26967 KFAIL in two more test-cases |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm fail Patch failed to apply
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 fail Patch failed to apply

Commit Message

Tom de Vries March 20, 2024, 9:11 a.m. UTC
  On aarch64-linux (debian 12), when running test-case
gdb.base/longjmp-until-in-main.exp, I run into:
...
(gdb) until 33^M
warning: Breakpoint address adjusted from 0x70f727c678928489 to 0xfff727c678928489.^M
Warning:^M
Cannot insert breakpoint 0.^M
Cannot access memory at address 0xfff727c678928489^M
^M
0x0000fffff7e3a580 in siglongjmp () from /lib/aarch64-linux-gnu/libc.so.6^M
(gdb) FAIL: gdb.base/longjmp-until-in-main.exp: until $line, in main
...

This is PR gdb/26967: no longjmp probe is available:
...
(gdb) info probes stap libc ^longjmp$^M
No probes matched.^M
...
and glibc applies pointer mangling which makes it fairly difficult for gdb to
get the longjmp target.

There's a KFAIL for this in test-case gdb.base/longjmp.exp, added in commit
b5e7cd5cd3d ("[gdb/testsuite] Add KFAILs in gdb.base/longjmp.exp").

Factor out new proc have_longjmp_probe, and use it to add similar KFAIL in
this and one more test-case.

Tested on aarch64-linux.
---
 .../gdb.base/longjmp-until-in-main.exp        | 24 ++++++++++++++++---
 gdb/testsuite/gdb.base/longjmp.exp            | 11 +--------
 .../premature-dummy-frame-removal.exp         | 22 ++++++++++++++++-
 gdb/testsuite/lib/gdb.exp                     | 19 +++++++++++++++
 4 files changed, 62 insertions(+), 14 deletions(-)


base-commit: 8a61ee551ce3059f602fee1e576af08c03f991bc
  

Comments

Tom Tromey March 20, 2024, 5:08 p.m. UTC | #1
>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:

Tom> Factor out new proc have_longjmp_probe, and use it to add similar KFAIL in
Tom> this and one more test-case.

Thanks for doing that.  This looks good to me.
Approved-By: Tom Tromey <tom@tromey.com>

Tom
  

Patch

diff --git a/gdb/testsuite/gdb.base/longjmp-until-in-main.exp b/gdb/testsuite/gdb.base/longjmp-until-in-main.exp
index d755c86ed88..2e308f5b710 100644
--- a/gdb/testsuite/gdb.base/longjmp-until-in-main.exp
+++ b/gdb/testsuite/gdb.base/longjmp-until-in-main.exp
@@ -35,10 +35,28 @@  if {![runto_main]} {
     return
 }
 
+set have_longjmp_probe [have_longjmp_probe]
+
 delete_breakpoints
 
 set until_to_line [gdb_get_line_number "until to here"]
 
-gdb_test "until $until_to_line" \
-    " until to here .*" \
-    "until \$line, in main"
+set re_cannot_insert_bp \
+    [multi_line \
+	 "Warning:" \
+	 "Cannot insert breakpoint $::decimal\\." \
+	 "Cannot access memory at address $::hex"]
+
+set test "until \$line, in main"
+gdb_test_multiple "until $until_to_line" $test {
+    -re -wrap "\r\n$re_cannot_insert_bp\r\n.*" {
+	if { $have_longjmp_probe } {
+	    fail $gdb_test_name
+	} else {
+	    kfail gdb/26967 $gdb_test_name
+	}
+    }
+    -re -wrap " until to here .*" {
+	pass $gdb_test_name
+    }
+}
diff --git a/gdb/testsuite/gdb.base/longjmp.exp b/gdb/testsuite/gdb.base/longjmp.exp
index 1e6860445d0..00a3fcbe741 100644
--- a/gdb/testsuite/gdb.base/longjmp.exp
+++ b/gdb/testsuite/gdb.base/longjmp.exp
@@ -62,16 +62,7 @@  proc do_test { with_probes } {
     #
     # 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 have_longjmp_probe [have_longjmp_probe]
 
     if { $with_probes } {
 	if { !$have_longjmp_probe } {
diff --git a/gdb/testsuite/gdb.base/premature-dummy-frame-removal.exp b/gdb/testsuite/gdb.base/premature-dummy-frame-removal.exp
index 100c24aae20..19e28bb6631 100644
--- a/gdb/testsuite/gdb.base/premature-dummy-frame-removal.exp
+++ b/gdb/testsuite/gdb.base/premature-dummy-frame-removal.exp
@@ -49,7 +49,27 @@  if {![runto_main]} {
 set pyfile [gdb_remote_download host ${srcdir}/${subdir}/${testfile}.py]
 gdb_test_no_output "source ${pyfile}" "load python file"
 
-gdb_test "p some_func ()" " = 0"
+set have_longjmp_probe [have_longjmp_probe]
+
+set re_cannot_insert_bp \
+    [multi_line \
+	 "Warning:" \
+	 "Cannot insert breakpoint $::decimal\\." \
+	 "Cannot access memory at address $::hex"]
+
+gdb_test_multiple "p some_func ()" "" {
+    -re -wrap "\r\n$re_cannot_insert_bp\r\n.*" {
+	if { $have_longjmp_probe } {
+	    fail $gdb_test_name
+	} else {
+	    kfail gdb/26967 $gdb_test_name
+	    return 0
+	}
+    }
+    -re -wrap " = 0" {
+	pass $gdb_test_name
+    }
+}
 
 # When frame debugging is turned on, this test has (previously)
 # revealed some crashes due to the Python frame unwinder trying to
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 4d27b60ef49..a0c4855ffc5 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -4622,6 +4622,25 @@  proc skip_libstdcxx_probe_tests {} {
     return [skip_libstdcxx_probe_tests_prompt "$gdb_prompt $"]
 }
 
+# Return 1 if libc supports the longjmp probe.  Note that we're not using
+# gdb_caching_proc because the probe may have been disabled.
+
+proc have_longjmp_probe {} {
+    set have_probe -1
+    gdb_test_multiple "info probes stap libc ^longjmp$" "" {
+	-re -wrap "No probes matched\\." {
+	    set have_probe 0
+	}
+	-re -wrap "\r\nstap\[ \t\]+libc\[ \t\]+longjmp\[ \t\]+.*" {
+	    set have_probe 1
+	}
+    }
+    if { $have_probe == -1 } {
+	error "failed to get libc longjmp probe status"
+    }
+    return $have_probe
+}
+
 # Helper for gdb_is_target_* procs.  TARGET_NAME is the name of the target
 # we're looking for (used to build the test name).  TARGET_STACK_REGEXP
 # is a regexp that will match the output of "maint print target-stack" if