From patchwork Tue Feb 6 17:31:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 85372 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7C41E3858C53 for ; Tue, 6 Feb 2024 17:32:16 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta38.uswest2.a.cloudfilter.net (omta38.uswest2.a.cloudfilter.net [35.89.44.37]) by sourceware.org (Postfix) with ESMTPS id 501AB3858D38 for ; Tue, 6 Feb 2024 17:31:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 501AB3858D38 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 501AB3858D38 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=35.89.44.37 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707240707; cv=none; b=KBPBTcuykWmJB84EoQrD3bv81hnNJZAOc2Mgr9S7Cve3+tY9iHYnASkMnyyzuN7jMQ81ZX8r8K5if2AZ6ehC7KZPTK+8IvNpDBcTZ73FwKaPTLA2UfLS2aJhIy95sLbFKJV4PDYEoJTX9oj7zzNB2CnDAAYOK0qZNYXg2w3IIGg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707240707; c=relaxed/simple; bh=ZuDgTWpgW7Pjni6oiu1IvRaHLXV2rvfcgXmTAEF+jxc=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=v5Fw9pMOrBpzPWGTnIpkmJYRcvAZ+bedqYCFZN8ZZtBHaPIy3UjHyZ+9bCaDeDunN6E5BeSJGkPIxGn0bF1uGOwoiZukkPeHsoZzeL/JuTGr9c9yzxaqeAhQUTOC2umJ1nkFUy+SHTeQqlYkemgs8qru/BkyX3Al/A1x+2iGFLQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-5002a.ext.cloudfilter.net ([10.0.29.215]) by cmsmtp with ESMTPS id XKq0rN4vcrh9zXPINrXeXc; Tue, 06 Feb 2024 17:31:43 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id XPIMrRCvxHto8XPIMrnkfn; Tue, 06 Feb 2024 17:31:43 +0000 X-Authority-Analysis: v=2.4 cv=c9kIQg9l c=1 sm=1 tr=0 ts=65c26cff a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=k7vzHIieQBIA:10 a=Qbun_eYptAEA:10 a=KYSU83W1siF9DBUWkqYA:9 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:Message-ID:Date:Subject: Cc:To:From:Sender:Reply-To:Content-Type:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=52IMWKusYA6bS5tdQfJ0FV+8tCLUGmXqpi3wac/0VNs=; b=Lt68PhGEJJqg1SCv7frWh/1F2S JsynOg8rS3cOpPEMSGDZsTotojd7ekF6RTkZ40J9WRx0HBg/pOQjr8Dz+ZAi+Z3M3cyBYenhaUkON LE/gRVWOBQRiTyWXWaamSyoN2; Received: from 97-122-68-157.hlrn.qwest.net ([97.122.68.157]:52368 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.2) (envelope-from ) id 1rXPIM-000I0n-0G; Tue, 06 Feb 2024 10:31:42 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] Use save_vars when saving and restoring GDBFLAGS Date: Tue, 6 Feb 2024 10:31:32 -0700 Message-ID: <20240206173132.1272893-1-tom@tromey.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 97.122.68.157 X-Source-L: No X-Exim-ID: 1rXPIM-000I0n-0G X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-68-157.hlrn.qwest.net (localhost.localdomain) [97.122.68.157]:52368 X-Source-Auth: tom+tromey.com X-Email-Count: 5 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfJTInKiF46LtnLnMJTByV251kXZzO90EK7+SSJPEhQqhYTNdVMCzGdQ31eXcMK4yysOMqYa+LE2uf38LAfk14CquC2BXF+D4wuMWSgwRWb43zl74O+z6 TnlbmP8veN5BJXZM1h43blvfcWxZNyCNI1mZ0R7/wWcuFr3nIUPqamXfVtLuqN0npAKx2/loxkRz8m48cp6PHOZVt8RbpQlS5GI= X-Spam-Status: No, score=-3022.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org I noticed that mi-async.exp manually restored GDBFLAGS. I then looked and found a number of other places doing the same. This patch changes the test suite to use save_vars for this instead. Regression tested on x86-64 Fedora 38. --- .../gdb.base/batch-preserve-term-settings.exp | 4 ---- .../gdb.base/bp-cmds-execution-x-script.exp | 14 ++++---------- .../gdb.base/break-main-file-remove-fail.exp | 9 ++++----- .../gdb.base/break-on-linker-gcd-function.exp | 8 ++++---- gdb/testsuite/gdb.base/break-unload-file.exp | 9 ++++----- gdb/testsuite/gdb.base/code_elim.exp | 9 ++++----- .../gdb.base/paginate-execution-startup.exp | 8 ++------ gdb/testsuite/gdb.dwarf2/count.exp | 9 ++++----- gdb/testsuite/gdb.dwarf2/dw2-icycle.exp | 8 ++++---- gdb/testsuite/gdb.dwarf2/dw2-var-zero-addr.exp | 8 ++++---- gdb/testsuite/gdb.dwarf2/dw4-sig-type-unused.exp | 8 ++++---- gdb/testsuite/gdb.dwarf2/implptrconst.exp | 8 ++++---- gdb/testsuite/gdb.dwarf2/implptrpiece.exp | 8 ++++---- gdb/testsuite/gdb.dwarf2/nostaticblock.exp | 8 ++++---- gdb/testsuite/gdb.dwarf2/symtab-producer.exp | 15 ++++++--------- gdb/testsuite/gdb.mi/mi-async.exp | 13 +++++-------- gdb/testsuite/gdb.python/py-prompt.exp | 6 +----- gdb/testsuite/gdb.threads/fork-plus-threads.exp | 15 ++++++--------- .../forking-threads-plus-breakpoint.exp | 8 ++++---- .../process-dies-while-handling-bp.exp | 8 ++++---- gdb/testsuite/lib/gdb.exp | 16 ++++++---------- 21 files changed, 82 insertions(+), 117 deletions(-) diff --git a/gdb/testsuite/gdb.base/batch-preserve-term-settings.exp b/gdb/testsuite/gdb.base/batch-preserve-term-settings.exp index fbaba634e20..00c53e1925a 100644 --- a/gdb/testsuite/gdb.base/batch-preserve-term-settings.exp +++ b/gdb/testsuite/gdb.base/batch-preserve-term-settings.exp @@ -229,8 +229,6 @@ proc test_terminal_settings_preserved_after_cli_exit { cmds } { return } - set saved_gdbflags $GDBFLAGS - set stty_supported [run_stty "stty before" stty_before] set test "start gdb" @@ -297,8 +295,6 @@ proc test_terminal_settings_preserved_after_sigterm { } { return } - set saved_gdbflags $GDBFLAGS - set stty_supported [run_stty "stty before" stty_before] set test "start gdb" diff --git a/gdb/testsuite/gdb.base/bp-cmds-execution-x-script.exp b/gdb/testsuite/gdb.base/bp-cmds-execution-x-script.exp index 02719b1a7af..12c3bd9a221 100644 --- a/gdb/testsuite/gdb.base/bp-cmds-execution-x-script.exp +++ b/gdb/testsuite/gdb.base/bp-cmds-execution-x-script.exp @@ -25,23 +25,17 @@ if {[build_executable "failed to prepare" $testfile $srcfile debug]} { set x_file ${srcdir}/${subdir}/$testfile.gdb -global GDBFLAGS -set saved_gdbflags $GDBFLAGS - # Run the test proper. proc test {} { global inferior_exited_re global binfile global gdb_prompt - global saved_gdbflags GDBFLAGS + global GDBFLAGS global x_file gdb_exit - set GDBFLAGS "$GDBFLAGS -x $x_file $binfile" - - set GDBFLAGS $saved_gdbflags append GDBFLAGS " -ex \"set height unlimited\"" append GDBFLAGS " -x \"$x_file\"" append GDBFLAGS " --args \"$binfile\"" @@ -65,6 +59,6 @@ proc test {} { } } -test - -set GDBFLAGS $saved_gdbflags +save_vars {GDBFLAGS} { + test +} diff --git a/gdb/testsuite/gdb.base/break-main-file-remove-fail.exp b/gdb/testsuite/gdb.base/break-main-file-remove-fail.exp index 8a8c508b340..c2e6ba33103 100644 --- a/gdb/testsuite/gdb.base/break-main-file-remove-fail.exp +++ b/gdb/testsuite/gdb.base/break-main-file-remove-fail.exp @@ -35,8 +35,6 @@ proc test_remove_bp { initial_load } { gdb_exit - set saved_gdbflags $GDBFLAGS - # See "used to behave differently" further below. if { $initial_load == "file" } { gdb_start @@ -48,12 +46,13 @@ proc test_remove_bp { initial_load } { # implementations use as binary. set last_loaded_file $binfile - set GDBFLAGS "$GDBFLAGS $binfile" - gdb_start + save_vars {GDBFLAGS} { + append GDBFLAGS " $binfile" + gdb_start + } } gdb_reinitialize_dir $srcdir/$subdir gdb_reload - set GDBFLAGS $saved_gdbflags if ![runto start] { return diff --git a/gdb/testsuite/gdb.base/break-on-linker-gcd-function.exp b/gdb/testsuite/gdb.base/break-on-linker-gcd-function.exp index 613c9dc47e8..f68e2c0b891 100644 --- a/gdb/testsuite/gdb.base/break-on-linker-gcd-function.exp +++ b/gdb/testsuite/gdb.base/break-on-linker-gcd-function.exp @@ -48,10 +48,10 @@ proc set_breakpoint_on_gcd_function {} { set_breakpoint_on_gcd_function -set saved_gdbflags $GDBFLAGS -set GDBFLAGS "$GDBFLAGS --readnow" -clean_restart ${testfile} -set GDBFLAGS $saved_gdbflags +save_vars {GDBFLAGS} { + append GDBFLAGS " --readnow" + clean_restart ${testfile} +} with_test_prefix "readnow" { set_breakpoint_on_gcd_function diff --git a/gdb/testsuite/gdb.base/break-unload-file.exp b/gdb/testsuite/gdb.base/break-unload-file.exp index 2641feccec9..5b06e501eef 100644 --- a/gdb/testsuite/gdb.base/break-unload-file.exp +++ b/gdb/testsuite/gdb.base/break-unload-file.exp @@ -38,8 +38,6 @@ proc test_break { initial_load always_inserted break_command } { with_test_prefix "$prefix" { gdb_exit - set saved_gdbflags $GDBFLAGS - # See "used to behave differently" further below. if { $initial_load == "file" } { gdb_start @@ -51,13 +49,14 @@ proc test_break { initial_load always_inserted break_command } { # implementations use as binary. set last_loaded_file $binfile - set GDBFLAGS "$GDBFLAGS $binfile" - gdb_start + save_vars {GDBFLAGS} { + append GDBFLAGS " $binfile" + gdb_start + } } gdb_reinitialize_dir $srcdir/$subdir gdb_reload - set GDBFLAGS $saved_gdbflags if {![runto_main]} { return diff --git a/gdb/testsuite/gdb.base/code_elim.exp b/gdb/testsuite/gdb.base/code_elim.exp index e66382fdbd9..9c4e0ff4022 100644 --- a/gdb/testsuite/gdb.base/code_elim.exp +++ b/gdb/testsuite/gdb.base/code_elim.exp @@ -93,11 +93,10 @@ with_test_prefix "single psymtabs" { # Same thing for symtabs gdb_exit -global GDBFLAGS -set saved_gdbflags $GDBFLAGS -set GDBFLAGS "$GDBFLAGS --readnow $binfile1" -gdb_start -set GDBFLAGS $saved_gdbflags +save_vars {GDBFLAGS} { + append GDBFLAGS " --readnow $binfile1" + gdb_start +} with_test_prefix "single symtabs" { test_eliminated_var my_global_symbol diff --git a/gdb/testsuite/gdb.base/paginate-execution-startup.exp b/gdb/testsuite/gdb.base/paginate-execution-startup.exp index 3f0e74e5efa..66fb8965b4f 100644 --- a/gdb/testsuite/gdb.base/paginate-execution-startup.exp +++ b/gdb/testsuite/gdb.base/paginate-execution-startup.exp @@ -27,9 +27,6 @@ if [is_remote host] { set file_arg [remote_download host $file_arg] } -global GDBFLAGS -set saved_gdbflags $GDBFLAGS - # Returns true if the board can 'gdb -ex "start"', false otherwise. proc probe_can_run_cmdline {} { @@ -172,7 +169,8 @@ proc test_fg_execution_pagination_cancel { how } { } } -save_vars { INTERNAL_GDBFLAGS } { +save_vars { GDBFLAGS INTERNAL_GDBFLAGS } { + set saved_gdbflags $GDBFLAGS set INTERNAL_GDBFLAGS [string map {"-q" ""} $INTERNAL_GDBFLAGS] if {[probe_can_run_cmdline] > 0} { @@ -183,5 +181,3 @@ save_vars { INTERNAL_GDBFLAGS } { test_fg_execution_pagination_cancel "quit" } } - -set GDBFLAGS $saved_gdbflags diff --git a/gdb/testsuite/gdb.dwarf2/count.exp b/gdb/testsuite/gdb.dwarf2/count.exp index 99c52d231ae..02aa9cd645f 100644 --- a/gdb/testsuite/gdb.dwarf2/count.exp +++ b/gdb/testsuite/gdb.dwarf2/count.exp @@ -138,11 +138,10 @@ if { [gdb_compile [list ${binfile}1.o ${binfile}2.o] \ return -1 } -global GDBFLAGS -set saved_gdbflags $GDBFLAGS -set GDBFLAGS [concat $GDBFLAGS " -readnow"] -clean_restart ${testfile} -set GDBFLAGS $saved_gdbflags +save_vars {GDBFLAGS} { + append GDBFLAGS " -readnow" + clean_restart ${testfile} +} if ![runto_main] { return -1 diff --git a/gdb/testsuite/gdb.dwarf2/dw2-icycle.exp b/gdb/testsuite/gdb.dwarf2/dw2-icycle.exp index 9c004562d69..b7a68b8f367 100644 --- a/gdb/testsuite/gdb.dwarf2/dw2-icycle.exp +++ b/gdb/testsuite/gdb.dwarf2/dw2-icycle.exp @@ -33,10 +33,10 @@ if { [build_executable "failed to prepare" ${testfile} \ # start the debugger with -readnow. This force expansion as soon as # the objfile is loaded. -set saved_gdbflags $GDBFLAGS -set GDBFLAGS "$GDBFLAGS -readnow" -clean_restart ${testfile} -set GDBFLAGS $saved_gdbflags +save_vars {GDBFLAGS} { + append GDBFLAGS " -readnow" + clean_restart ${testfile} +} # And just to be sure that the debugger did not crash after having # expanded our symbols, do a life-check. diff --git a/gdb/testsuite/gdb.dwarf2/dw2-var-zero-addr.exp b/gdb/testsuite/gdb.dwarf2/dw2-var-zero-addr.exp index 2a5aa3ee0c1..614edda9fcc 100644 --- a/gdb/testsuite/gdb.dwarf2/dw2-var-zero-addr.exp +++ b/gdb/testsuite/gdb.dwarf2/dw2-var-zero-addr.exp @@ -32,10 +32,10 @@ proc test { } { test -set saved_gdbflags $GDBFLAGS -set GDBFLAGS "$GDBFLAGS --readnow" -clean_restart ${binfile} -set GDBFLAGS $saved_gdbflags +save_vars {GDBFLAGS} { + append GDBFLAGS " --readnow" + clean_restart ${binfile} +} with_test_prefix "readnow" { test diff --git a/gdb/testsuite/gdb.dwarf2/dw4-sig-type-unused.exp b/gdb/testsuite/gdb.dwarf2/dw4-sig-type-unused.exp index 63c834b8846..a4c512a7cb3 100644 --- a/gdb/testsuite/gdb.dwarf2/dw4-sig-type-unused.exp +++ b/gdb/testsuite/gdb.dwarf2/dw4-sig-type-unused.exp @@ -24,9 +24,9 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" object {}] != "" return -1 } -set saved_gdbflags $GDBFLAGS -set GDBFLAGS "$GDBFLAGS --readnow" -clean_restart $executable -set GDBFLAGS $saved_gdbflags +save_vars {GDBFLAGS} { + append GDBFLAGS " --readnow" + clean_restart $executable +} gdb_test "p 1" " = 1" "alive" diff --git a/gdb/testsuite/gdb.dwarf2/implptrconst.exp b/gdb/testsuite/gdb.dwarf2/implptrconst.exp index 796b8b70307..0004b51dc25 100644 --- a/gdb/testsuite/gdb.dwarf2/implptrconst.exp +++ b/gdb/testsuite/gdb.dwarf2/implptrconst.exp @@ -90,10 +90,10 @@ if { [build_executable ${testfile}.exp ${testfile} \ # We need --readnow because otherwise we never read in the CU we # created above. -set saved_gdbflags $GDBFLAGS -set GDBFLAGS "$GDBFLAGS -readnow" -clean_restart ${testfile} -set GDBFLAGS $saved_gdbflags +save_vars {GDBFLAGS} { + append GDBFLAGS " -readnow" + clean_restart ${testfile} +} if ![runto_main] { return -1 diff --git a/gdb/testsuite/gdb.dwarf2/implptrpiece.exp b/gdb/testsuite/gdb.dwarf2/implptrpiece.exp index 83bdf991135..aa411edb5f1 100644 --- a/gdb/testsuite/gdb.dwarf2/implptrpiece.exp +++ b/gdb/testsuite/gdb.dwarf2/implptrpiece.exp @@ -108,10 +108,10 @@ if { [build_executable ${testfile}.exp ${testfile} \ # We need --readnow because otherwise we never read in the CU we # created above. -set saved_gdbflags $GDBFLAGS -set GDBFLAGS "$GDBFLAGS -readnow" -clean_restart ${testfile} -set GDBFLAGS $saved_gdbflags +save_vars {GDBFLAGS} { + append GDBFLAGS " -readnow" + clean_restart ${testfile} +} if ![runto_main] { return -1 diff --git a/gdb/testsuite/gdb.dwarf2/nostaticblock.exp b/gdb/testsuite/gdb.dwarf2/nostaticblock.exp index 46e2b4c4ca8..b026073d41f 100644 --- a/gdb/testsuite/gdb.dwarf2/nostaticblock.exp +++ b/gdb/testsuite/gdb.dwarf2/nostaticblock.exp @@ -38,9 +38,9 @@ if { [build_executable ${testfile}.exp ${testfile} \ return -1 } -set saved_gdbflags $GDBFLAGS -set GDBFLAGS "$GDBFLAGS --readnow" -clean_restart $testfile -set GDBFLAGS $saved_gdbflags +save_vars {GDBFLAGS} { + append GDBFLAGS " --readnow" + clean_restart $testfile +} gdb_test "p 1" " = 1" "alive" diff --git a/gdb/testsuite/gdb.dwarf2/symtab-producer.exp b/gdb/testsuite/gdb.dwarf2/symtab-producer.exp index 756b1d60bf2..7981e0117ab 100644 --- a/gdb/testsuite/gdb.dwarf2/symtab-producer.exp +++ b/gdb/testsuite/gdb.dwarf2/symtab-producer.exp @@ -73,17 +73,14 @@ Dwarf::assemble $asm_file { # We need --readnow because otherwise we never read in the CUs we # created above. -set saved_gdbflags $GDBFLAGS -set GDBFLAGS "$GDBFLAGS -readnow" - -if { [prepare_for_testing "failed to prepare" ${testfile} \ - [list $srcfile $asm_file] {nodebug}] } { - set GDBFLAGS $saved_gdbflags - return -1 +save_vars {GDBFLAGS} { + append GDBFLAGS " -readnow" + if { [prepare_for_testing "failed to prepare" ${testfile} \ + [list $srcfile $asm_file] {nodebug}] } { + return -1 + } } -set GDBFLAGS $saved_gdbflags - gdb_py_test_silent_cmd "python with_producer = gdb.lookup_global_symbol(\"with_producer\")" \ "get with_producer symbol" 0 diff --git a/gdb/testsuite/gdb.mi/mi-async.exp b/gdb/testsuite/gdb.mi/mi-async.exp index fc138a6e9ea..fa527191d8b 100644 --- a/gdb/testsuite/gdb.mi/mi-async.exp +++ b/gdb/testsuite/gdb.mi/mi-async.exp @@ -29,10 +29,6 @@ if {![istarget *-linux*]} { # Check if start command is supported. require !use_gdb_stub -# The plan is for async mode to become the default but toggle for now. -set saved_gdbflags $GDBFLAGS -set GDBFLAGS [concat $GDBFLAGS " -ex \"set mi-async on\""] - load_lib mi-support.exp standard_testfile basics.c @@ -42,8 +38,11 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb return -1 } -if {[mi_clean_restart $binfile]} { - return +save_vars {GDBFLAGS} { + append GDBFLAGS " -ex \"set mi-async on\"" + if {[mi_clean_restart $binfile]} { + return + } } # mi_gdb_test cannot be used for asynchronous commands because there are @@ -75,5 +74,3 @@ proc linux_async_tests {} { linux_async_tests mi_gdb_exit - -set GDBFLAGS $saved_gdbflags diff --git a/gdb/testsuite/gdb.python/py-prompt.exp b/gdb/testsuite/gdb.python/py-prompt.exp index b37d2fbd3eb..7d3cafb9539 100644 --- a/gdb/testsuite/gdb.python/py-prompt.exp +++ b/gdb/testsuite/gdb.python/py-prompt.exp @@ -27,11 +27,9 @@ if {[build_executable $testfile.exp $testfile $srcfile debug] == -1} { return -1 } -save_vars { INTERNAL_GDBFLAGS } { +save_vars { GDBFLAGS INTERNAL_GDBFLAGS } { set INTERNAL_GDBFLAGS [string map {"-q" ""} $INTERNAL_GDBFLAGS] - global GDBFLAGS - set saved_gdbflags $GDBFLAGS set GDBFLAGS [concat $GDBFLAGS " -ex \"set height 0\""] set GDBFLAGS [concat $GDBFLAGS " -ex \"set width 0\""] set GDBFLAGS [concat $GDBFLAGS " -ex \"python p = list()\""] @@ -74,7 +72,6 @@ save_vars { INTERNAL_GDBFLAGS } { } if {![can_spawn_for_attach]} { - set GDBFLAGS $saved_gdbflags return 0 } @@ -117,6 +114,5 @@ save_vars { INTERNAL_GDBFLAGS } { gdb_exit } - set GDBFLAGS $saved_gdbflags kill_wait_spawned_process $test_spawn_id } diff --git a/gdb/testsuite/gdb.threads/fork-plus-threads.exp b/gdb/testsuite/gdb.threads/fork-plus-threads.exp index 431ad4a8b7f..96e309151be 100644 --- a/gdb/testsuite/gdb.threads/fork-plus-threads.exp +++ b/gdb/testsuite/gdb.threads/fork-plus-threads.exp @@ -34,17 +34,14 @@ proc do_test { detach-on-fork } { global srcfile testfile global gdb_prompt - set saved_gdbflags $GDBFLAGS - set GDBFLAGS [concat $GDBFLAGS " -ex \"set non-stop on\""] - - if {[prepare_for_testing "failed to prepare" \ - $testfile $srcfile {debug pthreads}] == -1} { - set GDBFLAGS $saved_gdbflags - return -1 + save_vars {GDBFLAGS} { + append GDBFLAGS " -ex \"set non-stop on\"" + if {[prepare_for_testing "failed to prepare" \ + $testfile $srcfile {debug pthreads}] == -1} { + return -1 + } } - set GDBFLAGS $saved_gdbflags - if {![runto_main]} { return 0 } diff --git a/gdb/testsuite/gdb.threads/forking-threads-plus-breakpoint.exp b/gdb/testsuite/gdb.threads/forking-threads-plus-breakpoint.exp index 7f010045e29..d81bfc68ba4 100644 --- a/gdb/testsuite/gdb.threads/forking-threads-plus-breakpoint.exp +++ b/gdb/testsuite/gdb.threads/forking-threads-plus-breakpoint.exp @@ -72,10 +72,10 @@ proc do_test { cond_bp_target detach_on_fork displaced } { global linenum global is_remote_target - set saved_gdbflags $GDBFLAGS - set GDBFLAGS [concat $GDBFLAGS " -ex \"set non-stop on\""] - clean_restart $binfile - set GDBFLAGS $saved_gdbflags + save_vars {GDBFLAGS} { + append GDBFLAGS " -ex \"set non-stop on\"" + clean_restart $binfile + } if {![runto_main]} { return 0 diff --git a/gdb/testsuite/gdb.threads/process-dies-while-handling-bp.exp b/gdb/testsuite/gdb.threads/process-dies-while-handling-bp.exp index a4c50d1c1f1..ccb99b172e1 100644 --- a/gdb/testsuite/gdb.threads/process-dies-while-handling-bp.exp +++ b/gdb/testsuite/gdb.threads/process-dies-while-handling-bp.exp @@ -40,10 +40,10 @@ proc do_test { non_stop cond_bp_target } { global binfile global linenum - set saved_gdbflags $GDBFLAGS - set GDBFLAGS [concat $GDBFLAGS " -ex \"set non-stop $non_stop\""] - clean_restart $binfile - set GDBFLAGS $saved_gdbflags + save_vars {GDBFLAGS} { + append GDBFLAGS " -ex \"set non-stop $non_stop\"" + clean_restart $binfile + } if {![runto_main]} { return 0 diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 9a906f0f349..6b82331bd15 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -6050,18 +6050,14 @@ proc gdb_spawn { } { proc gdb_spawn_with_cmdline_opts { cmdline_flags } { global GDBFLAGS - set saved_gdbflags $GDBFLAGS + save_vars {GDBFLAGS} { + if {$GDBFLAGS != ""} { + append GDBFLAGS " " + } + append GDBFLAGS $cmdline_flags - if {$GDBFLAGS != ""} { - append GDBFLAGS " " + return [gdb_spawn] } - append GDBFLAGS $cmdline_flags - - set res [gdb_spawn] - - set GDBFLAGS $saved_gdbflags - - return $res } # Start gdb running, wait for prompt, and disable the pagers.