Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi via Gdb-patches <gdb-patches@sourceware.org>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: [PATCH 5/6] gdb.base/foll-fork.exp: use foreach_with_prefix to handle prefixes
Date: Fri, 10 Sep 2021 16:54:01 -0400	[thread overview]
Message-ID: <20210910205402.3853607-5-simon.marchi@efficios.com> (raw)
In-Reply-To: <20210910205402.3853607-1-simon.marchi@efficios.com>

No behavior change in the test expected, other than in the test names.

Change-Id: I111137483858ab0f23138439f2930009779a2b3d
---
 gdb/testsuite/gdb.base/foll-fork.exp | 165 +++++++++++++--------------
 1 file changed, 81 insertions(+), 84 deletions(-)

diff --git a/gdb/testsuite/gdb.base/foll-fork.exp b/gdb/testsuite/gdb.base/foll-fork.exp
index 3b90bb2e785..3a0cc2fe456 100644
--- a/gdb/testsuite/gdb.base/foll-fork.exp
+++ b/gdb/testsuite/gdb.base/foll-fork.exp
@@ -79,109 +79,106 @@ proc_with_prefix test_follow_fork { follow-fork-mode detach-on-fork cmd } {
     global srcfile
     global testfile
 
-    with_test_prefix "follow ${follow-fork-mode}, detach ${detach-on-fork}, command \"$cmd\"" {
-
-	# Start a new debugger session each time so defaults are legitimate.
-	if { ![setup] } {
-	    return
-	}
+    # Start a new debugger session each time so defaults are legitimate.
+    if { ![setup] } {
+	return
+    }
 
-	# The "Detaching..." and "Attaching..." messages may be hidden by
-	# default.
-	gdb_test_no_output "set verbose"
+    # The "Detaching..." and "Attaching..." messages may be hidden by
+    # default.
+    gdb_test_no_output "set verbose"
 
-	# Set follow-fork-mode if we aren't using the default.
-	if {${follow-fork-mode} == "default"} {
-	    set follow-fork-mode "parent"
-	} else {
-	    gdb_test_no_output "set follow-fork ${follow-fork-mode}"
-	}
+    # Set follow-fork-mode if we aren't using the default.
+    if {${follow-fork-mode} == "default"} {
+	set follow-fork-mode "parent"
+    } else {
+	gdb_test_no_output "set follow-fork ${follow-fork-mode}"
+    }
 
-	gdb_test "show follow-fork" \
-	"Debugger response to a program call of fork or vfork is \"${follow-fork-mode}\"."
+    gdb_test "show follow-fork" \
+    "Debugger response to a program call of fork or vfork is \"${follow-fork-mode}\"."
 
-	# Set detach-on-fork mode if we aren't using the default.
-	if {${detach-on-fork} == "default"} {
-	    set detach-on-fork "on"
-	} else {
-	    gdb_test_no_output "set detach-on-fork ${detach-on-fork}"
-	}
+    # Set detach-on-fork mode if we aren't using the default.
+    if {${detach-on-fork} == "default"} {
+	set detach-on-fork "on"
+    } else {
+	gdb_test_no_output "set detach-on-fork ${detach-on-fork}"
+    }
 
-	gdb_test "show detach-on-fork" \
-		 "Whether gdb will detach.* fork is ${detach-on-fork}."
+    gdb_test "show detach-on-fork" \
+	     "Whether gdb will detach.* fork is ${detach-on-fork}."
 
-	# Set a breakpoint after the fork if we aren't single-stepping
-	# past the fork.
-	if {$cmd == "continue"} {
-	    set bp_after_fork [gdb_get_line_number "set breakpoint here"]
-	    gdb_test "break ${srcfile}:$bp_after_fork" \
-		     "Breakpoint.*, line $bp_after_fork.*" \
-		     "set breakpoint after fork"
-	}
+    # Set a breakpoint after the fork if we aren't single-stepping
+    # past the fork.
+    if {$cmd == "continue"} {
+	set bp_after_fork [gdb_get_line_number "set breakpoint here"]
+	gdb_test "break ${srcfile}:$bp_after_fork" \
+		 "Breakpoint.*, line $bp_after_fork.*" \
+		 "set breakpoint after fork"
+    }
 
-	# Set up the output we expect to see after we run.
-	set expected_re ""
-	if {${follow-fork-mode} == "child"} {
-	    set expected_re "\\\[Attaching after.* fork to.*"
-	    if {${detach-on-fork} == "on"} {
-		append expected_re "\\\[Detaching after fork from .*"
-	    }
-	    append expected_re "set breakpoint here.*"
-	} elseif {${follow-fork-mode} == "parent" && ${detach-on-fork} == "on"} {
-	    set expected_re "\\\[Detaching after fork from .*set breakpoint here.*"
-	} else {
-	    set expected_re ".*set breakpoint here.*"
+    # Set up the output we expect to see after we run.
+    set expected_re ""
+    if {${follow-fork-mode} == "child"} {
+	set expected_re "\\\[Attaching after.* fork to.*"
+	if {${detach-on-fork} == "on"} {
+	    append expected_re "\\\[Detaching after fork from .*"
 	}
+	append expected_re "set breakpoint here.*"
+    } elseif {${follow-fork-mode} == "parent" && ${detach-on-fork} == "on"} {
+	set expected_re "\\\[Detaching after fork from .*set breakpoint here.*"
+    } else {
+	set expected_re ".*set breakpoint here.*"
+    }
 
-	# Test running past and following the fork, using the parameters
-	# set above.
-	gdb_test $cmd $expected_re "$cmd past fork"
+    # Test running past and following the fork, using the parameters
+    # set above.
+    gdb_test $cmd $expected_re "$cmd past fork"
 
-	# Check that we have the inferiors arranged correctly after 
-	# following the fork.
-	set resume_unfollowed 0
-	if {${follow-fork-mode} == "parent" && ${detach-on-fork} == "on"} {
+    # Check that we have the inferiors arranged correctly after
+    # following the fork.
+    set resume_unfollowed 0
+    if {${follow-fork-mode} == "parent" && ${detach-on-fork} == "on"} {
 
-	    # Follow parent / detach child: the only inferior is the parent.
-	    gdb_test "info inferiors" "\\* 1 .* process.*"
+	# Follow parent / detach child: the only inferior is the parent.
+	gdb_test "info inferiors" "\\* 1 .* process.*"
 
-	} elseif {${follow-fork-mode} == "parent" && ${detach-on-fork} == "off"} {
+    } elseif {${follow-fork-mode} == "parent" && ${detach-on-fork} == "off"} {
 
-	    # Follow parent / keep child: two inferiors under debug, the
-	    # parent is the current inferior.
-	    gdb_test "info inferiors" "\\* 1 .*process.* 2 .*process.*"
+	# Follow parent / keep child: two inferiors under debug, the
+	# parent is the current inferior.
+	gdb_test "info inferiors" "\\* 1 .*process.* 2 .*process.*"
 
-	    gdb_test "inferior 2" "Switching to inferior 2 .*"
-	    set resume_unfollowed 1
+	gdb_test "inferior 2" "Switching to inferior 2 .*"
+	set resume_unfollowed 1
 
-	} elseif {${follow-fork-mode} == "child" && ${detach-on-fork} == "on"} {
+    } elseif {${follow-fork-mode} == "child" && ${detach-on-fork} == "on"} {
 
-	    # Follow child / detach parent: the child is under debug and is
-	    # the current inferior.  The parent is listed but is not under
-	    # debug.
-	    gdb_test "info inferiors" " 1 .*<null>.*\\* 2 .*process.*"
+	# Follow child / detach parent: the child is under debug and is
+	# the current inferior.  The parent is listed but is not under
+	# debug.
+	gdb_test "info inferiors" " 1 .*<null>.*\\* 2 .*process.*"
 
-	} elseif {${follow-fork-mode} == "child" && ${detach-on-fork} == "off"} {
+    } elseif {${follow-fork-mode} == "child" && ${detach-on-fork} == "off"} {
 
-	    # Follow child / keep parent: two inferiors under debug, the
-	    # child is the current inferior.
-	    gdb_test "info inferiors" " 1 .*process.*\\* 2 .*process.*"
+	# Follow child / keep parent: two inferiors under debug, the
+	# child is the current inferior.
+	gdb_test "info inferiors" " 1 .*process.*\\* 2 .*process.*"
 
-	    gdb_test "inferior 1" "Switching to inferior 1 .*"
-	    set resume_unfollowed 1
-	}
+	gdb_test "inferior 1" "Switching to inferior 1 .*"
+	set resume_unfollowed 1
+    }
 
-	if {$resume_unfollowed == 1} {
-	    if {$cmd == "next 2"} {
+    if {$resume_unfollowed == 1} {
+	if {$cmd == "next 2"} {
 
-		gdb_continue_to_end "continue unfollowed inferior to end"
+	    gdb_continue_to_end "continue unfollowed inferior to end"
 
-	    } elseif {$cmd == "continue"} {
+	} elseif {$cmd == "continue"} {
 
-		gdb_continue_to_breakpoint \
-		    "continue unfollowed inferior to bp" \
-		    ".* set breakpoint here.*"
-	    }
+	    gdb_continue_to_breakpoint \
+		"continue unfollowed inferior to bp" \
+		".* set breakpoint here.*"
 	}
     }
 }
@@ -395,14 +392,14 @@ if { ![check_fork_catchpoints] } {
 # The first loop should be sufficient to test the defaults.  There
 # is no need to test using the defaults in other permutations (e.g.
 # "default" "on", "parent" "default", etc.).
-foreach cmd {"next 2" "continue"} {
+foreach_with_prefix cmd {"next 2" "continue"} {
     test_follow_fork "default" "default" $cmd
 }
 
 # Now test all explicit permutations.
-foreach follow-fork-mode {"parent" "child"} {
-    foreach detach-on-fork {"on" "off"} {
-	foreach cmd {"next 2" "continue"} {
+foreach_with_prefix follow-fork-mode {"parent" "child"} {
+    foreach_with_prefix detach-on-fork {"on" "off"} {
+	foreach_with_prefix cmd {"next 2" "continue"} {
 	    test_follow_fork ${follow-fork-mode} ${detach-on-fork} $cmd
 	}
     }
-- 
2.33.0


  parent reply	other threads:[~2021-09-10 20:56 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-10 20:53 [PATCH 1/6] gdb.base/foll-fork.exp: remove DUPLICATEs Simon Marchi via Gdb-patches
2021-09-10 20:53 ` [PATCH 2/6] gdb.base/foll-fork.exp: remove gating based on target triplet Simon Marchi via Gdb-patches
2021-09-10 20:53 ` [PATCH 3/6] gdb.base/foll-fork.exp: refactor to restart GDB between each portion of the test Simon Marchi via Gdb-patches
2021-09-10 20:54 ` [PATCH 4/6] gdb.base/foll-fork.exp: rename variables Simon Marchi via Gdb-patches
2021-09-10 20:54 ` Simon Marchi via Gdb-patches [this message]
2021-09-10 20:54 ` [PATCH 6/6] gdb: don't share aspace/pspace on fork with "detach-on-fork on" and "follow-fork-mode child" Simon Marchi via Gdb-patches
2021-09-10 23:33   ` John Baldwin
2021-09-11  3:16     ` Simon Marchi via Gdb-patches
2021-09-11 13:02       ` Simon Marchi via Gdb-patches
2021-09-11 13:03         ` Simon Marchi via Gdb-patches
2021-09-27 19:32       ` Simon Marchi via Gdb-patches
2021-09-28 15:10         ` Tom de Vries via Gdb-patches
2021-09-28 19:12           ` Simon Marchi via Gdb-patches
2021-09-28 19:31             ` Pedro Alves
2021-09-28 19:35               ` Pedro Alves
2021-09-28 23:32                 ` Simon Marchi via Gdb-patches
2021-09-28 22:38             ` Tom de Vries via Gdb-patches
2021-09-23 19:23 ` [PATCH 1/6] gdb.base/foll-fork.exp: remove DUPLICATEs Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210910205402.3853607-5-simon.marchi@efficios.com \
    --to=gdb-patches@sourceware.org \
    --cc=simon.marchi@efficios.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox