2005-06-14 05:32:01 +08:00
|
|
|
/* Serial interface for raw TCP connections on Un*x like systems.
|
|
|
|
|
2013-01-01 14:33:28 +08:00
|
|
|
Copyright (C) 1992-2013 Free Software Foundation, Inc.
|
1999-04-16 09:35:26 +08:00
|
|
|
|
1999-07-08 04:19:36 +08:00
|
|
|
This file is part of GDB.
|
1999-04-16 09:35:26 +08:00
|
|
|
|
1999-07-08 04:19:36 +08:00
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
2007-08-24 02:08:50 +08:00
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
1999-07-08 04:19:36 +08:00
|
|
|
(at your option) any later version.
|
1999-04-16 09:35:26 +08:00
|
|
|
|
1999-07-08 04:19:36 +08:00
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
1999-04-16 09:35:26 +08:00
|
|
|
|
1999-07-08 04:19:36 +08:00
|
|
|
You should have received a copy of the GNU General Public License
|
2007-08-24 02:08:50 +08:00
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
|
|
#include "defs.h"
|
|
|
|
#include "serial.h"
|
2005-03-26 03:47:23 +08:00
|
|
|
#include "ser-base.h"
|
* NEWS: Mention native Windows support.
* Makefile.in (gdb_select_h, ser_tcp_h): New.
(ALLDEPFILES): Add ser-mingw.c.
(event-loop.o, inflow.o, mingw-hdep.o, posix-hdep.o, ser-base.o)
(ser-tcp.o, ser-unix.o): Update.
(ser-mingw.o): New rule.
* configure: Regenerated.
* configure.ac: Add ser-mingw.o for mingw32.
* ser-mingw.c: New file.
* event-loop.c: Include "gdb_select.h".
(gdb_select): Remove, moved to mingw-hdep.c and posix-hdep.c.
* ser-base.c: Include "gdb_select.h".
(ser_base_wait_for): Use gdb_select.
* serial.c (serial_for_fd): New function.
(serial_fdopen): Try "terminal" before "hardwire". Initialize
the allocated struct serial.
(serial_wait_handle): New function.
* serial.h (serial_for_fd, serial_wait_handle): New prototypes.
(struct serial_ops) [USE_WIN32API]: Add wait_handle.
* gdb_select.h: New file.
* ser-tcp.c: Include "ser-tcp.h". Remove unused "ser-unix.h" include.
(net_close, net_read_prim, net_write_prim): Make global.
(net_open): Likewise. Pass an exception set to select. Whitespace fix.
Document why we can not use gdb_select.
(_initialize_ser_tcp) [USE_WIN32API]: Do not register TCP support here.
* ser-tcp.h: New file.
* inflow.c (gdb_has_a_terminal): Don't initialize stdin_serial here.
(handle_sigio): Use gdb_select.
(initialize_stdin_serial): New function.
* terminal.h (initialize_stdin_serial): New prototype.
* top.c (gdb_init): Call initialize_stdin_serial.
* mingw-hdep.c (gdb_select): New function, moved from gdb_select in
event-loop.c. Add exception condition support. Use serial_for_fd
and serial_wait_handle. Fix timeout handling.
* posix-hdep.c: Include "gdb_select.h".
(gdb_select): New function.
* remote-st.c (connect_command): Use gdb_select.
* ser-unix.c: Include "gdb_select.h".
(hardwire_send_break, wait_for): Use gdb_select.
2006-02-11 06:01:43 +08:00
|
|
|
#include "ser-tcp.h"
|
2009-01-07 01:07:08 +08:00
|
|
|
#include "gdbcmd.h"
|
|
|
|
#include "cli/cli-decode.h"
|
|
|
|
#include "cli/cli-setshow.h"
|
PR gdb/7912:
* Makefile.in (SFILES): Add filestuff.c
(COMMON_OBS): Add filestuff.o.
(filestuff.o): New target.
* auto-load.c (auto_load_objfile_script_1): Use
gdb_fopen_cloexec.
* auxv.c (procfs_xfer_auxv): Use gdb_open_cloexec.
* cli/cli-cmds.c (shell_escape): Call close_most_fds.
* cli/cli-dump.c (fopen_with_cleanup): Use gdb_fopen_cloexec.
* common/agent.c (gdb_connect_sync_socket): Use
gdb_socket_cloexec.
* common/filestuff.c: New file.
* common/filestuff.h: New file.
* common/linux-osdata.c (linux_common_core_of_thread)
(command_from_pid, commandline_from_pid, print_source_lines)
(linux_xfer_osdata_shm, linux_xfer_osdata_sem)
(linux_xfer_osdata_msg, linux_xfer_osdata_modules): Use
gdb_fopen_cloexec.
* common/linux-procfs.c (linux_proc_get_int)
(linux_proc_pid_has_state): Use gdb_fopen_cloexec.
* config.in, configure: Rebuild.
* configure.ac: Don't check for sys/socket.h. Check for
fdwalk, pipe2.
* corelow.c (core_open): Use gdb_open_cloexec.
* dwarf2read.c (write_psymtabs_to_index): Use gdb_fopen_cloexec.
* fork-child.c (fork_inferior): Call close_most_fds.
* gdb_bfd.c (gdb_bfd_open): Use gdb_open_cloexec.
* inf-child.c (inf_child_fileio_readlink): Use gdb_open_cloexec.
* linux-nat.c (linux_nat_thread_name, linux_proc_pending_signals):
Use gdb_fopen_cloexec.
(linux_proc_xfer_partial, linux_proc_xfer_spu): Use
gdb_open_cloexec.
(linux_async_pipe): Use gdb_pipe_cloexec.
* remote-fileio.c (remote_fileio_func_open): Use
gdb_open_cloexec.
* remote.c (remote_file_put, remote_file_get): Use
gdb_fopen_cloexec.
* ser-pipe.c (pipe_open): Use gdb_socketpair_cloexec,
close_most_fds.
* ser-tcp.c (net_open): Use gdb_socket_cloexec.
* ser-unix.c (hardwire_open): Use gdb_open_cloexec.
* solib.c (solib_find): Use gdb_open_cloexec.
* source.c (openp, find_and_open_source): Use gdb_open_cloexec.
* tracepoint.c (tfile_start): Use gdb_fopen_cloexec.
(tfile_open): Use gdb_open_cloexec.
* tui/tui-io.c (tui_initialize_io): Use gdb_pipe_cloexec.
* ui-file.c (gdb_fopen): Use gdb_fopen_cloexec.
* xml-support.c (xml_fetch_content_from_file): Use
gdb_fopen_cloexec.
* main.c (captured_main): Call notice_open_fds.
gdbserver
* Makefile.in (SFILES): Add filestuff.c.
(OBS): Add filestuff.o.
(filestuff.o): New target.
* config.in, configure: Rebuild.
* configure.ac: Check for fdwalk, pipe2.
2013-04-23 00:46:15 +08:00
|
|
|
#include "filestuff.h"
|
1999-09-22 11:28:34 +08:00
|
|
|
|
1999-04-16 09:35:26 +08:00
|
|
|
#include <sys/types.h>
|
2001-12-08 01:57:05 +08:00
|
|
|
|
|
|
|
#ifdef HAVE_SYS_FILIO_H
|
2011-01-12 05:53:25 +08:00
|
|
|
#include <sys/filio.h> /* For FIONBIO. */
|
2001-12-08 01:57:05 +08:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_SYS_IOCTL_H
|
2011-01-12 05:53:25 +08:00
|
|
|
#include <sys/ioctl.h> /* For FIONBIO. */
|
2001-12-08 01:57:05 +08:00
|
|
|
#endif
|
|
|
|
|
1999-04-16 09:35:26 +08:00
|
|
|
#include <sys/time.h>
|
2005-04-21 13:34:33 +08:00
|
|
|
|
|
|
|
#ifdef USE_WIN32API
|
|
|
|
#include <winsock2.h>
|
2011-10-28 21:32:05 +08:00
|
|
|
#ifndef ETIMEDOUT
|
2005-04-21 13:34:33 +08:00
|
|
|
#define ETIMEDOUT WSAETIMEDOUT
|
2011-10-28 21:32:05 +08:00
|
|
|
#endif
|
2005-07-25 07:02:41 +08:00
|
|
|
#define close(fd) closesocket (fd)
|
2005-04-21 13:34:33 +08:00
|
|
|
#define ioctl ioctlsocket
|
|
|
|
#else
|
1999-04-16 09:35:26 +08:00
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
#include <netdb.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <netinet/tcp.h>
|
2005-04-21 13:34:33 +08:00
|
|
|
#endif
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2001-02-06 12:17:03 +08:00
|
|
|
#include <signal.h>
|
1999-04-16 09:35:26 +08:00
|
|
|
#include "gdb_string.h"
|
2009-01-07 01:07:08 +08:00
|
|
|
#include "gdb_select.h"
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2005-06-14 05:32:01 +08:00
|
|
|
#ifndef HAVE_SOCKLEN_T
|
|
|
|
typedef int socklen_t;
|
|
|
|
#endif
|
|
|
|
|
1999-09-22 11:28:34 +08:00
|
|
|
void _initialize_ser_tcp (void);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2009-01-07 01:07:08 +08:00
|
|
|
/* For "set tcp" and "show tcp". */
|
|
|
|
|
|
|
|
static struct cmd_list_element *tcp_set_cmdlist;
|
|
|
|
static struct cmd_list_element *tcp_show_cmdlist;
|
|
|
|
|
|
|
|
/* Whether to auto-retry refused connections. */
|
|
|
|
|
|
|
|
static int tcp_auto_retry = 1;
|
|
|
|
|
|
|
|
/* Timeout period for connections, in seconds. */
|
|
|
|
|
2013-03-08 01:36:25 +08:00
|
|
|
static unsigned int tcp_retry_limit = 15;
|
2009-01-07 01:07:08 +08:00
|
|
|
|
2011-01-12 05:53:25 +08:00
|
|
|
/* How many times per second to poll deprecated_ui_loop_hook. */
|
2009-01-07 01:07:08 +08:00
|
|
|
|
|
|
|
#define POLL_INTERVAL 5
|
|
|
|
|
|
|
|
/* Helper function to wait a while. If SCB is non-null, wait on its
|
|
|
|
file descriptor. Otherwise just wait on a timeout, updating *POLLS.
|
|
|
|
Returns -1 on timeout or interrupt, otherwise the value of select. */
|
|
|
|
|
|
|
|
static int
|
2013-03-27 04:29:47 +08:00
|
|
|
wait_for_connect (struct serial *scb, unsigned int *polls)
|
2009-01-07 01:07:08 +08:00
|
|
|
{
|
|
|
|
struct timeval t;
|
|
|
|
int n;
|
|
|
|
|
|
|
|
/* While we wait for the connect to complete,
|
|
|
|
poll the UI so it can update or the user can
|
|
|
|
interrupt. */
|
|
|
|
if (deprecated_ui_loop_hook && deprecated_ui_loop_hook (0))
|
|
|
|
{
|
|
|
|
errno = EINTR;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check for timeout. */
|
|
|
|
if (*polls > tcp_retry_limit * POLL_INTERVAL)
|
|
|
|
{
|
|
|
|
errno = ETIMEDOUT;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Back off to polling once per second after the first POLL_INTERVAL
|
|
|
|
polls. */
|
|
|
|
if (*polls < POLL_INTERVAL)
|
|
|
|
{
|
|
|
|
t.tv_sec = 0;
|
|
|
|
t.tv_usec = 1000000 / POLL_INTERVAL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
t.tv_sec = 1;
|
|
|
|
t.tv_usec = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (scb)
|
|
|
|
{
|
|
|
|
fd_set rset, wset, eset;
|
2010-05-17 07:49:58 +08:00
|
|
|
|
2009-01-07 01:07:08 +08:00
|
|
|
FD_ZERO (&rset);
|
|
|
|
FD_SET (scb->fd, &rset);
|
|
|
|
wset = rset;
|
|
|
|
eset = rset;
|
|
|
|
|
|
|
|
/* POSIX systems return connection success or failure by signalling
|
|
|
|
wset. Windows systems return success in wset and failure in
|
|
|
|
eset.
|
|
|
|
|
|
|
|
We must call select here, rather than gdb_select, because
|
|
|
|
the serial structure has not yet been initialized - the
|
|
|
|
MinGW select wrapper will not know that this FD refers
|
|
|
|
to a socket. */
|
|
|
|
n = select (scb->fd + 1, &rset, &wset, &eset, &t);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
/* Use gdb_select here, since we have no file descriptors, and on
|
|
|
|
Windows, plain select doesn't work in that case. */
|
|
|
|
n = gdb_select (0, NULL, NULL, NULL, &t);
|
|
|
|
|
|
|
|
/* If we didn't time out, only count it as one poll. */
|
|
|
|
if (n > 0 || *polls < POLL_INTERVAL)
|
|
|
|
(*polls)++;
|
|
|
|
else
|
|
|
|
(*polls) += POLL_INTERVAL;
|
|
|
|
|
|
|
|
return n;
|
|
|
|
}
|
2001-12-04 14:12:56 +08:00
|
|
|
|
2011-01-12 05:53:25 +08:00
|
|
|
/* Open a tcp socket. */
|
1999-04-16 09:35:26 +08:00
|
|
|
|
* NEWS: Mention native Windows support.
* Makefile.in (gdb_select_h, ser_tcp_h): New.
(ALLDEPFILES): Add ser-mingw.c.
(event-loop.o, inflow.o, mingw-hdep.o, posix-hdep.o, ser-base.o)
(ser-tcp.o, ser-unix.o): Update.
(ser-mingw.o): New rule.
* configure: Regenerated.
* configure.ac: Add ser-mingw.o for mingw32.
* ser-mingw.c: New file.
* event-loop.c: Include "gdb_select.h".
(gdb_select): Remove, moved to mingw-hdep.c and posix-hdep.c.
* ser-base.c: Include "gdb_select.h".
(ser_base_wait_for): Use gdb_select.
* serial.c (serial_for_fd): New function.
(serial_fdopen): Try "terminal" before "hardwire". Initialize
the allocated struct serial.
(serial_wait_handle): New function.
* serial.h (serial_for_fd, serial_wait_handle): New prototypes.
(struct serial_ops) [USE_WIN32API]: Add wait_handle.
* gdb_select.h: New file.
* ser-tcp.c: Include "ser-tcp.h". Remove unused "ser-unix.h" include.
(net_close, net_read_prim, net_write_prim): Make global.
(net_open): Likewise. Pass an exception set to select. Whitespace fix.
Document why we can not use gdb_select.
(_initialize_ser_tcp) [USE_WIN32API]: Do not register TCP support here.
* ser-tcp.h: New file.
* inflow.c (gdb_has_a_terminal): Don't initialize stdin_serial here.
(handle_sigio): Use gdb_select.
(initialize_stdin_serial): New function.
* terminal.h (initialize_stdin_serial): New prototype.
* top.c (gdb_init): Call initialize_stdin_serial.
* mingw-hdep.c (gdb_select): New function, moved from gdb_select in
event-loop.c. Add exception condition support. Use serial_for_fd
and serial_wait_handle. Fix timeout handling.
* posix-hdep.c: Include "gdb_select.h".
(gdb_select): New function.
* remote-st.c (connect_command): Use gdb_select.
* ser-unix.c: Include "gdb_select.h".
(hardwire_send_break, wait_for): Use gdb_select.
2006-02-11 06:01:43 +08:00
|
|
|
int
|
2002-05-14 12:26:25 +08:00
|
|
|
net_open (struct serial *scb, const char *name)
|
1999-04-16 09:35:26 +08:00
|
|
|
{
|
2001-12-04 14:12:56 +08:00
|
|
|
char *port_str, hostname[100];
|
|
|
|
int n, port, tmp;
|
2002-05-14 12:26:25 +08:00
|
|
|
int use_udp;
|
1999-04-16 09:35:26 +08:00
|
|
|
struct hostent *hostent;
|
|
|
|
struct sockaddr_in sockaddr;
|
2005-04-21 13:34:33 +08:00
|
|
|
#ifdef USE_WIN32API
|
|
|
|
u_long ioarg;
|
|
|
|
#else
|
|
|
|
int ioarg;
|
|
|
|
#endif
|
2013-03-27 04:29:47 +08:00
|
|
|
unsigned int polls = 0;
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2002-05-14 12:26:25 +08:00
|
|
|
use_udp = 0;
|
|
|
|
if (strncmp (name, "udp:", 4) == 0)
|
|
|
|
{
|
|
|
|
use_udp = 1;
|
|
|
|
name = name + 4;
|
|
|
|
}
|
|
|
|
else if (strncmp (name, "tcp:", 4) == 0)
|
|
|
|
name = name + 4;
|
|
|
|
|
1999-04-16 09:35:26 +08:00
|
|
|
port_str = strchr (name, ':');
|
|
|
|
|
|
|
|
if (!port_str)
|
2011-01-12 05:53:25 +08:00
|
|
|
error (_("net_open: No colon in host name!")); /* Shouldn't ever
|
|
|
|
happen. */
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
|
|
tmp = min (port_str - name, (int) sizeof hostname - 1);
|
2011-01-12 05:53:25 +08:00
|
|
|
strncpy (hostname, name, tmp); /* Don't want colon. */
|
|
|
|
hostname[tmp] = '\000'; /* Tie off host name. */
|
1999-04-16 09:35:26 +08:00
|
|
|
port = atoi (port_str + 1);
|
|
|
|
|
2011-01-12 05:53:25 +08:00
|
|
|
/* Default hostname is localhost. */
|
2001-08-02 17:08:03 +08:00
|
|
|
if (!hostname[0])
|
|
|
|
strcpy (hostname, "localhost");
|
|
|
|
|
1999-04-16 09:35:26 +08:00
|
|
|
hostent = gethostbyname (hostname);
|
|
|
|
if (!hostent)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stderr, "%s: unknown host\n", hostname);
|
|
|
|
errno = ENOENT;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2009-01-07 01:07:08 +08:00
|
|
|
sockaddr.sin_family = PF_INET;
|
|
|
|
sockaddr.sin_port = htons (port);
|
|
|
|
memcpy (&sockaddr.sin_addr.s_addr, hostent->h_addr,
|
|
|
|
sizeof (struct in_addr));
|
|
|
|
|
|
|
|
retry:
|
|
|
|
|
2002-05-14 12:26:25 +08:00
|
|
|
if (use_udp)
|
PR gdb/7912:
* Makefile.in (SFILES): Add filestuff.c
(COMMON_OBS): Add filestuff.o.
(filestuff.o): New target.
* auto-load.c (auto_load_objfile_script_1): Use
gdb_fopen_cloexec.
* auxv.c (procfs_xfer_auxv): Use gdb_open_cloexec.
* cli/cli-cmds.c (shell_escape): Call close_most_fds.
* cli/cli-dump.c (fopen_with_cleanup): Use gdb_fopen_cloexec.
* common/agent.c (gdb_connect_sync_socket): Use
gdb_socket_cloexec.
* common/filestuff.c: New file.
* common/filestuff.h: New file.
* common/linux-osdata.c (linux_common_core_of_thread)
(command_from_pid, commandline_from_pid, print_source_lines)
(linux_xfer_osdata_shm, linux_xfer_osdata_sem)
(linux_xfer_osdata_msg, linux_xfer_osdata_modules): Use
gdb_fopen_cloexec.
* common/linux-procfs.c (linux_proc_get_int)
(linux_proc_pid_has_state): Use gdb_fopen_cloexec.
* config.in, configure: Rebuild.
* configure.ac: Don't check for sys/socket.h. Check for
fdwalk, pipe2.
* corelow.c (core_open): Use gdb_open_cloexec.
* dwarf2read.c (write_psymtabs_to_index): Use gdb_fopen_cloexec.
* fork-child.c (fork_inferior): Call close_most_fds.
* gdb_bfd.c (gdb_bfd_open): Use gdb_open_cloexec.
* inf-child.c (inf_child_fileio_readlink): Use gdb_open_cloexec.
* linux-nat.c (linux_nat_thread_name, linux_proc_pending_signals):
Use gdb_fopen_cloexec.
(linux_proc_xfer_partial, linux_proc_xfer_spu): Use
gdb_open_cloexec.
(linux_async_pipe): Use gdb_pipe_cloexec.
* remote-fileio.c (remote_fileio_func_open): Use
gdb_open_cloexec.
* remote.c (remote_file_put, remote_file_get): Use
gdb_fopen_cloexec.
* ser-pipe.c (pipe_open): Use gdb_socketpair_cloexec,
close_most_fds.
* ser-tcp.c (net_open): Use gdb_socket_cloexec.
* ser-unix.c (hardwire_open): Use gdb_open_cloexec.
* solib.c (solib_find): Use gdb_open_cloexec.
* source.c (openp, find_and_open_source): Use gdb_open_cloexec.
* tracepoint.c (tfile_start): Use gdb_fopen_cloexec.
(tfile_open): Use gdb_open_cloexec.
* tui/tui-io.c (tui_initialize_io): Use gdb_pipe_cloexec.
* ui-file.c (gdb_fopen): Use gdb_fopen_cloexec.
* xml-support.c (xml_fetch_content_from_file): Use
gdb_fopen_cloexec.
* main.c (captured_main): Call notice_open_fds.
gdbserver
* Makefile.in (SFILES): Add filestuff.c.
(OBS): Add filestuff.o.
(filestuff.o): New target.
* config.in, configure: Rebuild.
* configure.ac: Check for fdwalk, pipe2.
2013-04-23 00:46:15 +08:00
|
|
|
scb->fd = gdb_socket_cloexec (PF_INET, SOCK_DGRAM, 0);
|
2002-05-14 12:26:25 +08:00
|
|
|
else
|
PR gdb/7912:
* Makefile.in (SFILES): Add filestuff.c
(COMMON_OBS): Add filestuff.o.
(filestuff.o): New target.
* auto-load.c (auto_load_objfile_script_1): Use
gdb_fopen_cloexec.
* auxv.c (procfs_xfer_auxv): Use gdb_open_cloexec.
* cli/cli-cmds.c (shell_escape): Call close_most_fds.
* cli/cli-dump.c (fopen_with_cleanup): Use gdb_fopen_cloexec.
* common/agent.c (gdb_connect_sync_socket): Use
gdb_socket_cloexec.
* common/filestuff.c: New file.
* common/filestuff.h: New file.
* common/linux-osdata.c (linux_common_core_of_thread)
(command_from_pid, commandline_from_pid, print_source_lines)
(linux_xfer_osdata_shm, linux_xfer_osdata_sem)
(linux_xfer_osdata_msg, linux_xfer_osdata_modules): Use
gdb_fopen_cloexec.
* common/linux-procfs.c (linux_proc_get_int)
(linux_proc_pid_has_state): Use gdb_fopen_cloexec.
* config.in, configure: Rebuild.
* configure.ac: Don't check for sys/socket.h. Check for
fdwalk, pipe2.
* corelow.c (core_open): Use gdb_open_cloexec.
* dwarf2read.c (write_psymtabs_to_index): Use gdb_fopen_cloexec.
* fork-child.c (fork_inferior): Call close_most_fds.
* gdb_bfd.c (gdb_bfd_open): Use gdb_open_cloexec.
* inf-child.c (inf_child_fileio_readlink): Use gdb_open_cloexec.
* linux-nat.c (linux_nat_thread_name, linux_proc_pending_signals):
Use gdb_fopen_cloexec.
(linux_proc_xfer_partial, linux_proc_xfer_spu): Use
gdb_open_cloexec.
(linux_async_pipe): Use gdb_pipe_cloexec.
* remote-fileio.c (remote_fileio_func_open): Use
gdb_open_cloexec.
* remote.c (remote_file_put, remote_file_get): Use
gdb_fopen_cloexec.
* ser-pipe.c (pipe_open): Use gdb_socketpair_cloexec,
close_most_fds.
* ser-tcp.c (net_open): Use gdb_socket_cloexec.
* ser-unix.c (hardwire_open): Use gdb_open_cloexec.
* solib.c (solib_find): Use gdb_open_cloexec.
* source.c (openp, find_and_open_source): Use gdb_open_cloexec.
* tracepoint.c (tfile_start): Use gdb_fopen_cloexec.
(tfile_open): Use gdb_open_cloexec.
* tui/tui-io.c (tui_initialize_io): Use gdb_pipe_cloexec.
* ui-file.c (gdb_fopen): Use gdb_fopen_cloexec.
* xml-support.c (xml_fetch_content_from_file): Use
gdb_fopen_cloexec.
* main.c (captured_main): Call notice_open_fds.
gdbserver
* Makefile.in (SFILES): Add filestuff.c.
(OBS): Add filestuff.o.
(filestuff.o): New target.
* config.in, configure: Rebuild.
* configure.ac: Check for fdwalk, pipe2.
2013-04-23 00:46:15 +08:00
|
|
|
scb->fd = gdb_socket_cloexec (PF_INET, SOCK_STREAM, 0);
|
2002-05-14 12:26:25 +08:00
|
|
|
|
2010-05-27 06:40:24 +08:00
|
|
|
if (scb->fd == -1)
|
2001-12-04 14:12:56 +08:00
|
|
|
return -1;
|
|
|
|
|
2011-01-12 05:53:25 +08:00
|
|
|
/* Set socket nonblocking. */
|
2005-04-21 13:34:33 +08:00
|
|
|
ioarg = 1;
|
|
|
|
ioctl (scb->fd, FIONBIO, &ioarg);
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2011-01-06 06:22:53 +08:00
|
|
|
/* Use Non-blocking connect. connect() will return 0 if connected
|
2011-01-12 05:53:25 +08:00
|
|
|
already. */
|
2001-12-04 14:12:56 +08:00
|
|
|
n = connect (scb->fd, (struct sockaddr *) &sockaddr, sizeof (sockaddr));
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2009-01-07 01:07:08 +08:00
|
|
|
if (n < 0)
|
|
|
|
{
|
2005-04-21 13:34:33 +08:00
|
|
|
#ifdef USE_WIN32API
|
2009-01-07 01:07:08 +08:00
|
|
|
int err = WSAGetLastError();
|
2005-04-21 13:34:33 +08:00
|
|
|
#else
|
2009-01-07 01:07:08 +08:00
|
|
|
int err = errno;
|
2005-04-21 13:34:33 +08:00
|
|
|
#endif
|
2009-01-07 01:07:08 +08:00
|
|
|
|
|
|
|
/* Maybe we're waiting for the remote target to become ready to
|
|
|
|
accept connections. */
|
|
|
|
if (tcp_auto_retry
|
2005-04-21 13:34:33 +08:00
|
|
|
#ifdef USE_WIN32API
|
2009-01-07 01:07:08 +08:00
|
|
|
&& err == WSAECONNREFUSED
|
|
|
|
#else
|
|
|
|
&& err == ECONNREFUSED
|
2005-04-21 13:34:33 +08:00
|
|
|
#endif
|
2009-01-07 01:07:08 +08:00
|
|
|
&& wait_for_connect (NULL, &polls) >= 0)
|
|
|
|
{
|
|
|
|
close (scb->fd);
|
|
|
|
goto retry;
|
|
|
|
}
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2009-01-07 01:07:08 +08:00
|
|
|
if (
|
|
|
|
#ifdef USE_WIN32API
|
|
|
|
/* Under Windows, calling "connect" with a non-blocking socket
|
|
|
|
results in WSAEWOULDBLOCK, not WSAEINPROGRESS. */
|
|
|
|
err != WSAEWOULDBLOCK
|
|
|
|
#else
|
|
|
|
err != EINPROGRESS
|
|
|
|
#endif
|
|
|
|
)
|
|
|
|
{
|
|
|
|
errno = err;
|
|
|
|
net_close (scb);
|
|
|
|
return -1;
|
|
|
|
}
|
2001-12-04 14:12:56 +08:00
|
|
|
|
2011-01-12 05:53:25 +08:00
|
|
|
/* Looks like we need to wait for the connect. */
|
2001-12-04 14:12:56 +08:00
|
|
|
do
|
|
|
|
{
|
2009-01-07 01:07:08 +08:00
|
|
|
n = wait_for_connect (scb, &polls);
|
2001-12-04 14:12:56 +08:00
|
|
|
}
|
2009-01-07 01:07:08 +08:00
|
|
|
while (n == 0);
|
|
|
|
if (n < 0)
|
2001-12-04 14:12:56 +08:00
|
|
|
{
|
2002-05-14 12:26:25 +08:00
|
|
|
net_close (scb);
|
2001-12-04 14:12:56 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
1999-04-16 09:35:26 +08:00
|
|
|
|
2011-01-12 05:53:25 +08:00
|
|
|
/* Got something. Is it an error? */
|
2001-12-04 14:12:56 +08:00
|
|
|
{
|
2005-05-27 04:49:03 +08:00
|
|
|
int res, err;
|
|
|
|
socklen_t len;
|
2010-05-17 07:49:58 +08:00
|
|
|
|
* NEWS: Mention native Windows support.
* Makefile.in (gdb_select_h, ser_tcp_h): New.
(ALLDEPFILES): Add ser-mingw.c.
(event-loop.o, inflow.o, mingw-hdep.o, posix-hdep.o, ser-base.o)
(ser-tcp.o, ser-unix.o): Update.
(ser-mingw.o): New rule.
* configure: Regenerated.
* configure.ac: Add ser-mingw.o for mingw32.
* ser-mingw.c: New file.
* event-loop.c: Include "gdb_select.h".
(gdb_select): Remove, moved to mingw-hdep.c and posix-hdep.c.
* ser-base.c: Include "gdb_select.h".
(ser_base_wait_for): Use gdb_select.
* serial.c (serial_for_fd): New function.
(serial_fdopen): Try "terminal" before "hardwire". Initialize
the allocated struct serial.
(serial_wait_handle): New function.
* serial.h (serial_for_fd, serial_wait_handle): New prototypes.
(struct serial_ops) [USE_WIN32API]: Add wait_handle.
* gdb_select.h: New file.
* ser-tcp.c: Include "ser-tcp.h". Remove unused "ser-unix.h" include.
(net_close, net_read_prim, net_write_prim): Make global.
(net_open): Likewise. Pass an exception set to select. Whitespace fix.
Document why we can not use gdb_select.
(_initialize_ser_tcp) [USE_WIN32API]: Do not register TCP support here.
* ser-tcp.h: New file.
* inflow.c (gdb_has_a_terminal): Don't initialize stdin_serial here.
(handle_sigio): Use gdb_select.
(initialize_stdin_serial): New function.
* terminal.h (initialize_stdin_serial): New prototype.
* top.c (gdb_init): Call initialize_stdin_serial.
* mingw-hdep.c (gdb_select): New function, moved from gdb_select in
event-loop.c. Add exception condition support. Use serial_for_fd
and serial_wait_handle. Fix timeout handling.
* posix-hdep.c: Include "gdb_select.h".
(gdb_select): New function.
* remote-st.c (connect_command): Use gdb_select.
* ser-unix.c: Include "gdb_select.h".
(hardwire_send_break, wait_for): Use gdb_select.
2006-02-11 06:01:43 +08:00
|
|
|
len = sizeof (err);
|
2005-04-21 13:34:33 +08:00
|
|
|
/* On Windows, the fourth parameter to getsockopt is a "char *";
|
|
|
|
on UNIX systems it is generally "void *". The cast to "void *"
|
|
|
|
is OK everywhere, since in C "void *" can be implicitly
|
|
|
|
converted to any pointer type. */
|
|
|
|
res = getsockopt (scb->fd, SOL_SOCKET, SO_ERROR, (void *) &err, &len);
|
2001-12-04 14:12:56 +08:00
|
|
|
if (res < 0 || err)
|
|
|
|
{
|
2009-01-07 01:07:08 +08:00
|
|
|
/* Maybe the target still isn't ready to accept the connection. */
|
|
|
|
if (tcp_auto_retry
|
|
|
|
#ifdef USE_WIN32API
|
|
|
|
&& err == WSAECONNREFUSED
|
|
|
|
#else
|
|
|
|
&& err == ECONNREFUSED
|
|
|
|
#endif
|
|
|
|
&& wait_for_connect (NULL, &polls) >= 0)
|
|
|
|
{
|
|
|
|
close (scb->fd);
|
|
|
|
goto retry;
|
|
|
|
}
|
2001-12-04 14:12:56 +08:00
|
|
|
if (err)
|
|
|
|
errno = err;
|
2002-05-14 12:26:25 +08:00
|
|
|
net_close (scb);
|
2001-12-04 14:12:56 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
2002-05-14 12:26:25 +08:00
|
|
|
|
2011-01-12 05:53:25 +08:00
|
|
|
/* Turn off nonblocking. */
|
2005-04-21 13:34:33 +08:00
|
|
|
ioarg = 0;
|
|
|
|
ioctl (scb->fd, FIONBIO, &ioarg);
|
2001-12-04 14:12:56 +08:00
|
|
|
|
2002-05-14 12:26:25 +08:00
|
|
|
if (use_udp == 0)
|
|
|
|
{
|
2011-01-12 05:53:25 +08:00
|
|
|
/* Disable Nagle algorithm. Needed in some cases. */
|
2002-05-14 12:26:25 +08:00
|
|
|
tmp = 1;
|
|
|
|
setsockopt (scb->fd, IPPROTO_TCP, TCP_NODELAY,
|
|
|
|
(char *)&tmp, sizeof (tmp));
|
|
|
|
}
|
|
|
|
|
2005-03-17 01:05:31 +08:00
|
|
|
#ifdef SIGPIPE
|
2001-12-04 14:12:56 +08:00
|
|
|
/* If we don't do this, then GDB simply exits
|
|
|
|
when the remote side dies. */
|
|
|
|
signal (SIGPIPE, SIG_IGN);
|
2005-03-17 01:05:31 +08:00
|
|
|
#endif
|
1999-04-16 09:35:26 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
* NEWS: Mention native Windows support.
* Makefile.in (gdb_select_h, ser_tcp_h): New.
(ALLDEPFILES): Add ser-mingw.c.
(event-loop.o, inflow.o, mingw-hdep.o, posix-hdep.o, ser-base.o)
(ser-tcp.o, ser-unix.o): Update.
(ser-mingw.o): New rule.
* configure: Regenerated.
* configure.ac: Add ser-mingw.o for mingw32.
* ser-mingw.c: New file.
* event-loop.c: Include "gdb_select.h".
(gdb_select): Remove, moved to mingw-hdep.c and posix-hdep.c.
* ser-base.c: Include "gdb_select.h".
(ser_base_wait_for): Use gdb_select.
* serial.c (serial_for_fd): New function.
(serial_fdopen): Try "terminal" before "hardwire". Initialize
the allocated struct serial.
(serial_wait_handle): New function.
* serial.h (serial_for_fd, serial_wait_handle): New prototypes.
(struct serial_ops) [USE_WIN32API]: Add wait_handle.
* gdb_select.h: New file.
* ser-tcp.c: Include "ser-tcp.h". Remove unused "ser-unix.h" include.
(net_close, net_read_prim, net_write_prim): Make global.
(net_open): Likewise. Pass an exception set to select. Whitespace fix.
Document why we can not use gdb_select.
(_initialize_ser_tcp) [USE_WIN32API]: Do not register TCP support here.
* ser-tcp.h: New file.
* inflow.c (gdb_has_a_terminal): Don't initialize stdin_serial here.
(handle_sigio): Use gdb_select.
(initialize_stdin_serial): New function.
* terminal.h (initialize_stdin_serial): New prototype.
* top.c (gdb_init): Call initialize_stdin_serial.
* mingw-hdep.c (gdb_select): New function, moved from gdb_select in
event-loop.c. Add exception condition support. Use serial_for_fd
and serial_wait_handle. Fix timeout handling.
* posix-hdep.c: Include "gdb_select.h".
(gdb_select): New function.
* remote-st.c (connect_command): Use gdb_select.
* ser-unix.c: Include "gdb_select.h".
(hardwire_send_break, wait_for): Use gdb_select.
2006-02-11 06:01:43 +08:00
|
|
|
void
|
2002-05-14 12:26:25 +08:00
|
|
|
net_close (struct serial *scb)
|
1999-04-16 09:35:26 +08:00
|
|
|
{
|
2010-05-27 06:40:24 +08:00
|
|
|
if (scb->fd == -1)
|
1999-04-16 09:35:26 +08:00
|
|
|
return;
|
|
|
|
|
1999-07-08 04:19:36 +08:00
|
|
|
close (scb->fd);
|
1999-04-16 09:35:26 +08:00
|
|
|
scb->fd = -1;
|
|
|
|
}
|
|
|
|
|
* NEWS: Mention native Windows support.
* Makefile.in (gdb_select_h, ser_tcp_h): New.
(ALLDEPFILES): Add ser-mingw.c.
(event-loop.o, inflow.o, mingw-hdep.o, posix-hdep.o, ser-base.o)
(ser-tcp.o, ser-unix.o): Update.
(ser-mingw.o): New rule.
* configure: Regenerated.
* configure.ac: Add ser-mingw.o for mingw32.
* ser-mingw.c: New file.
* event-loop.c: Include "gdb_select.h".
(gdb_select): Remove, moved to mingw-hdep.c and posix-hdep.c.
* ser-base.c: Include "gdb_select.h".
(ser_base_wait_for): Use gdb_select.
* serial.c (serial_for_fd): New function.
(serial_fdopen): Try "terminal" before "hardwire". Initialize
the allocated struct serial.
(serial_wait_handle): New function.
* serial.h (serial_for_fd, serial_wait_handle): New prototypes.
(struct serial_ops) [USE_WIN32API]: Add wait_handle.
* gdb_select.h: New file.
* ser-tcp.c: Include "ser-tcp.h". Remove unused "ser-unix.h" include.
(net_close, net_read_prim, net_write_prim): Make global.
(net_open): Likewise. Pass an exception set to select. Whitespace fix.
Document why we can not use gdb_select.
(_initialize_ser_tcp) [USE_WIN32API]: Do not register TCP support here.
* ser-tcp.h: New file.
* inflow.c (gdb_has_a_terminal): Don't initialize stdin_serial here.
(handle_sigio): Use gdb_select.
(initialize_stdin_serial): New function.
* terminal.h (initialize_stdin_serial): New prototype.
* top.c (gdb_init): Call initialize_stdin_serial.
* mingw-hdep.c (gdb_select): New function, moved from gdb_select in
event-loop.c. Add exception condition support. Use serial_for_fd
and serial_wait_handle. Fix timeout handling.
* posix-hdep.c: Include "gdb_select.h".
(gdb_select): New function.
* remote-st.c (connect_command): Use gdb_select.
* ser-unix.c: Include "gdb_select.h".
(hardwire_send_break, wait_for): Use gdb_select.
2006-02-11 06:01:43 +08:00
|
|
|
int
|
2005-04-21 13:34:33 +08:00
|
|
|
net_read_prim (struct serial *scb, size_t count)
|
|
|
|
{
|
2013-04-20 01:48:10 +08:00
|
|
|
/* Need to cast to silence -Wpointer-sign on MinGW, as Winsock's
|
|
|
|
'recv' takes 'char *' as second argument, while 'scb->buf' is
|
|
|
|
'unsigned char *'. */
|
|
|
|
return recv (scb->fd, (void *) scb->buf, count, 0);
|
2005-04-21 13:34:33 +08:00
|
|
|
}
|
|
|
|
|
* NEWS: Mention native Windows support.
* Makefile.in (gdb_select_h, ser_tcp_h): New.
(ALLDEPFILES): Add ser-mingw.c.
(event-loop.o, inflow.o, mingw-hdep.o, posix-hdep.o, ser-base.o)
(ser-tcp.o, ser-unix.o): Update.
(ser-mingw.o): New rule.
* configure: Regenerated.
* configure.ac: Add ser-mingw.o for mingw32.
* ser-mingw.c: New file.
* event-loop.c: Include "gdb_select.h".
(gdb_select): Remove, moved to mingw-hdep.c and posix-hdep.c.
* ser-base.c: Include "gdb_select.h".
(ser_base_wait_for): Use gdb_select.
* serial.c (serial_for_fd): New function.
(serial_fdopen): Try "terminal" before "hardwire". Initialize
the allocated struct serial.
(serial_wait_handle): New function.
* serial.h (serial_for_fd, serial_wait_handle): New prototypes.
(struct serial_ops) [USE_WIN32API]: Add wait_handle.
* gdb_select.h: New file.
* ser-tcp.c: Include "ser-tcp.h". Remove unused "ser-unix.h" include.
(net_close, net_read_prim, net_write_prim): Make global.
(net_open): Likewise. Pass an exception set to select. Whitespace fix.
Document why we can not use gdb_select.
(_initialize_ser_tcp) [USE_WIN32API]: Do not register TCP support here.
* ser-tcp.h: New file.
* inflow.c (gdb_has_a_terminal): Don't initialize stdin_serial here.
(handle_sigio): Use gdb_select.
(initialize_stdin_serial): New function.
* terminal.h (initialize_stdin_serial): New prototype.
* top.c (gdb_init): Call initialize_stdin_serial.
* mingw-hdep.c (gdb_select): New function, moved from gdb_select in
event-loop.c. Add exception condition support. Use serial_for_fd
and serial_wait_handle. Fix timeout handling.
* posix-hdep.c: Include "gdb_select.h".
(gdb_select): New function.
* remote-st.c (connect_command): Use gdb_select.
* ser-unix.c: Include "gdb_select.h".
(hardwire_send_break, wait_for): Use gdb_select.
2006-02-11 06:01:43 +08:00
|
|
|
int
|
2005-04-21 13:34:33 +08:00
|
|
|
net_write_prim (struct serial *scb, const void *buf, size_t count)
|
|
|
|
{
|
|
|
|
return send (scb->fd, buf, count, 0);
|
|
|
|
}
|
|
|
|
|
2008-09-04 07:54:19 +08:00
|
|
|
int
|
|
|
|
ser_tcp_send_break (struct serial *scb)
|
|
|
|
{
|
2011-01-12 05:53:25 +08:00
|
|
|
/* Send telnet IAC and BREAK characters. */
|
2008-09-04 07:54:19 +08:00
|
|
|
return (serial_write (scb, "\377\363", 2));
|
|
|
|
}
|
|
|
|
|
2009-01-07 01:07:08 +08:00
|
|
|
/* Support for "set tcp" and "show tcp" commands. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
set_tcp_cmd (char *args, int from_tty)
|
|
|
|
{
|
|
|
|
help_list (tcp_set_cmdlist, "set tcp ", -1, gdb_stdout);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
show_tcp_cmd (char *args, int from_tty)
|
|
|
|
{
|
|
|
|
help_list (tcp_show_cmdlist, "show tcp ", -1, gdb_stdout);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-04-16 09:35:26 +08:00
|
|
|
void
|
1999-09-22 11:28:34 +08:00
|
|
|
_initialize_ser_tcp (void)
|
1999-04-16 09:35:26 +08:00
|
|
|
{
|
2005-04-21 13:34:33 +08:00
|
|
|
#ifdef USE_WIN32API
|
* NEWS: Mention native Windows support.
* Makefile.in (gdb_select_h, ser_tcp_h): New.
(ALLDEPFILES): Add ser-mingw.c.
(event-loop.o, inflow.o, mingw-hdep.o, posix-hdep.o, ser-base.o)
(ser-tcp.o, ser-unix.o): Update.
(ser-mingw.o): New rule.
* configure: Regenerated.
* configure.ac: Add ser-mingw.o for mingw32.
* ser-mingw.c: New file.
* event-loop.c: Include "gdb_select.h".
(gdb_select): Remove, moved to mingw-hdep.c and posix-hdep.c.
* ser-base.c: Include "gdb_select.h".
(ser_base_wait_for): Use gdb_select.
* serial.c (serial_for_fd): New function.
(serial_fdopen): Try "terminal" before "hardwire". Initialize
the allocated struct serial.
(serial_wait_handle): New function.
* serial.h (serial_for_fd, serial_wait_handle): New prototypes.
(struct serial_ops) [USE_WIN32API]: Add wait_handle.
* gdb_select.h: New file.
* ser-tcp.c: Include "ser-tcp.h". Remove unused "ser-unix.h" include.
(net_close, net_read_prim, net_write_prim): Make global.
(net_open): Likewise. Pass an exception set to select. Whitespace fix.
Document why we can not use gdb_select.
(_initialize_ser_tcp) [USE_WIN32API]: Do not register TCP support here.
* ser-tcp.h: New file.
* inflow.c (gdb_has_a_terminal): Don't initialize stdin_serial here.
(handle_sigio): Use gdb_select.
(initialize_stdin_serial): New function.
* terminal.h (initialize_stdin_serial): New prototype.
* top.c (gdb_init): Call initialize_stdin_serial.
* mingw-hdep.c (gdb_select): New function, moved from gdb_select in
event-loop.c. Add exception condition support. Use serial_for_fd
and serial_wait_handle. Fix timeout handling.
* posix-hdep.c: Include "gdb_select.h".
(gdb_select): New function.
* remote-st.c (connect_command): Use gdb_select.
* ser-unix.c: Include "gdb_select.h".
(hardwire_send_break, wait_for): Use gdb_select.
2006-02-11 06:01:43 +08:00
|
|
|
/* Do nothing; the TCP serial operations will be initialized in
|
|
|
|
ser-mingw.c. */
|
|
|
|
#else
|
|
|
|
struct serial_ops *ops;
|
2010-05-17 07:49:58 +08:00
|
|
|
|
2005-04-21 13:34:33 +08:00
|
|
|
ops = XMALLOC (struct serial_ops);
|
2003-05-14 03:40:11 +08:00
|
|
|
memset (ops, 0, sizeof (struct serial_ops));
|
1999-09-22 11:28:34 +08:00
|
|
|
ops->name = "tcp";
|
|
|
|
ops->next = 0;
|
2002-05-14 12:26:25 +08:00
|
|
|
ops->open = net_open;
|
|
|
|
ops->close = net_close;
|
2005-04-21 13:34:33 +08:00
|
|
|
ops->readchar = ser_base_readchar;
|
2005-03-26 04:06:36 +08:00
|
|
|
ops->write = ser_base_write;
|
|
|
|
ops->flush_output = ser_base_flush_output;
|
|
|
|
ops->flush_input = ser_base_flush_input;
|
2008-09-04 07:54:19 +08:00
|
|
|
ops->send_break = ser_tcp_send_break;
|
2005-03-26 04:06:36 +08:00
|
|
|
ops->go_raw = ser_base_raw;
|
|
|
|
ops->get_tty_state = ser_base_get_tty_state;
|
2011-03-05 03:23:42 +08:00
|
|
|
ops->copy_tty_state = ser_base_copy_tty_state;
|
2005-03-26 04:06:36 +08:00
|
|
|
ops->set_tty_state = ser_base_set_tty_state;
|
|
|
|
ops->print_tty_state = ser_base_print_tty_state;
|
|
|
|
ops->noflush_set_tty_state = ser_base_noflush_set_tty_state;
|
|
|
|
ops->setbaudrate = ser_base_setbaudrate;
|
|
|
|
ops->setstopbits = ser_base_setstopbits;
|
|
|
|
ops->drain_output = ser_base_drain_output;
|
|
|
|
ops->async = ser_base_async;
|
2005-04-21 13:34:33 +08:00
|
|
|
ops->read_prim = net_read_prim;
|
|
|
|
ops->write_prim = net_write_prim;
|
1999-09-22 11:28:34 +08:00
|
|
|
serial_add_interface (ops);
|
* NEWS: Mention native Windows support.
* Makefile.in (gdb_select_h, ser_tcp_h): New.
(ALLDEPFILES): Add ser-mingw.c.
(event-loop.o, inflow.o, mingw-hdep.o, posix-hdep.o, ser-base.o)
(ser-tcp.o, ser-unix.o): Update.
(ser-mingw.o): New rule.
* configure: Regenerated.
* configure.ac: Add ser-mingw.o for mingw32.
* ser-mingw.c: New file.
* event-loop.c: Include "gdb_select.h".
(gdb_select): Remove, moved to mingw-hdep.c and posix-hdep.c.
* ser-base.c: Include "gdb_select.h".
(ser_base_wait_for): Use gdb_select.
* serial.c (serial_for_fd): New function.
(serial_fdopen): Try "terminal" before "hardwire". Initialize
the allocated struct serial.
(serial_wait_handle): New function.
* serial.h (serial_for_fd, serial_wait_handle): New prototypes.
(struct serial_ops) [USE_WIN32API]: Add wait_handle.
* gdb_select.h: New file.
* ser-tcp.c: Include "ser-tcp.h". Remove unused "ser-unix.h" include.
(net_close, net_read_prim, net_write_prim): Make global.
(net_open): Likewise. Pass an exception set to select. Whitespace fix.
Document why we can not use gdb_select.
(_initialize_ser_tcp) [USE_WIN32API]: Do not register TCP support here.
* ser-tcp.h: New file.
* inflow.c (gdb_has_a_terminal): Don't initialize stdin_serial here.
(handle_sigio): Use gdb_select.
(initialize_stdin_serial): New function.
* terminal.h (initialize_stdin_serial): New prototype.
* top.c (gdb_init): Call initialize_stdin_serial.
* mingw-hdep.c (gdb_select): New function, moved from gdb_select in
event-loop.c. Add exception condition support. Use serial_for_fd
and serial_wait_handle. Fix timeout handling.
* posix-hdep.c: Include "gdb_select.h".
(gdb_select): New function.
* remote-st.c (connect_command): Use gdb_select.
* ser-unix.c: Include "gdb_select.h".
(hardwire_send_break, wait_for): Use gdb_select.
2006-02-11 06:01:43 +08:00
|
|
|
#endif /* USE_WIN32API */
|
2009-01-07 01:07:08 +08:00
|
|
|
|
|
|
|
add_prefix_cmd ("tcp", class_maintenance, set_tcp_cmd, _("\
|
|
|
|
TCP protocol specific variables\n\
|
|
|
|
Configure variables specific to remote TCP connections"),
|
|
|
|
&tcp_set_cmdlist, "set tcp ",
|
|
|
|
0 /* allow-unknown */, &setlist);
|
|
|
|
add_prefix_cmd ("tcp", class_maintenance, show_tcp_cmd, _("\
|
|
|
|
TCP protocol specific variables\n\
|
|
|
|
Configure variables specific to remote TCP connections"),
|
|
|
|
&tcp_show_cmdlist, "show tcp ",
|
|
|
|
0 /* allow-unknown */, &showlist);
|
|
|
|
|
|
|
|
add_setshow_boolean_cmd ("auto-retry", class_obscure,
|
|
|
|
&tcp_auto_retry, _("\
|
|
|
|
Set auto-retry on socket connect"), _("\
|
|
|
|
Show auto-retry on socket connect"),
|
|
|
|
NULL, NULL, NULL,
|
|
|
|
&tcp_set_cmdlist, &tcp_show_cmdlist);
|
|
|
|
|
|
|
|
add_setshow_uinteger_cmd ("connect-timeout", class_obscure,
|
|
|
|
&tcp_retry_limit, _("\
|
Accept "set foo unlimited" in integer/uinteger/zuinteger_unlimited commands.
Currently, several commands take "0" or "-1" to mean "unlimited".
"show" knows when to print "unlimited":
(gdb) show height
Number of lines gdb thinks are in a page is 45.
(gdb) set height 0
(gdb) show height
Number of lines gdb thinks are in a page is unlimited.
However, the user can't herself specify "unlimited" directly:
(gdb) set height unlimited
No symbol table is loaded. Use the "file" command.
(gdb)
This patch addresses that, by adjusting the set handler for all
integer/uinteger/zuinteger_unlimited commands to accept literal
"unlimited". It also installs a completer. Presently, we complete on
symbols by default, and at
<http://sourceware.org/ml/gdb-patches/2013-03/msg00864.html> I've
shown a WIP prototype that tried to keep that half working in these
commands. In the end, it turned out to be more complicated than
justifiable, IMO. It's super rare to want to pass the value of a
variable/symbol in the program to a GDB set/show knob. That'll still
work, it's just that we won't assist with completion anymore. This
patch just sticks with the simple, and completes on "unlimited", and
nothing else. This simplification means that
"set he<tab><tab>"
is all it takes to get to:
"set height unlimited"
The patch then goes through all integer/uinteger/zuinteger_unlimited
commands in the tree, and updates both the online help and the manual
to mention that "unlimited" is accepted in addition to 0/-1. In the
cases where the command had no online help text at all, this adds it.
I've tried to make the texts read in a way that "unlimited" is
suggested before "0" or "-1" is.
Tested on x86_64 Fedora 17.
gdb/
2013-04-10 Pedro Alves <palves@redhat.com>
* cli/cli-decode.c (integer_unlimited_completer): New function.
(add_setshow_integer_cmd, add_setshow_uinteger_cmd)
(add_setshow_zuinteger_unlimited_cmd): Install the "unlimited"
completer.
* cli/cli-setshow.c: Include "cli/cli-utils.h".
(is_unlimited_literal): New function.
(do_set_command): Handle literal "unlimited" arguments.
* frame.c (_initialize_frame) <set backtrace limit>: Document
"unlimited".
* printcmd.c (_initialize_printcmd) <set print
max-symbolic-offset>: Add help text.
* record-full.c (_initialize_record_full) <set record full
insn-number-max>: Likewise.
* record.c (_initialize_record) <set record
instruction-history-size, set record function-call-history-size>:
Add help text.
* ser-tcp.c (_initialize_ser_tcp) <set tcp connect-timeout>: Add
help text.
* tracepoint.c (_initialize_tracepoint) <set trace-buffer-size>:
Likewise.
* source.c (_initialize_source) <set listsize>: Add help text.
* utils.c (initialize_utils) <set height, set width>: Likewise.
<set pagination>: Mention "set height unlimited".
* valprint.c (_initialize_valprint) <set print elements, set print
repeats>: Document "unlimited".
gdb/doc/
2013-04-10 Pedro Alves <palves@redhat.com>
* gdb.texinfo (Process Record and Replay): Document that "set
record full insn-number-max", "set record
instruction-history-size" and "set record
function-call-history-size" accept "unlimited".
(Backtrace): Document that "set backtrace limit" accepts
"unlimited".
(List): Document that "set listsize" accepts "unlimited".
(Print Settings)" Document that "set print max-symbolic-offset",
"set print elements" and "set print repeats" accept "unlimited".
(Starting and Stopping Trace Experiments): Document that "set
trace-buffer-size" accepts "unlimited".
(Remote Configuration): Document that "set tcp connect-timeout"
accepts "unlimited".
(Command History): Document that "set history size" accepts
"unlimited".
(Screen Size): Document that "set height" and "set width" accepts
"unlimited". Adjust "set pagination"'s description to suggest
"set height unlimited" instead of "set height 0".
gdb/testsuite/
2013-04-10 Pedro Alves <palves@redhat.com>
* gdb.base/completion.exp: Test "set height", "set listsize" and
"set trace-buffer-size" completion.
* gdb.base/setshow.exp: Test "set height unlimited".
* gdb.trace/trace-buffer-size.exp: Test "set trace-buffer-size
unlimited".
2013-04-10 23:11:12 +08:00
|
|
|
Set timeout limit in seconds for socket connection"), _("\
|
|
|
|
Show timeout limit in seconds for socket connection"), _("\
|
|
|
|
If set to \"unlimited\", GDB will keep attempting to establish a\n\
|
|
|
|
connection forever, unless interrupted with Ctrl-c.\n\
|
|
|
|
The default is 15 seconds."),
|
|
|
|
NULL, NULL,
|
|
|
|
&tcp_set_cmdlist, &tcp_show_cmdlist);
|
1999-04-16 09:35:26 +08:00
|
|
|
}
|