[gdb/testsuite] Fix gdb.threads/stepi-over-clone.exp regexp
authorTom de Vries <tdevries@suse.de>
Tue, 14 Nov 2023 13:54:33 +0000 (14:54 +0100)
committerTom de Vries <tdevries@suse.de>
Tue, 14 Nov 2023 13:54:33 +0000 (14:54 +0100)
I ran into the following FAIL:
...
(gdb) PASS: gdb.threads/stepi-over-clone.exp: catch process syscalls
continue^M
Continuing.^M
^M
Catchpoint 2 (call to syscall clone), clone () at \
  ../sysdeps/unix/sysv/linux/x86_64/clone.S:78^M
warning: 78     ../sysdeps/unix/sysv/linux/x86_64/clone.S: \
  No such file or directory^M
(gdb) FAIL: gdb.threads/stepi-over-clone.exp: continue
...

All but one regexps in the .exp file use "clone\[23\]?" with "?" to
also accept "clone", except the failing case.  This commit fixes that
case to also use "?".

Furthermore, there are FAILs like this:
...
(gdb) PASS: gdb.threads/stepi-over-clone.exp: third_thread=false: \
   non-stop=on: displaced=off: i=0: continue
stepi^M
[New Thread 0x7ffff7ff8700 (LWP 15301)]^M
Hello from the first thread.^M
78      in ../sysdeps/unix/sysv/linux/x86_64/clone.S^M
(gdb) XXX: Consume the initial command
XXX: Consume new thread line
XXX: Consume first worker thread message
FAIL: gdb.threads/stepi-over-clone.exp: third_thread=false: non-stop=on: \
  displaced=off: i=0: stepi
...
because this output is expected instead:
...
Hello from the first thread.^M
0x00000000004212cd in clone3 ()^M
...

The root cause for the difference is the presence of .debug_line info for
clone.

Fix this by updating the relevant regexps.

Tested on x86_64-linux, specifically:
- openSUSE Leap 15.4 (where the FAILs where observed), and
- openSUSE Tumbleweed (where the FAILs where not observed).

Co-Authored-By: Pedro Alves <pedro@palves.net>
Approved-By: Pedro Alves <pedro@palves.net>
Change-Id: I74ca9e7d4cfe6af294fd50e8c509fcbad289b78c

gdb/testsuite/gdb.threads/stepi-over-clone.exp

index 4c49642963272ca3a79a426256961c49786201ae..ea774d24a268b5edaf22440d1886af6cc350bfe4 100644 (file)
@@ -44,8 +44,12 @@ gdb_test_multiple "catch syscall group:process" "catch process syscalls" {
     }
 }
 
+set re_loc1 "$hex in clone\[23\]? \\(\\)"
+set re_loc2 "$decimal\[ \t\]+in \[^\r\n\]+"
+set re_loc3 "clone\[23\]? \\(\\) at \[^:\]+:$decimal"
+
 gdb_test "continue" \
-    "Catchpoint $decimal \\(call to syscall clone\[23\]\\), .*"
+    "Catchpoint $decimal \\(call to syscall clone\[23\]?\\), ($re_loc1|$re_loc3).*"
 
 # Return true if INSN is a syscall instruction.
 
@@ -201,7 +205,7 @@ proc test {non_stop displaced third_thread} {
 
                -i $::gdb_spawn_id
 
-               -re "^$hex in clone\[23\]? \\(\\)\r\n" {
+               -re "^($::re_loc1|$::re_loc2)\r\n" {
                    verbose -log "XXX: Consume stop location line"
                    set thread_1_stopped true
                    if { !$seen_prompt } {
@@ -240,7 +244,7 @@ proc test {non_stop displaced third_thread} {
                    }
 
                }
-               -re "^Thread 2\[^\r\n\]+ hit Breakpoint $decimal, $hex in clone\[23\]? \\(\\)\r\n" {
+               -re "^Thread 2\[^\r\n\]+ hit Breakpoint $decimal, ($::re_loc1|$::re_loc3)\r\n" {
                    verbose -log "XXX: Consume thread 2 hit breakpoint"
                    set thread_2_stopped true
                    if { !$seen_prompt } {
@@ -277,7 +281,7 @@ proc test {non_stop displaced third_thread} {
            # always still be in clone.
            set match_code {}
            lappend match_code {
-               -re "\\*?\\s+1\\s+Thread\[^\r\n\]+clone\[23\]? \\(\\)\r\n" {
+               -re "\\*?\\s+1\\s+Thread\[^\r\n\]+($::re_loc1|$::re_loc3)\r\n" {
                    incr thread_count
                    exp_continue
                }
@@ -291,7 +295,7 @@ proc test {non_stop displaced third_thread} {
                    # be stopped at the breakpoint in clone (just before the
                    # third thread is actually created).
                    lappend match_code {
-                       -re "\\*?\\s+2\\s+Thread\[^\r\n\]+$hex in clone\[23\]? \\(\\)\r\n" {
+                       -re "\\*?\\s+2\\s+Thread\[^\r\n\]+($::re_loc1|$::re_loc3)\r\n" {
                            incr thread_count
                            exp_continue
                        }