aboutsummaryrefslogtreecommitdiff
path: root/gdbserver
diff options
context:
space:
mode:
Diffstat (limited to 'gdbserver')
-rw-r--r--gdbserver/.dir-locals.el2
-rw-r--r--gdbserver/Makefile.in3
-rw-r--r--gdbserver/ax-result-types.def2
-rw-r--r--gdbserver/ax.cc2
-rw-r--r--gdbserver/ax.h2
-rwxr-xr-xgdbserver/configure225
-rw-r--r--gdbserver/configure.ac4
-rw-r--r--gdbserver/configure.srv7
-rw-r--r--gdbserver/debug.cc2
-rw-r--r--gdbserver/debug.h2
-rw-r--r--gdbserver/dll.cc2
-rw-r--r--gdbserver/dll.h2
-rw-r--r--gdbserver/fork-child.cc2
-rw-r--r--gdbserver/gdb_proc_service.h2
-rw-r--r--gdbserver/gdbreplay.cc4
-rw-r--r--gdbserver/gdbthread.h2
-rw-r--r--gdbserver/hostio.cc64
-rw-r--r--gdbserver/hostio.h2
-rw-r--r--gdbserver/i387-fp.cc42
-rw-r--r--gdbserver/i387-fp.h2
-rw-r--r--gdbserver/inferiors.cc2
-rw-r--r--gdbserver/inferiors.h2
-rw-r--r--gdbserver/linux-aarch32-low.cc2
-rw-r--r--gdbserver/linux-aarch32-low.h2
-rw-r--r--gdbserver/linux-aarch32-tdesc.cc2
-rw-r--r--gdbserver/linux-aarch32-tdesc.h2
-rw-r--r--gdbserver/linux-aarch64-ipa.cc2
-rw-r--r--gdbserver/linux-aarch64-low.cc48
-rw-r--r--gdbserver/linux-aarch64-tdesc.cc2
-rw-r--r--gdbserver/linux-aarch64-tdesc.h2
-rw-r--r--gdbserver/linux-amd64-ipa.cc12
-rw-r--r--gdbserver/linux-arc-low.cc2
-rw-r--r--gdbserver/linux-arm-low.cc2
-rw-r--r--gdbserver/linux-arm-tdesc.cc2
-rw-r--r--gdbserver/linux-arm-tdesc.h2
-rw-r--r--gdbserver/linux-csky-low.cc2
-rw-r--r--gdbserver/linux-i386-ipa.cc8
-rw-r--r--gdbserver/linux-ia64-low.cc2
-rw-r--r--gdbserver/linux-loongarch-low.cc2
-rw-r--r--gdbserver/linux-low.cc62
-rw-r--r--gdbserver/linux-low.h11
-rw-r--r--gdbserver/linux-m68k-low.cc2
-rw-r--r--gdbserver/linux-microblaze-low.cc245
-rw-r--r--gdbserver/linux-mips-low.cc2
-rw-r--r--gdbserver/linux-or1k-low.cc2
-rw-r--r--gdbserver/linux-ppc-ipa.cc2
-rw-r--r--gdbserver/linux-ppc-low.cc2
-rw-r--r--gdbserver/linux-ppc-tdesc-init.h2
-rw-r--r--gdbserver/linux-riscv-low.cc2
-rw-r--r--gdbserver/linux-s390-ipa.cc2
-rw-r--r--gdbserver/linux-s390-low.cc2
-rw-r--r--gdbserver/linux-s390-tdesc.h2
-rw-r--r--gdbserver/linux-sh-low.cc2
-rw-r--r--gdbserver/linux-sparc-low.cc2
-rw-r--r--gdbserver/linux-tic6x-low.cc2
-rw-r--r--gdbserver/linux-x86-low.cc46
-rw-r--r--gdbserver/linux-x86-tdesc.cc2
-rw-r--r--gdbserver/linux-xtensa-low.cc2
-rw-r--r--gdbserver/mem-break.cc2
-rw-r--r--gdbserver/mem-break.h2
-rw-r--r--gdbserver/netbsd-aarch64-low.cc2
-rw-r--r--gdbserver/netbsd-amd64-low.cc2
-rw-r--r--gdbserver/netbsd-i386-low.cc2
-rw-r--r--gdbserver/netbsd-low.cc2
-rw-r--r--gdbserver/netbsd-low.h2
-rw-r--r--gdbserver/notif.cc2
-rw-r--r--gdbserver/notif.h2
-rw-r--r--gdbserver/proc-service.cc2
-rw-r--r--gdbserver/proc-service.list2
-rw-r--r--gdbserver/regcache.cc7
-rw-r--r--gdbserver/regcache.h2
-rw-r--r--gdbserver/remote-utils.cc2
-rw-r--r--gdbserver/remote-utils.h2
-rw-r--r--gdbserver/server.cc488
-rw-r--r--gdbserver/server.h3
-rw-r--r--gdbserver/setup.cfg4
-rw-r--r--gdbserver/symbol.cc2
-rw-r--r--gdbserver/target.cc11
-rw-r--r--gdbserver/target.h9
-rw-r--r--gdbserver/tdesc.cc2
-rw-r--r--gdbserver/tdesc.h2
-rw-r--r--gdbserver/thread-db.cc2
-rw-r--r--gdbserver/tracepoint.cc10
-rw-r--r--gdbserver/tracepoint.h2
-rw-r--r--gdbserver/utils.cc4
-rw-r--r--gdbserver/utils.h2
-rw-r--r--gdbserver/win32-i386-low.cc2
-rw-r--r--gdbserver/win32-low.cc2
-rw-r--r--gdbserver/win32-low.h2
-rw-r--r--gdbserver/x86-low.cc2
-rw-r--r--gdbserver/x86-low.h2
-rw-r--r--gdbserver/x86-tdesc.h2
-rw-r--r--gdbserver/xtensa-xtregs.cc2
93 files changed, 891 insertions, 568 deletions
diff --git a/gdbserver/.dir-locals.el b/gdbserver/.dir-locals.el
index eb4edba..8228d2b 100644
--- a/gdbserver/.dir-locals.el
+++ b/gdbserver/.dir-locals.el
@@ -1,5 +1,5 @@
;; Emacs settings.
-;; Copyright (C) 2012-2024 Free Software Foundation, Inc.
+;; Copyright (C) 2012-2025 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
diff --git a/gdbserver/Makefile.in b/gdbserver/Makefile.in
index 491882e..dbcc18a 100644
--- a/gdbserver/Makefile.in
+++ b/gdbserver/Makefile.in
@@ -1,4 +1,4 @@
-# Copyright (C) 1989-2024 Free Software Foundation, Inc.
+# Copyright (C) 1989-2025 Free Software Foundation, Inc.
# This file is part of GDB.
@@ -194,6 +194,7 @@ SFILES = \
$(srcdir)/linux-loongarch-low.cc \
$(srcdir)/linux-low.cc \
$(srcdir)/linux-m68k-low.cc \
+ $(srcdir)/linux-microblaze-low.cc \
$(srcdir)/linux-mips-low.cc \
$(srcdir)/linux-or1k-low.cc \
$(srcdir)/linux-ppc-low.cc \
diff --git a/gdbserver/ax-result-types.def b/gdbserver/ax-result-types.def
index 67188a7..a5cd933 100644
--- a/gdbserver/ax-result-types.def
+++ b/gdbserver/ax-result-types.def
@@ -1,6 +1,6 @@
/* Agent expression result types.
- Copyright (C) 2023-2024 Free Software Foundation, Inc.
+ Copyright (C) 2023-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdbserver/ax.cc b/gdbserver/ax.cc
index ff42795..567ef7f 100644
--- a/gdbserver/ax.cc
+++ b/gdbserver/ax.cc
@@ -1,5 +1,5 @@
/* Agent expression code for remote server.
- Copyright (C) 2009-2024 Free Software Foundation, Inc.
+ Copyright (C) 2009-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdbserver/ax.h b/gdbserver/ax.h
index 12f9569..ff8a1f5 100644
--- a/gdbserver/ax.h
+++ b/gdbserver/ax.h
@@ -1,5 +1,5 @@
/* Data structures and functions associated with agent expressions in GDB.
- Copyright (C) 2009-2024 Free Software Foundation, Inc.
+ Copyright (C) 2009-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdbserver/configure b/gdbserver/configure
index b45b55f..1554296 100755
--- a/gdbserver/configure
+++ b/gdbserver/configure
@@ -7531,119 +7531,6 @@ $as_echo "#define HAVE_CXX17 1" >>confdefs.h
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
-$as_echo_n "checking for ANSI C header files... " >&6; }
-if ${ac_cv_header_stdc+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <float.h>
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- ac_cv_header_stdc=yes
-else
- ac_cv_header_stdc=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-
-if test $ac_cv_header_stdc = yes; then
- # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <string.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- $EGREP "memchr" >/dev/null 2>&1; then :
-
-else
- ac_cv_header_stdc=no
-fi
-rm -f conftest*
-
-fi
-
-if test $ac_cv_header_stdc = yes; then
- # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <stdlib.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- $EGREP "free" >/dev/null 2>&1; then :
-
-else
- ac_cv_header_stdc=no
-fi
-rm -f conftest*
-
-fi
-
-if test $ac_cv_header_stdc = yes; then
- # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
- if test "$cross_compiling" = yes; then :
- :
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <ctype.h>
-#include <stdlib.h>
-#if ((' ' & 0x0FF) == 0x020)
-# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
-# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
-#else
-# define ISLOWER(c) \
- (('a' <= (c) && (c) <= 'i') \
- || ('j' <= (c) && (c) <= 'r') \
- || ('s' <= (c) && (c) <= 'z'))
-# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
-#endif
-
-#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
-int
-main ()
-{
- int i;
- for (i = 0; i < 256; i++)
- if (XOR (islower (i), ISLOWER (i))
- || toupper (i) != TOUPPER (i))
- return 2;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-
-else
- ac_cv_header_stdc=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
- conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-fi
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5
-$as_echo "$ac_cv_header_stdc" >&6; }
-if test $ac_cv_header_stdc = yes; then
-
-$as_echo "#define STDC_HEADERS 1" >>confdefs.h
-
-fi
-
-
ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default"
if test "x$ac_cv_type_size_t" = xyes; then :
@@ -7920,118 +7807,6 @@ fi
# Set the 'development' global.
. $srcdir/../bfd/development.sh
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
-$as_echo_n "checking for ANSI C header files... " >&6; }
-if ${ac_cv_header_stdc+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <float.h>
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- ac_cv_header_stdc=yes
-else
- ac_cv_header_stdc=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-
-if test $ac_cv_header_stdc = yes; then
- # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <string.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- $EGREP "memchr" >/dev/null 2>&1; then :
-
-else
- ac_cv_header_stdc=no
-fi
-rm -f conftest*
-
-fi
-
-if test $ac_cv_header_stdc = yes; then
- # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <stdlib.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
- $EGREP "free" >/dev/null 2>&1; then :
-
-else
- ac_cv_header_stdc=no
-fi
-rm -f conftest*
-
-fi
-
-if test $ac_cv_header_stdc = yes; then
- # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
- if test "$cross_compiling" = yes; then :
- :
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <ctype.h>
-#include <stdlib.h>
-#if ((' ' & 0x0FF) == 0x020)
-# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
-# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
-#else
-# define ISLOWER(c) \
- (('a' <= (c) && (c) <= 'i') \
- || ('j' <= (c) && (c) <= 'r') \
- || ('s' <= (c) && (c) <= 'z'))
-# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
-#endif
-
-#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
-int
-main ()
-{
- int i;
- for (i = 0; i < 256; i++)
- if (XOR (islower (i), ISLOWER (i))
- || toupper (i) != TOUPPER (i))
- return 2;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
-
-else
- ac_cv_header_stdc=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
- conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-fi
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5
-$as_echo "$ac_cv_header_stdc" >&6; }
-if test $ac_cv_header_stdc = yes; then
-
-$as_echo "#define STDC_HEADERS 1" >>confdefs.h
-
-fi
-
# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
# for constant arguments. Useless!
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working alloca.h" >&5
diff --git a/gdbserver/configure.ac b/gdbserver/configure.ac
index 2abe93e..f5a669a 100644
--- a/gdbserver/configure.ac
+++ b/gdbserver/configure.ac
@@ -1,5 +1,5 @@
dnl Autoconf configure script for GDB server.
-dnl Copyright (C) 2000-2024 Free Software Foundation, Inc.
+dnl Copyright (C) 2000-2025 Free Software Foundation, Inc.
dnl
dnl This file is part of GDB.
dnl
@@ -50,8 +50,6 @@ AC_ARG_PROGRAM
# necessary, set CXX_DIALECT to some -std=xxx switch.
AX_CXX_COMPILE_STDCXX(17, , mandatory)
-AC_HEADER_STDC
-
GDB_AC_COMMON
# This is set by GDB_AC_COMMON.
AC_SUBST(WIN32APILIBS)
diff --git a/gdbserver/configure.srv b/gdbserver/configure.srv
index e8dc8ef..6281cda 100644
--- a/gdbserver/configure.srv
+++ b/gdbserver/configure.srv
@@ -169,6 +169,13 @@ case "${gdbserver_host}" in
srv_linux_regsets=yes
srv_linux_thread_db=yes
;;
+ microblaze*-*-linux*) srv_regobj="microblaze-linux.o"
+ srv_tgtobj="$srv_linux_obj linux-microblaze-low.o"
+ srv_xmlfiles="microblaze-linux.xml"
+ srv_xmlfiles="${srv_xmlfiles} microblaze-core.xml"
+ srv_linux_usrregs=yes
+ srv_linux_thread_db=yes
+ ;;
mips*-*-linux*) srv_regobj="mips-linux.o"
srv_regobj="${srv_regobj} mips-dsp-linux.o"
srv_regobj="${srv_regobj} mips64-linux.o"
diff --git a/gdbserver/debug.cc b/gdbserver/debug.cc
index 3d05a76..0370608 100644
--- a/gdbserver/debug.cc
+++ b/gdbserver/debug.cc
@@ -1,5 +1,5 @@
/* Debugging routines for the remote server for GDB.
- Copyright (C) 2014-2024 Free Software Foundation, Inc.
+ Copyright (C) 2014-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdbserver/debug.h b/gdbserver/debug.h
index eb6f695..eec87eb 100644
--- a/gdbserver/debug.h
+++ b/gdbserver/debug.h
@@ -1,5 +1,5 @@
/* Debugging routines for the remote server for GDB.
- Copyright (C) 2014-2024 Free Software Foundation, Inc.
+ Copyright (C) 2014-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdbserver/dll.cc b/gdbserver/dll.cc
index f49aa56..5ce8b2b 100644
--- a/gdbserver/dll.cc
+++ b/gdbserver/dll.cc
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002-2024 Free Software Foundation, Inc.
+/* Copyright (C) 2002-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdbserver/dll.h b/gdbserver/dll.h
index e603df4..b5d9c39 100644
--- a/gdbserver/dll.h
+++ b/gdbserver/dll.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993-2024 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdbserver/fork-child.cc b/gdbserver/fork-child.cc
index 7e4c69b..2e960a9 100644
--- a/gdbserver/fork-child.cc
+++ b/gdbserver/fork-child.cc
@@ -1,5 +1,5 @@
/* Fork a Unix child process, and set up to debug it, for GDBserver.
- Copyright (C) 1989-2024 Free Software Foundation, Inc.
+ Copyright (C) 1989-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdbserver/gdb_proc_service.h b/gdbserver/gdb_proc_service.h
index fdddd1b..9a1e45c 100644
--- a/gdbserver/gdb_proc_service.h
+++ b/gdbserver/gdb_proc_service.h
@@ -1,5 +1,5 @@
/* <proc_service.h> replacement for systems that don't have it.
- Copyright (C) 2000-2024 Free Software Foundation, Inc.
+ Copyright (C) 2000-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdbserver/gdbreplay.cc b/gdbserver/gdbreplay.cc
index 7f19faf..a517031 100644
--- a/gdbserver/gdbreplay.cc
+++ b/gdbserver/gdbreplay.cc
@@ -1,5 +1,5 @@
/* Replay a remote debug session logfile for GDB.
- Copyright (C) 1996-2024 Free Software Foundation, Inc.
+ Copyright (C) 1996-2025 Free Software Foundation, Inc.
Written by Fred Fish (fnf@cygnus.com) from pieces of gdbserver.
This file is part of GDB.
@@ -462,7 +462,7 @@ static void
gdbreplay_version (void)
{
printf ("GNU gdbreplay %s%s\n"
- "Copyright (C) 2024 Free Software Foundation, Inc.\n"
+ "Copyright (C) 2025 Free Software Foundation, Inc.\n"
"gdbreplay is free software, covered by "
"the GNU General Public License.\n"
"This gdbreplay was configured as \"%s\"\n",
diff --git a/gdbserver/gdbthread.h b/gdbserver/gdbthread.h
index d6e90b1..5e61301 100644
--- a/gdbserver/gdbthread.h
+++ b/gdbserver/gdbthread.h
@@ -1,5 +1,5 @@
/* Multi-thread control defs for remote server for GDB.
- Copyright (C) 1993-2024 Free Software Foundation, Inc.
+ Copyright (C) 1993-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdbserver/hostio.cc b/gdbserver/hostio.cc
index cc47d68..69729a8 100644
--- a/gdbserver/hostio.cc
+++ b/gdbserver/hostio.cc
@@ -1,5 +1,5 @@
/* Host file transfer support for gdbserver.
- Copyright (C) 2007-2024 Free Software Foundation, Inc.
+ Copyright (C) 2007-2025 Free Software Foundation, Inc.
Contributed by CodeSourcery.
@@ -89,12 +89,18 @@ require_filename (char **pp, char *filename)
return 0;
}
+template <typename T>
static int
-require_int (char **pp, int *value)
+require_int (char **pp, T *value)
{
+ constexpr bool is_signed = std::is_signed<T>::value;
+
char *p;
int count, firstdigit;
+ /* Max count of hexadecimal digits in T (1 hex digit is 4 bits). */
+ int max_count = sizeof (T) * CHAR_BIT / 4;
+
p = *pp;
*value = 0;
count = 0;
@@ -111,7 +117,8 @@ require_int (char **pp, int *value)
firstdigit = nib;
/* Don't allow overflow. */
- if (count >= 8 || (count == 7 && firstdigit >= 0x8))
+ if (count >= max_count
+ || (is_signed && count == (max_count - 1) && firstdigit >= 0x8))
return -1;
*value = *value * 16 + nib;
@@ -343,7 +350,8 @@ handle_open (char *own_buf)
static void
handle_pread (char *own_buf, int *new_packet_len)
{
- int fd, ret, len, offset, bytes_sent;
+ int fd, ret, len, bytes_sent;
+ off_t offset;
char *p, *data;
static int max_reply_size = -1;
@@ -410,7 +418,8 @@ handle_pread (char *own_buf, int *new_packet_len)
static void
handle_pwrite (char *own_buf, int packet_len)
{
- int fd, ret, len, offset;
+ int fd, ret, len;
+ off_t offset;
char *p, *data;
p = own_buf + strlen ("vFile:pwrite:");
@@ -504,7 +513,48 @@ handle_stat (char *own_buf, int *new_packet_len)
return;
}
- if (lstat (filename, &st) == -1)
+ if (stat (filename, &st) == -1)
+ {
+ hostio_error (own_buf);
+ return;
+ }
+
+ host_to_fileio_stat (&st, &fst);
+
+ bytes_sent = hostio_reply_with_data (own_buf,
+ (char *) &fst, sizeof (fst),
+ new_packet_len);
+
+ /* If the response does not fit into a single packet, do not attempt
+ to return a partial response, but simply fail. */
+ if (bytes_sent < sizeof (fst))
+ write_enn (own_buf);
+}
+
+static void
+handle_lstat (char *own_buf, int *new_packet_len)
+{
+ int ret, bytes_sent;
+ char *p;
+ struct stat st;
+ struct fio_stat fst;
+ char filename[HOSTIO_PATH_MAX];
+
+ p = own_buf + strlen ("vFile:lstat:");
+
+ if (require_filename (&p, filename)
+ || require_end (p))
+ {
+ hostio_packet_error (own_buf);
+ return;
+ }
+
+ if (hostio_fs_pid != 0)
+ ret = the_target->multifs_lstat (hostio_fs_pid, filename, &st);
+ else
+ ret = lstat (filename, &st);
+
+ if (ret == -1)
{
hostio_error (own_buf);
return;
@@ -641,6 +691,8 @@ handle_vFile (char *own_buf, int packet_len, int *new_packet_len)
handle_fstat (own_buf, new_packet_len);
else if (startswith (own_buf, "vFile:stat:"))
handle_stat (own_buf, new_packet_len);
+ else if (startswith (own_buf, "vFile:lstat:"))
+ handle_lstat (own_buf, new_packet_len);
else if (startswith (own_buf, "vFile:close:"))
handle_close (own_buf);
else if (startswith (own_buf, "vFile:unlink:"))
diff --git a/gdbserver/hostio.h b/gdbserver/hostio.h
index ae406ea..e8852f5 100644
--- a/gdbserver/hostio.h
+++ b/gdbserver/hostio.h
@@ -1,5 +1,5 @@
/* Host file transfer support for gdbserver.
- Copyright (C) 1993-2024 Free Software Foundation, Inc.
+ Copyright (C) 1993-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdbserver/i387-fp.cc b/gdbserver/i387-fp.cc
index bb7b2fc..90824bd 100644
--- a/gdbserver/i387-fp.cc
+++ b/gdbserver/i387-fp.cc
@@ -1,5 +1,5 @@
/* i387-specific utility functions, for the remote server for GDB.
- Copyright (C) 2000-2024 Free Software Foundation, Inc.
+ Copyright (C) 2000-2025 Free Software Foundation, Inc.
This file is part of GDB.
@@ -21,7 +21,7 @@
#include "nat/x86-xstate.h"
/* Default to SSE. */
-static uint64_t x86_xcr0 = X86_XSTATE_SSE_MASK;
+static uint64_t x86_xstate_bv = X86_XSTATE_SSE_MASK;
static const int num_avx512_k_registers = 8;
static const int num_pkeys_registers = 1;
@@ -265,7 +265,7 @@ i387_cache_to_xsave (struct regcache *regcache, void *buf)
/* The supported bits in `xstat_bv' are 8 bytes. Clear part in
vector registers if its bit in xstat_bv is zero. */
- clear_bv = (~fp->xstate_bv) & x86_xcr0;
+ clear_bv = (~fp->xstate_bv) & x86_xstate_bv;
/* Clear part in x87 and vector registers if its bit in xstat_bv is
zero. */
@@ -315,7 +315,7 @@ i387_cache_to_xsave (struct regcache *regcache, void *buf)
}
/* Check if any x87 registers are changed. */
- if ((x86_xcr0 & X86_XSTATE_X87))
+ if ((x86_xstate_bv & X86_XSTATE_X87))
{
int st0_regnum = find_regno (regcache->tdesc, "st0");
@@ -332,7 +332,7 @@ i387_cache_to_xsave (struct regcache *regcache, void *buf)
}
/* Check if any SSE registers are changed. */
- if ((x86_xcr0 & X86_XSTATE_SSE))
+ if ((x86_xstate_bv & X86_XSTATE_SSE))
{
int xmm0_regnum = find_regno (regcache->tdesc, "xmm0");
@@ -349,7 +349,7 @@ i387_cache_to_xsave (struct regcache *regcache, void *buf)
}
/* Check if any AVX registers are changed. */
- if ((x86_xcr0 & X86_XSTATE_AVX))
+ if ((x86_xstate_bv & X86_XSTATE_AVX))
{
int ymm0h_regnum = find_regno (regcache->tdesc, "ymm0h");
@@ -366,7 +366,7 @@ i387_cache_to_xsave (struct regcache *regcache, void *buf)
}
/* Check if any K registers are changed. */
- if ((x86_xcr0 & X86_XSTATE_K))
+ if ((x86_xstate_bv & X86_XSTATE_K))
{
int k0_regnum = find_regno (regcache->tdesc, "k0");
@@ -383,7 +383,7 @@ i387_cache_to_xsave (struct regcache *regcache, void *buf)
}
/* Check if any of ZMM0H-ZMM15H registers are changed. */
- if ((x86_xcr0 & X86_XSTATE_ZMM_H))
+ if ((x86_xstate_bv & X86_XSTATE_ZMM_H))
{
int zmm0h_regnum = find_regno (regcache->tdesc, "zmm0h");
@@ -400,7 +400,7 @@ i387_cache_to_xsave (struct regcache *regcache, void *buf)
}
/* Check if any of ZMM16-ZMM31 registers are changed. */
- if ((x86_xcr0 & X86_XSTATE_ZMM) && num_zmm_high_registers != 0)
+ if ((x86_xstate_bv & X86_XSTATE_ZMM) && num_zmm_high_registers != 0)
{
int zmm16h_regnum = find_regno (regcache->tdesc, "zmm16h");
int ymm16h_regnum = find_regno (regcache->tdesc, "ymm16h");
@@ -437,7 +437,7 @@ i387_cache_to_xsave (struct regcache *regcache, void *buf)
}
/* Check if any PKEYS registers are changed. */
- if ((x86_xcr0 & X86_XSTATE_PKRU))
+ if ((x86_xstate_bv & X86_XSTATE_PKRU))
{
int pkru_regnum = find_regno (regcache->tdesc, "pkru");
@@ -453,7 +453,7 @@ i387_cache_to_xsave (struct regcache *regcache, void *buf)
}
}
- if ((x86_xcr0 & X86_XSTATE_SSE) || (x86_xcr0 & X86_XSTATE_AVX))
+ if ((x86_xstate_bv & X86_XSTATE_SSE) || (x86_xstate_bv & X86_XSTATE_AVX))
{
collect_register_by_name (regcache, "mxcsr", raw);
if (memcmp (raw, &fp->mxcsr, 4) != 0)
@@ -465,7 +465,7 @@ i387_cache_to_xsave (struct regcache *regcache, void *buf)
}
}
- if (x86_xcr0 & X86_XSTATE_X87)
+ if (x86_xstate_bv & X86_XSTATE_X87)
{
collect_register_by_name (regcache, "fioff", raw);
if (memcmp (raw, &fp->fioff, 4) != 0)
@@ -658,10 +658,10 @@ i387_xsave_to_cache (struct regcache *regcache, const void *buf)
/* The supported bits in `xstat_bv' are 8 bytes. Clear part in
vector registers if its bit in xstat_bv is zero. */
- clear_bv = (~fp->xstate_bv) & x86_xcr0;
+ clear_bv = (~fp->xstate_bv) & x86_xstate_bv;
/* Check if any x87 registers are changed. */
- if ((x86_xcr0 & X86_XSTATE_X87) != 0)
+ if ((x86_xstate_bv & X86_XSTATE_X87) != 0)
{
int st0_regnum = find_regno (regcache->tdesc, "st0");
@@ -678,7 +678,7 @@ i387_xsave_to_cache (struct regcache *regcache, const void *buf)
}
}
- if ((x86_xcr0 & X86_XSTATE_SSE) != 0)
+ if ((x86_xstate_bv & X86_XSTATE_SSE) != 0)
{
int xmm0_regnum = find_regno (regcache->tdesc, "xmm0");
@@ -695,7 +695,7 @@ i387_xsave_to_cache (struct regcache *regcache, const void *buf)
}
}
- if ((x86_xcr0 & X86_XSTATE_AVX) != 0)
+ if ((x86_xstate_bv & X86_XSTATE_AVX) != 0)
{
int ymm0h_regnum = find_regno (regcache->tdesc, "ymm0h");
@@ -712,7 +712,7 @@ i387_xsave_to_cache (struct regcache *regcache, const void *buf)
}
}
- if ((x86_xcr0 & X86_XSTATE_K) != 0)
+ if ((x86_xstate_bv & X86_XSTATE_K) != 0)
{
int k0_regnum = find_regno (regcache->tdesc, "k0");
@@ -729,7 +729,7 @@ i387_xsave_to_cache (struct regcache *regcache, const void *buf)
}
}
- if ((x86_xcr0 & X86_XSTATE_ZMM_H) != 0)
+ if ((x86_xstate_bv & X86_XSTATE_ZMM_H) != 0)
{
int zmm0h_regnum = find_regno (regcache->tdesc, "zmm0h");
@@ -746,7 +746,7 @@ i387_xsave_to_cache (struct regcache *regcache, const void *buf)
}
}
- if ((x86_xcr0 & X86_XSTATE_ZMM) != 0 && num_zmm_high_registers != 0)
+ if ((x86_xstate_bv & X86_XSTATE_ZMM) != 0 && num_zmm_high_registers != 0)
{
int zmm16h_regnum = find_regno (regcache->tdesc, "zmm16h");
int ymm16h_regnum = find_regno (regcache->tdesc, "ymm16h");
@@ -773,7 +773,7 @@ i387_xsave_to_cache (struct regcache *regcache, const void *buf)
}
}
- if ((x86_xcr0 & X86_XSTATE_PKRU) != 0)
+ if ((x86_xstate_bv & X86_XSTATE_PKRU) != 0)
{
int pkru_regnum = find_regno (regcache->tdesc, "pkru");
@@ -858,5 +858,5 @@ i387_xsave_to_cache (struct regcache *regcache, const void *buf)
std::pair<uint64_t *, x86_xsave_layout *>
i387_get_xsave_storage ()
{
- return { &x86_xcr0, &xsave_layout };
+ return { &x86_xstate_bv, &xsave_layout };
}
diff --git a/gdbserver/i387-fp.h b/gdbserver/i387-fp.h
index 4ee21da..96fb66c 100644
--- a/gdbserver/i387-fp.h
+++ b/gdbserver/i387-fp.h
@@ -1,5 +1,5 @@
/* i387-specific utility functions, for the remote server for GDB.
- Copyright (C) 2000-2024 Free Software Foundation, Inc.
+ Copyright (C) 2000-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdbserver/inferiors.cc b/gdbserver/inferiors.cc
index 14556d3..f13c784 100644
--- a/gdbserver/inferiors.cc
+++ b/gdbserver/inferiors.cc
@@ -1,5 +1,5 @@
/* Inferior process information for the remote server for GDB.
- Copyright (C) 2002-2024 Free Software Foundation, Inc.
+ Copyright (C) 2002-2025 Free Software Foundation, Inc.
Contributed by MontaVista Software.
diff --git a/gdbserver/inferiors.h b/gdbserver/inferiors.h
index 3f7d80f..0578acd 100644
--- a/gdbserver/inferiors.h
+++ b/gdbserver/inferiors.h
@@ -1,5 +1,5 @@
/* Inferior process information for the remote server for GDB.
- Copyright (C) 1993-2024 Free Software Foundation, Inc.
+ Copyright (C) 1993-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdbserver/linux-aarch32-low.cc b/gdbserver/linux-aarch32-low.cc
index a70cc4a..3dbb7fe 100644
--- a/gdbserver/linux-aarch32-low.cc
+++ b/gdbserver/linux-aarch32-low.cc
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995-2024 Free Software Foundation, Inc.
+/* Copyright (C) 1995-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdbserver/linux-aarch32-low.h b/gdbserver/linux-aarch32-low.h
index b684a5d..2cd1c04 100644
--- a/gdbserver/linux-aarch32-low.h
+++ b/gdbserver/linux-aarch32-low.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995-2024 Free Software Foundation, Inc.
+/* Copyright (C) 1995-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdbserver/linux-aarch32-tdesc.cc b/gdbserver/linux-aarch32-tdesc.cc
index 441fe66..675eb58 100644
--- a/gdbserver/linux-aarch32-tdesc.cc
+++ b/gdbserver/linux-aarch32-tdesc.cc
@@ -1,4 +1,4 @@
-/* Copyright (C) 2019-2024 Free Software Foundation, Inc.
+/* Copyright (C) 2019-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdbserver/linux-aarch32-tdesc.h b/gdbserver/linux-aarch32-tdesc.h
index 173eac2..2aa74f1 100644
--- a/gdbserver/linux-aarch32-tdesc.h
+++ b/gdbserver/linux-aarch32-tdesc.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2019-2024 Free Software Foundation, Inc.
+/* Copyright (C) 2019-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdbserver/linux-aarch64-ipa.cc b/gdbserver/linux-aarch64-ipa.cc
index 99b7700..4a700b1 100644
--- a/gdbserver/linux-aarch64-ipa.cc
+++ b/gdbserver/linux-aarch64-ipa.cc
@@ -1,7 +1,7 @@
/* GNU/Linux/AArch64 specific low level interface, for the in-process
agent library for GDB.
- Copyright (C) 2015-2024 Free Software Foundation, Inc.
+ Copyright (C) 2015-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdbserver/linux-aarch64-low.cc b/gdbserver/linux-aarch64-low.cc
index 7dabd57..9d3ac80 100644
--- a/gdbserver/linux-aarch64-low.cc
+++ b/gdbserver/linux-aarch64-low.cc
@@ -1,7 +1,7 @@
/* GNU/Linux/AArch64 specific low level interface, for the remote server for
GDB.
- Copyright (C) 2009-2024 Free Software Foundation, Inc.
+ Copyright (C) 2009-2025 Free Software Foundation, Inc.
Contributed by ARM Ltd.
This file is part of GDB.
@@ -39,6 +39,7 @@
#include "gdb_proc_service.h"
#include "arch/aarch64.h"
+#include "arch/aarch64-gcs-linux.h"
#include "arch/aarch64-mte-linux.h"
#include "arch/aarch64-scalable-linux.h"
#include "linux-aarch32-tdesc.h"
@@ -321,6 +322,42 @@ aarch64_store_tlsregset (struct regcache *regcache, const void *buf)
supply_register (regcache, *regnum, tls_buf + sizeof (uint64_t));
}
+/* Fill BUF with the GCS registers from REGCACHE. */
+
+static void
+aarch64_fill_gcsregset (regcache *regcache, void *buf)
+{
+ user_gcs *regset = (user_gcs *) buf;
+ int gcspr_regnum = find_regno (regcache->tdesc, "gcspr");
+ int features_enabled_regnum = find_regno (regcache->tdesc,
+ "gcs_features_enabled");
+ int features_locked_regnum = find_regno (regcache->tdesc,
+ "gcs_features_locked");
+
+ collect_register (regcache, gcspr_regnum, &regset->gcspr_el0);
+ collect_register (regcache, features_enabled_regnum,
+ &regset->features_enabled);
+ collect_register (regcache, features_locked_regnum, &regset->features_locked);
+}
+
+/* Store the GCS registers in BUF to REGCACHE. */
+
+static void
+aarch64_store_gcsregset (regcache *regcache, const void *buf)
+{
+ const user_gcs *regset = (const user_gcs *) buf;
+ int gcspr_regnum = find_regno (regcache->tdesc, "gcspr");
+ int features_enabled_regnum = find_regno (regcache->tdesc,
+ "gcs_features_enabled");
+ int features_locked_regnum = find_regno (regcache->tdesc,
+ "gcs_features_locked");
+
+ supply_register (regcache, gcspr_regnum, &regset->gcspr_el0);
+ supply_register (regcache, features_enabled_regnum,
+ &regset->features_enabled);
+ supply_register (regcache, features_locked_regnum, &regset->features_locked);
+}
+
bool
aarch64_target::low_supports_breakpoints ()
{
@@ -846,6 +883,10 @@ static struct regset_info aarch64_regsets[] =
{ PTRACE_GETREGSET, PTRACE_SETREGSET, NT_ARM_TLS,
0, OPTIONAL_REGS,
aarch64_fill_tlsregset, aarch64_store_tlsregset },
+ /* Guarded Control Stack registers. */
+ { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_ARM_GCS,
+ 0, OPTIONAL_REGS,
+ aarch64_fill_gcsregset, aarch64_store_gcsregset },
NULL_REGSET
};
@@ -909,6 +950,10 @@ aarch64_adjust_register_sets (const struct aarch64_features &features)
if (features.sme2)
regset->size = AARCH64_SME2_ZT0_SIZE;
break;
+ case NT_ARM_GCS:
+ if (features.gcs_linux)
+ regset->size = sizeof (user_gcs);
+ break;
default:
gdb_assert_not_reached ("Unknown register set found.");
}
@@ -940,6 +985,7 @@ aarch64_target::low_arch_setup ()
/* A-profile MTE is 64-bit only. */
features.mte = linux_get_hwcap2 (pid, 8) & HWCAP2_MTE;
features.tls = aarch64_tls_register_count (tid);
+ features.gcs = features.gcs_linux = linux_get_hwcap (pid, 8) & HWCAP_GCS;
/* Scalable Matrix Extension feature and size check. */
if (linux_get_hwcap2 (pid, 8) & HWCAP2_SME)
diff --git a/gdbserver/linux-aarch64-tdesc.cc b/gdbserver/linux-aarch64-tdesc.cc
index 52642d5..cbd049d 100644
--- a/gdbserver/linux-aarch64-tdesc.cc
+++ b/gdbserver/linux-aarch64-tdesc.cc
@@ -1,6 +1,6 @@
/* GNU/Linux/aarch64 specific target description, for the remote server
for GDB.
- Copyright (C) 2017-2024 Free Software Foundation, Inc.
+ Copyright (C) 2017-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdbserver/linux-aarch64-tdesc.h b/gdbserver/linux-aarch64-tdesc.h
index 4076720..5a86082 100644
--- a/gdbserver/linux-aarch64-tdesc.h
+++ b/gdbserver/linux-aarch64-tdesc.h
@@ -1,6 +1,6 @@
/* Low level support for aarch64, shared between gdbserver and IPA.
- Copyright (C) 2016-2024 Free Software Foundation, Inc.
+ Copyright (C) 2016-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdbserver/linux-amd64-ipa.cc b/gdbserver/linux-amd64-ipa.cc
index 0466368..ec66367 100644
--- a/gdbserver/linux-amd64-ipa.cc
+++ b/gdbserver/linux-amd64-ipa.cc
@@ -1,7 +1,7 @@
/* GNU/Linux/x86-64 specific low level interface, for the in-process
agent library for GDB.
- Copyright (C) 2010-2024 Free Software Foundation, Inc.
+ Copyright (C) 2010-2025 Free Software Foundation, Inc.
This file is part of GDB.
@@ -82,7 +82,7 @@ get_raw_reg (const unsigned char *raw_regs, int regnum)
const struct target_desc *
get_ipa_tdesc (int idx)
{
- uint64_t xcr0 = x86_linux_tdesc_idx_to_xcr0 (idx);
+ uint64_t xstate_bv = x86_linux_tdesc_idx_to_xstate_bv (idx);
#if defined __ILP32__
bool is_x32 = true;
@@ -90,7 +90,7 @@ get_ipa_tdesc (int idx)
bool is_x32 = false;
#endif
- return amd64_linux_read_description (xcr0, is_x32);
+ return amd64_linux_read_description (xstate_bv, is_x32);
}
/* Allocate buffer for the jump pads. The branch instruction has a
@@ -159,9 +159,11 @@ initialize_low_tracepoint (void)
{
#if defined __ILP32__
for (int i = 0; i < x86_linux_x32_tdesc_count (); i++)
- amd64_linux_read_description (x86_linux_tdesc_idx_to_xcr0 (i), true);
+ amd64_linux_read_description
+ (x86_linux_tdesc_idx_to_xstate_bv (i), true);
#else
for (int i = 0; i < x86_linux_amd64_tdesc_count (); i++)
- amd64_linux_read_description (x86_linux_tdesc_idx_to_xcr0 (i), false);
+ amd64_linux_read_description
+ (x86_linux_tdesc_idx_to_xstate_bv (i), false);
#endif
}
diff --git a/gdbserver/linux-arc-low.cc b/gdbserver/linux-arc-low.cc
index 2d408bf..7d27a5b 100644
--- a/gdbserver/linux-arc-low.cc
+++ b/gdbserver/linux-arc-low.cc
@@ -1,6 +1,6 @@
/* Target dependent code for the remote server for GNU/Linux ARC.
- Copyright 2020-2024 Free Software Foundation, Inc.
+ Copyright 2020-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdbserver/linux-arm-low.cc b/gdbserver/linux-arm-low.cc
index 7688691..f4870ee 100644
--- a/gdbserver/linux-arm-low.cc
+++ b/gdbserver/linux-arm-low.cc
@@ -1,5 +1,5 @@
/* GNU/Linux/ARM specific low level interface, for the remote server for GDB.
- Copyright (C) 1995-2024 Free Software Foundation, Inc.
+ Copyright (C) 1995-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdbserver/linux-arm-tdesc.cc b/gdbserver/linux-arm-tdesc.cc
index fff2e94..2671f12 100644
--- a/gdbserver/linux-arm-tdesc.cc
+++ b/gdbserver/linux-arm-tdesc.cc
@@ -1,4 +1,4 @@
-/* Copyright (C) 2019-2024 Free Software Foundation, Inc.
+/* Copyright (C) 2019-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdbserver/linux-arm-tdesc.h b/gdbserver/linux-arm-tdesc.h
index bf12c8f..3793947 100644
--- a/gdbserver/linux-arm-tdesc.h
+++ b/gdbserver/linux-arm-tdesc.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2019-2024 Free Software Foundation, Inc.
+/* Copyright (C) 2019-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdbserver/linux-csky-low.cc b/gdbserver/linux-csky-low.cc
index 18a0d15..e9de986 100644
--- a/gdbserver/linux-csky-low.cc
+++ b/gdbserver/linux-csky-low.cc
@@ -1,5 +1,5 @@
/* GNU/Linux/MIPS specific low level interface, for the remote server for GDB.
- Copyright (C) 2022-2024 Free Software Foundation, Inc.
+ Copyright (C) 2022-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdbserver/linux-i386-ipa.cc b/gdbserver/linux-i386-ipa.cc
index 6dadaaf..4f8398d 100644
--- a/gdbserver/linux-i386-ipa.cc
+++ b/gdbserver/linux-i386-ipa.cc
@@ -1,7 +1,7 @@
/* GNU/Linux/x86 specific low level interface, for the in-process
agent library for GDB.
- Copyright (C) 2010-2024 Free Software Foundation, Inc.
+ Copyright (C) 2010-2025 Free Software Foundation, Inc.
This file is part of GDB.
@@ -174,9 +174,9 @@ initialize_fast_tracepoint_trampoline_buffer (void)
const struct target_desc *
get_ipa_tdesc (int idx)
{
- uint64_t xcr0 = x86_linux_tdesc_idx_to_xcr0 (idx);
+ uint64_t xstate_bv = x86_linux_tdesc_idx_to_xstate_bv (idx);
- return i386_linux_read_description (xcr0);
+ return i386_linux_read_description (xstate_bv);
}
/* Allocate buffer for the jump pads. On i386, we can reach an arbitrary
@@ -199,5 +199,5 @@ initialize_low_tracepoint (void)
{
initialize_fast_tracepoint_trampoline_buffer ();
for (int i = 0; i < x86_linux_i386_tdesc_count (); i++)
- i386_linux_read_description (x86_linux_tdesc_idx_to_xcr0 (i));
+ i386_linux_read_description (x86_linux_tdesc_idx_to_xstate_bv (i));
}
diff --git a/gdbserver/linux-ia64-low.cc b/gdbserver/linux-ia64-low.cc
index b7c3c64..48c5cc8 100644
--- a/gdbserver/linux-ia64-low.cc
+++ b/gdbserver/linux-ia64-low.cc
@@ -1,5 +1,5 @@
/* GNU/Linux/IA64 specific low level interface, for the remote server for GDB.
- Copyright (C) 1995-2024 Free Software Foundation, Inc.
+ Copyright (C) 1995-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdbserver/linux-loongarch-low.cc b/gdbserver/linux-loongarch-low.cc
index 795b6f5..62592a5 100644
--- a/gdbserver/linux-loongarch-low.cc
+++ b/gdbserver/linux-loongarch-low.cc
@@ -1,6 +1,6 @@
/* GNU/Linux/LoongArch specific low level interface, for the remote server
for GDB.
- Copyright (C) 2022-2024 Free Software Foundation, Inc.
+ Copyright (C) 2022-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index 65268a6..e8c4eb8 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -1,5 +1,5 @@
/* Low level interface to ptrace, for the remote server for GDB.
- Copyright (C) 1995-2024 Free Software Foundation, Inc.
+ Copyright (C) 1995-2025 Free Software Foundation, Inc.
This file is part of GDB.
@@ -751,7 +751,7 @@ linux_process_target::handle_extended_wait (lwp_info **orig_event_lwp,
/* Set the event status. */
event_lwp->waitstatus.set_execd
(make_unique_xstrdup
- (linux_proc_pid_to_exec_file (event_thr->id.lwp ())));
+ (pid_to_exec_file (event_thr->id.lwp ())));
/* Mark the exec status as pending. */
event_lwp->stopped = 1;
@@ -5006,23 +5006,31 @@ regsets_fetch_inferior_registers (struct regsets_info *regsets_info,
if (res < 0)
{
if (errno == EIO
- || (errno == EINVAL && regset->type == OPTIONAL_REGS))
+ || (errno == EINVAL
+ && (regset->type == OPTIONAL_REGS
+ || regset->type == OPTIONAL_RUNTIME_REGS)))
{
/* If we get EIO on a regset, or an EINVAL and the regset is
- optional, do not try it again for this process mode. */
+ optional, do not try it again for this process mode.
+ Even if the regset can be enabled at runtime it is safe
+ to deactivate the regset in case of EINVAL, as we know
+ the regset itself was the invalid argument of the ptrace
+ call which means that it's unsupported by the kernel. */
disable_regset (regsets_info, regset);
}
- else if (errno == ENODATA)
+ else if (errno == ENODATA
+ || (errno == ENODEV
+ && regset->type == OPTIONAL_RUNTIME_REGS)
+ || errno == ESRCH)
{
- /* ENODATA may be returned if the regset is currently
- not "active". This can happen in normal operation,
- so suppress the warning in this case. */
- }
- else if (errno == ESRCH)
- {
- /* At this point, ESRCH should mean the process is
- already gone, in which case we simply ignore attempts
- to read its registers. */
+ /* ENODATA or ENODEV may be returned if the regset is
+ currently not "active". For ENODEV we additionally check
+ if the register set is of type OPTIONAL_RUNTIME_REGS.
+ This can happen in normal operation, so suppress the
+ warning in this case.
+ ESRCH should mean the process is already gone at this
+ point, in which case we simply ignore attempts to read
+ its registers. */
}
else
{
@@ -5104,12 +5112,26 @@ regsets_store_inferior_registers (struct regsets_info *regsets_info,
if (res < 0)
{
if (errno == EIO
- || (errno == EINVAL && regset->type == OPTIONAL_REGS))
+ || (errno == EINVAL
+ && (regset->type == OPTIONAL_REGS
+ || regset->type == OPTIONAL_RUNTIME_REGS)))
{
/* If we get EIO on a regset, or an EINVAL and the regset is
- optional, do not try it again for this process mode. */
+ optional, do not try it again for this process mode.
+ Even if the regset can be enabled at runtime it is safe
+ to deactivate the regset in case of EINVAL, as we know
+ the regset itself was the invalid argument of the ptrace
+ call which means that it's unsupported by the kernel. */
disable_regset (regsets_info, regset);
}
+ else if (errno == ENODEV
+ && regset->type == OPTIONAL_RUNTIME_REGS)
+ {
+ /* If we get ENODEV on a regset and the regset can be
+ enabled at runtime try it again for this process mode.
+ This can happen in normal operation, so suppress the
+ warning in this case. */
+ }
else if (errno == ESRCH)
{
/* At this point, ESRCH should mean the process is
@@ -6033,7 +6055,7 @@ linux_process_target::supports_pid_to_exec_file ()
const char *
linux_process_target::pid_to_exec_file (int pid)
{
- return linux_proc_pid_to_exec_file (pid);
+ return linux_proc_pid_to_exec_file (pid, linux_ns_same (pid, LINUX_NS_MNT));
}
bool
@@ -6050,6 +6072,12 @@ linux_process_target::multifs_open (int pid, const char *filename,
}
int
+linux_process_target::multifs_lstat (int pid, const char *filename, struct stat *sb)
+{
+ return linux_mntns_lstat (pid, filename, sb);
+}
+
+int
linux_process_target::multifs_unlink (int pid, const char *filename)
{
return linux_mntns_unlink (pid, filename);
diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h
index 75af38d..5710e49 100644
--- a/gdbserver/linux-low.h
+++ b/gdbserver/linux-low.h
@@ -1,5 +1,5 @@
/* Internal interfaces for the GNU/Linux specific target code for gdbserver.
- Copyright (C) 2002-2024 Free Software Foundation, Inc.
+ Copyright (C) 2002-2025 Free Software Foundation, Inc.
This file is part of GDB.
@@ -42,7 +42,12 @@ enum regset_type {
GENERAL_REGS,
FP_REGS,
EXTENDED_REGS,
- OPTIONAL_REGS, /* Do not error if the regset cannot be accessed. */
+ OPTIONAL_REGS, /* Do not error if the regset cannot be accessed.
+ Disable the regset instead. */
+ OPTIONAL_RUNTIME_REGS, /* Some optional regsets can only be accessed
+ dependent on the execution flow. For such
+ access errors don't show a warning and don't
+ disable the regset. */
};
/* The arch's regsets array initializer must be terminated with a NULL
@@ -304,6 +309,8 @@ public:
int multifs_open (int pid, const char *filename, int flags,
mode_t mode) override;
+ int multifs_lstat (int pid, const char *filename, struct stat *st) override;
+
int multifs_unlink (int pid, const char *filename) override;
ssize_t multifs_readlink (int pid, const char *filename, char *buf,
diff --git a/gdbserver/linux-m68k-low.cc b/gdbserver/linux-m68k-low.cc
index 8020e49..776e843 100644
--- a/gdbserver/linux-m68k-low.cc
+++ b/gdbserver/linux-m68k-low.cc
@@ -1,5 +1,5 @@
/* GNU/Linux/m68k specific low level interface, for the remote server for GDB.
- Copyright (C) 1995-2024 Free Software Foundation, Inc.
+ Copyright (C) 1995-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdbserver/linux-microblaze-low.cc b/gdbserver/linux-microblaze-low.cc
new file mode 100644
index 0000000..2d97eef
--- /dev/null
+++ b/gdbserver/linux-microblaze-low.cc
@@ -0,0 +1,245 @@
+/* GNU/Linux/Microblaze specific low level interface, for the remote server for
+ GDB.
+ Copyright (C) 1995-2025 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ 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/>. */
+
+#include "server.h"
+#include "linux-low.h"
+
+#include "elf/common.h"
+#include "nat/gdb_ptrace.h"
+#include <endian.h>
+
+#include <asm/ptrace.h>
+#include <sys/procfs.h>
+#include <sys/ptrace.h>
+
+#include "gdb_proc_service.h"
+
+
+static int microblaze_regmap[] =
+ {PT_GPR(0), PT_GPR(1), PT_GPR(2), PT_GPR(3),
+ PT_GPR(4), PT_GPR(5), PT_GPR(6), PT_GPR(7),
+ PT_GPR(8), PT_GPR(9), PT_GPR(10), PT_GPR(11),
+ PT_GPR(12), PT_GPR(13), PT_GPR(14), PT_GPR(15),
+ PT_GPR(16), PT_GPR(17), PT_GPR(18), PT_GPR(19),
+ PT_GPR(20), PT_GPR(21), PT_GPR(22), PT_GPR(23),
+ PT_GPR(24), PT_GPR(25), PT_GPR(26), PT_GPR(27),
+ PT_GPR(28), PT_GPR(29), PT_GPR(30), PT_GPR(31),
+ PT_PC, PT_MSR, PT_EAR, PT_ESR,
+ PT_FSR
+ };
+
+
+
+class microblaze_target : public linux_process_target
+{
+public:
+
+ const regs_info *get_regs_info () override;
+
+ const gdb_byte *sw_breakpoint_from_kind (int kind, int *size) override;
+
+protected:
+
+ void low_arch_setup () override;
+
+ bool low_cannot_fetch_register (int regno) override;
+
+ bool low_cannot_store_register (int regno) override;
+
+ bool low_supports_breakpoints () override;
+
+ CORE_ADDR low_get_pc (regcache *regcache) override;
+
+ void low_set_pc (regcache *regcache, CORE_ADDR newpc) override;
+
+ bool low_breakpoint_at (CORE_ADDR pc) override;
+};
+
+/* The singleton target ops object. */
+
+static microblaze_target the_microblaze_target;
+
+constexpr auto microblaze_num_regs
+ = sizeof (microblaze_regmap) / sizeof (microblaze_regmap[0]);
+
+/* Defined in auto-generated file microblaze-linux-generated.c. */
+void init_registers_microblaze_linux ();
+extern const target_desc *tdesc_microblaze_linux;
+
+bool
+microblaze_target::low_supports_breakpoints ()
+{
+ return true;
+}
+
+bool
+microblaze_target::low_cannot_store_register (int regno)
+{
+ if (microblaze_regmap[regno] == -1 || regno == 0)
+ return 1;
+
+ return 0;
+}
+
+bool
+microblaze_target::low_cannot_fetch_register (int regno)
+{
+ return 0;
+}
+
+CORE_ADDR
+microblaze_target::low_get_pc (regcache *regcache)
+{
+ unsigned long pc;
+
+ collect_register_by_name (regcache, "rpc", &pc);
+ return pc;
+}
+
+void
+microblaze_target::low_set_pc (regcache *regcache, CORE_ADDR pc)
+{
+ unsigned long newpc = pc;
+
+ supply_register_by_name (regcache, "rpc", &newpc);
+}
+
+/* dbtrap insn */
+/* brki r16, 0x18; */
+static const uint32_t microblaze_breakpoint = 0xba0c0018;
+#define microblaze_breakpoint_len 4
+
+const gdb_byte *
+microblaze_target::sw_breakpoint_from_kind (int kind, int *size)
+{
+ *size = microblaze_breakpoint_len;
+ return reinterpret_cast<const gdb_byte *> (&microblaze_breakpoint);
+}
+
+bool
+microblaze_target::low_breakpoint_at (CORE_ADDR where)
+{
+ uint32_t insn;
+
+ read_memory (where, (unsigned char *) &insn, 4);
+ /* If necessary, recognize more trap instructions here. GDB only uses the
+ one. */
+ return insn == microblaze_breakpoint;
+}
+
+#ifdef HAVE_PTRACE_GETREGS
+
+static void
+microblaze_collect_ptrace_register (struct regcache *regcache, int regno,
+ char *buf)
+{
+ memset (buf, 0, sizeof (long));
+
+ if (__BYTE_ORDER == __LITTLE_ENDIAN)
+ {
+ collect_register (regcache, regno, buf);
+ }
+ else if (__BYTE_ORDER == __BIG_ENDIAN)
+ {
+ int size = register_size (regcache->tdesc, regno);
+
+ if (size < sizeof (long))
+ collect_register (regcache, regno, buf + sizeof (long) - size);
+ else
+ collect_register (regcache, regno, buf);
+ }
+}
+
+/* Collect GPRs from REGCACHE into BUF. */
+
+static void microblaze_fill_gregset (struct regcache *regcache, void *buf)
+{
+ int i;
+
+ for (i = 0; i < microblaze_num_regs; i++)
+ microblaze_collect_ptrace_register (regcache, i,
+ (char *) buf + microblaze_regmap[i]);
+}
+
+/* Supply GPRs from BUF into REGCACHE. */
+
+static void
+microblaze_store_gregset (struct regcache *regcache, const void *buf)
+{
+ int i;
+
+ for (i = 0; i < microblaze_num_regs; i++)
+ supply_register (regcache, i, (char *) buf + microblaze_regmap[i]);
+}
+
+static struct regset_info microblaze_regsets[] = {
+ { PTRACE_GETREGS, PTRACE_SETREGS, NT_PRSTATUS,
+ sizeof (elf_gregset_t), GENERAL_REGS,
+ microblaze_fill_gregset, microblaze_store_gregset
+ },
+ NULL_REGSET
+};
+#endif /* HAVE_PTRACE_GETREGS */
+
+static struct usrregs_info microblaze_usrregs_info =
+ {
+ microblaze_num_regs,
+ microblaze_regmap,
+ };
+
+#ifdef HAVE_PTRACE_GETREGS
+static struct regsets_info microblaze_regsets_info =
+ {
+ microblaze_regsets, /* regsets */
+ 0, /* num_regsets */
+ nullptr /* disabled_regsets */
+ };
+#endif /* HAVE_PTRACE_GETREGS */
+
+static struct regs_info microblaze_regs_info =
+ {
+ nullptr, /* regset_bitmap */
+ &microblaze_usrregs_info,
+#ifdef HAVE_PTRACE_GETREGS
+ &microblaze_regsets_info
+#endif /* HAVE_PTRACE_GETREGS */
+ };
+
+const regs_info *
+microblaze_target::get_regs_info ()
+{
+ return &microblaze_regs_info;
+}
+
+void
+microblaze_target::low_arch_setup ()
+{
+ current_process ()->tdesc = tdesc_microblaze_linux;
+}
+
+linux_process_target *the_linux_target = &the_microblaze_target;
+
+void
+initialize_low_arch ()
+{
+ init_registers_microblaze_linux ();
+#ifdef HAVE_PTRACE_GETREGS
+ initialize_regsets_info (&microblaze_regsets_info);
+#endif /* HAVE_PTRACE_GETREGS */
+}
diff --git a/gdbserver/linux-mips-low.cc b/gdbserver/linux-mips-low.cc
index fafcdef..295eb87 100644
--- a/gdbserver/linux-mips-low.cc
+++ b/gdbserver/linux-mips-low.cc
@@ -1,5 +1,5 @@
/* GNU/Linux/MIPS specific low level interface, for the remote server for GDB.
- Copyright (C) 1995-2024 Free Software Foundation, Inc.
+ Copyright (C) 1995-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdbserver/linux-or1k-low.cc b/gdbserver/linux-or1k-low.cc
index 1e0fa39..a527913 100644
--- a/gdbserver/linux-or1k-low.cc
+++ b/gdbserver/linux-or1k-low.cc
@@ -1,5 +1,5 @@
/* GNU/Linux/OR1K specific low level interface for the GDB server.
- Copyright (C) 2021-2024 Free Software Foundation, Inc.
+ Copyright (C) 2021-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdbserver/linux-ppc-ipa.cc b/gdbserver/linux-ppc-ipa.cc
index cbbfcfa..66e3940 100644
--- a/gdbserver/linux-ppc-ipa.cc
+++ b/gdbserver/linux-ppc-ipa.cc
@@ -1,7 +1,7 @@
/* GNU/Linux/PowerPC specific low level interface, for the in-process
agent library for GDB.
- Copyright (C) 2016-2024 Free Software Foundation, Inc.
+ Copyright (C) 2016-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdbserver/linux-ppc-low.cc b/gdbserver/linux-ppc-low.cc
index 4fd0ebe..dc8a48b 100644
--- a/gdbserver/linux-ppc-low.cc
+++ b/gdbserver/linux-ppc-low.cc
@@ -1,6 +1,6 @@
/* GNU/Linux/PowerPC specific low level interface, for the remote server for
GDB.
- Copyright (C) 1995-2024 Free Software Foundation, Inc.
+ Copyright (C) 1995-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdbserver/linux-ppc-tdesc-init.h b/gdbserver/linux-ppc-tdesc-init.h
index b64423b..1c18b2a 100644
--- a/gdbserver/linux-ppc-tdesc-init.h
+++ b/gdbserver/linux-ppc-tdesc-init.h
@@ -1,6 +1,6 @@
/* Low level support for ppc, shared between gdbserver and IPA.
- Copyright (C) 2016-2024 Free Software Foundation, Inc.
+ Copyright (C) 2016-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdbserver/linux-riscv-low.cc b/gdbserver/linux-riscv-low.cc
index 44c805bb..8c742f4 100644
--- a/gdbserver/linux-riscv-low.cc
+++ b/gdbserver/linux-riscv-low.cc
@@ -1,6 +1,6 @@
/* GNU/Linux/RISC-V specific low level interface, for the remote server
for GDB.
- Copyright (C) 2020-2024 Free Software Foundation, Inc.
+ Copyright (C) 2020-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdbserver/linux-s390-ipa.cc b/gdbserver/linux-s390-ipa.cc
index 55ce4a4..c547490 100644
--- a/gdbserver/linux-s390-ipa.cc
+++ b/gdbserver/linux-s390-ipa.cc
@@ -1,7 +1,7 @@
/* GNU/Linux S/390 specific low level interface, for the in-process
agent library for GDB.
- Copyright (C) 2016-2024 Free Software Foundation, Inc.
+ Copyright (C) 2016-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdbserver/linux-s390-low.cc b/gdbserver/linux-s390-low.cc
index cd874f6..29bdf58 100644
--- a/gdbserver/linux-s390-low.cc
+++ b/gdbserver/linux-s390-low.cc
@@ -1,6 +1,6 @@
/* GNU/Linux S/390 specific low level interface, for the remote server
for GDB.
- Copyright (C) 2001-2024 Free Software Foundation, Inc.
+ Copyright (C) 2001-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdbserver/linux-s390-tdesc.h b/gdbserver/linux-s390-tdesc.h
index b996e80..24fe550 100644
--- a/gdbserver/linux-s390-tdesc.h
+++ b/gdbserver/linux-s390-tdesc.h
@@ -1,6 +1,6 @@
/* Low level support for s390, shared between gdbserver and IPA.
- Copyright (C) 2016-2024 Free Software Foundation, Inc.
+ Copyright (C) 2016-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdbserver/linux-sh-low.cc b/gdbserver/linux-sh-low.cc
index 64e6de3..f3f65df 100644
--- a/gdbserver/linux-sh-low.cc
+++ b/gdbserver/linux-sh-low.cc
@@ -1,5 +1,5 @@
/* GNU/Linux/SH specific low level interface, for the remote server for GDB.
- Copyright (C) 1995-2024 Free Software Foundation, Inc.
+ Copyright (C) 1995-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdbserver/linux-sparc-low.cc b/gdbserver/linux-sparc-low.cc
index 1ad4122..be42788 100644
--- a/gdbserver/linux-sparc-low.cc
+++ b/gdbserver/linux-sparc-low.cc
@@ -1,5 +1,5 @@
/* Low level interface to ptrace, for the remote server for GDB.
- Copyright (C) 1995-2024 Free Software Foundation, Inc.
+ Copyright (C) 1995-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdbserver/linux-tic6x-low.cc b/gdbserver/linux-tic6x-low.cc
index 707be2e..4400ede 100644
--- a/gdbserver/linux-tic6x-low.cc
+++ b/gdbserver/linux-tic6x-low.cc
@@ -1,6 +1,6 @@
/* Target dependent code for GDB on TI C6x systems.
- Copyright (C) 2010-2024 Free Software Foundation, Inc.
+ Copyright (C) 2010-2025 Free Software Foundation, Inc.
Contributed by Andrew Jenner <andrew@codesourcery.com>
Contributed by Yao Qi <yao@codesourcery.com>
diff --git a/gdbserver/linux-x86-low.cc b/gdbserver/linux-x86-low.cc
index 6c2688d..44257d5 100644
--- a/gdbserver/linux-x86-low.cc
+++ b/gdbserver/linux-x86-low.cc
@@ -1,6 +1,6 @@
/* GNU/Linux/x86-64 specific low level interface, for the remote server
for GDB.
- Copyright (C) 2002-2024 Free Software Foundation, Inc.
+ Copyright (C) 2002-2025 Free Software Foundation, Inc.
This file is part of GDB.
@@ -253,7 +253,8 @@ static const int x86_64_regmap[] =
-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
- -1 /* pkru */
+ -1, /* pkru */
+ -1 /* CET user mode register PL3_SSP. */
};
#define X86_64_NUM_REGS (sizeof (x86_64_regmap) / sizeof (x86_64_regmap[0]))
@@ -406,6 +407,18 @@ x86_target::low_cannot_fetch_register (int regno)
}
static void
+x86_fill_ssp_reg (regcache *regcache, void *buf)
+{
+ collect_register_by_name (regcache, "pl3_ssp", buf);
+}
+
+static void
+x86_store_ssp_reg (regcache *regcache, const void *buf)
+{
+ supply_register_by_name (regcache, "pl3_ssp", buf);
+}
+
+static void
collect_register_i386 (struct regcache *regcache, int regno, void *buf)
{
collect_register (regcache, regno, buf);
@@ -544,6 +557,8 @@ static struct regset_info x86_regsets[] =
x86_fill_gregset, x86_store_gregset },
{ PTRACE_GETREGSET, PTRACE_SETREGSET, NT_X86_XSTATE, 0,
EXTENDED_REGS, x86_fill_xstateregset, x86_store_xstateregset },
+ { PTRACE_GETREGSET, PTRACE_SETREGSET, NT_X86_SHSTK, 0,
+ OPTIONAL_RUNTIME_REGS, x86_fill_ssp_reg, x86_store_ssp_reg },
# ifndef __x86_64__
# ifdef HAVE_PTRACE_GETFPXREGS
{ PTRACE_GETFPXREGS, PTRACE_SETFPXREGS, 0, sizeof (elf_fpxregset_t),
@@ -873,7 +888,7 @@ x86_linux_read_description ()
bool have_ptrace_getregset_was_unknown
= have_ptrace_getregset == TRIBOOL_UNKNOWN;
- /* Get pointers to where we should store the xcr0 and xsave_layout
+ /* Get pointers to where we should store the xstate_bv and xsave_layout
values. These will be filled in by x86_linux_tdesc_for_tid the first
time that the function is called. Subsequent calls will not modify
the stored values. */
@@ -894,7 +909,23 @@ x86_linux_read_description ()
regset++)
{
if (regset->get_request == PTRACE_GETREGSET)
- regset->size = xsave_len;
+ {
+ if (regset->nt_type == NT_X86_XSTATE)
+ regset->size = xsave_len;
+ else if (regset->nt_type == NT_X86_SHSTK)
+ {
+ /* We must configure the size of the NT_X86_SHSTK regset
+ from non-zero value to it's appropriate size, even though
+ the ptrace call is only tested for NT_X86_XSTATE request,
+ because the NT_X86_SHSTK regset is of type
+ OPTIONAL_RUNTIME_REGS. A ptrace call with NT_X86_SHSTK
+ request may only be successful later on, once shadow
+ stack is enabled for the current thread. */
+ regset->size = sizeof (CORE_ADDR);
+ }
+ else
+ gdb_assert_not_reached ("invalid regset type.");
+ }
else if (regset->type != GENERAL_REGS)
regset->size = 0;
}
@@ -2887,17 +2918,16 @@ x86_target::get_ipa_tdesc_idx ()
|| tdesc == tdesc_amd64_linux_no_xml.get ()
#endif /* __x86_64__ */
);
- return x86_linux_xcr0_to_tdesc_idx (X86_XSTATE_SSE_MASK);
+ return x86_linux_xstate_bv_to_tdesc_idx (X86_XSTATE_SSE_MASK);
}
- /* The xcr0 value and xsave layout value are cached when the target
+ /* The xstate_bv value and xsave layout value are cached when the target
description is read. Grab their cache location, and use the cached
value to calculate a tdesc index. */
std::pair<uint64_t *, x86_xsave_layout *> storage
= i387_get_xsave_storage ();
- uint64_t xcr0 = *storage.first;
- return x86_linux_xcr0_to_tdesc_idx (xcr0);
+ return x86_linux_xstate_bv_to_tdesc_idx (*storage.first);
}
/* The linux target ops object. */
diff --git a/gdbserver/linux-x86-tdesc.cc b/gdbserver/linux-x86-tdesc.cc
index 6aa5c4a..4cb0664 100644
--- a/gdbserver/linux-x86-tdesc.cc
+++ b/gdbserver/linux-x86-tdesc.cc
@@ -1,6 +1,6 @@
/* GNU/Linux/x86-64 specific target description, for the remote server
for GDB.
- Copyright (C) 2017-2024 Free Software Foundation, Inc.
+ Copyright (C) 2017-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdbserver/linux-xtensa-low.cc b/gdbserver/linux-xtensa-low.cc
index b20b62e..27a5ed8 100644
--- a/gdbserver/linux-xtensa-low.cc
+++ b/gdbserver/linux-xtensa-low.cc
@@ -1,5 +1,5 @@
/* GNU/Linux/Xtensa specific low level interface, for the remote server for GDB.
- Copyright (C) 2007-2024 Free Software Foundation, Inc.
+ Copyright (C) 2007-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdbserver/mem-break.cc b/gdbserver/mem-break.cc
index 134e243..1a212ec 100644
--- a/gdbserver/mem-break.cc
+++ b/gdbserver/mem-break.cc
@@ -1,5 +1,5 @@
/* Memory breakpoint operations for the remote server for GDB.
- Copyright (C) 2002-2024 Free Software Foundation, Inc.
+ Copyright (C) 2002-2025 Free Software Foundation, Inc.
Contributed by MontaVista Software.
diff --git a/gdbserver/mem-break.h b/gdbserver/mem-break.h
index 12ad19a..0d3009c 100644
--- a/gdbserver/mem-break.h
+++ b/gdbserver/mem-break.h
@@ -1,5 +1,5 @@
/* Memory breakpoint interfaces for the remote server for GDB.
- Copyright (C) 2002-2024 Free Software Foundation, Inc.
+ Copyright (C) 2002-2025 Free Software Foundation, Inc.
Contributed by MontaVista Software.
diff --git a/gdbserver/netbsd-aarch64-low.cc b/gdbserver/netbsd-aarch64-low.cc
index 8834e0a..90f136d 100644
--- a/gdbserver/netbsd-aarch64-low.cc
+++ b/gdbserver/netbsd-aarch64-low.cc
@@ -1,4 +1,4 @@
-/* Copyright (C) 2020-2024 Free Software Foundation, Inc.
+/* Copyright (C) 2020-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdbserver/netbsd-amd64-low.cc b/gdbserver/netbsd-amd64-low.cc
index ad7cb43..c99393a 100644
--- a/gdbserver/netbsd-amd64-low.cc
+++ b/gdbserver/netbsd-amd64-low.cc
@@ -1,4 +1,4 @@
-/* Copyright (C) 2020-2024 Free Software Foundation, Inc.
+/* Copyright (C) 2020-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdbserver/netbsd-i386-low.cc b/gdbserver/netbsd-i386-low.cc
index ea6fce4..d9e2ef7 100644
--- a/gdbserver/netbsd-i386-low.cc
+++ b/gdbserver/netbsd-i386-low.cc
@@ -1,4 +1,4 @@
-/* Copyright (C) 2020-2024 Free Software Foundation, Inc.
+/* Copyright (C) 2020-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdbserver/netbsd-low.cc b/gdbserver/netbsd-low.cc
index 0c75f4b..2984b5b 100644
--- a/gdbserver/netbsd-low.cc
+++ b/gdbserver/netbsd-low.cc
@@ -1,4 +1,4 @@
-/* Copyright (C) 2020-2024 Free Software Foundation, Inc.
+/* Copyright (C) 2020-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdbserver/netbsd-low.h b/gdbserver/netbsd-low.h
index aef1ce4..a503afd 100644
--- a/gdbserver/netbsd-low.h
+++ b/gdbserver/netbsd-low.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2020-2024 Free Software Foundation, Inc.
+/* Copyright (C) 2020-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdbserver/notif.cc b/gdbserver/notif.cc
index 60478dc..0c787fb 100644
--- a/gdbserver/notif.cc
+++ b/gdbserver/notif.cc
@@ -1,5 +1,5 @@
/* Notification to GDB.
- Copyright (C) 1989-2024 Free Software Foundation, Inc.
+ Copyright (C) 1989-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdbserver/notif.h b/gdbserver/notif.h
index 33b7882..50be0b8 100644
--- a/gdbserver/notif.h
+++ b/gdbserver/notif.h
@@ -1,5 +1,5 @@
/* Notification to GDB.
- Copyright (C) 1989-2024 Free Software Foundation, Inc.
+ Copyright (C) 1989-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdbserver/proc-service.cc b/gdbserver/proc-service.cc
index 198a6f2..9575302 100644
--- a/gdbserver/proc-service.cc
+++ b/gdbserver/proc-service.cc
@@ -1,5 +1,5 @@
/* libthread_db helper functions for the remote server for GDB.
- Copyright (C) 2002-2024 Free Software Foundation, Inc.
+ Copyright (C) 2002-2025 Free Software Foundation, Inc.
Contributed by MontaVista Software.
diff --git a/gdbserver/proc-service.list b/gdbserver/proc-service.list
index 1eed6e0..c6320c8 100644
--- a/gdbserver/proc-service.list
+++ b/gdbserver/proc-service.list
@@ -1,6 +1,6 @@
/* -Wl,--dynamic-list symbols exported for libthread_db.
- Copyright (C) 2010-2024 Free Software Foundation, Inc.
+ Copyright (C) 2010-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdbserver/regcache.cc b/gdbserver/regcache.cc
index ee0c1b3..a937a34 100644
--- a/gdbserver/regcache.cc
+++ b/gdbserver/regcache.cc
@@ -1,5 +1,5 @@
/* Register support routines for the remote server for GDB.
- Copyright (C) 2001-2024 Free Software Foundation, Inc.
+ Copyright (C) 2001-2025 Free Software Foundation, Inc.
This file is part of GDB.
@@ -353,8 +353,7 @@ supply_register_by_name_zeroed (struct regcache *regcache,
#endif
/* Supply the whole register set whose contents are stored in BUF, to
- REGCACHE. If BUF is NULL, all the registers' values are recorded
- as unavailable. */
+ REGCACHE. */
void
supply_regblock (struct regcache *regcache, const void *buf)
@@ -503,7 +502,7 @@ regcache::raw_compare (int regnum, const void *buf, int offset) const
gdb_assert (buf != NULL);
gdb::array_view<const gdb_byte> regbuf = register_data (this, regnum);
- gdb_assert (offset < regbuf.size ());
+ gdb_assert (offset <= regbuf.size ());
regbuf = regbuf.slice (offset);
return memcmp (buf, regbuf.data (), regbuf.size ()) == 0;
diff --git a/gdbserver/regcache.h b/gdbserver/regcache.h
index 96d2a4d..89e801f 100644
--- a/gdbserver/regcache.h
+++ b/gdbserver/regcache.h
@@ -1,5 +1,5 @@
/* Register support routines for the remote server for GDB.
- Copyright (C) 2001-2024 Free Software Foundation, Inc.
+ Copyright (C) 2001-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdbserver/remote-utils.cc b/gdbserver/remote-utils.cc
index 67225c5..15f073d 100644
--- a/gdbserver/remote-utils.cc
+++ b/gdbserver/remote-utils.cc
@@ -1,5 +1,5 @@
/* Remote utility routines for the remote server for GDB.
- Copyright (C) 1986-2024 Free Software Foundation, Inc.
+ Copyright (C) 1986-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdbserver/remote-utils.h b/gdbserver/remote-utils.h
index 65ce604..b7a33bc 100644
--- a/gdbserver/remote-utils.h
+++ b/gdbserver/remote-utils.h
@@ -1,5 +1,5 @@
/* Remote utility routines for the remote server for GDB.
- Copyright (C) 1993-2024 Free Software Foundation, Inc.
+ Copyright (C) 1993-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdbserver/server.cc b/gdbserver/server.cc
index def01c1..669c761 100644
--- a/gdbserver/server.cc
+++ b/gdbserver/server.cc
@@ -1,5 +1,5 @@
/* Main code for remote server for GDB.
- Copyright (C) 1989-2024 Free Software Foundation, Inc.
+ Copyright (C) 1989-2025 Free Software Foundation, Inc.
This file is part of GDB.
@@ -51,6 +51,9 @@
#include "gdbsupport/scoped_restore.h"
#include "gdbsupport/search.h"
#include "gdbsupport/gdb_argv_vec.h"
+#include "gdbsupport/remote-args.h"
+
+#include <getopt.h>
/* PBUFSIZ must also be at least as big as IPA_CMD_BUF_SIZE, because
the client state data is passed directly to some agent
@@ -140,6 +143,7 @@ unsigned long signal_pid;
in gdbserver, for the sake of testing GDB against stubs that don't
support them. */
bool disable_packet_vCont;
+bool disable_packet_vCont_step;
bool disable_packet_Tthread;
bool disable_packet_qC;
bool disable_packet_qfThreadInfo;
@@ -1017,20 +1021,15 @@ handle_general_set (char *own_buf)
});
}
- for (const auto &iter : set_options)
- {
- thread_info *thread = iter.first;
- gdb_thread_options options = iter.second;
-
- if (thread->thread_options != options)
- {
- threads_debug_printf ("[options for %s are now %s]\n",
- target_pid_to_str (thread->id).c_str (),
- to_string (options).c_str ());
+ for (const auto &[thread, options] : set_options)
+ if (thread->thread_options != options)
+ {
+ threads_debug_printf ("[options for %s are now %s]\n",
+ target_pid_to_str (thread->id).c_str (),
+ to_string (options).c_str ());
- thread->thread_options = options;
- }
- }
+ thread->thread_options = options;
+ }
write_ok (own_buf);
return;
@@ -2863,7 +2862,7 @@ handle_query (char *own_buf, int packet_len, int *new_packet_len_p)
{
char *end_buf = own_buf + strlen (own_buf);
sprintf (end_buf, ";QThreadOptions=%s",
- phex_nz (supported_options, sizeof (supported_options)));
+ phex_nz (supported_options));
}
strcat (own_buf, ";QThreadEvents+");
@@ -3465,7 +3464,7 @@ handle_v_run (char *own_buf)
else
program_path.set (new_program_name.get ());
- program_args = construct_inferior_arguments (new_argv.get (), true);
+ program_args = gdb::remote_args::join (new_argv.get ());
try
{
@@ -3540,9 +3539,10 @@ handle_v_requests (char *own_buf, int packet_len, int *new_packet_len)
{
strcpy (own_buf, "vCont;c;C;t");
- if (target_supports_hardware_single_step ()
- || target_supports_software_single_step ()
- || !cs.vCont_supported)
+ if (!disable_packet_vCont_step
+ && (target_supports_hardware_single_step ()
+ || target_supports_software_single_step ()
+ || !cs.vCont_supported))
{
/* If target supports single step either by hardware or by
software, add actions s and S to the list of supported
@@ -3812,7 +3812,7 @@ static void
gdbserver_version (void)
{
printf ("GNU gdbserver %s%s\n"
- "Copyright (C) 2024 Free Software Foundation, Inc.\n"
+ "Copyright (C) 2025 Free Software Foundation, Inc.\n"
"gdbserver is free software, covered by the "
"GNU General Public License.\n"
"This gdbserver was configured as \"%s\"\n",
@@ -3875,7 +3875,7 @@ gdbserver_usage (FILE *stream)
" --disable-packet=OPT1[,OPT2,...]\n"
" Disable support for RSP packets or features.\n"
" Options:\n"
- " vCont, T, Tthread, qC, qfThreadInfo and \n"
+ " vCont, vConts, T, Tthread, qC, qfThreadInfo and\n"
" threads (disable all threading packets).\n"
"\n"
"For more information, consult the GDB manual (available as on-line \n"
@@ -4071,6 +4071,33 @@ test_memory_tagging_functions (void)
&& tags.size () == 5);
}
+/* Exercise the behavior of doing a 0-length comparison for a register in a
+ register buffer, which should return true. */
+
+static void test_registers_raw_compare_zero_length ()
+{
+ /* Start off with a dummy target description. */
+ target_desc dummy_tdesc;
+
+ /* Make it 8 bytes long. */
+ dummy_tdesc.registers_size = 8;
+
+ /* Add a couple dummy 32-bit registers. */
+ dummy_tdesc.reg_defs.emplace_back ("r0", 0, 32);
+ dummy_tdesc.reg_defs.emplace_back ("r1", 32, 32);
+
+ /* Create our dummy register cache so we can invoke the raw_compare method
+ we want to validate. */
+ regcache dummy_regcache (&dummy_tdesc);
+
+ /* Create a dummy byte buffer we can pass to the raw_compare method. */
+ gdb_byte dummy_buffer[8];
+
+ /* Validate the 0-length comparison (due to the comparison offset being
+ equal to the length of the register) returns true. */
+ SELF_CHECK (dummy_regcache.raw_compare (0, dummy_buffer, 4));
+}
+
} /* namespace selftests */
#endif /* GDB_SELF_TEST */
@@ -4080,20 +4107,17 @@ test_memory_tagging_functions (void)
[[noreturn]] static void
captured_main (int argc, char *argv[])
{
- int bad_attach;
int pid;
- char *arg_end;
- const char *port = NULL;
- char **next_arg = &argv[1];
- volatile int multi_mode = 0;
- volatile int attach = 0;
- int was_running;
+ volatile bool multi_mode = false;
+ volatile bool attach = false;
bool selftest = false;
#if GDB_SELF_TEST
std::vector<const char *> selftest_filters;
selftests::register_test ("remote_memory_tagging",
selftests::test_memory_tagging_functions);
+ selftests::register_test ("test_registers_raw_compare_zero_length",
+ selftests::test_registers_raw_compare_zero_length);
#endif
current_directory = getcwd (NULL, 0);
@@ -4105,184 +4129,280 @@ captured_main (int argc, char *argv[])
safe_strerror (errno));
}
- while (*next_arg != NULL && **next_arg == '-')
- {
- if (strcmp (*next_arg, "--version") == 0)
+ enum opts { OPT_VERSION = 1, OPT_HELP, OPT_ATTACH, OPT_MULTI, OPT_WRAPPER,
+ OPT_DEBUG, OPT_DEBUG_FILE, OPT_DEBUG_FORMAT, OPT_DISABLE_PACKET,
+ OPT_DISABLE_RANDOMIZATION, OPT_NO_DISABLE_RANDOMIZATION,
+ OPT_STARTUP_WITH_SHELL, OPT_NO_STARTUP_WITH_SHELL, OPT_ONCE,
+ OPT_SELFTEST,
+ };
+
+ static struct option longopts[] =
+ {
+ {"version", no_argument, nullptr, OPT_VERSION},
+ {"help", no_argument, nullptr, OPT_HELP},
+ {"attach", no_argument, nullptr, OPT_ATTACH},
+ {"multi", no_argument, nullptr, OPT_MULTI},
+ {"wrapper", no_argument, nullptr, OPT_WRAPPER},
+ {"debug", optional_argument, nullptr, OPT_DEBUG},
+ {"debug-file", required_argument, nullptr, OPT_DEBUG_FILE},
+ {"debug-format", required_argument, nullptr, OPT_DEBUG_FORMAT},
+ /* --disable-packet is optional_argument only so that we can print a
+ better help list when the argument is missing. */
+ {"disable-packet", optional_argument, nullptr, OPT_DISABLE_PACKET},
+ {"disable-randomization", no_argument, nullptr,
+ OPT_DISABLE_RANDOMIZATION},
+ {"no-disable-randomization", no_argument, nullptr,
+ OPT_NO_DISABLE_RANDOMIZATION},
+ {"startup-with-shell", no_argument, nullptr, OPT_STARTUP_WITH_SHELL},
+ {"no-startup-with-shell", no_argument, nullptr,
+ OPT_NO_STARTUP_WITH_SHELL},
+ {"once", no_argument, nullptr, OPT_ONCE},
+ {"selftest", optional_argument, nullptr, OPT_SELFTEST},
+ {nullptr, no_argument, nullptr, 0}
+ };
+
+ /* Ask getopt_long not to print error messages, we'll do that ourselves.
+ Look for handling of '?' from getopt_long. */
+ opterr = 0;
+
+ int optc, longindex;
+
+ /* The '+' passed to getopt_long here stops ARGV being reordered. In a
+ command line like: 'gdbserver PORT program --arg1 --arg2', the
+ '--arg1' and '--arg2' are arguments to 'program', not to gdbserver.
+ If getopt_long is free to reorder ARGV then it will try to steal those
+ arguments for itself. */
+ while ((longindex = -1,
+ optc = getopt_long (argc, argv, "+", longopts, &longindex)) != -1)
+ {
+ /* We only support '--option=value' form, not '--option value'. To
+ achieve this, if global OPTARG points to the start of the previous
+ ARGV entry, then we must have used the second (unsupported) form,
+ so set OPTARG to NULL and decrement OPTIND to make it appear that
+ there was no value passed. If the option requires an argument,
+ then this means we should convert OPTC to '?' to indicate an
+ error. */
+ if (longindex != -1
+ && longopts[longindex].has_arg != no_argument)
{
- gdbserver_version ();
- exit (0);
+ if (optarg == argv[optind - 1])
+ {
+ optarg = nullptr;
+ --optind;
+ }
+
+ if (longopts[longindex].has_arg == required_argument
+ && optarg == nullptr)
+ optc = '?';
}
- else if (strcmp (*next_arg, "--help") == 0)
+
+ switch (optc)
{
+ case OPT_VERSION:
+ gdbserver_version ();
+ exit (0);
+
+ case OPT_HELP:
gdbserver_usage (stdout);
exit (0);
- }
- else if (strcmp (*next_arg, "--attach") == 0)
- attach = 1;
- else if (strcmp (*next_arg, "--multi") == 0)
- multi_mode = 1;
- else if (strcmp (*next_arg, "--wrapper") == 0)
- {
- char **tmp;
- next_arg++;
+ case OPT_ATTACH:
+ attach = true;
+ break;
- tmp = next_arg;
- while (*next_arg != NULL && strcmp (*next_arg, "--") != 0)
- {
- wrapper_argv += *next_arg;
- wrapper_argv += ' ';
- next_arg++;
- }
+ case OPT_MULTI:
+ multi_mode = true;
+ break;
- if (!wrapper_argv.empty ())
- {
- /* Erase the last whitespace. */
- wrapper_argv.erase (wrapper_argv.end () - 1);
- }
+ case OPT_WRAPPER:
+ {
+ int original_optind = optind;
- if (next_arg == tmp || *next_arg == NULL)
- {
- gdbserver_usage (stderr);
- exit (1);
- }
+ while (argv[optind] != nullptr
+ && strcmp (argv[optind], "--") != 0)
+ {
+ wrapper_argv += argv[optind];
+ wrapper_argv += ' ';
+ ++optind;
+ }
- /* Consume the "--". */
- *next_arg = NULL;
- }
- else if (startswith (*next_arg, "--debug="))
- {
- try
- {
- parse_debug_options ((*next_arg) + sizeof ("--debug=") - 1);
- }
- catch (const gdb_exception_error &exception)
- {
- fflush (stdout);
- fprintf (stderr, "gdbserver: %s\n", exception.what ());
- exit (1);
- }
- }
- else if (strcmp (*next_arg, "--debug") == 0)
- {
- try
- {
- parse_debug_options ("");
- }
- catch (const gdb_exception_error &exception)
- {
- fflush (stdout);
- fprintf (stderr, "gdbserver: %s\n", exception.what ());
- exit (1);
- }
- }
- else if (startswith (*next_arg, "--debug-format="))
- {
- std::string error_msg
- = parse_debug_format_options ((*next_arg)
- + sizeof ("--debug-format=") - 1, 0);
+ if (!wrapper_argv.empty ())
+ {
+ /* Erase the last whitespace. */
+ wrapper_argv.erase (wrapper_argv.end () - 1);
+ }
- if (!error_msg.empty ())
- {
- fprintf (stderr, "%s", error_msg.c_str ());
- exit (1);
- }
- }
- else if (startswith (*next_arg, "--debug-file="))
- debug_set_output ((*next_arg) + sizeof ("--debug-file=") -1);
- else if (strcmp (*next_arg, "--disable-packet") == 0)
- {
- gdbserver_show_disableable (stdout);
- exit (0);
- }
- else if (startswith (*next_arg, "--disable-packet="))
- {
- char *packets = *next_arg += sizeof ("--disable-packet=") - 1;
- char *saveptr;
- for (char *tok = strtok_r (packets, ",", &saveptr);
- tok != NULL;
- tok = strtok_r (NULL, ",", &saveptr))
- {
- if (strcmp ("vCont", tok) == 0)
- disable_packet_vCont = true;
- else if (strcmp ("Tthread", tok) == 0)
- disable_packet_Tthread = true;
- else if (strcmp ("qC", tok) == 0)
- disable_packet_qC = true;
- else if (strcmp ("qfThreadInfo", tok) == 0)
- disable_packet_qfThreadInfo = true;
- else if (strcmp ("T", tok) == 0)
- disable_packet_T = true;
- else if (strcmp ("threads", tok) == 0)
- {
+ if (original_optind == optind || argv[optind] == nullptr)
+ {
+ gdbserver_usage (stderr);
+ exit (1);
+ }
+
+ /* Consume the "--". */
+ ++optind;
+ }
+ break;
+
+ case OPT_DEBUG:
+ {
+ const char *debug_opt = (optarg == nullptr) ? "" : optarg;
+ try
+ {
+ parse_debug_options (debug_opt);
+ }
+ catch (const gdb_exception_error &exception)
+ {
+ fflush (stdout);
+ fprintf (stderr, "gdbserver: %s\n", exception.what ());
+ exit (1);
+ }
+ }
+ break;
+
+ case OPT_DEBUG_FILE:
+ {
+ gdb_assert (optarg != nullptr);
+ debug_set_output (optarg);
+ }
+ break;
+
+ case OPT_DEBUG_FORMAT:
+ {
+ gdb_assert (optarg != nullptr);
+ std::string error_msg
+ = parse_debug_format_options (optarg, 0);
+
+ if (!error_msg.empty ())
+ {
+ fprintf (stderr, "%s", error_msg.c_str ());
+ exit (1);
+ }
+ }
+ break;
+
+ case OPT_DISABLE_PACKET:
+ {
+ char *packets = optarg;
+ if (packets == nullptr)
+ {
+ gdbserver_show_disableable (stdout);
+ exit (1);
+ }
+ char *saveptr;
+ for (char *tok = strtok_r (packets, ",", &saveptr);
+ tok != nullptr;
+ tok = strtok_r (nullptr, ",", &saveptr))
+ {
+ if (strcmp ("vCont", tok) == 0)
disable_packet_vCont = true;
+ else if (strcmp ("vConts", tok) == 0)
+ disable_packet_vCont_step = true;
+ else if (strcmp ("Tthread", tok) == 0)
disable_packet_Tthread = true;
+ else if (strcmp ("qC", tok) == 0)
disable_packet_qC = true;
+ else if (strcmp ("qfThreadInfo", tok) == 0)
disable_packet_qfThreadInfo = true;
- }
- else
- {
- fprintf (stderr, "Don't know how to disable \"%s\".\n\n",
- tok);
- gdbserver_show_disableable (stderr);
- exit (1);
- }
- }
- }
- else if (strcmp (*next_arg, "-") == 0)
- {
- /* "-" specifies a stdio connection and is a form of port
- specification. */
- port = STDIO_CONNECTION_NAME;
+ else if (strcmp ("T", tok) == 0)
+ disable_packet_T = true;
+ else if (strcmp ("threads", tok) == 0)
+ {
+ disable_packet_vCont = true;
+ disable_packet_Tthread = true;
+ disable_packet_qC = true;
+ disable_packet_qfThreadInfo = true;
+ }
+ else
+ {
+ fprintf (stderr, "Don't know how to disable \"%s\".\n\n",
+ tok);
+ gdbserver_show_disableable (stderr);
+ exit (1);
+ }
+ }
+ }
+ break;
- /* Implying --once here prevents a hang after stdin has been closed. */
- run_once = true;
+ case OPT_DISABLE_RANDOMIZATION:
+ cs.disable_randomization = 1;
+ break;
- next_arg++;
+ case OPT_NO_DISABLE_RANDOMIZATION:
+ cs.disable_randomization = 0;
break;
- }
- else if (strcmp (*next_arg, "--disable-randomization") == 0)
- cs.disable_randomization = 1;
- else if (strcmp (*next_arg, "--no-disable-randomization") == 0)
- cs.disable_randomization = 0;
- else if (strcmp (*next_arg, "--startup-with-shell") == 0)
- startup_with_shell = true;
- else if (strcmp (*next_arg, "--no-startup-with-shell") == 0)
- startup_with_shell = false;
- else if (strcmp (*next_arg, "--once") == 0)
- run_once = true;
- else if (strcmp (*next_arg, "--selftest") == 0)
- selftest = true;
- else if (startswith (*next_arg, "--selftest="))
- {
- selftest = true;
+ case OPT_STARTUP_WITH_SHELL:
+ startup_with_shell = true;
+ break;
+
+ case OPT_NO_STARTUP_WITH_SHELL:
+ startup_with_shell = false;
+ break;
+
+ case OPT_ONCE:
+ run_once = true;
+ break;
+
+ case OPT_SELFTEST:
+ {
+ selftest = true;
+ if (optarg != nullptr)
+ {
#if GDB_SELF_TEST
- const char *filter = *next_arg + strlen ("--selftest=");
- if (*filter == '\0')
- {
- fprintf (stderr, _("Error: selftest filter is empty.\n"));
- exit (1);
- }
+ if (*optarg == '\0')
+ {
+ fprintf (stderr, _("Error: selftest filter is empty.\n"));
+ exit (1);
+ }
- selftest_filters.push_back (filter);
+ selftest_filters.push_back (optarg);
#endif
- }
- else
- {
- fprintf (stderr, "Unknown argument: %s\n", *next_arg);
+ }
+ }
+ break;
+
+ case '?':
+ /* Figuring out which element of ARGV contained the invalid
+ argument is not simple. There are a couple of cases we need
+ to consider.
+
+ (1) Something like '-x'. gdbserver doesn't support single
+ character options, so a '-' followed by a character is
+ always invalid. In this case global OPTOPT will be set to
+ 'x', and global OPTIND will point to the next ARGV entry.
+
+ (2) Something like '-xyz'. gdbserver doesn't support single
+ dash arguments for its command line options. The
+ getopt_long call treats this like '-x -y -z', in which
+ case global OPTOPT is set to 'x' and global OPTIND will
+ point to this ARGV entry.
+
+ (3) Something like '--unknown'. This is just an unknown
+ double dash argument. Global OPTOPT is set to '\0', and
+ global OPTIND points to the next ARGV entry. */
+ std::string bad_arg;
+ if (optopt == '\0' || argv[optind] == nullptr
+ || argv[optind][0] != '-' || argv[optind][1] != optopt)
+ bad_arg = argv[optind - 1];
+ else
+ bad_arg = argv[optind];
+
+ fprintf (stderr, "Unknown argument: %s\n", bad_arg.c_str ());
exit (1);
}
-
- next_arg++;
- continue;
}
- if (port == NULL)
+ const char *port = argv[optind];
+ ++optind;
+ if (port != nullptr && strcmp (port, "-") == 0)
{
- port = *next_arg;
- next_arg++;
+ port = STDIO_CONNECTION_NAME;
+
+ /* Implying --once here prevents a hang after stdin has been closed. */
+ run_once = true;
}
+
+ char **next_arg = &argv[optind];
if ((port == NULL || (!attach && !multi_mode && *next_arg == NULL))
&& !selftest)
{
@@ -4303,24 +4423,25 @@ captured_main (int argc, char *argv[])
if (port != NULL)
remote_prepare (port);
- bad_attach = 0;
+ bool bad_attach = false;
pid = 0;
/* --attach used to come after PORT, so allow it there for
compatibility. */
if (*next_arg != NULL && strcmp (*next_arg, "--attach") == 0)
{
- attach = 1;
+ attach = true;
next_arg++;
}
+ char *arg_end;
if (attach
&& (*next_arg == NULL
|| (*next_arg)[0] == '\0'
|| (pid = strtoul (*next_arg, &arg_end, 0)) == 0
|| *arg_end != '\0'
|| next_arg[1] != NULL))
- bad_attach = 1;
+ bad_attach = true;
if (bad_attach)
{
@@ -4385,11 +4506,12 @@ captured_main (int argc, char *argv[])
if (current_thread != nullptr)
current_process ()->dlls_changed = false;
+ bool was_running;
if (cs.last_status.kind () == TARGET_WAITKIND_EXITED
|| cs.last_status.kind () == TARGET_WAITKIND_SIGNALLED)
- was_running = 0;
+ was_running = false;
else
- was_running = 1;
+ was_running = true;
if (!was_running && !multi_mode)
error ("No program to debug");
diff --git a/gdbserver/server.h b/gdbserver/server.h
index e1297d4..b9dacb8 100644
--- a/gdbserver/server.h
+++ b/gdbserver/server.h
@@ -1,5 +1,5 @@
/* Common definitions for remote server for GDB.
- Copyright (C) 1993-2024 Free Software Foundation, Inc.
+ Copyright (C) 1993-2025 Free Software Foundation, Inc.
This file is part of GDB.
@@ -68,6 +68,7 @@ void initialize_low ();
extern bool server_waiting;
extern bool disable_packet_vCont;
+extern bool disable_packet_vCont_step;
extern bool disable_packet_Tthread;
extern bool disable_packet_qC;
extern bool disable_packet_qfThreadInfo;
diff --git a/gdbserver/setup.cfg b/gdbserver/setup.cfg
deleted file mode 100644
index 08646b8..0000000
--- a/gdbserver/setup.cfg
+++ /dev/null
@@ -1,4 +0,0 @@
-[codespell]
-# Skip ChangeLogs and generated files.
-skip = ChangeLog*,configure
-ignore-words = gdb/contrib/codespell-ignore-words.txt
diff --git a/gdbserver/symbol.cc b/gdbserver/symbol.cc
index 435acc7..2807a20 100644
--- a/gdbserver/symbol.cc
+++ b/gdbserver/symbol.cc
@@ -1,6 +1,6 @@
/* Symbol manipulating routines for the remote server for GDB.
- Copyright (C) 2014-2024 Free Software Foundation, Inc.
+ Copyright (C) 2014-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdbserver/target.cc b/gdbserver/target.cc
index a26e159..c400174c 100644
--- a/gdbserver/target.cc
+++ b/gdbserver/target.cc
@@ -1,5 +1,5 @@
/* Target operations for the remote server for GDB.
- Copyright (C) 2002-2024 Free Software Foundation, Inc.
+ Copyright (C) 2002-2025 Free Software Foundation, Inc.
Contributed by MontaVista Software.
@@ -258,7 +258,7 @@ target_pid_to_str (ptid_t ptid)
else if (ptid.tid () != 0)
return string_printf("Thread %d.0x%s",
ptid.pid (),
- phex_nz (ptid.tid (), sizeof (ULONGEST)));
+ phex_nz (ptid.tid ()));
else if (ptid.lwp () != 0)
return string_printf("LWP %d.%ld",
ptid.pid (), ptid.lwp ());
@@ -773,6 +773,13 @@ process_stratum_target::multifs_open (int pid, const char *filename,
}
int
+process_stratum_target::multifs_lstat (int pid, const char *filename,
+ struct stat *sb)
+{
+ return lstat (filename, sb);
+}
+
+int
process_stratum_target::multifs_unlink (int pid, const char *filename)
{
return unlink (filename);
diff --git a/gdbserver/target.h b/gdbserver/target.h
index 782e22c..66ca72f 100644
--- a/gdbserver/target.h
+++ b/gdbserver/target.h
@@ -1,5 +1,5 @@
/* Target operations for the remote server for GDB.
- Copyright (C) 2002-2024 Free Software Foundation, Inc.
+ Copyright (C) 2002-2025 Free Software Foundation, Inc.
Contributed by MontaVista Software.
@@ -31,6 +31,7 @@
#include "gdbsupport/btrace-common.h"
#include <vector>
#include "gdbsupport/byte-vector.h"
+#include <sys/stat.h>
struct emit_ops;
struct process_info;
@@ -441,6 +442,12 @@ public:
virtual int multifs_open (int pid, const char *filename,
int flags, mode_t mode);
+ /* Multiple-filesystem-aware lstat. Like lstat(2), but operating in
+ the filesystem as it appears to process PID. Systems where all
+ processes share a common filesystem should not override this.
+ The default behavior is to use lstat(2). */
+ virtual int multifs_lstat (int pid, const char *filename, struct stat *sb);
+
/* Multiple-filesystem-aware unlink. Like unlink(2), but operates
in the filesystem as it appears to process PID. Systems where
all processes share a common filesystem should not override this.
diff --git a/gdbserver/tdesc.cc b/gdbserver/tdesc.cc
index da1287a..54c105c 100644
--- a/gdbserver/tdesc.cc
+++ b/gdbserver/tdesc.cc
@@ -1,4 +1,4 @@
-/* Copyright (C) 2012-2024 Free Software Foundation, Inc.
+/* Copyright (C) 2012-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdbserver/tdesc.h b/gdbserver/tdesc.h
index 9264786..58b2395 100644
--- a/gdbserver/tdesc.h
+++ b/gdbserver/tdesc.h
@@ -1,5 +1,5 @@
/* Target description definitions for remote server for GDB.
- Copyright (C) 2012-2024 Free Software Foundation, Inc.
+ Copyright (C) 2012-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdbserver/thread-db.cc b/gdbserver/thread-db.cc
index 430504d..20e1dcc 100644
--- a/gdbserver/thread-db.cc
+++ b/gdbserver/thread-db.cc
@@ -1,5 +1,5 @@
/* Thread management interface, for the remote server for GDB.
- Copyright (C) 2002-2024 Free Software Foundation, Inc.
+ Copyright (C) 2002-2025 Free Software Foundation, Inc.
Contributed by MontaVista Software.
diff --git a/gdbserver/tracepoint.cc b/gdbserver/tracepoint.cc
index 5e3792e..b308c82 100644
--- a/gdbserver/tracepoint.cc
+++ b/gdbserver/tracepoint.cc
@@ -1,5 +1,5 @@
/* Tracepoint code for remote server for GDB.
- Copyright (C) 2009-2024 Free Software Foundation, Inc.
+ Copyright (C) 2009-2025 Free Software Foundation, Inc.
This file is part of GDB.
@@ -948,7 +948,7 @@ struct ipa_trace_buffer_control
who wrote last to the buffer control structure. We need to freeze
any inferior writing to the buffer while GDBserver touches memory,
so that the inferior can correctly detect that GDBserver had been
- there, otherwise, it could mistakingly think its commit was
+ there, otherwise, it could mistakenly think its commit was
successful; that's implemented by simply having GDBserver set a
breakpoint the inferior hits if it is the critical region.
@@ -3461,8 +3461,8 @@ cmd_qtstatus (char *packet)
free_space (), phex_nz (trace_buffer_hi - trace_buffer_lo, 0),
circular_trace_buffer,
disconnected_tracing,
- phex_nz (tracing_start_time, sizeof (tracing_start_time)),
- phex_nz (tracing_stop_time, sizeof (tracing_stop_time)),
+ phex_nz (tracing_start_time),
+ phex_nz (tracing_stop_time),
buf1, buf2);
}
@@ -4990,7 +4990,7 @@ build_traceframe_info_xml (char blocktype, unsigned char *dataptr, void *data)
dataptr += sizeof (mlen);
string_xml_appendf (*buffer,
"<memory start=\"0x%s\" length=\"0x%s\"/>\n",
- paddress (maddr), phex_nz (mlen, sizeof (mlen)));
+ paddress (maddr), phex_nz (mlen));
break;
}
case 'V':
diff --git a/gdbserver/tracepoint.h b/gdbserver/tracepoint.h
index b2e410f..602f103 100644
--- a/gdbserver/tracepoint.h
+++ b/gdbserver/tracepoint.h
@@ -1,5 +1,5 @@
/* Tracepoint code for remote server for GDB.
- Copyright (C) 1993-2024 Free Software Foundation, Inc.
+ Copyright (C) 1993-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdbserver/utils.cc b/gdbserver/utils.cc
index 57fceb1..a86405e 100644
--- a/gdbserver/utils.cc
+++ b/gdbserver/utils.cc
@@ -1,5 +1,5 @@
/* General utility routines for the remote server for GDB.
- Copyright (C) 1986-2024 Free Software Foundation, Inc.
+ Copyright (C) 1986-2025 Free Software Foundation, Inc.
This file is part of GDB.
@@ -102,5 +102,5 @@ internal_vwarning (const char *file, int line, const char *fmt, va_list args)
const char *
paddress (CORE_ADDR addr)
{
- return phex_nz (addr, sizeof (CORE_ADDR));
+ return phex_nz (addr);
}
diff --git a/gdbserver/utils.h b/gdbserver/utils.h
index ad1f82c..bebe74a 100644
--- a/gdbserver/utils.h
+++ b/gdbserver/utils.h
@@ -1,5 +1,5 @@
/* General utility routines for the remote server for GDB.
- Copyright (C) 1993-2024 Free Software Foundation, Inc.
+ Copyright (C) 1993-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdbserver/win32-i386-low.cc b/gdbserver/win32-i386-low.cc
index b3e6878..26de2ec 100644
--- a/gdbserver/win32-i386-low.cc
+++ b/gdbserver/win32-i386-low.cc
@@ -1,4 +1,4 @@
-/* Copyright (C) 2007-2024 Free Software Foundation, Inc.
+/* Copyright (C) 2007-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index 3cfae74..89831de 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -1,5 +1,5 @@
/* Low level interface to Windows debugging, for gdbserver.
- Copyright (C) 2006-2024 Free Software Foundation, Inc.
+ Copyright (C) 2006-2025 Free Software Foundation, Inc.
Contributed by Leo Zayas. Based on "win32-nat.c" from GDB.
diff --git a/gdbserver/win32-low.h b/gdbserver/win32-low.h
index e9dd6ad..a76ed9f 100644
--- a/gdbserver/win32-low.h
+++ b/gdbserver/win32-low.h
@@ -1,5 +1,5 @@
/* Internal interfaces for the Win32 specific target code for gdbserver.
- Copyright (C) 2007-2024 Free Software Foundation, Inc.
+ Copyright (C) 2007-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdbserver/x86-low.cc b/gdbserver/x86-low.cc
index c59b31b..14cb012 100644
--- a/gdbserver/x86-low.cc
+++ b/gdbserver/x86-low.cc
@@ -1,6 +1,6 @@
/* Low level support for x86 (i386 and x86-64).
- Copyright (C) 2009-2024 Free Software Foundation, Inc.
+ Copyright (C) 2009-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdbserver/x86-low.h b/gdbserver/x86-low.h
index 89941c5..fcc18f5 100644
--- a/gdbserver/x86-low.h
+++ b/gdbserver/x86-low.h
@@ -1,6 +1,6 @@
/* Low level support for x86 (i386 and x86-64).
- Copyright (C) 2009-2024 Free Software Foundation, Inc.
+ Copyright (C) 2009-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdbserver/x86-tdesc.h b/gdbserver/x86-tdesc.h
index b98d8cf..be903ba 100644
--- a/gdbserver/x86-tdesc.h
+++ b/gdbserver/x86-tdesc.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2018-2024 Free Software Foundation, Inc.
+/* Copyright (C) 2018-2025 Free Software Foundation, Inc.
This file is part of GDB.
diff --git a/gdbserver/xtensa-xtregs.cc b/gdbserver/xtensa-xtregs.cc
index b76a9a9..7e1faca 100644
--- a/gdbserver/xtensa-xtregs.cc
+++ b/gdbserver/xtensa-xtregs.cc
@@ -1,5 +1,5 @@
/* Table mapping between kernel xtregset and GDB register cache.
- Copyright (C) 2007-2024 Free Software Foundation, Inc.
+ Copyright (C) 2007-2025 Free Software Foundation, Inc.
This file is part of GDB.