]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb] Remove unnecessary defs.h/common-defs.h includes
authorTom de Vries <tdevries@suse.de>
Tue, 21 Apr 2026 21:12:13 +0000 (23:12 +0200)
committerTom de Vries <tdevries@suse.de>
Tue, 21 Apr 2026 21:12:13 +0000 (23:12 +0200)
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 and
gdbserver/server.h.

Tested by rebuilding gdb on x86_64-linux.

V1 submitted here [1].

Changes in v1:
- also handle gdbserver/server.h
- change error message to use "manually" instead of "twice"

Approved-By: Simon Marchi <simon.marchi@efficios.com>
[1] https://sourceware.org/pipermail/gdb-patches/2026-April/226694.html

gdb/amd64-gnu-tdep.c
gdb/break-cond-parse.c
gdb/defs.h
gdb/nat/x86-linux.c
gdb/riscv-linux-canonicalize-syscall-gen.c
gdb/syscalls/riscv-linux-canonicalize-syscall-gen.py
gdb/unittests/remote-arg-selftests.c
gdbserver/linux-microblaze-low.cc
gdbserver/server.h
gdbsupport/common-defs.h
gdbsupport/remote-args.cc

index 366cc4584adab861c71f56b0d3cc53296dc43195..8415ce7468a6a69881e40436a595b139f35e96dd 100644 (file)
@@ -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"
index 4fec4dbef94ffbb8b55d1b78077125667394c3d3..7cb70df378c83543dbb2d609d3f52723605580b0 100644 (file)
@@ -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"
index 6029a2144d02802c247c5f29fb96065c60352f77..90abf0d343286f6ef463202ee9d7152cfdbacdea 100644 (file)
@@ -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 manually
 #endif /* GDB_DEFS_H */
index 92979ae652d03d8c33a4906c3efc931632431549..16391dcde24407fc2c219194bc960f761bd048fe 100644 (file)
@@ -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"
index be1eabcabc0e1144d1504b34dd50ceddb936648d..2d625bdfa8c11d3e263d15fb51b402f746f84c17 100644 (file)
@@ -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
index ca7dbe0b306510294c8f700a5b1e074349189c34..63b359f226bb73ff104a5f1cd17d83e3e744bd3c 100755 (executable)
@@ -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
index e878fefb2ef7488b29415d3d47a9c77d170494c3..7d4e63deefd3579fcfb13fe2cd1ad5e699594e54 100644 (file)
@@ -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"
index e5bdba12dfc86b0ed945f5a067928135a3b94464..21793d9a80199f8092b3e4be5203b3bf790dbaaa 100644 (file)
@@ -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 "server.h"
 #include "linux-low.h"
 
 #include "elf/common.h"
index 284f61821c0eb02f8422f1d107bb97fdcfd33d8e..bbba3650de7d8af15fc2d73b923a7dcddcc70eba 100644 (file)
@@ -214,4 +214,6 @@ client_state &get_client_state ();
 #include "gdbthread.h"
 #include "inferiors.h"
 
+#else
+#  error gdbserver/server.h should not be included manually
 #endif /* GDBSERVER_SERVER_H */
index f181044f383ed17189a362087d2bcb0804f54540..1c0ae0ad9d1b253c6968c434bac4be21720fff53 100644 (file)
 #define HAVE_USEFUL_SBRK 1
 #endif
 
+#else
+#  error gdbsupport/common-defs.h should not be included manually
 #endif /* GDBSUPPORT_COMMON_DEFS_H */
index 232adbff998ab5cf8faccea3c5f495bbfebfbd26..2abf61aa86b5302acf62582a8c68bef413d63aaa 100644 (file)
@@ -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"