From: Andrew Burgess Date: Mon, 23 Jun 2025 12:45:02 +0000 (+0100) Subject: gdbserver: include sys/stat.h for 'struct stat' X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=98cc89d9ca11e3f89a35698ce21d25dd48cf97eb;p=thirdparty%2Fbinutils-gdb.git gdbserver: include sys/stat.h for 'struct stat' Tom de Vries reported a build failure on x86_64-w64-mingw32 after commit: commit bd389c9515d240f55b117075b43184efdea41287 Date: Wed Jun 11 22:52:16 2025 +0200 gdb: implement linux namespace support for fileio_lstat and vFile::lstat The build failure looks like this: ../../src/gdbserver/hostio.cc: In function 'void handle_lstat(char*, int*)': ../../src/gdbserver/hostio.cc:544:63: error: cannot convert '_stat64*' to 'stat*' 544 | ret = the_target->multifs_lstat (hostio_fs_pid, filename, &st); | ^~~ | | | _stat64* In file included from ./../../src/gdbserver/server.h:58, from : ./../../src/gdbserver/target.h:448:74: note: initializing argument 3 of 'virtual int process_stratum_target::multifs_lstat(int, const char*, stat*)' 448 | virtual int multifs_lstat (int pid, const char *filename, struct stat *sb); | ~~~~~~~~~~~~~^~ The problem is that in sys/stat.h for mingw, 'stat' is #defined to _stat64, but target.h doesn't include sys/stat.h, and so doesn't see this #define. However, target.h does, by luck, manages to see the actual definition of 'struct stat', which isn't in sys/stat.h itself, but is in some other header that just happens to be pulled in by chance. As a result of all this, the declaration of process_stratum_target::multifs_lstat in target.h uses 'struct stat' for its argument type, while the call in hostio.cc, uses 'struct _stat64' as its argument type, which causes the build error seen above. The fix is to include sys/stat.h in target.h so that the declaration's argument type will change to 'struct _stat64' (via the #define). --- diff --git a/gdbserver/target.h b/gdbserver/target.h index 4d3f80f736d..66ca72fec17 100644 --- a/gdbserver/target.h +++ b/gdbserver/target.h @@ -31,6 +31,7 @@ #include "gdbsupport/btrace-common.h" #include #include "gdbsupport/byte-vector.h" +#include struct emit_ops; struct process_info;