diff options
author | Haibo Huang <hhb@google.com> | 2020-03-17 15:29:25 -0700 |
---|---|---|
committer | Haibo Huang <hhb@google.com> | 2020-03-18 12:24:38 -0700 |
commit | fb3e0dcd57c379215f4c7d1c036bd497f1dccb4b (patch) | |
tree | 2ff2c290e469ba1b5b18b05a580f9bee8fae217a | |
parent | 6946403d2926faf71fc214a9444ba6aca3b2ff5c (diff) | |
download | gdb-fb3e0dcd57c379215f4c7d1c036bd497f1dccb4b.tar.gz |
Cherry-pick local changes to 9.1
Cherry-picked commits:
b711aa8: Add Unix domain socket support to gdbserver 7.9.1.
4c58332: Go back to snprintf rather than strlcpy.
b2aa3bd: [NDK] fix gdb 8.3 build for windows (updated)
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)
Test: build
Change-Id: I098bc2f1696580f2c1de6b58af8047fd5e9b40e9
-rw-r--r-- | gdb-9.1/gdb/arch/aarch32.c | 2 | ||||
-rw-r--r-- | gdb-9.1/gdb/arch/aarch64.c | 2 | ||||
-rw-r--r-- | gdb-9.1/gdb/arch/arm.c | 2 | ||||
-rwxr-xr-x | gdb-9.1/gdb/configure | 2 | ||||
-rwxr-xr-x | gdb-9.1/gdb/gdbserver/configure | 18 | ||||
-rw-r--r-- | gdb-9.1/gdb/gdbserver/hostio.c | 8 | ||||
-rw-r--r-- | gdb-9.1/gdb/gdbserver/linux-low.c | 4 | ||||
-rw-r--r-- | gdb-9.1/gdb/gdbserver/remote-utils.c | 53 | ||||
-rw-r--r-- | gdb-9.1/gdb/gdbsupport/new-op.c | 6 | ||||
-rw-r--r-- | gdb-9.1/gnulib/configure | 8 |
10 files changed, 82 insertions, 23 deletions
diff --git a/gdb-9.1/gdb/arch/aarch32.c b/gdb-9.1/gdb/arch/aarch32.c index 5bc24a301..7d0208779 100644 --- a/gdb-9.1/gdb/arch/aarch32.c +++ b/gdb-9.1/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.1/gdb/arch/aarch64.c b/gdb-9.1/gdb/arch/aarch64.c index f61154349..4a23c13fe 100644 --- a/gdb-9.1/gdb/arch/aarch64.c +++ b/gdb-9.1/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.1/gdb/arch/arm.c b/gdb-9.1/gdb/arch/arm.c index 60d9f8588..ccb686dd9 100644 --- a/gdb-9.1/gdb/arch/arm.c +++ b/gdb-9.1/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.1/gdb/configure b/gdb-9.1/gdb/configure index b572d414c..d06110a2e 100755 --- a/gdb-9.1/gdb/configure +++ b/gdb-9.1/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.1/gdb/gdbserver/configure b/gdb-9.1/gdb/gdbserver/configure index 4de751b44..37763d5af 100755 --- a/gdb-9.1/gdb/gdbserver/configure +++ b/gdb-9.1/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.1/gdb/gdbserver/hostio.c b/gdb-9.1/gdb/gdbserver/hostio.c index 8af4fbf40..edc75cba8 100644 --- a/gdb-9.1/gdb/gdbserver/hostio.c +++ b/gdb-9.1/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.1/gdb/gdbserver/linux-low.c b/gdb-9.1/gdb/gdbserver/linux-low.c index 4255795ea..762f8bafb 100644 --- a/gdb-9.1/gdb/gdbserver/linux-low.c +++ b/gdb-9.1/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.1/gdb/gdbserver/remote-utils.c b/gdb-9.1/gdb/gdbserver/remote-utils.c index b757740ec..ee04b508a 100644 --- a/gdb-9.1/gdb/gdbserver/remote-utils.c +++ b/gdb-9.1/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.1/gdb/gdbsupport/new-op.c b/gdb-9.1/gdb/gdbsupport/new-op.c index cf2525c95..c0c943e1a 100644 --- a/gdb-9.1/gdb/gdbsupport/new-op.c +++ b/gdb-9.1/gdb/gdbsupport/new-op.c @@ -22,6 +22,10 @@ # define __has_feature(x) 0 #endif +// ANDROID CHANGE: Can not override operator new for libc++ in WIN32. +// See b/135839860. +#if !defined(_WIN32) + #if !__has_feature(address_sanitizer) && !defined(__SANITIZE_ADDRESS__) #include "common-defs.h" #include "host-defs.h" @@ -93,3 +97,5 @@ operator new[] (std::size_t sz, const std::nothrow_t&) noexcept return ::operator new (sz, std::nothrow); } #endif + +#endif diff --git a/gdb-9.1/gnulib/configure b/gdb-9.1/gnulib/configure index 7c74371e8..c0c2e37a3 100644 --- a/gdb-9.1/gnulib/configure +++ b/gdb-9.1/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. */ |