diff options
Diffstat (limited to 'gdb-7.11/gdb/gdbserver')
-rw-r--r-- | gdb-7.11/gdb/gdbserver/hostio.c | 8 | ||||
-rw-r--r-- | gdb-7.11/gdb/gdbserver/linux-low.c | 5 | ||||
-rw-r--r-- | gdb-7.11/gdb/gdbserver/remote-utils.c | 52 |
3 files changed, 59 insertions, 6 deletions
diff --git a/gdb-7.11/gdb/gdbserver/hostio.c b/gdb-7.11/gdb/gdbserver/hostio.c index 242206e7d..ae0b303e8 100644 --- a/gdb-7.11/gdb/gdbserver/hostio.c +++ b/gdb-7.11/gdb/gdbserver/hostio.c @@ -297,7 +297,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; @@ -321,7 +321,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-7.11/gdb/gdbserver/linux-low.c b/gdb-7.11/gdb/gdbserver/linux-low.c index 8b025bd1b..4c46e94fe 100644 --- a/gdb-7.11/gdb/gdbserver/linux-low.c +++ b/gdb-7.11/gdb/gdbserver/linux-low.c @@ -5783,10 +5783,7 @@ static void linux_request_interrupt (void) { extern unsigned long signal_pid; - - /* 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-7.11/gdb/gdbserver/remote-utils.c b/gdb-7.11/gdb/gdbserver/remote-utils.c index e75147356..4ae6553c3 100644 --- a/gdb-7.11/gdb/gdbserver/remote-utils.c +++ b/gdb-7.11/gdb/gdbserver/remote-utils.c @@ -283,11 +283,63 @@ remote_prepare (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 (char *name) { 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); + + transport_is_reliable = 1; +#endif + + return; + } + // ANDROID END. + port_str = strchr (name, ':'); #ifdef USE_WIN32API if (port_str == NULL) |