mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-20 09:58:19 +08:00
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:
@ -30,6 +30,12 @@
|
||||
#if HAVE_SYS_FILE_H
|
||||
#include <sys/file.h>
|
||||
#endif
|
||||
#if HAVE_NETINET_IN_H
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
#if HAVE_SYS_SOCKET_H
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
#if HAVE_NETDB_H
|
||||
#include <netdb.h>
|
||||
#endif
|
||||
@ -51,7 +57,10 @@
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
#include <sys/stat.h>
|
||||
#include "gdb_socket.h"
|
||||
|
||||
#if USE_WIN32API
|
||||
#include <winsock2.h>
|
||||
#endif
|
||||
|
||||
#if __QNX__
|
||||
#include <sys/iomgr.h>
|
||||
@ -144,14 +153,14 @@ enable_async_notification (int fd)
|
||||
static int
|
||||
handle_accept_event (int err, gdb_client_data client_data)
|
||||
{
|
||||
union gdb_sockaddr_u sockaddr;
|
||||
struct sockaddr_in sockaddr;
|
||||
socklen_t tmp;
|
||||
|
||||
if (debug_threads)
|
||||
debug_printf ("handling possible accept event\n");
|
||||
|
||||
tmp = sizeof (sockaddr.sa_in);
|
||||
remote_desc = accept (listen_desc, &sockaddr.sa, &tmp);
|
||||
tmp = sizeof (sockaddr);
|
||||
remote_desc = accept (listen_desc, (struct sockaddr *) &sockaddr, &tmp);
|
||||
if (remote_desc == -1)
|
||||
perror_with_name ("Accept failed");
|
||||
|
||||
@ -186,7 +195,7 @@ handle_accept_event (int err, gdb_client_data client_data)
|
||||
|
||||
/* Convert IP address to string. */
|
||||
fprintf (stderr, "Remote debugging from host %s\n",
|
||||
inet_ntoa (sockaddr.sa_in.sin_addr));
|
||||
inet_ntoa (sockaddr.sin_addr));
|
||||
|
||||
enable_async_notification (remote_desc);
|
||||
|
||||
@ -215,7 +224,7 @@ remote_prepare (char *name)
|
||||
static int winsock_initialized;
|
||||
#endif
|
||||
int port;
|
||||
union gdb_sockaddr_u sockaddr;
|
||||
struct sockaddr_in sockaddr;
|
||||
socklen_t tmp;
|
||||
char *port_end;
|
||||
|
||||
@ -260,11 +269,11 @@ remote_prepare (char *name)
|
||||
setsockopt (listen_desc, SOL_SOCKET, SO_REUSEADDR, (char *) &tmp,
|
||||
sizeof (tmp));
|
||||
|
||||
sockaddr.sa_in.sin_family = PF_INET;
|
||||
sockaddr.sa_in.sin_port = htons (port);
|
||||
sockaddr.sa_in.sin_addr.s_addr = INADDR_ANY;
|
||||
sockaddr.sin_family = PF_INET;
|
||||
sockaddr.sin_port = htons (port);
|
||||
sockaddr.sin_addr.s_addr = INADDR_ANY;
|
||||
|
||||
if (bind (listen_desc, &sockaddr.sa, sizeof (sockaddr.sa_in))
|
||||
if (bind (listen_desc, (struct sockaddr *) &sockaddr, sizeof (sockaddr))
|
||||
|| listen (listen_desc, 1))
|
||||
perror_with_name ("Can't bind address");
|
||||
|
||||
|
Reference in New Issue
Block a user