From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id cdfBGa2gFGqyHxoAWB0awg (envelope-from ) for ; Mon, 25 May 2026 15:19:09 -0400 Received: by simark.ca (Postfix, from userid 112) id 6598A1E0A3; Mon, 25 May 2026 15:19:09 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.3 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id AAE881E024 for ; Mon, 25 May 2026 15:19:08 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B33BD4BA7987 for ; Mon, 25 May 2026 19:19:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B33BD4BA7987 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) by sourceware.org (Postfix) with ESMTPS id 370EC4BA7992 for ; Mon, 25 May 2026 19:18:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 370EC4BA7992 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 370EC4BA7992 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=209.85.128.46 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1779736723; cv=none; b=Nc1PXhlC6OfIzjsbv8hRQxEBoIZEAjBuMFt/sWKNZj2VhnVi16Uk+LTe4JYALAvExZmyShohHiO88rmIkksZ6k5zzt78Kb1vymTFYAnXAPnOZ694t2WoT7+2zZK0hq3Qi0vvdw3ROISIuPwcNw0kma++5AGoxylJRHGu72/WvnY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1779736723; c=relaxed/simple; bh=kL5uXCsKasVui+N2ygVGkAF2xmDIBf2F3ytt8TNSrLI=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=rn56kVahk00ZUUp/RRJ6oOAKphWpZvFzDdhHw44/9UmklIuP8xcMP1HH83bUef81ktXvrjLer/wZCt3aULCKL+AWelhNioXTiKtotnPlmcKQqqmLZUN1kPlmrivazFIM+IGG0ZThegoKgAT0tT/rKtGRhvS1zddBg1LKUcj0LAo= ARC-Authentication-Results: i=1; sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 370EC4BA7992 Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-490426d72f7so31321115e9.3 for ; Mon, 25 May 2026 12:18:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779736722; x=1780341522; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=3SJ7VDP5/qri78M2h1iaf4Ojwdkv8S8pYvaFL7Sq9fI=; b=BjUJHk21iLOmRGY1LnbtxAFaAW6ZJvesOAagKOiqb+JSox1xEXHM1HEcUhKzwKjy8t +0JYIyt5Tev7upARRyZ2+8gBXcvzaWOQdJTwbhwekzBgAqDeh2bp6SnReAe6gGs6dJy0 hK/uzI16ESh6TqGATEo2mVjES+/GpbP77C92vUOrbRfZt8GJROZ8Q8CWimkzeGYUfX0s 3IkbntL9dl9JWq6xMV/Ht6PQybU8w+EQ6aSMW+CtxIRQS9jlXVcxBcsl8qFjUS2hhXay 9bS8QoRwHSP2JGKyr1QlUkKTk3E9o7JmY1vohC76lznkkDHFNCtmAoBxTs5hFU4y1/BQ +Ymg== X-Gm-Message-State: AOJu0YzyztyoDP//i7TaBgkUniPZ2hz6rEJHoBkt4D7njx6/Ad16jgwH NOc9trJwN1v3nq5W/QaG14HzkZKxUkCruGUpR/lj9u8LoirEXWDX0Cu4PulYzA== X-Gm-Gg: Acq92OGlDlkDAnLrS/qoxKqx6GXiWHbPGqr6076JMKAQ/gaTrH2RIfYNBOMCB37zR6F QJfSatF/dOfKzYMC/OhMtg/VmKbnXTp8m1Y5h3XubICpXrF1cW+dVWsHkcDIcWJavKH4beg21p3 t4Ua76sIH6brpDUZIG64fLhAnoe6sKWtOBt0JUtp/4gNpjOVjS+pRtpXZ18lKNcY/DRMHBBDqKT 1w+RDn6nXExahZ3Nav35KooKgNwCx8gfzpHAegRi7rMlmNaqLqbHf+KeFozjf4gNlr9c0A/48bI uCbSUevuHn+tqw9k/Bfmn9eoyTsvzC+6uamuCQpSPTgFvVVM5n6UT/aMvP1AbHFj+beioMLzZXe O3Wc+821wKL7WU1aQUYg3gQ9ZEvzZ1MiCWi8OC4xWm4HcAc3faVRKgu2z9Eim/Tq4ZJqnJIshfe 4CxsgTaxOjubY1pJ9RiH9mZA== X-Received: by 2002:a05:600d:844a:10b0:490:4b89:535d with SMTP id 5b1f17b1804b1-4904b8955f6mr150977675e9.1.1779736721794; Mon, 25 May 2026 12:18:41 -0700 (PDT) Received: from localhost ([2001:8a0:fae3:2600:dc16:ec0f:632c:5ba7]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-490417ac7dasm92969345e9.7.2026.05.25.12.18.41 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 25 May 2026 12:18:41 -0700 (PDT) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH v2 03/11] Adjust gdb.base/exitsignal.exp for MinGW, separate program names Date: Mon, 25 May 2026 20:18:21 +0100 Message-ID: <20260525191829.984105-4-pedro@palves.net> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260525191829.984105-1-pedro@palves.net> References: <20260525191829.984105-1-pedro@palves.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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~public-inbox=simark.ca@sourceware.org Currently, gdb.base/exitsignal.exp on MinGW skips half the tests, like so: # of expected passes 13 # of untested testcases 1 ... because the testcase actually compiles two programs, but the second program is compiled using the same executable name as the first, at a time when gdb still has the first executable open, resulting in: .../x86_64-w64-mingw32/bin/ld.exe: cannot open output file C:/.../gdb.base/exitsignal/exitsignal.exe: Permission denied The use of standard_testfile in the middle of a testcase is a bit surprising. Fix this by moving the second compilation to the top, and give each executable its own name. Move the bulk of test code to two procedures, one for testing exiting with signal, another for testing normal exit. With this, gdb.base/exitsignal.exp passes cleanly on x86_64-w64-mingw32. Change-Id: I9a1af298b0e4f62f38b5c4b14787d7e40a2b5e2c commit-id: e496754c --- gdb/testsuite/gdb.base/exitsignal.exp | 201 ++++++++++++++------------ 1 file changed, 112 insertions(+), 89 deletions(-) diff --git a/gdb/testsuite/gdb.base/exitsignal.exp b/gdb/testsuite/gdb.base/exitsignal.exp index 341197cf0c8..4f4c53e37cb 100644 --- a/gdb/testsuite/gdb.base/exitsignal.exp +++ b/gdb/testsuite/gdb.base/exitsignal.exp @@ -23,103 +23,126 @@ require {!target_info exists gdb,nosignals} -standard_testfile segv.c +set testfile "exitsignal" -if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } { - return -} +set exec1 "segv" +set srcfile1 ${exec1}.c +set binfile1 [standard_output_file ${exec1}] -# Run to main. But, before, change cwd to get the core into the -# output directory. -set_inferior_cwd_to_output_dir +set exec2 "normal" +set srcfile2 ${exec2}.c +set binfile2 [standard_output_file ${exec2}] -if { ![runto_main] } { - return +if { [build_executable "failed to build $exec1" ${exec1} "${srcfile1}" \ + {debug}] == -1 } { + return -1 } -# Get the inferior's PID for later. -set pid [get_inferior_pid] - -# Print $_exitsignal. It should be void now, because nothing -# happened. -gdb_test "print \$_exitsignal" " = void" \ - "\$_exitsignal is void before running" - -# Just to guarantee, making sure that $_exitcode is also void. -gdb_test "print \$_exitcode" " = void" \ - "\$_exitcode is void before running" - -# Trigger SIGSEGV. -gdb_test "continue" "(Thread .*|Program) received signal SIGSEGV.*" \ - "trigger SIGSEGV" - -if {[istarget "*-*-mingw*"]} { - # We're debugging a pure Win32 program with no SEH handler. The - # previous continue caught the first-chance exception. Now we - # catch the second-chance. - gdb_test "continue" "Thread .* received signal SIGSEGV.*" \ - "trigger SIGSEGV, second-chance" -} elseif {[istarget "*-*-cygwin*"]} { - # Cygwin calls DebugBreak before it lets the process exit. - gdb_test "continue" "Thread .* received signal SIGTRAP.*" \ - "trigger try_to_debug SIGTRAP" +if { [build_executable "failed to build $exec2" ${exec2} "${srcfile2}" \ + {debug}] == -1} { + return -1 } -# Continue until the end. -gdb_test "continue" "Program terminated with signal SIGSEGV.*" \ - "program terminated with SIGSEGV" - -# We don't need the core file, remove it. -remove_core $pid - -# Now, print $_exitsignal again. It should be 11 (SIGSEGV). -gdb_test "print \$_exitsignal" " = 11" \ - "\$_exitsignal is 11 (SIGSEGV) after SIGSEGV." - -# And $_exitcode should still be void, since the inferior died because -# of a signal, and did not return. -gdb_test "print \$_exitcode" " = void" \ - "\$_exitcode is still void after SIGSEGV" - -# Re-run to main, i.e., restart the executable. -rerun_to_main - -# Print the $_exitsignal again. Even in this normal scenario, it -# should still contain the signal triggered in the other run. -gdb_test "print \$_exitsignal" " = 11" \ - "\$_exitsignal is 11 (SIGSEGV) after restarting the inferior" - -# And, again, print $_exitcode. -gdb_test "print \$_exitcode" " = void" \ - "\$_exitcode is still void after restarting the inferior" - -# Now we test the behavior of $_exit{code,signal} during a normal -# inferior execution. -standard_testfile normal.c - -if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } { - return +proc test_signal {} { + clean_restart $::exec1 + + # Run to main. But, before, change cwd to get the core into the + # output directory. + set_inferior_cwd_to_output_dir + + if { ![runto_main] } { + return + } + + # Get the inferior's PID for later. + set pid [get_inferior_pid] + + # Print $_exitsignal. It should be void now, because nothing + # happened. + gdb_test "print \$_exitsignal" " = void" \ + "\$_exitsignal is void before running" + + # Just to guarantee, making sure that $_exitcode is also void. + gdb_test "print \$_exitcode" " = void" \ + "\$_exitcode is void before running" + + # Trigger SIGSEGV. + gdb_test "continue" "(Thread .*|Program) received signal SIGSEGV.*" \ + "trigger SIGSEGV" + + if {[istarget "*-*-mingw*"]} { + # We're debugging a pure Win32 program with no SEH handler. The + # previous continue caught the first-chance exception. Now we + # catch the second-chance one. + gdb_test "continue" "Thread .* received signal SIGSEGV.*" \ + "trigger SIGSEGV, second-chance" + } elseif {[istarget "*-*-cygwin*"]} { + # Cygwin calls DebugBreak before it lets the process exit. + gdb_test "continue" "Thread .* received signal SIGTRAP.*" \ + "trigger try_to_debug SIGTRAP" + } + + # Continue until the end. + gdb_test "continue" "Program terminated with signal SIGSEGV.*" \ + "program terminated with SIGSEGV" + + # We don't need the core file, remove it. + remove_core $pid + + # Now, print $_exitsignal again. It should be 11 (SIGSEGV). + gdb_test "print \$_exitsignal" " = 11" \ + "\$_exitsignal is 11 (SIGSEGV) after SIGSEGV." + + # And $_exitcode should still be void, since the inferior died + # because of a signal, and did not return. + gdb_test "print \$_exitcode" " = void" \ + "\$_exitcode is still void after SIGSEGV" + + # Re-run to main, i.e., restart the executable. + rerun_to_main + + # Print the $_exitsignal again. Even in this normal scenario, it + # should still contain the signal triggered in the other run. + gdb_test "print \$_exitsignal" " = 11" \ + "\$_exitsignal is 11 (SIGSEGV) after restarting the inferior" + + # And, again, print $_exitcode. + gdb_test "print \$_exitcode" " = void" \ + "\$_exitcode is still void after restarting the inferior" } -# Checking $_exitsignal and $_exitcode, both should be void before the -# inferior is executed. -gdb_test "print \$_exitsignal" " = void" \ - "\$_exitsignal is void before normal inferior is executed" -gdb_test "print \$_exitcode" " = void" \ - "\$_exitcode is void before normal inferior is executed" - -# Run the inferior until the end. -if { ![runto_main] } { - return +# Test the behavior of $_exit{code,signal} during a normal inferior +# execution. +proc test_normal {} { + clean_restart $::exec2 + + # Check $_exitsignal and $_exitcode, both should be void before + # the inferior is executed. + gdb_test "print \$_exitsignal" " = void" \ + "\$_exitsignal is void before normal inferior is executed" + gdb_test "print \$_exitcode" " = void" \ + "\$_exitcode is void before normal inferior is executed" + + # Run the inferior until the end. + if { ![runto_main] } { + return + } + + gdb_continue_to_end + + # Check $_exitcode. It should be 0. + gdb_test "print \$_exitcode" " = 0" \ + "\$_exitcode is zero after normal inferior is executed" + + # Check $_exitsignal. It should still be void, since the inferior + # has not received any signal. + gdb_test "print \$_exitsignal" " = void" \ + "\$_exitsignal is still void after normal inferior is executed" } -gdb_continue_to_end - -# Checking $_exitcode. It should be 0. -gdb_test "print \$_exitcode" " = 0" \ - "\$_exitcode is zero after normal inferior is executed" - -# Checking $_exitsignal. It should still be void, since the inferior -# has not received any signal. -gdb_test "print \$_exitsignal" " = void" \ - "\$_exitsignal is still void after normal inferior is executed" +with_test_prefix "signal" { + test_signal +} +with_test_prefix "normal" { + test_normal +} -- 2.53.0