From: Pedro Alves <pedro@palves.net>
To: gdb-patches@sourceware.org
Subject: [PATCH v2 04/11] gdb.base/exitsignal.exp: Exit with non-zero
Date: Mon, 25 May 2026 20:18:22 +0100 [thread overview]
Message-ID: <20260525191829.984105-5-pedro@palves.net> (raw)
In-Reply-To: <20260525191829.984105-1-pedro@palves.net>
gdb.base/exitsignal.exp currently tests exiting with exit code 0.
But, testing for 0 is typically more "dangerous" in the sense that
it's easy for some bug in GDB or the target backend to fail to extract
the exit code and return 0. Make it test exit code 1 instead.
gdb.base/coredump-filter-build-id.exp currently reuses normal.c. It
could still use it with this patch, but it seems better to me to
remove the coupling. Simply add a new .c file for that testcase,
which still returns 0.
Change-Id: I49ccfdbbe4be4445172476e7dd4e06142c8a672e
commit-id: d6b526ac
---
.../gdb.base/coredump-filter-build-id.c | 22 +++++++++++++++++++
.../gdb.base/coredump-filter-build-id.exp | 2 +-
gdb/testsuite/gdb.base/exitsignal.exp | 8 +++----
gdb/testsuite/gdb.base/normal.c | 7 ++++--
4 files changed, 32 insertions(+), 7 deletions(-)
create mode 100644 gdb/testsuite/gdb.base/coredump-filter-build-id.c
diff --git a/gdb/testsuite/gdb.base/coredump-filter-build-id.c b/gdb/testsuite/gdb.base/coredump-filter-build-id.c
new file mode 100644
index 00000000000..d78df952cb5
--- /dev/null
+++ b/gdb/testsuite/gdb.base/coredump-filter-build-id.c
@@ -0,0 +1,22 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2013-2026 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+int
+main ()
+{
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.base/coredump-filter-build-id.exp b/gdb/testsuite/gdb.base/coredump-filter-build-id.exp
index d267221e1bf..d8251e5c25f 100644
--- a/gdb/testsuite/gdb.base/coredump-filter-build-id.exp
+++ b/gdb/testsuite/gdb.base/coredump-filter-build-id.exp
@@ -21,7 +21,7 @@
# external tool, eu-unstrip, to verify if the corefile contains
# build-ids.
-standard_testfile "normal.c"
+standard_testfile
# This test is Linux x86_64 only.
if { ![istarget *-*-linux*] } {
diff --git a/gdb/testsuite/gdb.base/exitsignal.exp b/gdb/testsuite/gdb.base/exitsignal.exp
index 4f4c53e37cb..7ae6e19b093 100644
--- a/gdb/testsuite/gdb.base/exitsignal.exp
+++ b/gdb/testsuite/gdb.base/exitsignal.exp
@@ -128,11 +128,11 @@ proc test_normal {} {
return
}
- gdb_continue_to_end
+ gdb_test "continue" " exited with code 01\\\].*" "continue to exit"
- # Check $_exitcode. It should be 0.
- gdb_test "print \$_exitcode" " = 0" \
- "\$_exitcode is zero after normal inferior is executed"
+ # Check $_exitcode. It should be 1.
+ gdb_test "print \$_exitcode" " = 1" \
+ "\$_exitcode is one after normal inferior is executed"
# Check $_exitsignal. It should still be void, since the inferior
# has not received any signal.
diff --git a/gdb/testsuite/gdb.base/normal.c b/gdb/testsuite/gdb.base/normal.c
index dd371746235..ba04c861dad 100644
--- a/gdb/testsuite/gdb.base/normal.c
+++ b/gdb/testsuite/gdb.base/normal.c
@@ -15,10 +15,13 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-/* This test is just a normal return 0. */
+/* This test is just a normal return 1. */
int
main (int argc, char *argv[])
{
- return 0;
+ /* Non-zero specifically, as it would be otherwise easier for a
+ buggy GDB to report exit code 0 when it shouldn't and that
+ wouldn't be noticed. */
+ return 1;
}
--
2.53.0
next prev parent reply other threads:[~2026-05-25 19:19 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-25 19:18 [PATCH v2 00/11] Fix a few Cygwin/MinGW problems Pedro Alves
2026-05-25 19:18 ` [PATCH v2 01/11] Adjust gdb.base/exitsignal.exp for MinGW, trigger fault Pedro Alves
2026-05-25 19:18 ` [PATCH v2 02/11] Adjust gdb.base/exitsignal.exp for MinGW, second-chance SIGSEGV Pedro Alves
2026-05-26 11:18 ` Eli Zaretskii
2026-05-27 12:56 ` Pedro Alves
2026-05-25 19:18 ` [PATCH v2 03/11] Adjust gdb.base/exitsignal.exp for MinGW, separate program names Pedro Alves
2026-05-27 21:59 ` Thiago Jung Bauermann
2026-06-12 14:00 ` Pedro Alves
2026-05-25 19:18 ` Pedro Alves [this message]
2026-05-25 19:18 ` [PATCH v2 05/11] gdb.base/exitsignal.exp: Test attaching too Pedro Alves
2026-05-25 19:18 ` [PATCH v2 06/11] gdb/testsuite: Add mechanism to compile Windows native programs on Cygwin Pedro Alves
2026-05-25 19:18 ` [PATCH v2 07/11] Windows gdb+gdbserver: Share exit status logic Pedro Alves
2026-05-25 19:18 ` [PATCH v2 08/11] Windows gdb+gdbserver: Decode Cygwin ExitProcess codes Pedro Alves
2026-05-26 11:31 ` Eli Zaretskii
2026-05-27 13:58 ` Pedro Alves
2026-05-27 14:12 ` Eli Zaretskii
2026-05-27 22:00 ` Thiago Jung Bauermann
2026-05-25 19:18 ` [PATCH v2 09/11] Adjust gdb.python/py-events.exp for Cygwin/MinGW, thread IDs Pedro Alves
2026-05-25 19:18 ` [PATCH v2 10/11] Adjust gdb.python/py-events.exp for Cygwin/MinGW, no fork Pedro Alves
2026-05-25 19:18 ` [PATCH v2 11/11] Adjust gdb.python/py-events.exp for Cygwin/MinGW, "info proc" => "inferior" Pedro Alves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260525191829.984105-5-pedro@palves.net \
--to=pedro@palves.net \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox