summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaibo Huang <hhb@google.com>2020-09-14 11:23:34 -0700
committerHaibo Huang <hhb@google.com>2020-09-14 15:36:41 -0700
commit76f55a3e2a750d666fbe2e296125b31b4e792461 (patch)
tree3b8e919bc09f84590e2c43d8dd77d6d7979c3d4d
parent21c41ff4fba78da92074beff846c759201be5a70 (diff)
downloadgdb-76f55a3e2a750d666fbe2e296125b31b4e792461.tar.gz
Cherry-pick local changes to 9.2
Cherry-picked commits: b711aa8: Add Unix domain socket support to gdbserver 7.9.1. 4c58332: Go back to snprintf rather than strlcpy. c64829b: Fallback to open if multifs_open fails. 2177073: Fix gdbserver process interruption. 35ee683: Remove gdb hack. 78af0f6: Handle cross compile for locale configuration dfc5ca4: Set the default gdb osabi to GNU/Linux. 5cbd102: Specify osabi in arm/aarch64 tdescs. (updated) d378e66: Explicit link -ldl for gdbserver Test: build Change-Id: Iea7f0159ad5d4f5edba0db215a96bc85b3f332cd
-rw-r--r--gdb-9.2/gdb/arch/aarch32.c2
-rw-r--r--gdb-9.2/gdb/arch/aarch64.c2
-rw-r--r--gdb-9.2/gdb/arch/arm.c2
-rwxr-xr-xgdb-9.2/gdb/configure2
-rw-r--r--gdb-9.2/gdb/gdbserver/Makefile.in2
-rwxr-xr-xgdb-9.2/gdb/gdbserver/configure18
-rw-r--r--gdb-9.2/gdb/gdbserver/hostio.c8
-rw-r--r--gdb-9.2/gdb/gdbserver/linux-low.c4
-rw-r--r--gdb-9.2/gdb/gdbserver/remote-utils.c53
-rw-r--r--gdb-9.2/gnulib/configure8
10 files changed, 77 insertions, 24 deletions
diff --git a/gdb-9.2/gdb/arch/aarch32.c b/gdb-9.2/gdb/arch/aarch32.c
index 5bc24a301..7d0208779 100644
--- a/gdb-9.2/gdb/arch/aarch32.c
+++ b/gdb-9.2/gdb/arch/aarch32.c
@@ -39,5 +39,7 @@ aarch32_create_target_description ()
regnum = create_feature_arm_arm_vfpv3 (tdesc, regnum);
tdesc_create_feature (tdesc, "org.gnu.gdb.arm.neon");
+ set_tdesc_osabi (tdesc, "GNU/Linux");
+
return tdesc;
}
diff --git a/gdb-9.2/gdb/arch/aarch64.c b/gdb-9.2/gdb/arch/aarch64.c
index f61154349..4a23c13fe 100644
--- a/gdb-9.2/gdb/arch/aarch64.c
+++ b/gdb-9.2/gdb/arch/aarch64.c
@@ -47,5 +47,7 @@ aarch64_create_target_description (uint64_t vq, bool pauth_p)
if (pauth_p)
regnum = create_feature_aarch64_pauth (tdesc, regnum);
+ set_tdesc_osabi (tdesc, "GNU/Linux");
+
return tdesc;
}
diff --git a/gdb-9.2/gdb/arch/arm.c b/gdb-9.2/gdb/arch/arm.c
index 60d9f8588..ccb686dd9 100644
--- a/gdb-9.2/gdb/arch/arm.c
+++ b/gdb-9.2/gdb/arch/arm.c
@@ -419,6 +419,8 @@ arm_create_target_description (arm_fp_type fp_type)
error (_("Invalid Arm FP type: %d"), fp_type);
}
+ set_tdesc_osabi (tdesc, "GNU/Linux");
+
return tdesc;
}
diff --git a/gdb-9.2/gdb/configure b/gdb-9.2/gdb/configure
index b572d414c..d06110a2e 100755
--- a/gdb-9.2/gdb/configure
+++ b/gdb-9.2/gdb/configure
@@ -6737,7 +6737,7 @@ fi
# For other settings, only the main target counts.
gdb_sim=
-gdb_osabi=
+gdb_osabi=GDB_OSABI_LINUX
build_gdbserver=
targ=$target; . ${srcdir}/configure.tgt
diff --git a/gdb-9.2/gdb/gdbserver/Makefile.in b/gdb-9.2/gdb/gdbserver/Makefile.in
index 16a9f2fd3..782430936 100644
--- a/gdb-9.2/gdb/gdbserver/Makefile.in
+++ b/gdb-9.2/gdb/gdbserver/Makefile.in
@@ -410,7 +410,7 @@ gdbserver$(EXEEXT): $(sort $(OBS)) ${CDEPS} $(LIBGNU) $(LIBIBERTY)
$(SILENCE) rm -f gdbserver$(EXEEXT)
$(ECHO_CXXLD) $(CC_LD) $(INTERNAL_CFLAGS) $(INTERNAL_LDFLAGS) \
-o gdbserver$(EXEEXT) $(OBS) $(LIBGNU) $(LIBIBERTY) \
- $(GDBSERVER_LIBS) $(XM_CLIBS)
+ $(GDBSERVER_LIBS) $(XM_CLIBS) -ldl
$(LIBGNU) $(LIBIBERTY) $(GNULIB_H): all-lib
all-lib: $(GNULIB_BUILDDIR)/Makefile $(LIBIBERTY_BUILDDIR)/Makefile
diff --git a/gdb-9.2/gdb/gdbserver/configure b/gdb-9.2/gdb/gdbserver/configure
index 4de751b44..37763d5af 100755
--- a/gdb-9.2/gdb/gdbserver/configure
+++ b/gdb-9.2/gdb/gdbserver/configure
@@ -8511,20 +8511,7 @@ _ACEOF
fi
-case "${target}" in
- *-android*)
- # Starting with NDK version 9, <elf.h> actually includes definitions
- # of Elf32_auxv_t and Elf64_auxv_t. But sadly, <elf.h> includes
- # <sys/exec_elf.h> which defines some of the ELF types incorrectly,
- # leading to conflicts with the defintions from <linux/elf.h>.
- # This makes it impossible for us to include both <elf.h> and
- # <linux/elf.h>, which means that, in practice, we do not have
- # access to Elf32_auxv_t and Elf64_auxv_t on this platform.
- # Therefore, do not try to auto-detect availability, as it would
- # get it wrong on this platform.
- ;;
- *)
- ac_fn_c_check_type "$LINENO" "Elf32_auxv_t" "ac_cv_type_Elf32_auxv_t" "#include <elf.h>
+ac_fn_c_check_type "$LINENO" "Elf32_auxv_t" "ac_cv_type_Elf32_auxv_t" "#include <elf.h>
"
if test "x$ac_cv_type_Elf32_auxv_t" = xyes; then :
@@ -8547,9 +8534,6 @@ _ACEOF
fi
-esac
-
-
# Check whether --with-pkgversion was given.
if test "${with_pkgversion+set}" = set; then :
diff --git a/gdb-9.2/gdb/gdbserver/hostio.c b/gdb-9.2/gdb/gdbserver/hostio.c
index 8af4fbf40..edc75cba8 100644
--- a/gdb-9.2/gdb/gdbserver/hostio.c
+++ b/gdb-9.2/gdb/gdbserver/hostio.c
@@ -300,7 +300,7 @@ handle_open (char *own_buf)
{
char filename[HOSTIO_PATH_MAX];
char *p;
- int fileio_flags, fileio_mode, flags, fd;
+ int fileio_flags, fileio_mode, flags, fd = -1;
mode_t mode;
struct fd_list *new_fd;
@@ -324,7 +324,11 @@ handle_open (char *own_buf)
if (hostio_fs_pid != 0 && the_target->multifs_open != NULL)
fd = the_target->multifs_open (hostio_fs_pid, filename,
flags, mode);
- else
+
+ /* HACK: multifs_open will fail for android applications, because run-as does
+ not switch to the same mount namespace as the running application. Retry
+ with regular open if this happens. */
+ if (fd == -1)
fd = open (filename, flags, mode);
if (fd == -1)
diff --git a/gdb-9.2/gdb/gdbserver/linux-low.c b/gdb-9.2/gdb/gdbserver/linux-low.c
index 4255795ea..762f8bafb 100644
--- a/gdb-9.2/gdb/gdbserver/linux-low.c
+++ b/gdb-9.2/gdb/gdbserver/linux-low.c
@@ -5904,9 +5904,7 @@ linux_look_up_symbols (void)
static void
linux_request_interrupt (void)
{
- /* Send a SIGINT to the process group. This acts just like the user
- typed a ^C on the controlling terminal. */
- kill (-signal_pid, SIGINT);
+ kill (signal_pid, SIGINT);
}
/* Copy LEN bytes from inferior's auxiliary vector starting at OFFSET
diff --git a/gdb-9.2/gdb/gdbserver/remote-utils.c b/gdb-9.2/gdb/gdbserver/remote-utils.c
index b757740ec..ee04b508a 100644
--- a/gdb-9.2/gdb/gdbserver/remote-utils.c
+++ b/gdb-9.2/gdb/gdbserver/remote-utils.c
@@ -321,11 +321,64 @@ remote_prepare (const char *name)
/* Open a connection to a remote debugger.
NAME is the filename used for communication. */
+// ANDROID BEGIN.
+#ifndef USE_WIN32API
+#include <sys/un.h>
+#endif
+// ANDROID END.
+
void
remote_open (const char *name)
{
+ client_state &cs = get_client_state ();
const char *port_str;
+ // ANDROID BEGIN.
+ // The Android NDK uses Unix domain sockets because applications
+ // aren't allowed to bind to localhost TCP sockets, and developers
+ // debugging on production devices can't get root.
+ // Typical ndk-gdb usage is "gdbserver +debug-socket --attach 123".
+ if (name[0] == '+')
+ {
+#ifdef USE_WIN32API
+ error ("Only <host>:<port> is supported on this platform.");
+#else
+ struct sockaddr_un sockaddr;
+ socklen_t sockaddrlen;
+
+ listen_desc = socket (AF_UNIX, SOCK_STREAM, 0);
+ if (listen_desc == -1)
+ perror_with_name ("Can't create Unix domain socket");
+
+ /* Skip the initial '+'. */
+ name++;
+
+ memset (&sockaddr, 0, sizeof sockaddr);
+ sockaddr.sun_family = AF_UNIX;
+ snprintf (sockaddr.sun_path, sizeof (sockaddr.sun_path), "%s", name);
+ sockaddrlen = sizeof (sockaddr.sun_family) +
+ strlen (sockaddr.sun_path) + 1;
+
+ unlink (sockaddr.sun_path);
+
+ if (bind (listen_desc, (struct sockaddr *) &sockaddr, sockaddrlen)
+ || listen (listen_desc, 1))
+ perror_with_name ("Can't bind Unix domain socket");
+
+ fprintf (stderr, "Listening on Unix domain socket '%s'\n",
+ sockaddr.sun_path);
+ fflush (stderr);
+
+ /* Register the event loop handler. */
+ add_file_handler (listen_desc, handle_accept_event, NULL);
+
+ cs.transport_is_reliable = 1;
+#endif
+
+ return;
+ }
+ // ANDROID END.
+
port_str = strchr (name, ':');
#ifdef USE_WIN32API
if (port_str == NULL)
diff --git a/gdb-9.2/gnulib/configure b/gdb-9.2/gnulib/configure
index 7c74371e8..c0c2e37a3 100644
--- a/gdb-9.2/gnulib/configure
+++ b/gdb-9.2/gnulib/configure
@@ -10128,6 +10128,8 @@ $as_echo "$gl_cv_header_sys_socket_h_shut" >&6; }
$as_echo_n "checking absolute name of <sys/socket.h>... " >&6; }
if ${gl_cv_next_sys_socket_h+:} false; then :
$as_echo_n "(cached) " >&6
+elif test "$cross_compiling" = yes; then :
+ gt_cv_locale_ja=none
else
if test $ac_cv_header_sys_socket_h = yes; then
@@ -10320,6 +10322,8 @@ done
$as_echo_n "checking whether $gl_func is declared without a macro... " >&6; }
if eval \${$as_gl_Symbol+:} false; then :
$as_echo_n "(cached) " >&6
+elif test "$cross_compiling" = yes; then :
+ gt_cv_locale_zh_CN=none
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
@@ -10418,6 +10422,8 @@ $as_echo "#define HAVE_IPV4 1" >>confdefs.h
$as_echo_n "checking for IPv6 sockets... " >&6; }
if ${gl_cv_socket_ipv6+:} false; then :
$as_echo_n "(cached) " >&6
+elif test "$cross_compiling" = yes; then :
+ gt_cv_locale_fr_utf8=none
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
@@ -10554,6 +10560,8 @@ $as_echo "$gl_cv_next_limits_h" >&6; }
$as_echo_n "checking whether limits.h has ULLONG_WIDTH etc.... " >&6; }
if ${gl_cv_header_limits_width+:} false; then :
$as_echo_n "(cached) " >&6
+elif test "$cross_compiling" = yes; then :
+ gt_cv_locale_fr=none
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */