From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1726) id 76CCC3858427; Tue, 3 May 2022 09:48:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 76CCC3858427 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Andrew Burgess To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb/testsuite: change mi_gdb_start to take a list of flags X-Act-Checkin: binutils-gdb X-Git-Author: Andrew Burgess X-Git-Refname: refs/heads/master X-Git-Oldrev: 11039eff7166cf40d502c88e8b161dd7602120aa X-Git-Newrev: 43cef57a742bae20477bb2fbb306ab4c4167318c Message-Id: <20220503094858.76CCC3858427@sourceware.org> Date: Tue, 3 May 2022 09:48:58 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 May 2022 09:48:58 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D43cef57a742b= ae20477bb2fbb306ab4c4167318c commit 43cef57a742bae20477bb2fbb306ab4c4167318c Author: Andrew Burgess Date: Wed Apr 27 18:45:47 2022 +0100 gdb/testsuite: change mi_gdb_start to take a list of flags =20 After this previous commit I was thinking about the API of mi_gdb_start. I felt that the idea of passing flags as separate arguments and using 'args' to gather these into a list, though clever, was not an intuitive API. =20 In this commit I modify mi_gdb_start so that it expects a single argument, which should be a list of flags. Thus, where we previously would have said: =20 mi_gdb_start separate-mi-tty separate-inferior-tty =20 We would now say: =20 mi_gdb_start { separate-mi-tty separate-inferior-tty } =20 However, it turns out we never actually call mi_gdb_start passing two arguments in this way at all. We do in some places do this: =20 mi_gdb_start separate-inferior-tty =20 But that's fine, a single string like this works equally well as a single item list, so this will not need updating. =20 There is also one place where we do this: =20 eval mi_gdb_start $start_ops =20 where $start_ops is a list that might contains 0, 1, or 2 items. The eval here is used to expand the $start_ops list so mi_gdb_start sees the list contents as separate arguments. In this case we just need to drop the use of eval. =20 I think that the new API is more intuitive, but others might disagree, in which case I can drop this change. =20 There should be no change in what is tested after this commit. Diff: --- gdb/testsuite/gdb.mi/mi-exec-run.exp | 2 +- gdb/testsuite/lib/mi-support.exp | 24 ++++++++++++++++-------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/gdb/testsuite/gdb.mi/mi-exec-run.exp b/gdb/testsuite/gdb.mi/mi= -exec-run.exp index ffbe6bcd36e..f8e6550850f 100644 --- a/gdb/testsuite/gdb.mi/mi-exec-run.exp +++ b/gdb/testsuite/gdb.mi/mi-exec-run.exp @@ -60,7 +60,7 @@ proc test {inftty_mode mi_mode force_fail} { lappend start_ops "separate-mi-tty" } =20 - if [eval mi_gdb_start $start_ops] { + if [mi_gdb_start $start_ops] { return } =20 diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-suppor= t.exp index a231b8311b9..e578a7e6f9b 100644 --- a/gdb/testsuite/lib/mi-support.exp +++ b/gdb/testsuite/lib/mi-support.exp @@ -131,7 +131,13 @@ proc mi_create_inferior_pty {} { } } =20 -proc mi_gdb_start_separate_mi_tty { args } { +# +# Like default_mi_gdb_start below, but the MI is created as a separate +# ui in a new tty. The global MI_SPAWN_ID is updated to point at the +# new tty created for the MI interface. The global GDB_MAIN_SPAWN_ID +# is updated to the current value of the global GDB_SPAWN_ID. +# +proc mi_gdb_start_separate_mi_tty { { flags {} } } { global gdb_prompt mi_gdb_prompt global timeout global gdb_spawn_id gdb_main_spawn_id mi_spawn_id @@ -139,8 +145,8 @@ proc mi_gdb_start_separate_mi_tty { args } { =20 set separate_inferior_pty 0 =20 - foreach arg $args { - if {$arg =3D=3D "separate-inferior-tty"} { + foreach flag $flags { + if {$flag =3D=3D "separate-inferior-tty"} { set separate_inferior_pty 1 } } @@ -183,6 +189,8 @@ proc mi_gdb_start_separate_mi_tty { args } { # # default_mi_gdb_start [FLAGS] -- start gdb running, default procedure # +# FLAGS is a list of flags, each flag is a string. +# # If "separate-inferior-tty" is specified, the inferior works with # it's own PTY. # @@ -193,7 +201,7 @@ proc mi_gdb_start_separate_mi_tty { args } { # tests on different hosts all using the same server, things can # get really slow. Give gdb at least 3 minutes to start up. # -proc default_mi_gdb_start { args } { +proc default_mi_gdb_start { { flags {} } } { global use_gdb_stub global GDB global INTERNAL_GDBFLAGS GDBFLAGS @@ -218,16 +226,16 @@ proc default_mi_gdb_start { args } { =20 set separate_inferior_pty 0 =20 - foreach arg $args { - if {$arg =3D=3D "separate-mi-tty"} { + foreach flag $flags { + if {$flag =3D=3D "separate-mi-tty"} { set separate_mi_pty 1 - } elseif {$arg =3D=3D "separate-inferior-tty"} { + } elseif {$flag =3D=3D "separate-inferior-tty"} { set separate_inferior_pty 1 } } =20 if {$separate_mi_pty} { - return [eval mi_gdb_start_separate_mi_tty $args] + return [mi_gdb_start_separate_mi_tty $flags] } =20 set inferior_pty no-tty