From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [PATCH] [gdb] Remove unnecessary defs.h/common-defs.h includes
Date: Tue, 21 Apr 2026 18:24:54 +0200 [thread overview]
Message-ID: <20260421162454.1720072-1-tdevries@suse.de> (raw)
I asked an AI to review a patch that added a new file, and it mentioned I
should add an include of defs.h as first include.
That used to be true, but since commit 18d2988e5da ("gdb, gdbserver,
gdbsupport: remove includes of early headers") that's not the case anymore.
Error out when encountering a second include of defs.h, and remove a few of
those.
While we're at it, do the same for gdbsupport/common-defs.h.
Tested by rebuilding gdb on aarch64-linux.
---
gdb/amd64-gnu-tdep.c | 1 -
gdb/break-cond-parse.c | 1 -
gdb/defs.h | 2 ++
gdb/nat/x86-linux.c | 1 -
gdb/riscv-linux-canonicalize-syscall-gen.c | 1 -
gdb/syscalls/riscv-linux-canonicalize-syscall-gen.py | 1 -
gdb/unittests/remote-arg-selftests.c | 1 -
gdbsupport/common-defs.h | 2 ++
gdbsupport/remote-args.cc | 1 -
9 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/gdb/amd64-gnu-tdep.c b/gdb/amd64-gnu-tdep.c
index 366cc4584ad..8415ce7468a 100644
--- a/gdb/amd64-gnu-tdep.c
+++ b/gdb/amd64-gnu-tdep.c
@@ -16,7 +16,6 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-#include "defs.h"
#include "extract-store-integer.h"
#include "gdbcore.h"
#include "osabi.h"
diff --git a/gdb/break-cond-parse.c b/gdb/break-cond-parse.c
index 4fec4dbef94..7cb70df378c 100644
--- a/gdb/break-cond-parse.c
+++ b/gdb/break-cond-parse.c
@@ -15,7 +15,6 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-#include "defs.h"
#include "gdbsupport/gdb_assert.h"
#include "gdbsupport/selftest.h"
#include "test-target.h"
diff --git a/gdb/defs.h b/gdb/defs.h
index 6029a2144d0..5070d04adae 100644
--- a/gdb/defs.h
+++ b/gdb/defs.h
@@ -397,4 +397,6 @@ DEF_ENUM_FLAGS_TYPE (enum user_selected_what_flag, user_selected_what);
extern void _initialize_ ## NAME (); \
void _initialize_ ## NAME ()
+#else
+# error gdb/defs.h should not be included twice
#endif /* GDB_DEFS_H */
diff --git a/gdb/nat/x86-linux.c b/gdb/nat/x86-linux.c
index 92979ae652d..16391dcde24 100644
--- a/gdb/nat/x86-linux.c
+++ b/gdb/nat/x86-linux.c
@@ -18,7 +18,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "elf/common.h"
-#include "gdbsupport/common-defs.h"
#include "nat/gdb_ptrace.h"
#include "nat/linux-ptrace.h"
#include "nat/x86-cpuid.h"
diff --git a/gdb/riscv-linux-canonicalize-syscall-gen.c b/gdb/riscv-linux-canonicalize-syscall-gen.c
index be1eabcabc0..2d625bdfa8c 100644
--- a/gdb/riscv-linux-canonicalize-syscall-gen.c
+++ b/gdb/riscv-linux-canonicalize-syscall-gen.c
@@ -17,7 +17,6 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-#include "defs.h"
#include "riscv-linux-tdep.h"
/* riscv_linux_canonicalize_syscall maps from the native RISC-V Linux set
diff --git a/gdb/syscalls/riscv-linux-canonicalize-syscall-gen.py b/gdb/syscalls/riscv-linux-canonicalize-syscall-gen.py
index ca7dbe0b306..63b359f226b 100755
--- a/gdb/syscalls/riscv-linux-canonicalize-syscall-gen.py
+++ b/gdb/syscalls/riscv-linux-canonicalize-syscall-gen.py
@@ -59,7 +59,6 @@ HEAD = f"""\
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-#include "defs.h"
#include "riscv-linux-tdep.h"
/* riscv_linux_canonicalize_syscall maps from the native RISC-V Linux set
diff --git a/gdb/unittests/remote-arg-selftests.c b/gdb/unittests/remote-arg-selftests.c
index e878fefb2ef..7d4e63deefd 100644
--- a/gdb/unittests/remote-arg-selftests.c
+++ b/gdb/unittests/remote-arg-selftests.c
@@ -17,7 +17,6 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-#include "defs.h"
#include "gdbsupport/selftest.h"
#include "gdbsupport/buildargv.h"
#include "gdbsupport/common-inferior.h"
diff --git a/gdbsupport/common-defs.h b/gdbsupport/common-defs.h
index f181044f383..da94e38c60f 100644
--- a/gdbsupport/common-defs.h
+++ b/gdbsupport/common-defs.h
@@ -237,4 +237,6 @@
#define HAVE_USEFUL_SBRK 1
#endif
+#else
+# error gdbsupport/common-defs.h should not be included twice
#endif /* GDBSUPPORT_COMMON_DEFS_H */
diff --git a/gdbsupport/remote-args.cc b/gdbsupport/remote-args.cc
index 232adbff998..2abf61aa86b 100644
--- a/gdbsupport/remote-args.cc
+++ b/gdbsupport/remote-args.cc
@@ -15,7 +15,6 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-#include "gdbsupport/common-defs.h"
#include "gdbsupport/remote-args.h"
#include "gdbsupport/common-inferior.h"
#include "gdbsupport/buildargv.h"
base-commit: 8927b500532538cd86aae2d777c6452c51a210c6
--
2.51.0
next reply other threads:[~2026-04-21 16:25 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-21 16:24 Tom de Vries [this message]
2026-04-21 17:09 ` Simon Marchi
2026-04-21 19:44 ` Tom de Vries
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=20260421162454.1720072-1-tdevries@suse.de \
--to=tdevries@suse.de \
--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