public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] gdb/testsuite: extend the use of mi_clean_restart
@ 2023-02-28 11:09 Andrew Burgess
  0 siblings, 0 replies; only message in thread
From: Andrew Burgess @ 2023-02-28 11:09 UTC (permalink / raw)
  To: gdb-cvs

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

commit 1ccc4abbb3dda91c94c54d3aaaa417f0d7740a3f
Author: Andrew Burgess <aburgess@redhat.com>
Date:   Fri Feb 17 14:56:39 2023 +0000

    gdb/testsuite: extend the use of mi_clean_restart
    
    The mi_clean_restart proc calls the mi_gdb_start proc passing no
    arguments.
    
    In this commit I add an extra (optional) argument to the
    mi_clean_restart proc, and pass this through to mi_gdb_start.
    
    The benefit of this is that we can now use mi_clean_restart when we
    also want to pass the 'separate-mi-tty' or 'separate-inferior-tty'
    flags to mi_gdb_start, and avoids having to otherwise duplicate the
    contents of mi_clean_restart in different tests.
    
    I've updated the obvious places where this new functionality can be
    used, and I'm seeing no test regressions.
    
    Reviewed-By: Pedro Alves <pedro@palves.net>

Diff:
---
 gdb/testsuite/gdb.mi/mi-break.exp                   | 8 +-------
 gdb/testsuite/gdb.mi/mi-exec-run.exp                | 1 -
 gdb/testsuite/gdb.mi/mi-multi-commands.exp          | 3 +--
 gdb/testsuite/gdb.mi/mi-watch.exp                   | 8 +-------
 gdb/testsuite/gdb.mi/new-ui-mi-sync.exp             | 8 +-------
 gdb/testsuite/gdb.mi/user-selected-context-sync.exp | 8 +-------
 gdb/testsuite/lib/mi-support.exp                    | 4 ++--
 7 files changed, 7 insertions(+), 33 deletions(-)

diff --git a/gdb/testsuite/gdb.mi/mi-break.exp b/gdb/testsuite/gdb.mi/mi-break.exp
index 122a7dd77a4..5b5d3aad2e4 100644
--- a/gdb/testsuite/gdb.mi/mi-break.exp
+++ b/gdb/testsuite/gdb.mi/mi-break.exp
@@ -393,21 +393,15 @@ proc_with_prefix test_forced_conditions {} {
 proc test_break {mi_mode} {
     global srcdir subdir binfile
 
-    mi_gdb_exit
-
     if {$mi_mode == "separate"} {
 	set start_ops "separate-mi-tty"
     } else {
 	set start_ops ""
     }
-    if [mi_gdb_start $start_ops] {
+    if [mi_clean_restart $binfile $start_ops ] {
 	return
     }
 
-    mi_delete_breakpoints
-    mi_gdb_reinitialize_dir $srcdir/$subdir
-    mi_gdb_load ${binfile}
-
     test_tbreak_creation_and_listing
 
     test_ignore_count
diff --git a/gdb/testsuite/gdb.mi/mi-exec-run.exp b/gdb/testsuite/gdb.mi/mi-exec-run.exp
index e3e6d9d6a21..722634a472b 100644
--- a/gdb/testsuite/gdb.mi/mi-exec-run.exp
+++ b/gdb/testsuite/gdb.mi/mi-exec-run.exp
@@ -73,7 +73,6 @@ proc test {inftty_mode mi_mode force_fail} {
 
     mi_delete_breakpoints
     mi_gdb_reinitialize_dir $srcdir/$subdir
-    mi_gdb_reinitialize_dir $srcdir/$subdir
     mi_gdb_load ${bin}
 
     # Useful for debugging:
diff --git a/gdb/testsuite/gdb.mi/mi-multi-commands.exp b/gdb/testsuite/gdb.mi/mi-multi-commands.exp
index 00ab37cb64d..f07130d6fde 100644
--- a/gdb/testsuite/gdb.mi/mi-multi-commands.exp
+++ b/gdb/testsuite/gdb.mi/mi-multi-commands.exp
@@ -38,8 +38,7 @@ proc run_test { args } {
     global mi_gdb_prompt
     global decimal
 
-    gdb_exit
-    if [mi_gdb_start $args] {
+    if [mi_clean_restart "" $args] {
 	return
     }
 
diff --git a/gdb/testsuite/gdb.mi/mi-watch.exp b/gdb/testsuite/gdb.mi/mi-watch.exp
index 5303a41e86e..aaac7611015 100644
--- a/gdb/testsuite/gdb.mi/mi-watch.exp
+++ b/gdb/testsuite/gdb.mi/mi-watch.exp
@@ -150,14 +150,12 @@ proc test_watchpoint_all {mi_mode type} {
 	return
     }
 
-    mi_gdb_exit
-
     if {$mi_mode == "separate"} {
 	set start_ops "separate-mi-tty"
     } else {
 	set start_ops ""
     }
-    if [mi_gdb_start $start_ops] {
+    if [mi_clean_restart ${binfile} $start_ops] {
 	return
     }
 
@@ -170,10 +168,6 @@ proc test_watchpoint_all {mi_mode type} {
 	"567\\^done" \
 	"hw watchpoints toggle"
 
-    mi_delete_breakpoints
-    mi_gdb_reinitialize_dir $srcdir/$subdir
-    mi_gdb_load ${binfile}
-
     mi_runto callee4
     test_watchpoint_creation_and_listing
     #test_rwatch_creation_and_listing
diff --git a/gdb/testsuite/gdb.mi/new-ui-mi-sync.exp b/gdb/testsuite/gdb.mi/new-ui-mi-sync.exp
index 07b316c8ce9..a19bbb9f597 100644
--- a/gdb/testsuite/gdb.mi/new-ui-mi-sync.exp
+++ b/gdb/testsuite/gdb.mi/new-ui-mi-sync.exp
@@ -40,17 +40,11 @@ proc do_test {sync_command} {
     global gdb_spawn_id gdb_main_spawn_id mi_spawn_id inferior_spawn_id
     global gdb_prompt mi_gdb_prompt
 
-    mi_gdb_exit
-
-    if {[mi_gdb_start "separate-mi-tty"] != 0} {
+    if {[mi_clean_restart $binfile "separate-mi-tty"] != 0} {
 	fail "could not start gdb"
 	return
     }
 
-    mi_delete_breakpoints
-    mi_gdb_reinitialize_dir $srcdir/$subdir
-    mi_gdb_load $binfile
-
     # Start a synchronous run/continue on the MI UI.
     set test "send synchronous execution command"
     if {$sync_command == "run"} {
diff --git a/gdb/testsuite/gdb.mi/user-selected-context-sync.exp b/gdb/testsuite/gdb.mi/user-selected-context-sync.exp
index 91ca9b16bf8..9bcc90f06b4 100644
--- a/gdb/testsuite/gdb.mi/user-selected-context-sync.exp
+++ b/gdb/testsuite/gdb.mi/user-selected-context-sync.exp
@@ -396,22 +396,16 @@ proc_with_prefix test_setup { mode } {
 
     set any "\[^\r\n\]*"
 
-    mi_gdb_exit
-
     save_vars { GDBFLAGS } {
 	if { $mode == "non-stop" } {
 	    set GDBFLAGS [concat $GDBFLAGS " -ex \"set non-stop 1\""]
 	}
 
-	if { [mi_gdb_start "separate-mi-tty"] != 0 } {
+	if { [mi_clean_restart $binfile "separate-mi-tty"] != 0 } {
 	    return -1
 	}
     }
 
-    mi_delete_breakpoints
-    mi_gdb_reinitialize_dir $srcdir/$subdir
-    mi_gdb_load $binfile
-
     if { [mi_runto_main] < 0 } {
 	return -1
     }
diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp
index 3e20afa7049..cdebcc7d0f7 100644
--- a/gdb/testsuite/lib/mi-support.exp
+++ b/gdb/testsuite/lib/mi-support.exp
@@ -1012,7 +1012,7 @@ proc mi_run_with_cli {args} {
 # EXECUTABLE is the basename of the binary.
 # Return -1 if starting gdb or loading the executable failed.
 
-proc mi_clean_restart {{executable ""}} {
+proc mi_clean_restart {{executable ""} {flags {}}} {
     global srcdir
     global subdir
     global errcnt
@@ -1024,7 +1024,7 @@ proc mi_clean_restart {{executable ""}} {
     set errcnt 0
     set warncnt 0
 
-    if {[mi_gdb_start]} {
+    if {[mi_gdb_start $flags]} {
 	return -1
     }

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

only message in thread, other threads:[~2023-02-28 11:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-28 11:09 [binutils-gdb] gdb/testsuite: extend the use of mi_clean_restart Andrew Burgess

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