public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 00/14] Break up gdb.base/break.exp in multiple procs
@ 2022-11-23 18:39 Simon Marchi
  2022-11-23 18:39 ` [PATCH 01/14] gdb/testsuite/gdb.base/break.exp: split test_break_commands_clear Simon Marchi
                   ` (14 more replies)
  0 siblings, 15 replies; 17+ messages in thread
From: Simon Marchi @ 2022-11-23 18:39 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

The test gdb.base/break.exp feels like a big house of cards that will
crumble the second you touch it.  It is very long and it's really not
clear which test depends on the state left by which previous test.  This
series aims at making it more manageable by breaking it up into many
procs, each starting with a fresh GDB.  So you can be confident that the
tests in a proc only depends on the state of GDB resulting of other
tests in the same proc.

Simon Marchi (14):
  gdb/testsuite/gdb.base/break.exp: split test_break_commands_clear
  gdb/testsuite/gdb.base/break.exp: split
    test_break_file_line_convenience_var
  gdb/testsuite/gdb.base/break.exp: split test_rbreak_shlib
  gdb/testsuite/gdb.base/break.exp: split test_break_optimized_prologue
  gdb/testsuite/gdb.base/break.exp: use proc_with_prefix for
    test_next_with_recursion
  gdb/testsuite/gdb.base/break.exp: split test_finish_arguments
  gdb/testsuite/gdb.base/break.exp: split test_break_user_call
  gdb/testsuite/gdb.base/break.exp: split
    test_break_line_convenience_var
  gdb/testsuite/gdb.base/break.exp: split test_break_silent_and_more
  gdb/testsuite/gdb.base/break.exp: split test_break_default
  gdb/testsuite/gdb.base/break.exp: split test_break_nonexistent_line
  gdb/testsuite/gdb.base/break.exp: split test_no_break_on_catchpoint
  gdb/testsuite/gdb.base/break.exp: split test_tbreak
  gdb/testsuite/gdb.base/break.exp: split test_break

 gdb/testsuite/gdb.base/break.exp | 1191 +++++++++++++++---------------
 1 file changed, 615 insertions(+), 576 deletions(-)


base-commit: 8db533e7d6d28db1be0ae4c95ddea7aa3a6224c8
-- 
2.38.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 01/14] gdb/testsuite/gdb.base/break.exp: split test_break_commands_clear
  2022-11-23 18:39 [PATCH 00/14] Break up gdb.base/break.exp in multiple procs Simon Marchi
@ 2022-11-23 18:39 ` Simon Marchi
  2022-11-23 18:39 ` [PATCH 02/14] gdb/testsuite/gdb.base/break.exp: split test_break_file_line_convenience_var Simon Marchi
                   ` (13 subsequent siblings)
  14 siblings, 0 replies; 17+ messages in thread
From: Simon Marchi @ 2022-11-23 18:39 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

Change-Id: Ia58f90117d52fc419fc494836d9b4ed5d902fe9b
---
 gdb/testsuite/gdb.base/break.exp | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/gdb/testsuite/gdb.base/break.exp b/gdb/testsuite/gdb.base/break.exp
index cb5831ac6103..c0756cdccc23 100644
--- a/gdb/testsuite/gdb.base/break.exp
+++ b/gdb/testsuite/gdb.base/break.exp
@@ -897,13 +897,21 @@ with_test_prefix "set line:file breakpoint via convenience variable" {
 	"non-integer convenience variable disallowed"
 }
 
-#
 # Test that commands can be cleared without error.
-#
 
-gdb_test "commands\nprint 232323\nend" ">end" "set some breakpoint commands"
-gdb_test "commands\nend" ">end" "clear breakpoint commands"
-# We verify that the commands were cleared by ensuring that the last
-# breakpoint's location ends the output -- if there were commands,
-# they would have been printed after the location.
-gdb_test "info break" "$srcfile:$line_actual" "verify that they were cleared"
+proc_with_prefix test_break_commands_clear {} {
+    clean_restart breako2
+
+    set line [gdb_get_line_number "set breakpoint 1 here"]
+    gdb_breakpoint $line
+
+    gdb_test "commands\nprint 232323\nend" ">end" "set some breakpoint commands"
+    gdb_test "commands\nend" ">end" "clear breakpoint commands"
+
+    # We verify that the commands were cleared by ensuring that the last
+    # breakpoint's location ends the output -- if there were commands,
+    # they would have been printed after the location.
+    gdb_test "info break" "$::srcfile:$::decimal" "verify that they were cleared"
+}
+
+test_break_commands_clear
-- 
2.38.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 02/14] gdb/testsuite/gdb.base/break.exp: split test_break_file_line_convenience_var
  2022-11-23 18:39 [PATCH 00/14] Break up gdb.base/break.exp in multiple procs Simon Marchi
  2022-11-23 18:39 ` [PATCH 01/14] gdb/testsuite/gdb.base/break.exp: split test_break_commands_clear Simon Marchi
@ 2022-11-23 18:39 ` Simon Marchi
  2022-11-23 18:39 ` [PATCH 03/14] gdb/testsuite/gdb.base/break.exp: split test_rbreak_shlib Simon Marchi
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 17+ messages in thread
From: Simon Marchi @ 2022-11-23 18:39 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

Change-Id: I0c31b037669b2917e062bf431372fb6531f8f53c
---
 gdb/testsuite/gdb.base/break.exp | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/gdb/testsuite/gdb.base/break.exp b/gdb/testsuite/gdb.base/break.exp
index c0756cdccc23..be349d9e7eaf 100644
--- a/gdb/testsuite/gdb.base/break.exp
+++ b/gdb/testsuite/gdb.base/break.exp
@@ -868,18 +868,18 @@ gdb_test_multiple "" $test {
     }
 }
 
-#
 # Test break via convenience variable with file name
-#
 
-with_test_prefix "set line:file breakpoint via convenience variable" {
+proc_with_prefix test_break_file_line_convenience_var {} {
+    clean_restart breako2
+
     set line [gdb_get_line_number "set breakpoint 1 here"]
     gdb_test_no_output "set \$l = $line"
 
     set line_actual "-1"
-    set test "break ${srcfile}:\$l"
+    set test "break $::srcfile:\$l"
     gdb_test_multiple "$test" $test {
-	-re "Breakpoint $decimal at $hex: file .*break\\.c, line ($decimal)\\.\r\n$gdb_prompt $" {
+	-re "Breakpoint $::decimal at $::hex: file .*break\\.c, line ($::decimal)\\.\r\n$::gdb_prompt $" {
 	    # Save the actual line number on which the breakpoint was
 	    # actually set. On some systems (Eg: Ubuntu 16.04 with GCC
 	    # version 5.4.0), that line gets completely inlined, including
@@ -892,11 +892,13 @@ with_test_prefix "set line:file breakpoint via convenience variable" {
 
     gdb_test_no_output "set \$foo=81.5" \
 	"set convenience variable \$foo to 81.5"
-    gdb_test "break $srcfile:\$foo" \
+    gdb_test "break $::srcfile:\$foo" \
 	"Convenience variables used in line specs must have integer values.*" \
 	"non-integer convenience variable disallowed"
 }
 
+test_break_file_line_convenience_var
+
 # Test that commands can be cleared without error.
 
 proc_with_prefix test_break_commands_clear {} {
-- 
2.38.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 03/14] gdb/testsuite/gdb.base/break.exp: split test_rbreak_shlib
  2022-11-23 18:39 [PATCH 00/14] Break up gdb.base/break.exp in multiple procs Simon Marchi
  2022-11-23 18:39 ` [PATCH 01/14] gdb/testsuite/gdb.base/break.exp: split test_break_commands_clear Simon Marchi
  2022-11-23 18:39 ` [PATCH 02/14] gdb/testsuite/gdb.base/break.exp: split test_break_file_line_convenience_var Simon Marchi
@ 2022-11-23 18:39 ` Simon Marchi
  2022-11-23 18:39 ` [PATCH 04/14] gdb/testsuite/gdb.base/break.exp: split test_break_optimized_prologue Simon Marchi
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 17+ messages in thread
From: Simon Marchi @ 2022-11-23 18:39 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

Change-Id: I130e8914c2713095aab03e84aba1481b4c7af978
---
 gdb/testsuite/gdb.base/break.exp | 36 ++++++++++++++++----------------
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/gdb/testsuite/gdb.base/break.exp b/gdb/testsuite/gdb.base/break.exp
index be349d9e7eaf..a9728798fab9 100644
--- a/gdb/testsuite/gdb.base/break.exp
+++ b/gdb/testsuite/gdb.base/break.exp
@@ -835,9 +835,6 @@ gdb_test_multiple "continue" \
 	}
     }
 
-clean_restart breako2
-
-#
 # test that 'rbreak' on a symbol that may be from a shared library doesn't
 # cause a "Junk at end of arguments." error.
 #
@@ -846,28 +843,31 @@ clean_restart breako2
 # Note that this test won't necessarily choke on all targets even if
 # all the rbreak issue is present.  rbreak needs to match and set a
 # breakpoint on a symbol causes 'break' to choke.
-#
 
-gdb_test_no_output "set breakpoint pending on" "rbreak junk pending setup"
+proc_with_prefix test_rbreak_shlib {} {
+    clean_restart breako2
 
-# We expect at least one breakpoint to be set when we "rbreak main".
-gdb_test "rbreak main" \
-    ".*Breakpoint.*at.* file .*$srcfile, line.*" \
-    "rbreak junk set breakpoint"
+    gdb_test_no_output "set breakpoint pending on" "rbreak junk pending setup"
 
-# Run to a breakpoint.  Fail if we see "Junk at end of arguments".
-gdb_run_cmd
+    # We expect at least one breakpoint to be set when we "rbreak main".
+    gdb_test "rbreak main" \
+	".*Breakpoint.*at.* file .*$::srcfile, line.*"
 
-set test "rbreak junk"
-gdb_test_multiple "" $test {
-    -re "Junk at end of arguments" {
-	fail $test
-    }
-    -re ".*Breakpoint \[0-9\]+,.*$gdb_prompt $" {
-	pass $test
+    # Run to a breakpoint.  Fail if we see "Junk at end of arguments".
+    gdb_run_cmd
+
+    gdb_test_multiple "" "rbreak junk" {
+	-re -wrap "Junk at end of arguments.*" {
+	    fail $gdb_test_name
+	}
+	-re -wrap ".*Breakpoint \[0-9\]+,.*" {
+	    pass $gdb_test_name
+	}
     }
 }
 
+test_rbreak_shlib
+
 # Test break via convenience variable with file name
 
 proc_with_prefix test_break_file_line_convenience_var {} {
-- 
2.38.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 04/14] gdb/testsuite/gdb.base/break.exp: split test_break_optimized_prologue
  2022-11-23 18:39 [PATCH 00/14] Break up gdb.base/break.exp in multiple procs Simon Marchi
                   ` (2 preceding siblings ...)
  2022-11-23 18:39 ` [PATCH 03/14] gdb/testsuite/gdb.base/break.exp: split test_rbreak_shlib Simon Marchi
@ 2022-11-23 18:39 ` Simon Marchi
  2022-11-23 18:39 ` [PATCH 05/14] gdb/testsuite/gdb.base/break.exp: use proc_with_prefix for test_next_with_recursion Simon Marchi
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 17+ messages in thread
From: Simon Marchi @ 2022-11-23 18:39 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

Change-Id: Ibf17033c8ce72aa5cfe1b739be2902e84a5e945d
---
 gdb/testsuite/gdb.base/break.exp | 99 ++++++++++++++++----------------
 1 file changed, 48 insertions(+), 51 deletions(-)

diff --git a/gdb/testsuite/gdb.base/break.exp b/gdb/testsuite/gdb.base/break.exp
index a9728798fab9..7e410b4adeec 100644
--- a/gdb/testsuite/gdb.base/break.exp
+++ b/gdb/testsuite/gdb.base/break.exp
@@ -773,68 +773,65 @@ test_next_with_recursion
 # build a new file with optimization enabled so that we can try breakpoints
 # on targets with optimized prologues
 
-if { [prepare_for_testing "failed to prepare" "breako2" {break.c break1.c} {debug nowarnings optimize=-O2}] } {
+if { [build_executable "failed to prepare" "breako2" {break.c break1.c} {debug nowarnings optimize=-O2}] } {
     return -1
 }
 
-#
-# test break at function
-#
-gdb_test "break -q main" \
-    "Breakpoint.*at.* file .*, line.*" \
-    "breakpoint function, optimized file"
-
-#
-# test break at function
-#
-gdb_test "break marker4" \
-    "Breakpoint.*at.* file .*$srcfile1, line.*" \
-    "breakpoint small function, optimized file"
-
-#
-# run until the breakpoint at main is hit. For non-stubs-using targets.
-#
-gdb_run_cmd
-
-set test "run until function breakpoint, optimized file"
-gdb_test_multiple "" $test {
-    -re "Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.* \{.*$gdb_prompt $" {
-	pass $test
-    }
-    -re "Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$gdb_prompt $" {
-	pass "$test (code motion)"
-    }
-}
+proc_with_prefix test_break_optimized_prologue {} {
+    clean_restart breako2
 
-#
-# run until the breakpoint at a small function
-#
+    # test break at function
+    gdb_test "break -q main" \
+	"Breakpoint.*at.* file .*, line.*" \
+	"breakpoint function, optimized file"
 
-#
-# Add a second pass pattern.  The behavior differs here between stabs
-# and dwarf for one-line functions.  Stabs preserves two line symbols
-# (one before the prologue and one after) with the same line number, 
-# but dwarf regards these as duplicates and discards one of them.
-# Therefore the address after the prologue (where the breakpoint is)
-# has no exactly matching line symbol, and GDB reports the breakpoint
-# as if it were in the middle of a line rather than at the beginning.
+    # test break at function
+    gdb_test "break marker4" \
+	"Breakpoint.*at.* file .*$::srcfile1, line.*" \
+	"breakpoint small function, optimized file"
 
-set bp_location14 [gdb_get_line_number "set breakpoint 14 here" $srcfile1]
+    # run until the breakpoint at main is hit. For non-stubs-using targets.
+    gdb_run_cmd
 
-gdb_test_multiple "continue" \
-    "run until breakpoint set at small function, optimized file" {
-	-re "Breakpoint $decimal, marker4 \\(d=(d@entry=)?177601976\\) at .*$srcfile1:$bp_location14\[\r\n\]+$bp_location14\[\t \]+void marker4.*" {
-	    pass "run until breakpoint set at small function, optimized file (line bp_location14)"
+    set test "run until function breakpoint, optimized file"
+    gdb_test_multiple "" $test {
+	-re "Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$::srcfile:$::bp_location6.*$::bp_location6\[\t \]+if .argc.* \{.*$::gdb_prompt $" {
+	    pass $test
 	}
-	-re "Breakpoint $decimal, factorial \\(.*\\) .*\{\r\n$gdb_prompt" {
-	    # GCC 4.3 emits bad line number information - see gcc/36748.
-	    if { [test_compiler_info "gcc-4-3-*"] } {
-		setup_xfail *-*-*
-	    }
-	    fail "run until breakpoint set at small function, optimized file"
+	-re "Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$::gdb_prompt $" {
+	    pass "$test (code motion)"
 	}
     }
 
+    # run until the breakpoint at a small function
+    #
+    # Add a second pass pattern.  The behavior differs here between stabs
+    # and dwarf for one-line functions.  Stabs preserves two line symbols
+    # (one before the prologue and one after) with the same line number,
+    # but dwarf regards these as duplicates and discards one of them.
+    # Therefore the address after the prologue (where the breakpoint is)
+    # has no exactly matching line symbol, and GDB reports the breakpoint
+    # as if it were in the middle of a line rather than at the beginning.
+
+    set bp_location14 [gdb_get_line_number "set breakpoint 14 here" $::srcfile1]
+
+    gdb_test_multiple "continue" \
+	"run until breakpoint set at small function, optimized file" {
+	    -re "Breakpoint $::decimal, marker4 \\(d=(d@entry=)?177601976\\) at .*$::srcfile1:$bp_location14\[\r\n\]+$bp_location14\[\t \]+void marker4.*" {
+		pass "run until breakpoint set at small function, optimized file (line bp_location14)"
+	    }
+	    -re "Breakpoint $::decimal, factorial \\(.*\\) .*\{\r\n$::gdb_prompt" {
+		# GCC 4.3 emits bad line number information - see gcc/36748.
+		if { [test_compiler_info "gcc-4-3-*"] } {
+		    setup_xfail *-*-*
+		}
+		fail "run until breakpoint set at small function, optimized file"
+	    }
+	}
+}
+
+test_break_optimized_prologue
+
 # test that 'rbreak' on a symbol that may be from a shared library doesn't
 # cause a "Junk at end of arguments." error.
 #
-- 
2.38.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 05/14] gdb/testsuite/gdb.base/break.exp: use proc_with_prefix for test_next_with_recursion
  2022-11-23 18:39 [PATCH 00/14] Break up gdb.base/break.exp in multiple procs Simon Marchi
                   ` (3 preceding siblings ...)
  2022-11-23 18:39 ` [PATCH 04/14] gdb/testsuite/gdb.base/break.exp: split test_break_optimized_prologue Simon Marchi
@ 2022-11-23 18:39 ` Simon Marchi
  2022-11-23 18:39 ` [PATCH 06/14] gdb/testsuite/gdb.base/break.exp: split test_finish_arguments Simon Marchi
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 17+ messages in thread
From: Simon Marchi @ 2022-11-23 18:39 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

This one is already in a proc, just make the proc use proc_with_prefix,
for consistency.

Change-Id: I313ecf5097ff04526c29396529baeba84e37df5a
---
 gdb/testsuite/gdb.base/break.exp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.base/break.exp b/gdb/testsuite/gdb.base/break.exp
index 7e410b4adeec..a888de8e2715 100644
--- a/gdb/testsuite/gdb.base/break.exp
+++ b/gdb/testsuite/gdb.base/break.exp
@@ -692,7 +692,7 @@ gdb_test_multiple "finish" "finish from outermost frame disallowed" {
 # Test "next" over recursive function call.
 #
 
-proc test_next_with_recursion {} { 
+proc_with_prefix test_next_with_recursion {} {
     global gdb_prompt
     global decimal
     global binfile
-- 
2.38.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 06/14] gdb/testsuite/gdb.base/break.exp: split test_finish_arguments
  2022-11-23 18:39 [PATCH 00/14] Break up gdb.base/break.exp in multiple procs Simon Marchi
                   ` (4 preceding siblings ...)
  2022-11-23 18:39 ` [PATCH 05/14] gdb/testsuite/gdb.base/break.exp: use proc_with_prefix for test_next_with_recursion Simon Marchi
@ 2022-11-23 18:39 ` Simon Marchi
  2022-11-23 18:39 ` [PATCH 07/14] gdb/testsuite/gdb.base/break.exp: split test_break_user_call Simon Marchi
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 17+ messages in thread
From: Simon Marchi @ 2022-11-23 18:39 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

Change-Id: Id84babed1eeb3ce7d14b94ff332795964e8ead51
---
 gdb/testsuite/gdb.base/break.exp | 50 ++++++++++++++++++--------------
 1 file changed, 28 insertions(+), 22 deletions(-)

diff --git a/gdb/testsuite/gdb.base/break.exp b/gdb/testsuite/gdb.base/break.exp
index a888de8e2715..1f6c620ee0cb 100644
--- a/gdb/testsuite/gdb.base/break.exp
+++ b/gdb/testsuite/gdb.base/break.exp
@@ -656,35 +656,41 @@ gdb_test_multiple "finish" "finish from called function" {
 
 # Verify that GDB responds gracefully to a "finish" command with
 # arguments.
-#
-if ![runto_main] then {
-    return
-}
 
-send_gdb "finish 123\n"
-gdb_expect {
-  -re "The \"finish\" command does not take any arguments.\r\n$gdb_prompt $"\
-          {pass "finish with arguments disallowed"}
-  -re "$gdb_prompt $"\
-          {fail "finish with arguments disallowed"}
-  timeout {fail "(timeout) finish with arguments disallowed"}
-}
+proc_with_prefix test_finish_arguments {} {
+    clean_restart break
 
-# Verify that GDB responds gracefully to a request to "finish" from
-# the outermost frame.  On a stub that never exits, this will just
-# run to the stubs routine, so we don't get this error...  Thus the 
-# second condition.
-#
+    if ![runto_main] then {
+	return
+    }
 
-gdb_test_multiple "finish" "finish from outermost frame disallowed" {
-    -re "\"finish\" not meaningful in the outermost frame.\r\n$gdb_prompt $" {
-	pass "finish from outermost frame disallowed"
+    send_gdb "finish 123\n"
+    gdb_expect {
+      -re "The \"finish\" command does not take any arguments.\r\n$::gdb_prompt $"\
+	      {pass "finish with arguments disallowed"}
+      -re "$::gdb_prompt $"\
+	      {fail "finish with arguments disallowed"}
+      timeout {fail "(timeout) finish with arguments disallowed"}
     }
-    -re "Run till exit from.*\r\n$gdb_prompt $" {
-	pass "finish from outermost frame disallowed"
+
+    # Verify that GDB responds gracefully to a request to "finish" from
+    # the outermost frame.  On a stub that never exits, this will just
+    # run to the stubs routine, so we don't get this error...  Thus the
+    # second condition.
+    #
+
+    gdb_test_multiple "finish" "finish from outermost frame disallowed" {
+	-re "\"finish\" not meaningful in the outermost frame.\r\n$::gdb_prompt $" {
+	    pass "finish from outermost frame disallowed"
+	}
+	-re "Run till exit from.*\r\n$::gdb_prompt $" {
+	    pass "finish from outermost frame disallowed"
+	}
     }
 }
 
+test_finish_arguments
+
 #********
 
 
-- 
2.38.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 07/14] gdb/testsuite/gdb.base/break.exp: split test_break_user_call
  2022-11-23 18:39 [PATCH 00/14] Break up gdb.base/break.exp in multiple procs Simon Marchi
                   ` (5 preceding siblings ...)
  2022-11-23 18:39 ` [PATCH 06/14] gdb/testsuite/gdb.base/break.exp: split test_finish_arguments Simon Marchi
@ 2022-11-23 18:39 ` Simon Marchi
  2022-11-23 18:39 ` [PATCH 08/14] gdb/testsuite/gdb.base/break.exp: split test_break_line_convenience_var Simon Marchi
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 17+ messages in thread
From: Simon Marchi @ 2022-11-23 18:39 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

Change-Id: I9151ce9db9435722b758f41c6606b461bf15f320
---
 gdb/testsuite/gdb.base/break.exp | 54 +++++++++++++++++++-------------
 1 file changed, 32 insertions(+), 22 deletions(-)

diff --git a/gdb/testsuite/gdb.base/break.exp b/gdb/testsuite/gdb.base/break.exp
index 1f6c620ee0cb..d9cfeb9b21f0 100644
--- a/gdb/testsuite/gdb.base/break.exp
+++ b/gdb/testsuite/gdb.base/break.exp
@@ -626,34 +626,44 @@ with_test_prefix "set line breakpoint via convenience variable" {
 }
 
 # Verify that we can set and trigger a breakpoint in a user-called function.
-#
-gdb_test "break marker2" \
-    "Breakpoint (\[0-9\]*) at .*, line $bp_location8.*" \
-    "set breakpoint on to-be-called function"
-
-gdb_test "print marker2(99)" \
-    "The program being debugged stopped while in a function called from GDB.\r\nEvaluation of the expression containing the function\r\n.[func marker2]. will be abandoned.\r\nWhen the function is done executing, GDB will silently stop.*" \
-    "hit breakpoint on called function"
 
-# As long as we're stopped (breakpointed) in a called function,
-# verify that we can successfully backtrace & such from here.
-gdb_test "bt" \
-    "#0\[ \t\]*($hex in )?marker2.*:$bp_location8\r\n#1\[ \t\]*<function called from gdb>.*" \
-    "backtrace while in called function"
+proc_with_prefix test_break_user_call {} {
+    clean_restart break
 
-# Return from the called function.  For remote targets, it's important to do
-# this before runto_main, which otherwise may silently stop on the dummy
-# breakpoint inserted by GDB at the program's entry point.
-#
-gdb_test_multiple "finish" "finish from called function" {
-    -re "Run till exit from .*marker2.* at .*$bp_location8\r\n.*function called from gdb.*$gdb_prompt $" {
-	pass "finish from called function"
+    if { ![runto_main] } {
+	return
     }
-    -re "Run till exit from .*marker2.* at .*$bp_location8\r\n.*Value returned.*$gdb_prompt $" {
-	pass "finish from called function"
+
+    gdb_test "break marker2" \
+	"Breakpoint (\[0-9\]*) at .*, line $::bp_location8.*" \
+	"set breakpoint on to-be-called function"
+
+    gdb_test "print marker2(99)" \
+	"The program being debugged stopped while in a function called from GDB.\r\nEvaluation of the expression containing the function\r\n.[func marker2]. will be abandoned.\r\nWhen the function is done executing, GDB will silently stop.*" \
+	"hit breakpoint on called function"
+
+    # As long as we're stopped (breakpointed) in a called function,
+    # verify that we can successfully backtrace & such from here.
+    gdb_test "bt" \
+	"#0\[ \t\]*($::hex in )?marker2.*:$::bp_location8\r\n#1\[ \t\]*<function called from gdb>.*" \
+	"backtrace while in called function"
+
+    # Return from the called function.  For remote targets, it's important to do
+    # this before runto_main, which otherwise may silently stop on the dummy
+    # breakpoint inserted by GDB at the program's entry point.
+    #
+    gdb_test_multiple "finish" "finish from called function" {
+	-re "Run till exit from .*marker2.* at .*$::bp_location8\r\n.*function called from gdb.*$::gdb_prompt $" {
+	    pass "finish from called function"
+	}
+	-re "Run till exit from .*marker2.* at .*$::bp_location8\r\n.*Value returned.*$::gdb_prompt $" {
+	    pass "finish from called function"
+	}
     }
 }
 
+test_break_user_call
+
 # Verify that GDB responds gracefully to a "finish" command with
 # arguments.
 
-- 
2.38.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 08/14] gdb/testsuite/gdb.base/break.exp: split test_break_line_convenience_var
  2022-11-23 18:39 [PATCH 00/14] Break up gdb.base/break.exp in multiple procs Simon Marchi
                   ` (6 preceding siblings ...)
  2022-11-23 18:39 ` [PATCH 07/14] gdb/testsuite/gdb.base/break.exp: split test_break_user_call Simon Marchi
@ 2022-11-23 18:39 ` Simon Marchi
  2022-11-23 18:39 ` [PATCH 09/14] gdb/testsuite/gdb.base/break.exp: split test_break_silent_and_more Simon Marchi
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 17+ messages in thread
From: Simon Marchi @ 2022-11-23 18:39 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

Change-Id: I593002373da971a0a4d6b5355d3fe321873479ab
---
 gdb/testsuite/gdb.base/break.exp | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/gdb/testsuite/gdb.base/break.exp b/gdb/testsuite/gdb.base/break.exp
index d9cfeb9b21f0..cc327c195f46 100644
--- a/gdb/testsuite/gdb.base/break.exp
+++ b/gdb/testsuite/gdb.base/break.exp
@@ -604,18 +604,22 @@ gdb_test "break marker3" "Breakpoint.*at.*" "break marker3 #2"
 gdb_test "clear marker3" {Deleted breakpoints [0-9]+ [0-9]+.*}
 
 # Verify that a breakpoint can be set via a convenience variable.
-#
 
-with_test_prefix "set line breakpoint via convenience variable" {
-    gdb_test_no_output "set \$foo=$bp_location11" \
+proc_with_prefix test_break_line_convenience_var {} {
+    clean_restart break
+
+    if { ![runto_main] } {
+	return
+    }
+
+    gdb_test_no_output "set \$foo=$::bp_location11" \
 	"set convenience variable \$foo to bp_location11"
 
     gdb_test "break \$foo" \
-	"Breakpoint (\[0-9\]*) at .*, line $bp_location11.*"
+	"Breakpoint (\[0-9\]*) at .*, line $::bp_location11.*"
 
     # Verify that GDB responds gracefully to an attempt to set a
     # breakpoint via a convenience variable whose type is not integer.
-    #
 
     gdb_test_no_output "set \$foo=81.5" \
 	"set convenience variable \$foo to 81.5"
@@ -625,6 +629,8 @@ with_test_prefix "set line breakpoint via convenience variable" {
 	"non-integer convenience variable disallowed"
 }
 
+test_break_line_convenience_var
+
 # Verify that we can set and trigger a breakpoint in a user-called function.
 
 proc_with_prefix test_break_user_call {} {
-- 
2.38.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 09/14] gdb/testsuite/gdb.base/break.exp: split test_break_silent_and_more
  2022-11-23 18:39 [PATCH 00/14] Break up gdb.base/break.exp in multiple procs Simon Marchi
                   ` (7 preceding siblings ...)
  2022-11-23 18:39 ` [PATCH 08/14] gdb/testsuite/gdb.base/break.exp: split test_break_line_convenience_var Simon Marchi
@ 2022-11-23 18:39 ` Simon Marchi
  2022-11-23 18:39 ` [PATCH 10/14] gdb/testsuite/gdb.base/break.exp: split test_break_default Simon Marchi
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 17+ messages in thread
From: Simon Marchi @ 2022-11-23 18:39 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

This one is a bit tricky.  The clear tests seem to depend on the various
breakpoints that have been set before, starting with the "silent"
breakpoints.  So, move all this in a single chunk, it can always be
split later if needed.

Change-Id: I7ba61a5b130ade63eda0c4790534840339f8a72f
---
 gdb/testsuite/gdb.base/break.exp | 118 ++++++++++++++++---------------
 1 file changed, 62 insertions(+), 56 deletions(-)

diff --git a/gdb/testsuite/gdb.base/break.exp b/gdb/testsuite/gdb.base/break.exp
index cc327c195f46..e8762ffa664c 100644
--- a/gdb/testsuite/gdb.base/break.exp
+++ b/gdb/testsuite/gdb.base/break.exp
@@ -533,75 +533,81 @@ gdb_test "break if (1)" \
 
 # Verify that a "silent" breakpoint can be set, and that GDB is indeed
 # "silent" about its triggering.
-#
-if ![runto_main] then {
-    return
-}
 
-gdb_test_multiple "break $bp_location1" \
-    "set to-be-silent break bp_location1" {
-	-re "Breakpoint (\[0-9\]*) at .*, line $bp_location1.*$gdb_prompt $" {
-	    set bpno $expect_out(1,string)
-	    pass "set to-be-silent break bp_location1"
-	}
+proc_with_prefix test_break_silent_and_more {} {
+    clean_restart break
+
+    if ![runto_main] then {
+	return
     }
 
-gdb_test "commands $bpno\nsilent\nend" ">end" "set silent break bp_location1"
+    gdb_test_multiple "break $::bp_location1" \
+	"set to-be-silent break bp_location1" {
+	    -re "Breakpoint (\[0-9\]*) at .*, line $::bp_location1.*$::gdb_prompt $" {
+		set bpno $expect_out(1,string)
+		pass "set to-be-silent break bp_location1"
+	    }
+	}
 
-gdb_test "info break $bpno" \
-    "\[0-9\]*\[ \t\]*breakpoint.*:$bp_location1\r\n\[ \t\]*silent.*" \
-    "info silent break bp_location1"
+    gdb_test "commands $bpno\nsilent\nend" ">end" "set silent break bp_location1"
 
-gdb_test "continue" "Continuing." \
-    "hit silent break bp_location1"
+    gdb_test "info break $bpno" \
+	"\[0-9\]*\[ \t\]*breakpoint.*:$::bp_location1\r\n\[ \t\]*silent.*" \
+	"info silent break bp_location1"
 
-gdb_test "bt" "#0  main .* at .*:$bp_location1.*" \
-    "stopped for silent break bp_location1"
+    gdb_test "continue" "Continuing." \
+	"hit silent break bp_location1"
 
-# Verify the $_hit_bpnum convenience variable is set to the silent hit bpno.
-gdb_test "printf \"%d\\n\", \$_hit_bpnum" "$bpno" \
-    "Silent breakpoint hit \$_hit_bpnum is silent $bpno"
- 
-# Verify that GDB can at least parse a breakpoint with the
-# "thread" keyword.  (We won't attempt to test here that a
-# thread-specific breakpoint really triggers appropriately.
-# The gdb.threads subdirectory contains tests for that.)
-#
-set bp_location12 [gdb_get_line_number "set breakpoint 12 here"]
-gdb_test "break $bp_location12 thread 999" "Unknown thread 999.*" \
-    "thread-specific breakpoint on non-existent thread disallowed"
+    gdb_test "bt" "#0  main .* at .*:$::bp_location1.*" \
+	"stopped for silent break bp_location1"
 
-gdb_test "break $bp_location12 thread foo" \
-    "Invalid thread ID: foo" \
-    "thread-specific breakpoint on bogus thread ID disallowed"
+    # Verify the $_hit_bpnum convenience variable is set to the silent hit bpno.
+    gdb_test "printf \"%d\\n\", \$_hit_bpnum" "$bpno" \
+	"Silent breakpoint hit \$_hit_bpnum is silent $bpno"
 
-# Verify that GDB responds gracefully to a breakpoint command with
-# trailing garbage.
-#
-gdb_test "break $bp_location12 foo" \
-    "malformed linespec error: unexpected string, \"foo\".*" \
-    "breakpoint with trailing garbage disallowed"
+    # Verify that GDB can at least parse a breakpoint with the
+    # "thread" keyword.  (We won't attempt to test here that a
+    # thread-specific breakpoint really triggers appropriately.
+    # The gdb.threads subdirectory contains tests for that.)
+    #
+    set bp_location12 [gdb_get_line_number "set breakpoint 12 here"]
+    gdb_test "break $bp_location12 thread 999" "Unknown thread 999.*" \
+	"thread-specific breakpoint on non-existent thread disallowed"
 
-# Verify that GDB responds gracefully to a "clear" command that has
-# no matching breakpoint.  (First, get us off the current source line,
-# which we know has a breakpoint.)
-#
-gdb_test "next" "marker1.*" "step over breakpoint"
+    gdb_test "break $bp_location12 thread foo" \
+	"Invalid thread ID: foo" \
+	"thread-specific breakpoint on bogus thread ID disallowed"
 
-gdb_test "clear 81" "No breakpoint at 81.*" \
-    "clear line has no breakpoint disallowed"
+    # Verify that GDB responds gracefully to a breakpoint command with
+    # trailing garbage.
+    #
+    gdb_test "break $bp_location12 foo" \
+	"malformed linespec error: unexpected string, \"foo\".*" \
+	"breakpoint with trailing garbage disallowed"
 
-gdb_test "clear" "No breakpoint at this line.*" \
-    "clear current line has no breakpoint disallowed"
+    # Verify that GDB responds gracefully to a "clear" command that has
+    # no matching breakpoint.  (First, get us off the current source line,
+    # which we know has a breakpoint.)
+    #
+    gdb_test "next" "marker1.*" "step over breakpoint"
 
-# Verify that we can set and clear multiple breakpoints.
-#
-# We don't test that it deletes the correct breakpoints.  We do at
-# least test that it deletes more than one breakpoint.
-#
-gdb_test "break marker3" "Breakpoint.*at.*" "break marker3 #1"
-gdb_test "break marker3" "Breakpoint.*at.*" "break marker3 #2"
-gdb_test "clear marker3" {Deleted breakpoints [0-9]+ [0-9]+.*}
+    gdb_test "clear 81" "No breakpoint at 81.*" \
+	"clear line has no breakpoint disallowed"
+
+    gdb_test "clear" "No breakpoint at this line.*" \
+	"clear current line has no breakpoint disallowed"
+
+    # Verify that we can set and clear multiple breakpoints.
+    #
+    # We don't test that it deletes the correct breakpoints.  We do at
+    # least test that it deletes more than one breakpoint.
+    #
+    gdb_test "break marker3" "Breakpoint.*at.*" "break marker3 #1"
+    gdb_test "break marker3" "Breakpoint.*at.*" "break marker3 #2"
+    gdb_test "clear marker3" {Deleted breakpoints [0-9]+ [0-9]+.*}
+}
+
+test_break_silent_and_more
 
 # Verify that a breakpoint can be set via a convenience variable.
 
-- 
2.38.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 10/14] gdb/testsuite/gdb.base/break.exp: split test_break_default
  2022-11-23 18:39 [PATCH 00/14] Break up gdb.base/break.exp in multiple procs Simon Marchi
                   ` (8 preceding siblings ...)
  2022-11-23 18:39 ` [PATCH 09/14] gdb/testsuite/gdb.base/break.exp: split test_break_silent_and_more Simon Marchi
@ 2022-11-23 18:39 ` Simon Marchi
  2022-11-23 18:39 ` [PATCH 11/14] gdb/testsuite/gdb.base/break.exp: split test_break_nonexistent_line Simon Marchi
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 17+ messages in thread
From: Simon Marchi @ 2022-11-23 18:39 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

One special thing here is that the part just above this one, that sets
catchpoints and verifies they are not hit, requires that we resume
execution to verify that the catchpoints are indeed not hit.   I guess
it was previously achieved by the until command, but it doesn't happen
now that the until is moved into test_break_default.  Add a
gdb_continue_to_end after setting the catchpoints.  If any catchpoint
were to be hit, it would catch the problem.

Change-Id: I5d4b43da91886b1beda9f6e56b05aa04331a9c05
---
 gdb/testsuite/gdb.base/break.exp | 62 +++++++++++++++++++-------------
 1 file changed, 37 insertions(+), 25 deletions(-)

diff --git a/gdb/testsuite/gdb.base/break.exp b/gdb/testsuite/gdb.base/break.exp
index e8762ffa664c..b4d12cb56a92 100644
--- a/gdb/testsuite/gdb.base/break.exp
+++ b/gdb/testsuite/gdb.base/break.exp
@@ -492,6 +492,8 @@ gdb_test "catch vfork" "Catchpoint \[0-9\]+ \\(vfork\\)" \
 gdb_test "catch exec" "Catchpoint \[0-9\]+ \\(exec\\)" \
     "set catch exec, never expected to trigger"
 
+gdb_continue_to_end
+
 # Verify that GDB responds gracefully when asked to set a breakpoint
 # on a nonexistent source line.
 #
@@ -500,36 +502,46 @@ gdb_test "break 999" \
     "No line 999 in the current file." \
     "break on non-existent source line"
 
-# Run to the desired default location. If not positioned here, the
-# tests below don't work.
-#
-gdb_test "until $bp_location1" "main .* at .*:$bp_location1.*" \
-    "until bp_location1"
+proc_with_prefix test_break_default {} {
+    clean_restart break
 
-# Verify that GDB allows one to just say "break", which is treated
-# as the "default" breakpoint.  Note that GDB gets cute when printing
-# the informational message about other breakpoints at the same
-# location.  We'll hit that bird with this stone too.
-#
-gdb_test "break" "Breakpoint \[0-9\]*.*" \
-    "break on default location, 1st time"
+    if ![runto_main] then {
+	return
+    }
 
-gdb_test "break" \
-    "Note: breakpoint \[0-9\]* also set at .*Breakpoint \[0-9\]*.*" \
-    "break on default location, 2nd time"
+    # Run to the desired default location. If not positioned here, the
+    # tests below don't work.
+    #
+    gdb_test "until $::bp_location1" "main .* at .*:$::bp_location1.*" \
+	"until bp_location1"
+
+    # Verify that GDB allows one to just say "break", which is treated
+    # as the "default" breakpoint.  Note that GDB gets cute when printing
+    # the informational message about other breakpoints at the same
+    # location.  We'll hit that bird with this stone too.
+    #
+    gdb_test "break" "Breakpoint \[0-9\]*.*" \
+	"break on default location, 1st time"
 
-gdb_test "break" \
-    "Note: breakpoints \[0-9\]* and \[0-9\]* also set at .*Breakpoint \[0-9\]*.*" \
-    "break on default location, 3rd time"
+    gdb_test "break" \
+	"Note: breakpoint \[0-9\]* also set at .*Breakpoint \[0-9\]*.*" \
+	"break on default location, 2nd time"
 
-gdb_test "break" \
-    "Note: breakpoints \[0-9\]*, \[0-9\]* and \[0-9\]* also set at .*Breakpoint \[0-9\]*.*" \
-    "break on default location, 4th time"
+    gdb_test "break" \
+	"Note: breakpoints \[0-9\]* and \[0-9\]* also set at .*Breakpoint \[0-9\]*.*" \
+	"break on default location, 3rd time"
+
+    gdb_test "break" \
+	"Note: breakpoints \[0-9\]*, \[0-9\]* and \[0-9\]* also set at .*Breakpoint \[0-9\]*.*" \
+	"break on default location, 4th time"
+
+    # Check setting a breakpoint at the default location with a condition attached.
+    gdb_test "break if (1)" \
+	"Note: breakpoints \[0-9\]*, \[0-9\]*, \[0-9\]* and \[0-9\]* also set at .*Breakpoint \[0-9\]*.*" \
+	"break on the default location, 5th time, but with a condition"
+}
 
-# Check setting a breakpoint at the default location with a condition attached.
-gdb_test "break if (1)" \
-    "Note: breakpoints \[0-9\]*, \[0-9\]*, \[0-9\]* and \[0-9\]* also set at .*Breakpoint \[0-9\]*.*" \
-    "break on the default location, 5th time, but with a condition"
+test_break_default
 
 # Verify that a "silent" breakpoint can be set, and that GDB is indeed
 # "silent" about its triggering.
-- 
2.38.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 11/14] gdb/testsuite/gdb.base/break.exp: split test_break_nonexistent_line
  2022-11-23 18:39 [PATCH 00/14] Break up gdb.base/break.exp in multiple procs Simon Marchi
                   ` (9 preceding siblings ...)
  2022-11-23 18:39 ` [PATCH 10/14] gdb/testsuite/gdb.base/break.exp: split test_break_default Simon Marchi
@ 2022-11-23 18:39 ` Simon Marchi
  2022-11-23 18:39 ` [PATCH 12/14] gdb/testsuite/gdb.base/break.exp: split test_no_break_on_catchpoint Simon Marchi
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 17+ messages in thread
From: Simon Marchi @ 2022-11-23 18:39 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

Change-Id: I4390dd5da23bae83ccc513ad0de0169ddff7df12
---
 gdb/testsuite/gdb.base/break.exp | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/gdb/testsuite/gdb.base/break.exp b/gdb/testsuite/gdb.base/break.exp
index b4d12cb56a92..a5ef521a4b0a 100644
--- a/gdb/testsuite/gdb.base/break.exp
+++ b/gdb/testsuite/gdb.base/break.exp
@@ -496,11 +496,21 @@ gdb_continue_to_end
 
 # Verify that GDB responds gracefully when asked to set a breakpoint
 # on a nonexistent source line.
-#
-gdb_test_no_output "set breakpoint pending off"
-gdb_test "break 999" \
-    "No line 999 in the current file." \
-    "break on non-existent source line"
+
+proc_with_prefix test_break_nonexistent_line {} {
+    clean_restart break
+
+    if ![runto_main] then {
+	return
+    }
+
+    gdb_test_no_output "set breakpoint pending off"
+    gdb_test "break 999" \
+	"No line 999 in the current file." \
+	"break on non-existent source line"
+}
+
+test_break_nonexistent_line
 
 proc_with_prefix test_break_default {} {
     clean_restart break
-- 
2.38.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 12/14] gdb/testsuite/gdb.base/break.exp: split test_no_break_on_catchpoint
  2022-11-23 18:39 [PATCH 00/14] Break up gdb.base/break.exp in multiple procs Simon Marchi
                   ` (10 preceding siblings ...)
  2022-11-23 18:39 ` [PATCH 11/14] gdb/testsuite/gdb.base/break.exp: split test_break_nonexistent_line Simon Marchi
@ 2022-11-23 18:39 ` Simon Marchi
  2022-11-23 18:39 ` [PATCH 13/14] gdb/testsuite/gdb.base/break.exp: split test_tbreak Simon Marchi
                   ` (2 subsequent siblings)
  14 siblings, 0 replies; 17+ messages in thread
From: Simon Marchi @ 2022-11-23 18:39 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

Change-Id: Ifa7070943f1de22c2839fedf5f346d6591bb5a76
---
 gdb/testsuite/gdb.base/break.exp | 28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/gdb/testsuite/gdb.base/break.exp b/gdb/testsuite/gdb.base/break.exp
index a5ef521a4b0a..4a2f130ff290 100644
--- a/gdb/testsuite/gdb.base/break.exp
+++ b/gdb/testsuite/gdb.base/break.exp
@@ -478,21 +478,27 @@ gdb_test "info break" "Num     Type.*Disp Enb Address.*What.*\[\r\n\]
 # Verify that catchpoints for fork, vfork and exec don't trigger
 # inappropriately.  (There are no calls to those system functions
 # in this test program.)
-#
-if ![runto_main] then {
-    return
-}
 
-gdb_test "catch fork" "Catchpoint \[0-9\]+ \\(fork\\)" \
-    "set catch fork, never expected to trigger"
+proc_with_prefix test_no_break_on_catchpoint {} {
+    clean_restart break
+
+    if ![runto_main] then {
+	return
+    }
+
+    gdb_test "catch fork" "Catchpoint \[0-9\]+ \\(fork\\)" \
+	"set catch fork, never expected to trigger"
 
-gdb_test "catch vfork" "Catchpoint \[0-9\]+ \\(vfork\\)" \
-    "set catch vfork, never expected to trigger"
+    gdb_test "catch vfork" "Catchpoint \[0-9\]+ \\(vfork\\)" \
+	"set catch vfork, never expected to trigger"
 
-gdb_test "catch exec" "Catchpoint \[0-9\]+ \\(exec\\)" \
-    "set catch exec, never expected to trigger"
+    gdb_test "catch exec" "Catchpoint \[0-9\]+ \\(exec\\)" \
+	"set catch exec, never expected to trigger"
+
+    gdb_continue_to_end
+}
 
-gdb_continue_to_end
+test_no_break_on_catchpoint
 
 # Verify that GDB responds gracefully when asked to set a breakpoint
 # on a nonexistent source line.
-- 
2.38.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 13/14] gdb/testsuite/gdb.base/break.exp: split test_tbreak
  2022-11-23 18:39 [PATCH 00/14] Break up gdb.base/break.exp in multiple procs Simon Marchi
                   ` (11 preceding siblings ...)
  2022-11-23 18:39 ` [PATCH 12/14] gdb/testsuite/gdb.base/break.exp: split test_no_break_on_catchpoint Simon Marchi
@ 2022-11-23 18:39 ` Simon Marchi
  2022-11-23 18:39 ` [PATCH 14/14] gdb/testsuite/gdb.base/break.exp: split test_break Simon Marchi
  2022-11-24  3:03 ` [PATCH 00/14] Break up gdb.base/break.exp in multiple procs Kevin Buettner
  14 siblings, 0 replies; 17+ messages in thread
From: Simon Marchi @ 2022-11-23 18:39 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

Leave setting bp_location11 in the global scope, so that it's accessible
to other procs.

Change-Id: I8928f01640d3a1e993649b2168b9eda0724ee1d9
---
 gdb/testsuite/gdb.base/break.exp | 82 ++++++++++++++------------------
 1 file changed, 36 insertions(+), 46 deletions(-)

diff --git a/gdb/testsuite/gdb.base/break.exp b/gdb/testsuite/gdb.base/break.exp
index 4a2f130ff290..1aa9476c0cf9 100644
--- a/gdb/testsuite/gdb.base/break.exp
+++ b/gdb/testsuite/gdb.base/break.exp
@@ -423,55 +423,45 @@ gdb_test "continue" \
     ".*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location10a.*$bp_location10a\[\t \]+}.*breakpoint 10a here.*" \
     "continue to breakpoint at }"
 
-#
-# delete all breakpoints so we can start over, course this can be a test too
-#
-delete_breakpoints
-
-#
-# test temporary breakpoint at function
-#
-
-gdb_test "tbreak -q main" "Temporary breakpoint.*at.* file .*$srcfile, line.*" "temporary breakpoint function"
-
-#
-# test break at function in file
-#
-
-gdb_test "tbreak $srcfile:factorial" "Temporary breakpoint.*at.* file .*$srcfile, line.*" \
-	"Temporary breakpoint function in file"
-
-#
-# test break at line number
-#
-gdb_test "tbreak $bp_location1" \
-    "Temporary breakpoint.*at.* file .*$srcfile, line $bp_location1.*" \
-    "temporary breakpoint line number #1"
-
-gdb_test "tbreak $bp_location6" "Temporary breakpoint.*at.* file .*$srcfile, line $bp_location6.*" "temporary breakpoint line number #2"
-
-#
-# test break at line number in file
-#
-gdb_test "tbreak $srcfile:$bp_location2" \
-    "Temporary breakpoint.*at.* file .*$srcfile, line $bp_location2.*" \
-    "temporary breakpoint line number in file #1"
-
 set bp_location11 [gdb_get_line_number "set breakpoint 11 here"]
-gdb_test  "tbreak $srcfile:$bp_location11" "Temporary breakpoint.*at.* file .*$srcfile, line $bp_location11.*" "Temporary breakpoint line number in file #2"
 
-#
-# check to see what breakpoints are set (temporary this time)
-#
-gdb_test "info break" "Num     Type.*Disp Enb Address.*What.*\[\r\n\]
-\[0-9\]+\[\t \]+breakpoint     del.*y.*in [func main] at .*$srcfile:$main_line.*\[\r\n\]
-\[0-9\]+\[\t \]+breakpoint     del.*y.*in [func factorial] at .*$srcfile:$bp_location7.*\[\r\n\]
-\[0-9\]+\[\t \]+breakpoint     del.*y.*in [func main] at .*$srcfile:$bp_location1.*\[\r\n\]
-\[0-9\]+\[\t \]+breakpoint     del.*y.*in [func main] at .*$srcfile:$bp_location6.*\[\r\n\]
-\[0-9\]+\[\t \]+breakpoint     del.*y.*in [func main] at .*$srcfile:$bp_location2.*\[\r\n\]
-\[0-9\]+\[\t \]+breakpoint     del.*y.*in [func main] at .*$srcfile:$bp_location11.*" \
-    "Temporary breakpoint info"
+proc_with_prefix test_tbreak {} {
+    clean_restart break
+
+    # test temporary breakpoint at function
+    gdb_test "tbreak -q main" "Temporary breakpoint.*at.* file .*$::srcfile, line.*" "temporary breakpoint function"
+
+    # test break at function in file
+    gdb_test "tbreak $::srcfile:factorial" "Temporary breakpoint.*at.* file .*$::srcfile, line.*" \
+	    "Temporary breakpoint function in file"
+
+    # test break at line number
+    gdb_test "tbreak $::bp_location1" \
+	"Temporary breakpoint.*at.* file .*$::srcfile, line $::bp_location1.*" \
+	"temporary breakpoint line number #1"
+
+    gdb_test "tbreak $::bp_location6" "Temporary breakpoint.*at.* file .*$::srcfile, line $::bp_location6.*" "temporary breakpoint line number #2"
+
+    # test break at line number in file
+    gdb_test "tbreak $::srcfile:$::bp_location2" \
+	"Temporary breakpoint.*at.* file .*$::srcfile, line $::bp_location2.*" \
+	"temporary breakpoint line number in file #1"
+
+    gdb_test  "tbreak $::srcfile:$::bp_location11" "Temporary breakpoint.*at.* file .*$::srcfile, line $::bp_location11.*" "Temporary breakpoint line number in file #2"
+
+    # check to see what breakpoints are set (temporary this time)
+    gdb_test "info break" \
+	[multi_line "Num     Type.*Disp Enb Address.*What.*" \
+		    "$::decimal\[\t \]+breakpoint     del.*y.*in [func main] at .*$::srcfile:$::main_line.*" \
+		    "$::decimal\[\t \]+breakpoint     del.*y.*in [func factorial] at .*$::srcfile:$::bp_location7.*" \
+		    "$::decimal\[\t \]+breakpoint     del.*y.*in [func main] at .*$::srcfile:$::bp_location1.*" \
+		    "$::decimal\[\t \]+breakpoint     del.*y.*in [func main] at .*$::srcfile:$::bp_location6.*" \
+		    "$::decimal\[\t \]+breakpoint     del.*y.*in [func main] at .*$::srcfile:$::bp_location2.*" \
+		    "$::decimal\[\t \]+breakpoint     del.*y.*in [func main] at .*$::srcfile:$::bp_location11.*"] \
+	"Temporary breakpoint info"
+}
 
+test_tbreak
 
 #***********
 
-- 
2.38.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 14/14] gdb/testsuite/gdb.base/break.exp: split test_break
  2022-11-23 18:39 [PATCH 00/14] Break up gdb.base/break.exp in multiple procs Simon Marchi
                   ` (12 preceding siblings ...)
  2022-11-23 18:39 ` [PATCH 13/14] gdb/testsuite/gdb.base/break.exp: split test_tbreak Simon Marchi
@ 2022-11-23 18:39 ` Simon Marchi
  2022-11-24  3:03 ` [PATCH 00/14] Break up gdb.base/break.exp in multiple procs Kevin Buettner
  14 siblings, 0 replies; 17+ messages in thread
From: Simon Marchi @ 2022-11-23 18:39 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

Move all the remaining tests to a single test_break proc.  It's a bit
big, but all of these are kind of tied together.  The procs starts by
setting breakpoints, checks that we can see them in "info breakpoints",
and tries stopping on them.

Move all the "set bp_locationX" calls together at the top.

Change-Id: Id05f98957e1a3462532d2dbd577cd0a7c7263900
---
 gdb/testsuite/gdb.base/break.exp | 600 +++++++++++++++----------------
 1 file changed, 293 insertions(+), 307 deletions(-)

diff --git a/gdb/testsuite/gdb.base/break.exp b/gdb/testsuite/gdb.base/break.exp
index 1aa9476c0cf9..258c468ed001 100644
--- a/gdb/testsuite/gdb.base/break.exp
+++ b/gdb/testsuite/gdb.base/break.exp
@@ -15,111 +15,22 @@
 
 # This file was written by Rob Savoye. (rob@cygnus.com)
 
-if { [prepare_for_testing "failed to prepare" "break" {break.c break1.c} {debug nowarnings}] } {
+if { [build_executable "failed to prepare" "break" {break.c break1.c} {debug nowarnings}] } {
     return -1
 }
 set srcfile break.c
 set srcfile1 break1.c
-#
-# test simple breakpoint setting commands
-#
-
-# Test deleting all breakpoints when there are none installed,
-# GDB should not prompt for confirmation.
-# Note that lib/gdb.exp provides a "delete_breakpoints" proc
-# for general use elsewhere.
-
-send_gdb "delete breakpoints\n"
-gdb_expect {
-     -re "Delete all breakpoints.*$" {
-	    send_gdb "y\n"
-	    gdb_expect {
-		-re "$gdb_prompt $" {
-		    fail "delete all breakpoints when none (unexpected prompt)"
-		}
-		timeout	{ fail "delete all breakpoints when none (timeout after unexpected prompt)" }
-	    }
-	}
-     -re ".*$gdb_prompt $"       { pass "delete all breakpoints when none" }
-    timeout	            { fail "delete all breakpoints when none (timeout)" }
-}
-
-#
-# test break at function
-#
-gdb_test "break -q main" \
-    "Breakpoint.*at.* file .*$srcfile, line.*" \
-    "breakpoint function"
-
-#
-# test break at quoted function
-#
-gdb_test "break \"marker2\"" \
-    "Breakpoint.*at.* file .*$srcfile1, line.*" \
-    "breakpoint quoted function"
-
-#
-# test break at function in file
-#
-gdb_test "break $srcfile:factorial" \
-    "Breakpoint.*at.* file .*$srcfile, line.*" \
-    "breakpoint function in file"
 
 set bp_location1 [gdb_get_line_number "set breakpoint 1 here"]
-
-#
-# test break at line number
-#
-# Note that the default source file is the last one whose source text
-# was printed.  For native debugging, before we've executed the
-# program, this is the file containing main, but for remote debugging,
-# it's wherever the processor was stopped when we connected to the
-# board.  So, to be sure, we do a list command.
-#
-gdb_test "list -q main" \
-    ".*main \\(int argc, char \\*\\*argv, char \\*\\*envp\\).*" \
-    "use `list' to establish default source file"
-gdb_test "break $bp_location1" \
-    "Breakpoint.*at.* file .*$srcfile, line $bp_location1\\." \
-    "breakpoint line number"
-
-#
-# test duplicate breakpoint
-#
-gdb_test "break $bp_location1" \
-    "Note: breakpoint \[0-9\]+ also set at pc.*Breakpoint \[0-9\]+ at.* file .*$srcfile, line $bp_location1\\." \
-    "breakpoint duplicate"
-
 set bp_location2 [gdb_get_line_number "set breakpoint 2 here"]
-
-#
-# test break at line number in file
-#
-gdb_test "break $srcfile:$bp_location2" \
-    "Breakpoint.*at.* file .*$srcfile, line $bp_location2\\." \
-    "breakpoint line number in file"
-
 set bp_location3 [gdb_get_line_number "set breakpoint 3 here"]
 set bp_location4 [gdb_get_line_number "set breakpoint 4 here"]
-
-#
-# Test putting a break at the start of a multi-line if conditional.
-# Verify the breakpoint was put at the start of the conditional.
-#
-gdb_test "break multi_line_if_conditional" \
-    "Breakpoint.*at.* file .*$srcfile, line $bp_location3\\." \
-    "breakpoint at start of multi line if conditional"
-
-gdb_test "break multi_line_while_conditional" \
-    "Breakpoint.*at.* file .*$srcfile, line $bp_location4\\." \
-    "breakpoint at start of multi line while conditional"
-
 set bp_location6 [gdb_get_line_number "set breakpoint 6 here"]
-
-set main_line $bp_location6
-
 set bp_location7 [gdb_get_line_number "set breakpoint 7 here"]
 set bp_location8 [gdb_get_line_number "set breakpoint 8 here" $srcfile1]
+set bp_location11 [gdb_get_line_number "set breakpoint 11 here"]
+
+set main_line $bp_location6
 
 # In C++ mode, we see a full prototype; in C mode, we only see the
 # function name, with no parameter info.
@@ -127,120 +38,95 @@ proc func {name} {
     return "${name}(?:\(\[^\r\n\]*\))?"
 }
 
-gdb_test "info break" \
-    "Num     Type\[ \]+Disp Enb Address\[ \]+What.*
-\[0-9\]+\[\t \]+breakpoint     keep y.* in [func main] at .*$srcfile:$main_line.*
-\[0-9\]+\[\t \]+breakpoint     keep y.* in [func marker2] at .*$srcfile1:$bp_location8.*
-\[0-9\]+\[\t \]+breakpoint     keep y.* in [func factorial] at .*$srcfile:$bp_location7.*
-\[0-9\]+\[\t \]+breakpoint     keep y.* in [func main] at .*$srcfile:$bp_location1.*
-\[0-9\]+\[\t \]+breakpoint     keep y.* in [func main] at .*$srcfile:$bp_location1.*
-\[0-9\]+\[\t \]+breakpoint     keep y.* in [func main] at .*$srcfile:$bp_location2.*
-\[0-9\]+\[\t \]+breakpoint     keep y.* in [func multi_line_if_conditional] at .*$srcfile:$bp_location3.*
-\[0-9\]+\[\t \]+breakpoint     keep y.* in [func multi_line_while_conditional] at .*$srcfile:$bp_location4" \
-    "breakpoint info"
+# test simple breakpoint setting commands
 
-#
-# Test info breakpoint with arguments
-#
+proc_with_prefix test_break {} {
+    clean_restart break
 
-set see1 0
-set see2 0
-set see3 0
-set see4 0
-set see5 0
-set see6 0
-
-gdb_test_multiple "info break 2 4 6" "info break 2 4 6" {
-    -re "1\[\t \]+breakpoint *keep y\[^\r\n\]*:$main_line\[^\r\n\]*" {
-	set see1 1
-	exp_continue
-    }
-    -re "2\[\t \]+breakpoint *keep y\[^\r\n\]* in [func marker2] at \[^\r\n\]*" {
-	set see2 1
-	exp_continue
-    }
-    -re "3\[\t \]+breakpoint *keep y\[^\r\n\]*$bp_location7\[^\r\n\]*" {
-	set see3 1
-	exp_continue
-    }
-    -re "4\[\t \]+breakpoint *keep y\[^\r\n\]*$bp_location1\[^\r\n\]*" {
-	set see4 1
-	exp_continue
-    }
-    -re "5\[\t \]+breakpoint *keep y\[^\r\n\]*$bp_location1\[^\r\n\]*" {
-	set see5 1
-	exp_continue
-    }
-    -re "6\[\t \]+breakpoint *keep y\[^\r\n\]*$bp_location2\[^\r\n\]*" {
-	set see6 1
-	exp_continue
-    }
-    -re ".*$gdb_prompt $" {
-	if { !$see1 && $see2 && !$see3 && $see4 && !$see5 && $see6 } then {
-	    pass "info break 2 4 6"
-	} else {
-	    fail "info break 2 4 6"
-	}
+    # Test deleting all breakpoints when there are none installed,
+    # GDB should not prompt for confirmation.
+    # Note that lib/gdb.exp provides a "delete_breakpoints" proc
+    # for general use elsewhere.
+    send_gdb "delete breakpoints\n"
+    gdb_expect {
+	 -re "Delete all breakpoints.*$" {
+		send_gdb "y\n"
+		gdb_expect {
+		    -re "$::gdb_prompt $" {
+			fail "delete all breakpoints when none (unexpected prompt)"
+		    }
+		    timeout	{ fail "delete all breakpoints when none (timeout after unexpected prompt)" }
+		}
+	    }
+	 -re ".*$::gdb_prompt $"       { pass "delete all breakpoints when none" }
+	timeout	            { fail "delete all breakpoints when none (timeout)" }
     }
-}
 
-set see1 0
-set see2 0
-set see3 0
-set see4 0
-set see5 0
-set see6 0
-
-gdb_test_multiple "info break 3-5" "info break 3-5" {
-    -re "1\[\t \]+breakpoint *keep y.* in [func main] at .*:$main_line\[^\r\n\]*" {
-	set see1 1
-	exp_continue
-    }
-    -re "2\[\t \]+breakpoint *keep y\[^\r\n\]* in [func marker2] at \[^\r\n\]*" {
-	set see2 1
-	exp_continue
-    }
-    -re "3\[\t \]+breakpoint *keep y\[^\r\n\]*$bp_location7\[^\r\n\]*" {
-	set see3 1
-	exp_continue
-    }
-    -re "4\[\t \]+breakpoint *keep y\[^\r\n\]*$bp_location1\[^\r\n\]*" {
-	set see4 1
-	exp_continue
-    }
-    -re "5\[\t \]+breakpoint *keep y\[^\r\n\]*$bp_location1\[^\r\n\]*" {
-	set see5 1
-	exp_continue
-    }
-    -re "6\[\t \]+breakpoint *keep y\[^\r\n\]*$bp_location2\[^\r\n\]*" {
-	set see6 1
-	exp_continue
-    }
-    -re ".*$gdb_prompt $" {
-	if { !$see1 && !$see2 && $see3 && $see4 && $see5 && !$see6 } then {
-	    pass "info break 3-5"
-	} else {
-	    fail "info break 3-5"
-	}
-    }
-}
+    # test break at function
+    gdb_test "break -q main" \
+	"Breakpoint.*at.* file .*$::srcfile, line.*" \
+	"breakpoint function"
 
-#
-# Test disable/enable with arguments
-#
+    # test break at quoted function
+    gdb_test "break \"marker2\"" \
+	"Breakpoint.*at.* file .*$::srcfile1, line.*" \
+	"breakpoint quoted function"
 
-# Test with value history
+    # test break at function in file
+    gdb_test "break $::srcfile:factorial" \
+	"Breakpoint.*at.* file .*$::srcfile, line.*" \
+	"breakpoint function in file"
 
-with_test_prefix "with value history" {
-    gdb_test "print 1"
-    gdb_test "print 2"
-    gdb_test "print 3"
-    gdb_test "print 4"
-    gdb_test "print 5"
-    gdb_test "print 6"
+    # test break at line number
+    #
+    # Note that the default source file is the last one whose source text
+    # was printed.  For native debugging, before we've executed the
+    # program, this is the file containing main, but for remote debugging,
+    # it's wherever the processor was stopped when we connected to the
+    # board.  So, to be sure, we do a list command.
+    gdb_test "list -q main" \
+	".*main \\(int argc, char \\*\\*argv, char \\*\\*envp\\).*" \
+	"use `list' to establish default source file"
+
+    gdb_test "break $::bp_location1" \
+	"Breakpoint.*at.* file .*$::srcfile, line $::bp_location1\\." \
+	"breakpoint line number"
+
+    # test duplicate breakpoint
+    gdb_test "break $::bp_location1" \
+	"Note: breakpoint \[0-9\]+ also set at pc.*Breakpoint \[0-9\]+ at.* file .*$::srcfile, line $::bp_location1\\." \
+	"breakpoint duplicate"
+
+    # test break at line number in file
+    gdb_test "break $::srcfile:$::bp_location2" \
+	"Breakpoint.*at.* file .*$::srcfile, line $::bp_location2\\." \
+	"breakpoint line number in file"
+
+    # Test putting a break at the start of a multi-line if conditional.
+    # Verify the breakpoint was put at the start of the conditional.
+    gdb_test "break multi_line_if_conditional" \
+	"Breakpoint.*at.* file .*$::srcfile, line $::bp_location3\\." \
+	"breakpoint at start of multi line if conditional"
 
-    # $2 is 2 and $$ is 5
-    gdb_test_no_output "disable \$2 \$\$" "disable using history values"
+    gdb_test "break multi_line_while_conditional" \
+	"Breakpoint.*at.* file .*$::srcfile, line $::bp_location4\\." \
+	"breakpoint at start of multi line while conditional"
+
+    gdb_test "info break" \
+	[multi_line "Num     Type\[ \]+Disp Enb Address\[ \]+What.*" \
+		    "$::decimal\[\t \]+breakpoint     keep y.* in [func main] at .*$::srcfile:$::main_line.*" \
+		    "$::decimal\[\t \]+breakpoint     keep y.* in [func marker2] at .*$::srcfile1:$::bp_location8.*" \
+		    "$::decimal\[\t \]+breakpoint     keep y.* in [func factorial] at .*$::srcfile:$::bp_location7.*" \
+		    "$::decimal\[\t \]+breakpoint     keep y.* in [func main] at .*$::srcfile:$::bp_location1.*" \
+		    "$::decimal\[\t \]+breakpoint     keep y.* in [func main] at .*$::srcfile:$::bp_location1.*" \
+		    "$::decimal\[\t \]+breakpoint     keep y.* in [func main] at .*$::srcfile:$::bp_location2.*" \
+		    "$::decimal\[\t \]+breakpoint     keep y.* in [func multi_line_if_conditional] at .*$::srcfile:$::bp_location3.*" \
+		    "$::decimal\[\t \]+breakpoint     keep y.* in [func multi_line_while_conditional] at .*$::srcfile:$::bp_location4"] \
+	"breakpoint info"
+
+    #
+    # Test info breakpoint with arguments
+    #
 
     set see1 0
     set see2 0
@@ -249,46 +135,39 @@ with_test_prefix "with value history" {
     set see5 0
     set see6 0
 
-    gdb_test_multiple "info break" "check disable with history values" {
-	-re "1\[\t \]+breakpoint *keep y.* in [func main] at .*:$main_line\[^\r\n\]*" {
+    gdb_test_multiple "info break 2 4 6" "info break 2 4 6" {
+	-re "1\[\t \]+breakpoint *keep y\[^\r\n\]*:$::main_line\[^\r\n\]*" {
 	    set see1 1
 	    exp_continue
 	}
-	-re "2\[\t \]+breakpoint *keep n\[^\r\n\]* in [func marker2] at \[^\r\n\]*" {
+	-re "2\[\t \]+breakpoint *keep y\[^\r\n\]* in [func marker2] at \[^\r\n\]*" {
 	    set see2 1
 	    exp_continue
 	}
-	-re "3\[\t \]+breakpoint *keep y\[^\r\n\]*$bp_location7\[^\r\n\]*" {
+	-re "3\[\t \]+breakpoint *keep y\[^\r\n\]*$::bp_location7\[^\r\n\]*" {
 	    set see3 1
 	    exp_continue
 	}
-	-re "4\[\t \]+breakpoint *keep y\[^\r\n\]*$bp_location1\[^\r\n\]*" {
+	-re "4\[\t \]+breakpoint *keep y\[^\r\n\]*$::bp_location1\[^\r\n\]*" {
 	    set see4 1
 	    exp_continue
 	}
-	-re "5\[\t \]+breakpoint *keep n\[^\r\n\]*$bp_location1\[^\r\n\]*" {
+	-re "5\[\t \]+breakpoint *keep y\[^\r\n\]*$::bp_location1\[^\r\n\]*" {
 	    set see5 1
 	    exp_continue
 	}
-	-re "6\[\t \]+breakpoint *keep y\[^\r\n\]*$bp_location2\[^\r\n\]*" {
+	-re "6\[\t \]+breakpoint *keep y\[^\r\n\]*$::bp_location2\[^\r\n\]*" {
 	    set see6 1
 	    exp_continue
 	}
-	-re ".*$gdb_prompt $" {
-	    if { $see1 && $see2 && $see3 && $see4 && $see5 && $see6 } then {
-		pass "check disable with history values"
+	-re ".*$::gdb_prompt $" {
+	    if { !$see1 && $see2 && !$see3 && $see4 && !$see5 && $see6 } then {
+		pass "info break 2 4 6"
 	    } else {
-		fail "check disable with history values"
+		fail "info break 2 4 6"
 	    }
 	}
     }
-}
-
-with_test_prefix "with convenience vars" {
-    gdb_test "enable"
-    gdb_test "set \$foo = 3"
-    gdb_test "set \$bar = 6"
-    gdb_test_no_output "disable \$foo \$bar" "disable with convenience values"
 
     set see1 0
     set see2 0
@@ -297,8 +176,8 @@ with_test_prefix "with convenience vars" {
     set see5 0
     set see6 0
 
-    gdb_test_multiple "info break" "check disable with convenience values" {
-	-re "1\[\t \]+breakpoint *keep y.* in [func main] at .*:$main_line\[^\r\n\]*" {
+    gdb_test_multiple "info break 3-5" "info break 3-5" {
+	-re "1\[\t \]+breakpoint *keep y.* in [func main] at .*:$::main_line\[^\r\n\]*" {
 	    set see1 1
 	    exp_continue
 	}
@@ -306,124 +185,231 @@ with_test_prefix "with convenience vars" {
 	    set see2 1
 	    exp_continue
 	}
-	-re "3\[\t \]+breakpoint *keep n\[^\r\n\]*$bp_location7\[^\r\n\]*" {
+	-re "3\[\t \]+breakpoint *keep y\[^\r\n\]*$::bp_location7\[^\r\n\]*" {
 	    set see3 1
 	    exp_continue
 	}
-	-re "4\[\t \]+breakpoint *keep y\[^\r\n\]*$bp_location1\[^\r\n\]*" {
+	-re "4\[\t \]+breakpoint *keep y\[^\r\n\]*$::bp_location1\[^\r\n\]*" {
 	    set see4 1
 	    exp_continue
 	}
-	-re "5\[\t \]+breakpoint *keep y\[^\r\n\]*$bp_location1\[^\r\n\]*" {
+	-re "5\[\t \]+breakpoint *keep y\[^\r\n\]*$::bp_location1\[^\r\n\]*" {
 	    set see5 1
 	    exp_continue
 	}
-	-re "6\[\t \]+breakpoint *keep n\[^\r\n\]*$bp_location2\[^\r\n\]*" {
+	-re "6\[\t \]+breakpoint *keep y\[^\r\n\]*$::bp_location2\[^\r\n\]*" {
 	    set see6 1
 	    exp_continue
 	}
-	-re ".*$gdb_prompt $" {
-	    if { $see1 && $see2 && $see3 && $see4 && $see5 && $see6 } then {
-		pass "check disable with convenience values"
+	-re ".*$::gdb_prompt $" {
+	    if { !$see1 && !$see2 && $see3 && $see4 && $see5 && !$see6 } then {
+		pass "info break 3-5"
 	    } else {
-		fail "check disable with convenience values"
+		fail "info break 3-5"
 	    }
 	}
     }
-}
 
-# test with bad values
-
-with_test_prefix "bad values" {
-    gdb_test "enable"
-    gdb_test "disable 10" "No breakpoint number 10." \
-	"disable non-existent breakpoint 10"
-
-    gdb_test_no_output "set \$baz = 1.234"
-    gdb_test "disable \$baz" \
-	"Convenience variable must have integer value.*" \
-	"disable with non-integer convenience var"
-    gdb_test "disable \$grbx" \
-	"Convenience variable must have integer value.*" \
-	"disable with non-existent convenience var"
-    gdb_test "disable \$10" \
-	"History has not yet reached .10." \
-	"disable with non-existent history value"
-    gdb_test "disable \$1foo" \
-	"Convenience variable must have integer value.*" \
-	"disable with badly formed history value"
-}
+    #
+    # Test disable/enable with arguments
+    #
 
-# FIXME: The rest of this test doesn't work with anything that can't
-# handle arguments.
-# Huh? There doesn't *appear* to be anything that passes arguments
-# below.
+    # Test with value history
+
+    with_test_prefix "with value history" {
+	gdb_test "print 1"
+	gdb_test "print 2"
+	gdb_test "print 3"
+	gdb_test "print 4"
+	gdb_test "print 5"
+	gdb_test "print 6"
+
+	# $2 is 2 and $$ is 5
+	gdb_test_no_output "disable \$2 \$\$" "disable using history values"
+
+	set see1 0
+	set see2 0
+	set see3 0
+	set see4 0
+	set see5 0
+	set see6 0
+
+	gdb_test_multiple "info break" "check disable with history values" {
+	    -re "1\[\t \]+breakpoint *keep y.* in [func main] at .*:$::main_line\[^\r\n\]*" {
+		set see1 1
+		exp_continue
+	    }
+	    -re "2\[\t \]+breakpoint *keep n\[^\r\n\]* in [func marker2] at \[^\r\n\]*" {
+		set see2 1
+		exp_continue
+	    }
+	    -re "3\[\t \]+breakpoint *keep y\[^\r\n\]*$::bp_location7\[^\r\n\]*" {
+		set see3 1
+		exp_continue
+	    }
+	    -re "4\[\t \]+breakpoint *keep y\[^\r\n\]*$::bp_location1\[^\r\n\]*" {
+		set see4 1
+		exp_continue
+	    }
+	    -re "5\[\t \]+breakpoint *keep n\[^\r\n\]*$::bp_location1\[^\r\n\]*" {
+		set see5 1
+		exp_continue
+	    }
+	    -re "6\[\t \]+breakpoint *keep y\[^\r\n\]*$::bp_location2\[^\r\n\]*" {
+		set see6 1
+		exp_continue
+	    }
+	    -re ".*$::gdb_prompt $" {
+		if { $see1 && $see2 && $see3 && $see4 && $see5 && $see6 } then {
+		    pass "check disable with history values"
+		} else {
+		    fail "check disable with history values"
+		}
+	    }
+	}
+    }
 
-#
-# run until the breakpoint at main is hit. For non-stubs-using targets.
-#
-gdb_run_cmd
-gdb_test "" \
-    "Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$srcfile:$bp_location6.*$bp_location6\[\t \]+if .argc.* \{.*" \
-    "run until function breakpoint"
-
-# Test the 'list' commands sets current file for the 'break LINENO' command.
-set bp_marker1 [gdb_get_line_number "set breakpoint 15 here" ${srcfile1}]
-gdb_test "list marker1" ".*"
-gdb_test "break $bp_marker1" "Breakpoint \[0-9\]+ at 0x\[0-9a-f\]+: file .*${srcfile1}, line ${bp_marker1}\\." \
-         "break lineno"
-gdb_test_no_output {delete $bpnum}
+    with_test_prefix "with convenience vars" {
+	gdb_test "enable"
+	gdb_test "set \$foo = 3"
+	gdb_test "set \$bar = 6"
+	gdb_test_no_output "disable \$foo \$bar" "disable with convenience values"
+
+	set see1 0
+	set see2 0
+	set see3 0
+	set see4 0
+	set see5 0
+	set see6 0
+
+	gdb_test_multiple "info break" "check disable with convenience values" {
+	    -re "1\[\t \]+breakpoint *keep y.* in [func main] at .*:$::main_line\[^\r\n\]*" {
+		set see1 1
+		exp_continue
+	    }
+	    -re "2\[\t \]+breakpoint *keep y\[^\r\n\]* in [func marker2] at \[^\r\n\]*" {
+		set see2 1
+		exp_continue
+	    }
+	    -re "3\[\t \]+breakpoint *keep n\[^\r\n\]*$::bp_location7\[^\r\n\]*" {
+		set see3 1
+		exp_continue
+	    }
+	    -re "4\[\t \]+breakpoint *keep y\[^\r\n\]*$::bp_location1\[^\r\n\]*" {
+		set see4 1
+		exp_continue
+	    }
+	    -re "5\[\t \]+breakpoint *keep y\[^\r\n\]*$::bp_location1\[^\r\n\]*" {
+		set see5 1
+		exp_continue
+	    }
+	    -re "6\[\t \]+breakpoint *keep n\[^\r\n\]*$::bp_location2\[^\r\n\]*" {
+		set see6 1
+		exp_continue
+	    }
+	    -re ".*$::gdb_prompt $" {
+		if { $see1 && $see2 && $see3 && $see4 && $see5 && $see6 } then {
+		    pass "check disable with convenience values"
+		} else {
+		    fail "check disable with convenience values"
+		}
+	    }
+	}
+    }
 
-#
-# run until the breakpoint at a line number
-#
-gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location1.*$bp_location1\[\t \]+printf.*factorial.*" \
-			"run until breakpoint set at a line number"
+    # test with bad values
+
+    with_test_prefix "bad values" {
+	gdb_test "enable"
+	gdb_test "disable 10" "No breakpoint number 10." \
+	    "disable non-existent breakpoint 10"
+
+	gdb_test_no_output "set \$baz = 1.234"
+	gdb_test "disable \$baz" \
+	    "Convenience variable must have integer value.*" \
+	    "disable with non-integer convenience var"
+	gdb_test "disable \$grbx" \
+	    "Convenience variable must have integer value.*" \
+	    "disable with non-existent convenience var"
+	gdb_test "disable \$10" \
+	    "History has not yet reached .10." \
+	    "disable with non-existent history value"
+	gdb_test "disable \$1foo" \
+	    "Convenience variable must have integer value.*" \
+	    "disable with badly formed history value"
+    }
 
-#
-# Run until the breakpoint set in a function in a file
-#
-for {set i 6} {$i >= 1} {incr i -1} {
-	gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, factorial \\(value=$i\\) at .*$srcfile:$bp_location7.*$bp_location7\[\t \]+.*if .value > 1. \{.*" \
-			"run until file:function($i) breakpoint"
-}
+    # FIXME: The rest of this test doesn't work with anything that can't
+    # handle arguments.
+    # Huh? There doesn't *appear* to be anything that passes arguments
+    # below.
 
-#
-# Run until the breakpoint set at a quoted function
-#
-gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, (0x\[0-9a-f\]+ in )?marker2 \\(a=43\\) at .*$srcfile1:$bp_location8.*" \
-		"run until quoted breakpoint"
-#
-# run until the file:function breakpoint at a line number in a file
-#
-gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location2.*$bp_location2\[\t \]+argc = \\(argc == 12345\\);.*" \
-		"run until file:linenum breakpoint"
+    #
+    # run until the breakpoint at main is hit. For non-stubs-using targets.
+    #
+    gdb_run_cmd
+    gdb_test "" \
+	"Breakpoint \[0-9\]+,.*main .*argc.*argv.* at .*$::srcfile:$::bp_location6.*$::bp_location6\[\t \]+if .argc.* \{.*" \
+	"run until function breakpoint"
 
-# Test break at offset +1
-set bp_location10 [gdb_get_line_number "set breakpoint 10 here"]
+    # Test the 'list' commands sets current file for the 'break LINENO' command.
+    set bp_marker1 [gdb_get_line_number "set breakpoint 15 here" $::srcfile1]
+    gdb_test "list marker1" ".*"
+    gdb_test "break $bp_marker1" "Breakpoint \[0-9\]+ at 0x\[0-9a-f\]+: file .*$::srcfile1, line ${bp_marker1}\\." \
+	     "break lineno"
+    gdb_test_no_output {delete $bpnum}
 
-gdb_test "break +1" \
-    "Breakpoint.*at.* file .*$srcfile, line $bp_location10\\." \
-    "breakpoint offset +1"
+    #
+    # run until the breakpoint at a line number
+    #
+    gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$::srcfile:$::bp_location1.*$::bp_location1\[\t \]+printf.*factorial.*" \
+			    "run until breakpoint set at a line number"
 
-# Check to see if breakpoint is hit when stepped onto
+    #
+    # Run until the breakpoint set in a function in a file
+    #
+    for {set i 6} {$i >= 1} {incr i -1} {
+	    gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, factorial \\(value=$i\\) at .*$::srcfile:$::bp_location7.*$::bp_location7\[\t \]+.*if .value > 1. \{.*" \
+			    "run until file:function($i) breakpoint"
+    }
 
-gdb_test "step" \
-    ".*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location10.*$bp_location10\[\t \]+return argc;.*breakpoint 10 here.*" \
-    "step onto breakpoint"
+    #
+    # Run until the breakpoint set at a quoted function
+    #
+    gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, (0x\[0-9a-f\]+ in )?marker2 \\(a=43\\) at .*$::srcfile1:$::bp_location8.*" \
+		    "run until quoted breakpoint"
+    #
+    # run until the file:function breakpoint at a line number in a file
+    #
+    gdb_test continue "Continuing\\..*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$::srcfile:$::bp_location2.*$::bp_location2\[\t \]+argc = \\(argc == 12345\\);.*" \
+		    "run until file:linenum breakpoint"
 
-# Check to see if breakpoint can be set on ending brace of function
-set bp_location10a [gdb_get_line_number "set breakpoint 10a here"]
+    # Test break at offset +1
+    set bp_location10 [gdb_get_line_number "set breakpoint 10 here"]
 
-gdb_test "break $bp_location10a" \
-    "Breakpoint.*at.* file .*$srcfile, line $bp_location10a\\." \
-    "setting breakpoint at }"
+    gdb_test "break +1" \
+	"Breakpoint.*at.* file .*$::srcfile, line $bp_location10\\." \
+	"breakpoint offset +1"
 
-gdb_test "continue" \
-    ".*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$srcfile:$bp_location10a.*$bp_location10a\[\t \]+}.*breakpoint 10a here.*" \
-    "continue to breakpoint at }"
+    # Check to see if breakpoint is hit when stepped onto
 
-set bp_location11 [gdb_get_line_number "set breakpoint 11 here"]
+    gdb_test "step" \
+	".*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$::srcfile:$bp_location10.*$bp_location10\[\t \]+return argc;.*breakpoint 10 here.*" \
+	"step onto breakpoint"
+
+    # Check to see if breakpoint can be set on ending brace of function
+    set bp_location10a [gdb_get_line_number "set breakpoint 10a here"]
+
+    gdb_test "break $bp_location10a" \
+	"Breakpoint.*at.* file .*$::srcfile, line $bp_location10a\\." \
+	"setting breakpoint at \}"
+
+    gdb_test "continue" \
+	".*Breakpoint \[0-9\]+, main \\(argc=.*, argv=.*, envp=.*\\) at .*$::srcfile:$bp_location10a.*$bp_location10a\[\t \]+\}.*breakpoint 10a here.*" \
+	"continue to breakpoint at \}"
+}
+
+test_break
 
 proc_with_prefix test_tbreak {} {
     clean_restart break
-- 
2.38.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 00/14] Break up gdb.base/break.exp in multiple procs
  2022-11-23 18:39 [PATCH 00/14] Break up gdb.base/break.exp in multiple procs Simon Marchi
                   ` (13 preceding siblings ...)
  2022-11-23 18:39 ` [PATCH 14/14] gdb/testsuite/gdb.base/break.exp: split test_break Simon Marchi
@ 2022-11-24  3:03 ` Kevin Buettner
  2022-11-24 15:14   ` Simon Marchi
  14 siblings, 1 reply; 17+ messages in thread
From: Kevin Buettner @ 2022-11-24  3:03 UTC (permalink / raw)
  To: Simon Marchi via Gdb-patches; +Cc: Simon Marchi

Hi Simon,

On Wed, 23 Nov 2022 13:39:45 -0500
Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> wrote:

> The test gdb.base/break.exp feels like a big house of cards that will
> crumble the second you touch it.  It is very long and it's really not
> clear which test depends on the state left by which previous test.  This
> series aims at making it more manageable by breaking it up into many
> procs, each starting with a fresh GDB.  So you can be confident that the
> tests in a proc only depends on the state of GDB resulting of other
> tests in the same proc.
> 
> Simon Marchi (14):
>   gdb/testsuite/gdb.base/break.exp: split test_break_commands_clear
>   gdb/testsuite/gdb.base/break.exp: split
>     test_break_file_line_convenience_var
>   gdb/testsuite/gdb.base/break.exp: split test_rbreak_shlib
>   gdb/testsuite/gdb.base/break.exp: split test_break_optimized_prologue
>   gdb/testsuite/gdb.base/break.exp: use proc_with_prefix for
>     test_next_with_recursion
>   gdb/testsuite/gdb.base/break.exp: split test_finish_arguments
>   gdb/testsuite/gdb.base/break.exp: split test_break_user_call
>   gdb/testsuite/gdb.base/break.exp: split
>     test_break_line_convenience_var
>   gdb/testsuite/gdb.base/break.exp: split test_break_silent_and_more
>   gdb/testsuite/gdb.base/break.exp: split test_break_default
>   gdb/testsuite/gdb.base/break.exp: split test_break_nonexistent_line
>   gdb/testsuite/gdb.base/break.exp: split test_no_break_on_catchpoint
>   gdb/testsuite/gdb.base/break.exp: split test_tbreak
>   gdb/testsuite/gdb.base/break.exp: split test_break
> 
>  gdb/testsuite/gdb.base/break.exp | 1191 +++++++++++++++---------------
>  1 file changed, 615 insertions(+), 576 deletions(-)

Thanks for doing this!

I looked at each patch in this series.  LGTM.

Kevin


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 00/14] Break up gdb.base/break.exp in multiple procs
  2022-11-24  3:03 ` [PATCH 00/14] Break up gdb.base/break.exp in multiple procs Kevin Buettner
@ 2022-11-24 15:14   ` Simon Marchi
  0 siblings, 0 replies; 17+ messages in thread
From: Simon Marchi @ 2022-11-24 15:14 UTC (permalink / raw)
  To: Kevin Buettner, Simon Marchi via Gdb-patches

On 11/23/22 22:03, Kevin Buettner wrote:
> Hi Simon,
> 
> On Wed, 23 Nov 2022 13:39:45 -0500
> Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> wrote:
> 
>> The test gdb.base/break.exp feels like a big house of cards that will
>> crumble the second you touch it.  It is very long and it's really not
>> clear which test depends on the state left by which previous test.  This
>> series aims at making it more manageable by breaking it up into many
>> procs, each starting with a fresh GDB.  So you can be confident that the
>> tests in a proc only depends on the state of GDB resulting of other
>> tests in the same proc.
>>
>> Simon Marchi (14):
>>   gdb/testsuite/gdb.base/break.exp: split test_break_commands_clear
>>   gdb/testsuite/gdb.base/break.exp: split
>>     test_break_file_line_convenience_var
>>   gdb/testsuite/gdb.base/break.exp: split test_rbreak_shlib
>>   gdb/testsuite/gdb.base/break.exp: split test_break_optimized_prologue
>>   gdb/testsuite/gdb.base/break.exp: use proc_with_prefix for
>>     test_next_with_recursion
>>   gdb/testsuite/gdb.base/break.exp: split test_finish_arguments
>>   gdb/testsuite/gdb.base/break.exp: split test_break_user_call
>>   gdb/testsuite/gdb.base/break.exp: split
>>     test_break_line_convenience_var
>>   gdb/testsuite/gdb.base/break.exp: split test_break_silent_and_more
>>   gdb/testsuite/gdb.base/break.exp: split test_break_default
>>   gdb/testsuite/gdb.base/break.exp: split test_break_nonexistent_line
>>   gdb/testsuite/gdb.base/break.exp: split test_no_break_on_catchpoint
>>   gdb/testsuite/gdb.base/break.exp: split test_tbreak
>>   gdb/testsuite/gdb.base/break.exp: split test_break
>>
>>  gdb/testsuite/gdb.base/break.exp | 1191 +++++++++++++++---------------
>>  1 file changed, 615 insertions(+), 576 deletions(-)
> 
> Thanks for doing this!
> 
> I looked at each patch in this series.  LGTM.
> 
> Kevin
> 

Thanks, will add you Approved-By and push.

Simon

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2022-11-24 15:14 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-23 18:39 [PATCH 00/14] Break up gdb.base/break.exp in multiple procs Simon Marchi
2022-11-23 18:39 ` [PATCH 01/14] gdb/testsuite/gdb.base/break.exp: split test_break_commands_clear Simon Marchi
2022-11-23 18:39 ` [PATCH 02/14] gdb/testsuite/gdb.base/break.exp: split test_break_file_line_convenience_var Simon Marchi
2022-11-23 18:39 ` [PATCH 03/14] gdb/testsuite/gdb.base/break.exp: split test_rbreak_shlib Simon Marchi
2022-11-23 18:39 ` [PATCH 04/14] gdb/testsuite/gdb.base/break.exp: split test_break_optimized_prologue Simon Marchi
2022-11-23 18:39 ` [PATCH 05/14] gdb/testsuite/gdb.base/break.exp: use proc_with_prefix for test_next_with_recursion Simon Marchi
2022-11-23 18:39 ` [PATCH 06/14] gdb/testsuite/gdb.base/break.exp: split test_finish_arguments Simon Marchi
2022-11-23 18:39 ` [PATCH 07/14] gdb/testsuite/gdb.base/break.exp: split test_break_user_call Simon Marchi
2022-11-23 18:39 ` [PATCH 08/14] gdb/testsuite/gdb.base/break.exp: split test_break_line_convenience_var Simon Marchi
2022-11-23 18:39 ` [PATCH 09/14] gdb/testsuite/gdb.base/break.exp: split test_break_silent_and_more Simon Marchi
2022-11-23 18:39 ` [PATCH 10/14] gdb/testsuite/gdb.base/break.exp: split test_break_default Simon Marchi
2022-11-23 18:39 ` [PATCH 11/14] gdb/testsuite/gdb.base/break.exp: split test_break_nonexistent_line Simon Marchi
2022-11-23 18:39 ` [PATCH 12/14] gdb/testsuite/gdb.base/break.exp: split test_no_break_on_catchpoint Simon Marchi
2022-11-23 18:39 ` [PATCH 13/14] gdb/testsuite/gdb.base/break.exp: split test_tbreak Simon Marchi
2022-11-23 18:39 ` [PATCH 14/14] gdb/testsuite/gdb.base/break.exp: split test_break Simon Marchi
2022-11-24  3:03 ` [PATCH 00/14] Break up gdb.base/break.exp in multiple procs Kevin Buettner
2022-11-24 15:14   ` Simon Marchi

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).