Revert union gdb_sockaddr_u

This reverts 366c75fc.

We don't actually need to access the object through
"struct sockaddr *", so we don't need the union:
   https://sourceware.org/ml/gdb-patches/2015-03/msg00213.html

gdb/ChangeLog:
2015-03-09  Pedro Alves  <palves@redhat.com>

	Revert:
	2015-03-07  Pedro Alves  <palves@redhat.com>
	* common/gdb_socket.h: New file.
	* ser-tcp.c: Include gdb_socket.h.  Don't include netinet/in.h nor
	sys/socket.h.
	(net_open): Use union gdb_sockaddr_u.

gdb/gdbserver/ChangeLog:
2015-03-09  Pedro Alves  <palves@redhat.com>

	Revert:
	2015-03-07  Pedro Alves  <palves@redhat.com>
	* gdbreplay.c: No longer include <netinet/in.h>, <sys/socket.h>,
	or <winsock2.h> here.  Instead include "gdb_socket.h".
	(remote_open): Use union gdb_sockaddr_u.
	* remote-utils.c: No longer include <netinet/in.h>, <sys/socket.h>
	or <winsock2.h> here.  Instead include "gdb_socket.h".
	(handle_accept_event, remote_prepare): Use union gdb_sockaddr_u.
	* tracepoint.c: Include "gdb_socket.h" instead of <sys/socket.h>
	or <sys/un.h>.
	(init_named_socket, gdb_agent_helper_thread): Use union
	gdb_sockaddr_u.
This commit is contained in:
Pedro Alves 2015-03-09 11:27:05 +00:00
parent 43fa85d9a8
commit 9eb1356e38
7 changed files with 76 additions and 77 deletions

View file

@ -6817,7 +6817,8 @@ run_inferior_command (char *cmd, int len)
#else /* !IN_PROCESS_AGENT */
#include "gdb_socket.h"
#include <sys/socket.h>
#include <sys/un.h>
#ifndef UNIX_PATH_MAX
#define UNIX_PATH_MAX sizeof(((struct sockaddr_un *) NULL)->sun_path)
@ -6836,7 +6837,7 @@ static int
init_named_socket (const char *name)
{
int result, fd;
union gdb_sockaddr_u addr;
struct sockaddr_un addr;
result = fd = socket (PF_UNIX, SOCK_STREAM, 0);
if (result == -1)
@ -6845,10 +6846,10 @@ init_named_socket (const char *name)
return -1;
}
addr.sa_un.sun_family = AF_UNIX;
addr.sun_family = AF_UNIX;
strncpy (addr.sa_un.sun_path, name, UNIX_PATH_MAX);
addr.sa_un.sun_path[UNIX_PATH_MAX - 1] = '\0';
strncpy (addr.sun_path, name, UNIX_PATH_MAX);
addr.sun_path[UNIX_PATH_MAX - 1] = '\0';
result = access (name, F_OK);
if (result == 0)
@ -6864,7 +6865,7 @@ init_named_socket (const char *name)
warning ("socket %s already exists; overwriting", name);
}
result = bind (fd, &addr.sa, sizeof (addr.sa_un));
result = bind (fd, (struct sockaddr *) &addr, sizeof (addr));
if (result == -1)
{
warning ("bind failed: %s", strerror (errno));
@ -7163,17 +7164,17 @@ gdb_agent_helper_thread (void *arg)
while (1)
{
socklen_t tmp;
union gdb_sockaddr_u sockaddr;
struct sockaddr_un sockaddr;
int fd;
char buf[1];
int ret;
int stop_loop = 0;
tmp = sizeof (sockaddr.sa_un);
tmp = sizeof (sockaddr);
do
{
fd = accept (listen_fd, &sockaddr.sa, &tmp);
fd = accept (listen_fd, &sockaddr, &tmp);
}
/* It seems an ERESTARTSYS can escape out of accept. */
while (fd == -512 || (fd == -1 && errno == EINTR));