public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] gdb.base/skip.exp: Don't abuse gdb_test's question support
@ 2022-05-17 10:15 Pedro Alves
  0 siblings, 0 replies; only message in thread
From: Pedro Alves @ 2022-05-17 10:15 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=d7440bee9ffa6767e704f226ec28b9aa2fb748d6

commit d7440bee9ffa6767e704f226ec28b9aa2fb748d6
Author: Pedro Alves <pedro@palves.net>
Date:   Tue May 17 10:25:12 2022 +0100

    gdb.base/skip.exp: Don't abuse gdb_test's question support
    
    gdb.base/skip.exp abuses gdb_test's support for answering a GDB
    question to do this:
    
        # With gcc 9.2.0 we jump once back to main before entering foo here.
        # If that happens try to step a second time.
        gdb_test "step" "foo \\(\\) at.*" "step 3" \
            "main \\(\\) at .*\r\n$gdb_prompt " "step"
    
    After a patch later in this series, gdb_test will FAIL if GDB does NOT
    issue the question, so this test would start failing on older GCCs.
    
    Switch to using gdb_test_multiple instead.  There are three spots in
    the file that have the same pattern, and they're actually in a
    sequence of commands that is repeated those 3 times.  Factor all that
    out to a procedure.
    
    I don't have gcc 9.2 handy, but I do have gcc 6.5, and that one is
    affected as well, so update the comment.
    
    Change-Id: If0a7e3cdf5191b4eec95ce0c8845c3a4d801c39e

Diff:
---
 gdb/testsuite/gdb.base/skip.exp | 55 +++++++++++++++++++++++------------------
 1 file changed, 31 insertions(+), 24 deletions(-)

diff --git a/gdb/testsuite/gdb.base/skip.exp b/gdb/testsuite/gdb.base/skip.exp
index 7c71bb07a84..e6b660004d9 100644
--- a/gdb/testsuite/gdb.base/skip.exp
+++ b/gdb/testsuite/gdb.base/skip.exp
@@ -122,6 +122,32 @@ with_test_prefix "step after deleting 1" {
     gdb_test "step" "main \\(\\) at.*" "step 3"
 }
 
+# Test that we step into foo(), then into bar(), but not into baz().
+proc step_bar_foo_skip_baz {} {
+    gdb_test "step" "bar \\(\\) at.*" "step 1"
+    gdb_test "step" ".*" "step 2"; # Return from bar()
+
+    # With at least gcc 6.5.0 and 9.2.0, we jump once back to main
+    # before entering foo here.  If that happens try to step a second
+    # time.
+    set stepped_again 0
+    gdb_test_multiple "step" "step 3" {
+	-re -wrap "foo \\(\\) at.*" {
+	    pass $gdb_test_name
+	}
+	-re -wrap "main \\(\\) at .*" {
+	    if {!$stepped_again} {
+		set stepped_again 1
+		send_gdb "step\n"
+	    }
+	    exp_continue
+	}
+    }
+
+    gdb_test "step" ".*" "step 4"; # Return from foo()
+    gdb_test "step" "main \\(\\) at.*" "step 5"
+}
+
 # Now disable the skiplist entry for  skip1.c.  We should now
 # step into foo(), then into bar(), but not into baz().
 
@@ -136,14 +162,7 @@ with_test_prefix "step after disabling 3" {
 	return
     }
 
-    gdb_test "step" "bar \\(\\) at.*" "step 1"
-    gdb_test "step" ".*" "step 2"; # Return from bar()
-    # With gcc 9.2.0 we jump once back to main before entering foo here.
-    # If that happens try to step a second time.
-    gdb_test "step" "foo \\(\\) at.*" "step 3" \
-	"main \\(\\) at .*\r\n$gdb_prompt " "step"
-    gdb_test "step" ".*" "step 4"; # Return from foo()
-    gdb_test "step" "main \\(\\) at.*" "step 5"
+    step_bar_foo_skip_baz
 }
 
 # Enable skiplist entry 3 and make sure we step over it like before.
@@ -254,14 +273,8 @@ with_test_prefix "step using -fu for baz" {
 
     gdb_test_no_output "skip disable"
     gdb_test_no_output "skip enable 7"
-    gdb_test "step" "bar \\(\\) at.*" "step 1"
-    gdb_test "step" ".*" "step 2"; # Return from bar()
-    # With gcc 9.2.0 we jump once back to main before entering foo here.
-    # If that happens try to step a second time.
-    gdb_test "step" "foo \\(\\) at.*" "step 3" \
-	"main \\(\\) at .*\r\n$gdb_prompt " "step"
-    gdb_test "step" ".*" "step 4"; # Return from foo()
-    gdb_test "step" "main \\(\\) at.*" "step 5"
+
+    step_bar_foo_skip_baz
 }
 
 with_test_prefix "step using -rfu for baz" {
@@ -271,14 +284,8 @@ with_test_prefix "step using -rfu for baz" {
 
     gdb_test_no_output "skip disable"
     gdb_test_no_output "skip enable 8"
-    gdb_test "step" "bar \\(\\) at.*" "step 1"
-    gdb_test "step" ".*" "step 2"; # Return from bar()
-    # With gcc 9.2.0 we jump once back to main before entering foo here.
-    # If that happens try to step a second time.
-    gdb_test "step" "foo \\(\\) at.*" "step 3" \
-	"main \\(\\) at .*\r\n$gdb_prompt " "step"
-    gdb_test "step" ".*" "step 4"; # Return from foo()
-    gdb_test "step" "main \\(\\) at.*" "step 5"
+
+    step_bar_foo_skip_baz
 }
 
 # Test -fi + -fu.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-05-17 10:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-17 10:15 [binutils-gdb] gdb.base/skip.exp: Don't abuse gdb_test's question support Pedro Alves

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).