2005-06-13 23:32:01 +02:00
|
|
|
/* Serial interface for raw TCP connections on Un*x like systems.
|
|
|
|
|
2017-01-01 07:50:51 +01:00
|
|
|
Copyright (C) 1992-2017 Free Software Foundation, Inc.
|
1999-04-16 03:35:26 +02:00
|
|
|
|
1999-07-07 22:19:36 +02:00
|
|
|
This file is part of GDB.
|
1999-04-16 03:35:26 +02:00
|
|
|
|
1999-07-07 22:19:36 +02: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-23 20:08:50 +02:00
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
1999-07-07 22:19:36 +02:00
|
|
|
(at your option) any later version.
|
1999-04-16 03:35:26 +02:00
|
|
|
|
1999-07-07 22:19:36 +02: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 03:35:26 +02:00
|
|
|
|
1999-07-07 22:19:36 +02:00
|
|
|
You should have received a copy of the GNU General Public License
|
2007-08-23 20:08:50 +02:00
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
|
|
|
#include "defs.h"
|
|
|
|
#include "serial.h"
|
2005-03-25 20:47:23 +01: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-10 23:01:43 +01:00
|
|
|
#include "ser-tcp.h"
|
2009-01-06 18:07:08 +01: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-22 18:46:15 +02:00
|
|
|
#include "filestuff.h"
|
1999-09-22 05:28:34 +02:00
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
#include <sys/types.h>
|
2001-12-07 18:57:05 +01:00
|
|
|
|
|
|
|
#ifdef HAVE_SYS_FILIO_H
|
2011-01-11 22:53:25 +01:00
|
|
|
#include <sys/filio.h> /* For FIONBIO. */
|
2001-12-07 18:57:05 +01:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_SYS_IOCTL_H
|
2011-01-11 22:53:25 +01:00
|
|
|
#include <sys/ioctl.h> /* For FIONBIO. */
|
2001-12-07 18:57:05 +01:00
|
|
|
#endif
|
|
|
|
|
2015-08-24 19:50:55 +02:00
|
|
|
#include "gdb_sys_time.h"
|
2005-04-21 07:34:33 +02:00
|
|
|
|
|
|
|
#ifdef USE_WIN32API
|
|
|
|
#include <winsock2.h>
|
2011-10-28 15:32:05 +02:00
|
|
|
#ifndef ETIMEDOUT
|
2005-04-21 07:34:33 +02:00
|
|
|
#define ETIMEDOUT WSAETIMEDOUT
|
2011-10-28 15:32:05 +02:00
|
|
|
#endif
|
Import "glob" and "getcwd" modules from gnulib
These two modules are necessary because of the rework that will be
done in the "change directory" logic on GDB/gdbserver in the next
commits.
First, we will get rid of the "gdb_dirbuf" global variable and instead
rely on the fact that "getcwd (NULL, 0)", which is a GNU extension,
returns a heap-allocated string with the necessary bytes to hold the
full path. This is a good practice not only because globals are not
ideal but also because there is no good way to know beforehand the
size of the full pathname allowed in the filesystem ("PATH_MAX" is not
portable and does not reflect all the possible filesystems out there).
We will also have a way to "cd" to a directory also on gdbserver, but
in order to do that uniformly, there must be a way to do tilde
expansion on directories provided by the user. Currently, GDB uses
"tilde_expand" from readline to do that, but gdbserver doesn't link
against readline and therefore cannot use this function. The solution
is to use "glob" instead, which can perform tilde expansion as a GNU
extension. Therefore, we need gnulib's version of "glob".
A special note is necessary for gdb/ser-tcp.c. It defines "close" as
"closesocket" on Win32 targets. If we leave the code as is, this
would conflict with gnulib's definition of "close". Therefore, in
order to keep the same code path from before this import, I decided to
"#undef close" first, and then let the original (re)definition of it
take place.
gdb/ChangeLog:
2017-09-22 Sergio Durigan Junior <sergiodj@redhat.com>
* gnulib/aclocal.m4: Regenerate.
* gnulib/config.in: Regenerate.
* gnulib/configure: Regenerate.
* gnulib/import/Makefile.am: Regenerate.
* gnulib/import/Makefile.in: Regenerate.
* gnulib/import/assure.h: New file.
* gnulib/import/at-func.c: Likewise
* gnulib/import/chdir-long.c: New file.
* gnulib/import/chdir-long.h: New file.
* gnulib/import/cloexec.c: New file.
* gnulib/import/cloexec.h: New file.
* gnulib/import/close.c: New file.
* gnulib/import/closedir.c: New file.
* gnulib/import/dirent-private.h: New file.
* gnulib/import/dup-safer.c: New file.
* gnulib/import/dup.c: New file.
* gnulib/import/dup2.c: New file.
* gnulib/import/error.c: New file.
* gnulib/import/error.h: New file.
* gnulib/import/exitfail.c: New file.
* gnulib/import/exitfail.h: New file.
* gnulib/import/fchdir.c: New file.
* gnulib/import/fcntl.c: New file.
* gnulib/import/fcntl.in.h: New file.
* gnulib/import/fd-hook.c: New file.
* gnulib/import/fd-hook.h: New file.
* gnulib/import/fd-safer.c: New file.
* gnulib/import/fdopendir.c: New file.
* gnulib/import/filename.h: New file.
* gnulib/import/filenamecat-lgpl.c: New file.
* gnulib/import/filenamecat.h: New file.
* gnulib/import/fstat.c: New file.
* gnulib/import/fstatat.c: New file.
* gnulib/import/getcwd-lgpl.c: New file.
* gnulib/import/getcwd.c: New file.
* gnulib/import/getdtablesize.c: New file.
* gnulib/import/getlogin_r.c: New file.
* gnulib/import/getprogname.c: New file.
* gnulib/import/getprogname.h: New file.
* gnulib/import/gettext.h: New file.
* gnulib/import/glob-libc.h: New file.
* gnulib/import/glob.c: New file.
* gnulib/import/glob.in.h: New file.
* gnulib/import/intprops.h: New file.
* gnulib/import/m4/chdir-long.m4: New file.
* gnulib/import/m4/close.m4: New file.
* gnulib/import/m4/closedir.m4: New file.
* gnulib/import/m4/d-ino.m4: New file.
* gnulib/import/m4/d-type.m4: New file.
* gnulib/import/m4/dup.m4: New file.
* gnulib/import/m4/dup2.m4: New file.
* gnulib/import/m4/error.m4: New file.
* gnulib/import/m4/fchdir.m4: New file.
* gnulib/import/m4/fcntl.m4: New file.
* gnulib/import/m4/fcntl_h.m4: New file.
* gnulib/import/m4/fdopendir.m4: New file.
* gnulib/import/m4/filenamecat.m4: New file.
* gnulib/import/m4/fstat.m4: New file.
* gnulib/import/m4/fstatat.m4: New file.
* gnulib/import/m4/getcwd-abort-bug.m4: New file.
* gnulib/import/m4/getcwd-path-max.m4: New file.
* gnulib/import/m4/getcwd.m4: New file.
* gnulib/import/m4/getdtablesize.m4: New file.
* gnulib/import/m4/getlogin_r.m4: New file.
* gnulib/import/m4/getprogname.m4: New file.
* gnulib/import/m4/glob.m4: New file.
* gnulib/import/m4/gnulib-cache.m4: Regenerate.
* gnulib/import/m4/gnulib-comp.m4: Regenerate.
* gnulib/import/m4/mempcpy.m4: New file.
* gnulib/import/m4/memrchr.m4: New file.
* gnulib/import/m4/mode_t.m4: New file.
* gnulib/import/m4/msvc-inval.m4: New file.
* gnulib/import/m4/msvc-nothrow.m4: New file.
* gnulib/import/m4/open.m4: New file.
* gnulib/import/m4/openat.m4: New file.
* gnulib/import/m4/opendir.m4: New file.
* gnulib/import/m4/readdir.m4: New file.
* gnulib/import/m4/realloc.m4: New file.
* gnulib/import/m4/rewinddir.m4: New file.
* gnulib/import/m4/save-cwd.m4: New file.
* gnulib/import/m4/strdup.m4: New file.
* gnulib/import/m4/strerror.m4: New file.
* gnulib/import/m4/unistd-safer.m4: New file.
* gnulib/import/mempcpy.c: New file.
* gnulib/import/memrchr.c: New file.
* gnulib/import/msvc-inval.c: New file.
* gnulib/import/msvc-inval.h: New file.
* gnulib/import/msvc-nothrow.c: New file.
* gnulib/import/msvc-nothrow.h: New file.
* gnulib/import/open.c: New file.
* gnulib/import/openat-die.c: New file.
* gnulib/import/openat-priv.h: New file.
* gnulib/import/openat-proc.c: New file.
* gnulib/import/openat.c: New file.
* gnulib/import/openat.h: New file.
* gnulib/import/opendir.c: New file.
* gnulib/import/pipe-safer.c: New file.
* gnulib/import/readdir.c: New file.
* gnulib/import/realloc.c: New file.
* gnulib/import/rewinddir.c: New file.
* gnulib/import/save-cwd.c: New file.
* gnulib/import/save-cwd.h: New file.
* gnulib/import/strdup.c: New file.
* gnulib/import/strerror-override.c: New file.
* gnulib/import/strerror-override.h: New file.
* gnulib/import/strerror.c: New file.
* gnulib/import/unistd--.h: New file.
* gnulib/import/unistd-safer.h: New file.
* gnulib/update-gnulib.sh (IMPORTED_GNULIB_MODULES): Add
"getcwd" and "glob".
* ser-tcp.c: Undefine "close" before redefining it.
2017-09-09 02:09:12 +02:00
|
|
|
/* Gnulib defines close too, but gnulib's replacement
|
|
|
|
doesn't call closesocket unless we import the
|
|
|
|
socketlib module. */
|
|
|
|
#undef close
|
2005-07-25 01:02:41 +02:00
|
|
|
#define close(fd) closesocket (fd)
|
2005-04-21 07:34:33 +02:00
|
|
|
#define ioctl ioctlsocket
|
|
|
|
#else
|
2015-03-09 12:27:05 +01:00
|
|
|
#include <netinet/in.h>
|
1999-04-16 03:35:26 +02:00
|
|
|
#include <arpa/inet.h>
|
|
|
|
#include <netdb.h>
|
2015-03-09 12:27:05 +01:00
|
|
|
#include <sys/socket.h>
|
1999-04-16 03:35:26 +02:00
|
|
|
#include <netinet/tcp.h>
|
2005-04-21 07:34:33 +02:00
|
|
|
#endif
|
1999-04-16 03:35:26 +02:00
|
|
|
|
2001-02-06 05:17:03 +01:00
|
|
|
#include <signal.h>
|
2009-01-06 18:07:08 +01:00
|
|
|
#include "gdb_select.h"
|
gdb: Use std::min and std::max throughout
Otherwise including <string> or some other C++ header is broken.
E.g.:
In file included from /opt/gcc/include/c++/7.0.0/bits/char_traits.h:39:0,
from /opt/gcc/include/c++/7.0.0/string:40,
from /home/pedro/gdb/mygit/cxx-convertion/src/gdb/infrun.c:68:
/opt/gcc/include/c++/7.0.0/bits/stl_algobase.h:243:56: error: macro "min" passed 3 arguments, but takes just 2
min(const _Tp& __a, const _Tp& __b, _Compare __comp)
^
/opt/gcc/include/c++/7.0.0/bits/stl_algobase.h:265:56: error: macro "max" passed 3 arguments, but takes just 2
max(const _Tp& __a, const _Tp& __b, _Compare __comp)
^
In file included from .../src/gdb/infrun.c:21:0:
To the best of my grepping abilities, I believe I adjusted all min/max
calls.
gdb/ChangeLog:
2016-09-16 Pedro Alves <palves@redhat.com>
* defs.h (min, max): Delete.
* aarch64-tdep.c: Include <algorithm> and use std::min and
std::max throughout.
* aarch64-tdep.c: Likewise.
* alpha-tdep.c: Likewise.
* amd64-tdep.c: Likewise.
* amd64-windows-tdep.c: Likewise.
* arm-tdep.c: Likewise.
* avr-tdep.c: Likewise.
* breakpoint.c: Likewise.
* btrace.c: Likewise.
* ctf.c: Likewise.
* disasm.c: Likewise.
* doublest.c: Likewise.
* dwarf2loc.c: Likewise.
* dwarf2read.c: Likewise.
* environ.c: Likewise.
* exec.c: Likewise.
* f-exp.y: Likewise.
* findcmd.c: Likewise.
* ft32-tdep.c: Likewise.
* gcore.c: Likewise.
* hppa-tdep.c: Likewise.
* i386-darwin-tdep.c: Likewise.
* i386-tdep.c: Likewise.
* linux-thread-db.c: Likewise.
* lm32-tdep.c: Likewise.
* m32r-tdep.c: Likewise.
* m88k-tdep.c: Likewise.
* memrange.c: Likewise.
* minidebug.c: Likewise.
* mips-tdep.c: Likewise.
* moxie-tdep.c: Likewise.
* nds32-tdep.c: Likewise.
* nios2-tdep.c: Likewise.
* nto-procfs.c: Likewise.
* parse.c: Likewise.
* ppc-sysv-tdep.c: Likewise.
* probe.c: Likewise.
* record-btrace.c: Likewise.
* remote.c: Likewise.
* rs6000-tdep.c: Likewise.
* rx-tdep.c: Likewise.
* s390-linux-nat.c: Likewise.
* s390-linux-tdep.c: Likewise.
* ser-tcp.c: Likewise.
* sh-tdep.c: Likewise.
* sh64-tdep.c: Likewise.
* source.c: Likewise.
* sparc-tdep.c: Likewise.
* symfile.c: Likewise.
* target-memory.c: Likewise.
* target.c: Likewise.
* tic6x-tdep.c: Likewise.
* tilegx-tdep.c: Likewise.
* tracefile-tfile.c: Likewise.
* tracepoint.c: Likewise.
* valprint.c: Likewise.
* value.c: Likewise.
* xtensa-tdep.c: Likewise.
* cli/cli-cmds.c: Likewise.
* compile/compile-object-load.c: Likewise.
2016-09-16 20:55:17 +02:00
|
|
|
#include <algorithm>
|
1999-04-16 03:35:26 +02:00
|
|
|
|
2005-06-13 23:32:01 +02:00
|
|
|
#ifndef HAVE_SOCKLEN_T
|
|
|
|
typedef int socklen_t;
|
|
|
|
#endif
|
|
|
|
|
2009-01-06 18:07:08 +01: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-07 18:36:25 +01:00
|
|
|
static unsigned int tcp_retry_limit = 15;
|
2009-01-06 18:07:08 +01:00
|
|
|
|
2011-01-11 22:53:25 +01:00
|
|
|
/* How many times per second to poll deprecated_ui_loop_hook. */
|
2009-01-06 18:07:08 +01: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-26 21:29:47 +01:00
|
|
|
wait_for_connect (struct serial *scb, unsigned int *polls)
|
2009-01-06 18:07:08 +01: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 01:49:58 +02:00
|
|
|
|
2009-01-06 18:07:08 +01: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 07:12:56 +01:00
|
|
|
|
2011-01-11 22:53:25 +01:00
|
|
|
/* Open a tcp socket. */
|
1999-04-16 03:35:26 +02: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-10 23:01:43 +01:00
|
|
|
int
|
2002-05-14 06:26:25 +02:00
|
|
|
net_open (struct serial *scb, const char *name)
|
1999-04-16 03:35:26 +02:00
|
|
|
{
|
2015-10-13 20:40:50 +02:00
|
|
|
char hostname[100];
|
|
|
|
const char *port_str;
|
2001-12-04 07:12:56 +01:00
|
|
|
int n, port, tmp;
|
2002-05-14 06:26:25 +02:00
|
|
|
int use_udp;
|
1999-04-16 03:35:26 +02:00
|
|
|
struct hostent *hostent;
|
2015-03-09 12:27:05 +01:00
|
|
|
struct sockaddr_in sockaddr;
|
2005-04-21 07:34:33 +02:00
|
|
|
#ifdef USE_WIN32API
|
|
|
|
u_long ioarg;
|
|
|
|
#else
|
|
|
|
int ioarg;
|
|
|
|
#endif
|
2013-03-26 21:29:47 +01:00
|
|
|
unsigned int polls = 0;
|
1999-04-16 03:35:26 +02:00
|
|
|
|
2002-05-14 06:26:25 +02:00
|
|
|
use_udp = 0;
|
2015-03-06 10:42:06 +01:00
|
|
|
if (startswith (name, "udp:"))
|
2002-05-14 06:26:25 +02:00
|
|
|
{
|
|
|
|
use_udp = 1;
|
|
|
|
name = name + 4;
|
|
|
|
}
|
2015-03-06 10:42:06 +01:00
|
|
|
else if (startswith (name, "tcp:"))
|
2002-05-14 06:26:25 +02:00
|
|
|
name = name + 4;
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
port_str = strchr (name, ':');
|
|
|
|
|
|
|
|
if (!port_str)
|
2011-01-11 22:53:25 +01:00
|
|
|
error (_("net_open: No colon in host name!")); /* Shouldn't ever
|
|
|
|
happen. */
|
1999-04-16 03:35:26 +02:00
|
|
|
|
gdb: Use std::min and std::max throughout
Otherwise including <string> or some other C++ header is broken.
E.g.:
In file included from /opt/gcc/include/c++/7.0.0/bits/char_traits.h:39:0,
from /opt/gcc/include/c++/7.0.0/string:40,
from /home/pedro/gdb/mygit/cxx-convertion/src/gdb/infrun.c:68:
/opt/gcc/include/c++/7.0.0/bits/stl_algobase.h:243:56: error: macro "min" passed 3 arguments, but takes just 2
min(const _Tp& __a, const _Tp& __b, _Compare __comp)
^
/opt/gcc/include/c++/7.0.0/bits/stl_algobase.h:265:56: error: macro "max" passed 3 arguments, but takes just 2
max(const _Tp& __a, const _Tp& __b, _Compare __comp)
^
In file included from .../src/gdb/infrun.c:21:0:
To the best of my grepping abilities, I believe I adjusted all min/max
calls.
gdb/ChangeLog:
2016-09-16 Pedro Alves <palves@redhat.com>
* defs.h (min, max): Delete.
* aarch64-tdep.c: Include <algorithm> and use std::min and
std::max throughout.
* aarch64-tdep.c: Likewise.
* alpha-tdep.c: Likewise.
* amd64-tdep.c: Likewise.
* amd64-windows-tdep.c: Likewise.
* arm-tdep.c: Likewise.
* avr-tdep.c: Likewise.
* breakpoint.c: Likewise.
* btrace.c: Likewise.
* ctf.c: Likewise.
* disasm.c: Likewise.
* doublest.c: Likewise.
* dwarf2loc.c: Likewise.
* dwarf2read.c: Likewise.
* environ.c: Likewise.
* exec.c: Likewise.
* f-exp.y: Likewise.
* findcmd.c: Likewise.
* ft32-tdep.c: Likewise.
* gcore.c: Likewise.
* hppa-tdep.c: Likewise.
* i386-darwin-tdep.c: Likewise.
* i386-tdep.c: Likewise.
* linux-thread-db.c: Likewise.
* lm32-tdep.c: Likewise.
* m32r-tdep.c: Likewise.
* m88k-tdep.c: Likewise.
* memrange.c: Likewise.
* minidebug.c: Likewise.
* mips-tdep.c: Likewise.
* moxie-tdep.c: Likewise.
* nds32-tdep.c: Likewise.
* nios2-tdep.c: Likewise.
* nto-procfs.c: Likewise.
* parse.c: Likewise.
* ppc-sysv-tdep.c: Likewise.
* probe.c: Likewise.
* record-btrace.c: Likewise.
* remote.c: Likewise.
* rs6000-tdep.c: Likewise.
* rx-tdep.c: Likewise.
* s390-linux-nat.c: Likewise.
* s390-linux-tdep.c: Likewise.
* ser-tcp.c: Likewise.
* sh-tdep.c: Likewise.
* sh64-tdep.c: Likewise.
* source.c: Likewise.
* sparc-tdep.c: Likewise.
* symfile.c: Likewise.
* target-memory.c: Likewise.
* target.c: Likewise.
* tic6x-tdep.c: Likewise.
* tilegx-tdep.c: Likewise.
* tracefile-tfile.c: Likewise.
* tracepoint.c: Likewise.
* valprint.c: Likewise.
* value.c: Likewise.
* xtensa-tdep.c: Likewise.
* cli/cli-cmds.c: Likewise.
* compile/compile-object-load.c: Likewise.
2016-09-16 20:55:17 +02:00
|
|
|
tmp = std::min (port_str - name, (ptrdiff_t) sizeof hostname - 1);
|
2011-01-11 22:53:25 +01:00
|
|
|
strncpy (hostname, name, tmp); /* Don't want colon. */
|
|
|
|
hostname[tmp] = '\000'; /* Tie off host name. */
|
1999-04-16 03:35:26 +02:00
|
|
|
port = atoi (port_str + 1);
|
|
|
|
|
2011-01-11 22:53:25 +01:00
|
|
|
/* Default hostname is localhost. */
|
2001-08-02 11:08:03 +02:00
|
|
|
if (!hostname[0])
|
|
|
|
strcpy (hostname, "localhost");
|
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
hostent = gethostbyname (hostname);
|
|
|
|
if (!hostent)
|
|
|
|
{
|
|
|
|
fprintf_unfiltered (gdb_stderr, "%s: unknown host\n", hostname);
|
|
|
|
errno = ENOENT;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2015-03-09 12:27:05 +01:00
|
|
|
sockaddr.sin_family = PF_INET;
|
|
|
|
sockaddr.sin_port = htons (port);
|
|
|
|
memcpy (&sockaddr.sin_addr.s_addr, hostent->h_addr,
|
2009-01-06 18:07:08 +01:00
|
|
|
sizeof (struct in_addr));
|
|
|
|
|
|
|
|
retry:
|
|
|
|
|
2002-05-14 06:26:25 +02: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-22 18:46:15 +02:00
|
|
|
scb->fd = gdb_socket_cloexec (PF_INET, SOCK_DGRAM, 0);
|
2002-05-14 06:26:25 +02: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-22 18:46:15 +02:00
|
|
|
scb->fd = gdb_socket_cloexec (PF_INET, SOCK_STREAM, 0);
|
2002-05-14 06:26:25 +02:00
|
|
|
|
2010-05-27 00:40:24 +02:00
|
|
|
if (scb->fd == -1)
|
2001-12-04 07:12:56 +01:00
|
|
|
return -1;
|
|
|
|
|
2011-01-11 22:53:25 +01:00
|
|
|
/* Set socket nonblocking. */
|
2005-04-21 07:34:33 +02:00
|
|
|
ioarg = 1;
|
|
|
|
ioctl (scb->fd, FIONBIO, &ioarg);
|
1999-04-16 03:35:26 +02:00
|
|
|
|
2011-01-05 23:22:53 +01:00
|
|
|
/* Use Non-blocking connect. connect() will return 0 if connected
|
2011-01-11 22:53:25 +01:00
|
|
|
already. */
|
2015-03-09 12:27:05 +01:00
|
|
|
n = connect (scb->fd, (struct sockaddr *) &sockaddr, sizeof (sockaddr));
|
1999-04-16 03:35:26 +02:00
|
|
|
|
2009-01-06 18:07:08 +01:00
|
|
|
if (n < 0)
|
|
|
|
{
|
2005-04-21 07:34:33 +02:00
|
|
|
#ifdef USE_WIN32API
|
2009-01-06 18:07:08 +01:00
|
|
|
int err = WSAGetLastError();
|
2005-04-21 07:34:33 +02:00
|
|
|
#else
|
2009-01-06 18:07:08 +01:00
|
|
|
int err = errno;
|
2005-04-21 07:34:33 +02:00
|
|
|
#endif
|
2009-01-06 18:07:08 +01:00
|
|
|
|
|
|
|
/* Maybe we're waiting for the remote target to become ready to
|
|
|
|
accept connections. */
|
|
|
|
if (tcp_auto_retry
|
2005-04-21 07:34:33 +02:00
|
|
|
#ifdef USE_WIN32API
|
2009-01-06 18:07:08 +01:00
|
|
|
&& err == WSAECONNREFUSED
|
|
|
|
#else
|
|
|
|
&& err == ECONNREFUSED
|
2005-04-21 07:34:33 +02:00
|
|
|
#endif
|
2009-01-06 18:07:08 +01:00
|
|
|
&& wait_for_connect (NULL, &polls) >= 0)
|
|
|
|
{
|
|
|
|
close (scb->fd);
|
|
|
|
goto retry;
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
2009-01-06 18:07:08 +01: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 07:12:56 +01:00
|
|
|
|
2011-01-11 22:53:25 +01:00
|
|
|
/* Looks like we need to wait for the connect. */
|
2001-12-04 07:12:56 +01:00
|
|
|
do
|
|
|
|
{
|
2009-01-06 18:07:08 +01:00
|
|
|
n = wait_for_connect (scb, &polls);
|
2001-12-04 07:12:56 +01:00
|
|
|
}
|
2009-01-06 18:07:08 +01:00
|
|
|
while (n == 0);
|
|
|
|
if (n < 0)
|
2001-12-04 07:12:56 +01:00
|
|
|
{
|
2002-05-14 06:26:25 +02:00
|
|
|
net_close (scb);
|
2001-12-04 07:12:56 +01:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
1999-04-16 03:35:26 +02:00
|
|
|
|
2011-01-11 22:53:25 +01:00
|
|
|
/* Got something. Is it an error? */
|
2001-12-04 07:12:56 +01:00
|
|
|
{
|
2005-05-26 22:49:03 +02:00
|
|
|
int res, err;
|
|
|
|
socklen_t len;
|
2010-05-17 01:49:58 +02: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-10 23:01:43 +01:00
|
|
|
len = sizeof (err);
|
2005-04-21 07:34:33 +02:00
|
|
|
/* On Windows, the fourth parameter to getsockopt is a "char *";
|
2015-11-17 16:17:45 +01:00
|
|
|
on UNIX systems it is generally "void *". The cast to "char *"
|
|
|
|
is OK everywhere, since in C++ any data pointer type can be
|
|
|
|
implicitly converted to "void *". */
|
|
|
|
res = getsockopt (scb->fd, SOL_SOCKET, SO_ERROR, (char *) &err, &len);
|
2001-12-04 07:12:56 +01:00
|
|
|
if (res < 0 || err)
|
|
|
|
{
|
2009-01-06 18:07:08 +01: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 07:12:56 +01:00
|
|
|
if (err)
|
|
|
|
errno = err;
|
2002-05-14 06:26:25 +02:00
|
|
|
net_close (scb);
|
2001-12-04 07:12:56 +01:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
2002-05-14 06:26:25 +02:00
|
|
|
|
2011-01-11 22:53:25 +01:00
|
|
|
/* Turn off nonblocking. */
|
2005-04-21 07:34:33 +02:00
|
|
|
ioarg = 0;
|
|
|
|
ioctl (scb->fd, FIONBIO, &ioarg);
|
2001-12-04 07:12:56 +01:00
|
|
|
|
2002-05-14 06:26:25 +02:00
|
|
|
if (use_udp == 0)
|
|
|
|
{
|
2011-01-11 22:53:25 +01:00
|
|
|
/* Disable Nagle algorithm. Needed in some cases. */
|
2002-05-14 06:26:25 +02:00
|
|
|
tmp = 1;
|
|
|
|
setsockopt (scb->fd, IPPROTO_TCP, TCP_NODELAY,
|
|
|
|
(char *)&tmp, sizeof (tmp));
|
|
|
|
}
|
|
|
|
|
2005-03-16 18:05:31 +01:00
|
|
|
#ifdef SIGPIPE
|
2001-12-04 07:12:56 +01:00
|
|
|
/* If we don't do this, then GDB simply exits
|
|
|
|
when the remote side dies. */
|
|
|
|
signal (SIGPIPE, SIG_IGN);
|
2005-03-16 18:05:31 +01:00
|
|
|
#endif
|
1999-04-16 03:35:26 +02: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-10 23:01:43 +01:00
|
|
|
void
|
2002-05-14 06:26:25 +02:00
|
|
|
net_close (struct serial *scb)
|
1999-04-16 03:35:26 +02:00
|
|
|
{
|
2010-05-27 00:40:24 +02:00
|
|
|
if (scb->fd == -1)
|
1999-04-16 03:35:26 +02:00
|
|
|
return;
|
|
|
|
|
1999-07-07 22:19:36 +02:00
|
|
|
close (scb->fd);
|
1999-04-16 03:35:26 +02: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-10 23:01:43 +01:00
|
|
|
int
|
2005-04-21 07:34:33 +02:00
|
|
|
net_read_prim (struct serial *scb, size_t count)
|
|
|
|
{
|
2013-04-19 19:48:10 +02: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 *'. */
|
2015-11-17 16:17:45 +01:00
|
|
|
return recv (scb->fd, (char *) scb->buf, count, 0);
|
2005-04-21 07:34:33 +02: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-10 23:01:43 +01:00
|
|
|
int
|
2005-04-21 07:34:33 +02:00
|
|
|
net_write_prim (struct serial *scb, const void *buf, size_t count)
|
|
|
|
{
|
2015-11-17 16:17:45 +01:00
|
|
|
/* On Windows, the second parameter to send is a "const char *"; on
|
|
|
|
UNIX systems it is generally "const void *". The cast to "const
|
|
|
|
char *" is OK everywhere, since in C++ any data pointer type can
|
|
|
|
be implicitly converted to "const void *". */
|
|
|
|
return send (scb->fd, (const char *) buf, count, 0);
|
2005-04-21 07:34:33 +02:00
|
|
|
}
|
|
|
|
|
2008-09-04 01:54:19 +02:00
|
|
|
int
|
|
|
|
ser_tcp_send_break (struct serial *scb)
|
|
|
|
{
|
2011-01-11 22:53:25 +01:00
|
|
|
/* Send telnet IAC and BREAK characters. */
|
2008-09-04 01:54:19 +02:00
|
|
|
return (serial_write (scb, "\377\363", 2));
|
|
|
|
}
|
|
|
|
|
2009-01-06 18:07:08 +01:00
|
|
|
/* Support for "set tcp" and "show tcp" commands. */
|
|
|
|
|
|
|
|
static void
|
Constify add_prefix_cmd
This changes add_prefix_cmd to accept a const-taking function as an
argument; then fixes up all the callers.
In a couple of spots I had to add a non-const overload of a function,
because the function is passed to two different command-adding
"constructors". These overloads are temporary; once constification is
complete they can be removed.
This patch also fixes a typo I happened to notice while constifying.
Note that this touches a couple of files (gnu-nat.c and go32-nat.c)
that I can't build. So, while I made a best-effort there, I am not
certain they will still compile.
Tested by rebuilding.
gdb/ChangeLog
2017-10-11 Tom Tromey <tom@tromey.com>
* gdbthread.h (thread_command): Constify.
* inferior.h (detach_command): Constify.
* top.h (set_history, show_history): Constify.
* arm-tdep.c (set_arm_command, show_arm_command): Constify.
* serial.c (serial_set_cmd, serial_show_cmd): Constify.
* bsd-kvm.c (bsd_kvm_cmd): Constify.
* printcmd.c (set_command): Constify.
(non_const_set_command): New function.
* dcache.c (set_dcache_command, show_dcache_command): Constify.
* breakpoint.c (enable_command, disable_command, delete_command)
(catch_command, tcatch_command, set_breakpoint_cmd)
(show_breakpoint_cmd): Constify.
* macrocmd.c (macro_command): Constify.
* infcmd.c (unset_command, kill_command, detach_command)
(info_proc_cmd): Constify.
* i386-tdep.c (set_mpx_cmd, show_mpx_cmd): Constify.
* auto-load.c (show_auto_load_cmd, set_auto_load_cmd)
(info_auto_load_cmd): Constify.
* target-descriptions.c (set_tdesc_cmd, show_tdesc_cmd)
(unset_tdesc_cmd): Constify.
* ada-lang.c (set_ada_command, show_ada_command)
(maint_set_ada_cmd, maint_show_ada_cmd): Constify.
* guile/guile.c (set_guile_command, show_guile_command)
(info_guile_command): Constify.
* tui/tui-win.c (tui_command, set_tui_cmd, show_tui_cmd):
Constify.
* skip.c (skip_command): Constify.
* compile/compile.c (_initialize_compile): Constify.
* dwarf2read.c (set_dwarf_cmd, show_dwarf_cmd): Constify.
* btrace.c (maint_btrace_cmd, maint_btrace_set_cmd)
(maint_btrace_show_cmd, maint_btrace_pt_set_cmd)
(maint_btrace_pt_show_cmd): Constify.
* remote.c (set_remote_cmd, show_remote_cmd, remote_command):
Constify.
* python/python.c (user_show_python, user_set_python): Constify.
* mips-tdep.c (set_mips_command, show_mips_command)
(set_mipsfpu_command): Constify.
* record-btrace.c (cmd_record_btrace_start)
(cmd_set_record_btrace, cmd_show_record_btrace)
(cmd_set_record_btrace_bts, cmd_show_record_btrace_bts)
(cmd_set_record_btrace_pt, cmd_show_record_btrace_pt): Constify.
* rs6000-tdep.c (set_powerpc_command, show_powerpc_command):
Constify.
* symfile.c (overlay_command): Constify.
* spu-tdep.c (set_spu_command, show_spu_command): Constify.
* cli/cli-logging.c (set_logging_command, show_logging_command):
Constify.
* cli/cli-dump.c (dump_command, append_command)
(srec_dump_command, ihex_dump_command, verilog_dump_command)
(tekhex_dump_command, binary_dump_command)
(binary_append_command): Constify.
* cli/cli-decode.c (struct cmd_list_element): Change type of
"fun".
* cli/cli-cmds.c (info_command, show_command, set_debug)
(show_debug): Constify.
(show_command): Add non-const overload.
* top.c (set_history, show_history): Constify.
* sh-tdep.c (set_sh_command, show_sh_command): Constify.
* command.h (add_prefix_cmd): Accept a cmd_const_cfunc_ftype.
* target.c (target_command): Constify.
* sparc64-tdep.c (info_adi_command): Constify.
* record-full.c (cmd_record_full_start): Constify.
(set_record_full_command): Constify. Fix typo.
(show_record_full_command): Constify.
* thread.c (thread_command, thread_apply_command): Constify.
* memattr.c (dummy_cmd): Constify.
* value.c (function_command): Constify.
* frame.c (set_backtrace_cmd, show_backtrace_cmd): Constify.
* probe.c (info_probes_command): Constify.
* ser-tcp.c (set_tcp_cmd, show_tcp_cmd): Constify.
* gnu-nat.c (set_task_cmd, show_task_cmd, set_thread_cmd)
(show_thread_cmd, set_thread_default_cmd)
(show_thread_default_cmd): Constify.
(check_empty): Constify.
* tracepoint.c (tfind_command): Constify.
* cp-support.c (maint_cplus_command): Constify.
* windows-tdep.c (info_w32_command): Constify.
* record.c (cmd_record_start, set_record_command)
(show_record_command, info_record_command, cmd_record_goto):
Constify.
* ravenscar-thread.c (set_ravenscar_command)
(show_ravenscar_command): Constify.
* utils.c (set_internal_problem_cmd, show_internal_problem_cmd):
Constify.
(add_internal_problem_command): Remove casts.
* arc-tdep.c (maintenance_print_arc_command): Constify.
* valprint.c (set_print, show_print, set_print_raw)
(show_print_raw): Constify.
* maint.c (maintenance_command, maintenance_info_command)
(maintenance_print_command, maintenance_set_cmd)
(maintenance_show_cmd, set_per_command_cmd)
(show_per_command_cmd, maintenance_check_command): Constify.
* language.c (set_check, show_check): Constify.
* typeprint.c (show_print_type, set_print_type): Constify.
* go32-nat.c (go32_info_dos_command): Constify.
2017-09-26 06:28:30 +02:00
|
|
|
set_tcp_cmd (const char *args, int from_tty)
|
2009-01-06 18:07:08 +01:00
|
|
|
{
|
make calls to help_list use enumerator
Currently there are many calls to help_list that pass the constant -1
as the "class" value. However, the parameter is declared as being of
type enum command_class, and uses of the constant violate this
abstraction.
This patch fixes the error everywhere it occurs in the gdb sources.
Tested by rebuilding.
2014-06-13 Tom Tromey <tromey@redhat.com>
* cp-support.c (maint_cplus_command): Pass all_commands, not -1,
to help_list.
* guile/guile.c (info_guile_command): Pass all_commands, not -1,
to help_list.
* tui/tui-win.c (tui_command): Pass all_commands, not -1, to
help_list.
* tui/tui-regs.c (tui_reg_command): Pass all_commands, not -1, to
help_list.Pass all_commands, not -1, to help_list.
* cli/cli-dump.c (dump_command, append_command)
(srec_dump_command, ihex_dump_command, tekhex_dump_command)
(binary_dump_command, binary_append_command): Pass all_commands,
not -1, to help_list.
* cli/cli-cmds.c (info_command, set_debug): Pass all_commands, not
-1, to help_list.
* valprint.c (set_print, set_print_raw): Pass all_commands, not
-1, to help_list.
* typeprint.c (set_print_type): Pass all_commands, not -1, to
help_list.
* top.c (set_history): Pass all_commands, not -1, to help_list.
* target-descriptions.c (set_tdesc_cmd, unset_tdesc_cmd): Pass
all_commands, not -1, to help_list.
* symfile.c (overlay_command): Pass all_commands, not -1, to
help_list.
* spu-tdep.c (info_spu_command): Pass all_commands, not -1, to
help_list.
* serial.c (serial_set_cmd): Pass all_commands, not -1, to
help_list.
* ser-tcp.c (set_tcp_cmd, show_tcp_cmd): Pass all_commands, not
-1, to help_list.
* remote.c (remote_command, set_remote_cmd): Pass all_commands,
not -1, to help_list.
* ravenscar-thread.c (set_ravenscar_command): Pass all_commands,
not -1, to help_list.
* maint.c (maintenance_command, maintenance_info_command)
(maintenance_print_command, maintenance_set_cmd): Pass
all_commands, not -1, to help_list.
* macrocmd.c (macro_command): Pass all_commands, not -1, to
help_list.
* language.c (set_check): Pass all_commands, not -1, to help_list.
* infcmd.c (unset_command): Pass all_commands, not -1, to
help_list.
* frame.c (set_backtrace_cmd): Pass all_commands, not -1, to
help_list.
* dwarf2read.c (set_dwarf2_cmd): Pass all_commands, not -1, to
help_list.
* dcache.c (set_dcache_command): Pass all_commands, not -1, to
help_list.
* breakpoint.c (save_command): Pass all_commands, not -1, to
help_list.
* ada-lang.c (maint_set_ada_cmd, set_ada_command): Pass
all_commands, not -1, to help_list.
2014-06-05 16:25:00 +02:00
|
|
|
help_list (tcp_set_cmdlist, "set tcp ", all_commands, gdb_stdout);
|
2009-01-06 18:07:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
Constify add_prefix_cmd
This changes add_prefix_cmd to accept a const-taking function as an
argument; then fixes up all the callers.
In a couple of spots I had to add a non-const overload of a function,
because the function is passed to two different command-adding
"constructors". These overloads are temporary; once constification is
complete they can be removed.
This patch also fixes a typo I happened to notice while constifying.
Note that this touches a couple of files (gnu-nat.c and go32-nat.c)
that I can't build. So, while I made a best-effort there, I am not
certain they will still compile.
Tested by rebuilding.
gdb/ChangeLog
2017-10-11 Tom Tromey <tom@tromey.com>
* gdbthread.h (thread_command): Constify.
* inferior.h (detach_command): Constify.
* top.h (set_history, show_history): Constify.
* arm-tdep.c (set_arm_command, show_arm_command): Constify.
* serial.c (serial_set_cmd, serial_show_cmd): Constify.
* bsd-kvm.c (bsd_kvm_cmd): Constify.
* printcmd.c (set_command): Constify.
(non_const_set_command): New function.
* dcache.c (set_dcache_command, show_dcache_command): Constify.
* breakpoint.c (enable_command, disable_command, delete_command)
(catch_command, tcatch_command, set_breakpoint_cmd)
(show_breakpoint_cmd): Constify.
* macrocmd.c (macro_command): Constify.
* infcmd.c (unset_command, kill_command, detach_command)
(info_proc_cmd): Constify.
* i386-tdep.c (set_mpx_cmd, show_mpx_cmd): Constify.
* auto-load.c (show_auto_load_cmd, set_auto_load_cmd)
(info_auto_load_cmd): Constify.
* target-descriptions.c (set_tdesc_cmd, show_tdesc_cmd)
(unset_tdesc_cmd): Constify.
* ada-lang.c (set_ada_command, show_ada_command)
(maint_set_ada_cmd, maint_show_ada_cmd): Constify.
* guile/guile.c (set_guile_command, show_guile_command)
(info_guile_command): Constify.
* tui/tui-win.c (tui_command, set_tui_cmd, show_tui_cmd):
Constify.
* skip.c (skip_command): Constify.
* compile/compile.c (_initialize_compile): Constify.
* dwarf2read.c (set_dwarf_cmd, show_dwarf_cmd): Constify.
* btrace.c (maint_btrace_cmd, maint_btrace_set_cmd)
(maint_btrace_show_cmd, maint_btrace_pt_set_cmd)
(maint_btrace_pt_show_cmd): Constify.
* remote.c (set_remote_cmd, show_remote_cmd, remote_command):
Constify.
* python/python.c (user_show_python, user_set_python): Constify.
* mips-tdep.c (set_mips_command, show_mips_command)
(set_mipsfpu_command): Constify.
* record-btrace.c (cmd_record_btrace_start)
(cmd_set_record_btrace, cmd_show_record_btrace)
(cmd_set_record_btrace_bts, cmd_show_record_btrace_bts)
(cmd_set_record_btrace_pt, cmd_show_record_btrace_pt): Constify.
* rs6000-tdep.c (set_powerpc_command, show_powerpc_command):
Constify.
* symfile.c (overlay_command): Constify.
* spu-tdep.c (set_spu_command, show_spu_command): Constify.
* cli/cli-logging.c (set_logging_command, show_logging_command):
Constify.
* cli/cli-dump.c (dump_command, append_command)
(srec_dump_command, ihex_dump_command, verilog_dump_command)
(tekhex_dump_command, binary_dump_command)
(binary_append_command): Constify.
* cli/cli-decode.c (struct cmd_list_element): Change type of
"fun".
* cli/cli-cmds.c (info_command, show_command, set_debug)
(show_debug): Constify.
(show_command): Add non-const overload.
* top.c (set_history, show_history): Constify.
* sh-tdep.c (set_sh_command, show_sh_command): Constify.
* command.h (add_prefix_cmd): Accept a cmd_const_cfunc_ftype.
* target.c (target_command): Constify.
* sparc64-tdep.c (info_adi_command): Constify.
* record-full.c (cmd_record_full_start): Constify.
(set_record_full_command): Constify. Fix typo.
(show_record_full_command): Constify.
* thread.c (thread_command, thread_apply_command): Constify.
* memattr.c (dummy_cmd): Constify.
* value.c (function_command): Constify.
* frame.c (set_backtrace_cmd, show_backtrace_cmd): Constify.
* probe.c (info_probes_command): Constify.
* ser-tcp.c (set_tcp_cmd, show_tcp_cmd): Constify.
* gnu-nat.c (set_task_cmd, show_task_cmd, set_thread_cmd)
(show_thread_cmd, set_thread_default_cmd)
(show_thread_default_cmd): Constify.
(check_empty): Constify.
* tracepoint.c (tfind_command): Constify.
* cp-support.c (maint_cplus_command): Constify.
* windows-tdep.c (info_w32_command): Constify.
* record.c (cmd_record_start, set_record_command)
(show_record_command, info_record_command, cmd_record_goto):
Constify.
* ravenscar-thread.c (set_ravenscar_command)
(show_ravenscar_command): Constify.
* utils.c (set_internal_problem_cmd, show_internal_problem_cmd):
Constify.
(add_internal_problem_command): Remove casts.
* arc-tdep.c (maintenance_print_arc_command): Constify.
* valprint.c (set_print, show_print, set_print_raw)
(show_print_raw): Constify.
* maint.c (maintenance_command, maintenance_info_command)
(maintenance_print_command, maintenance_set_cmd)
(maintenance_show_cmd, set_per_command_cmd)
(show_per_command_cmd, maintenance_check_command): Constify.
* language.c (set_check, show_check): Constify.
* typeprint.c (show_print_type, set_print_type): Constify.
* go32-nat.c (go32_info_dos_command): Constify.
2017-09-26 06:28:30 +02:00
|
|
|
show_tcp_cmd (const char *args, int from_tty)
|
2009-01-06 18:07:08 +01:00
|
|
|
{
|
make calls to help_list use enumerator
Currently there are many calls to help_list that pass the constant -1
as the "class" value. However, the parameter is declared as being of
type enum command_class, and uses of the constant violate this
abstraction.
This patch fixes the error everywhere it occurs in the gdb sources.
Tested by rebuilding.
2014-06-13 Tom Tromey <tromey@redhat.com>
* cp-support.c (maint_cplus_command): Pass all_commands, not -1,
to help_list.
* guile/guile.c (info_guile_command): Pass all_commands, not -1,
to help_list.
* tui/tui-win.c (tui_command): Pass all_commands, not -1, to
help_list.
* tui/tui-regs.c (tui_reg_command): Pass all_commands, not -1, to
help_list.Pass all_commands, not -1, to help_list.
* cli/cli-dump.c (dump_command, append_command)
(srec_dump_command, ihex_dump_command, tekhex_dump_command)
(binary_dump_command, binary_append_command): Pass all_commands,
not -1, to help_list.
* cli/cli-cmds.c (info_command, set_debug): Pass all_commands, not
-1, to help_list.
* valprint.c (set_print, set_print_raw): Pass all_commands, not
-1, to help_list.
* typeprint.c (set_print_type): Pass all_commands, not -1, to
help_list.
* top.c (set_history): Pass all_commands, not -1, to help_list.
* target-descriptions.c (set_tdesc_cmd, unset_tdesc_cmd): Pass
all_commands, not -1, to help_list.
* symfile.c (overlay_command): Pass all_commands, not -1, to
help_list.
* spu-tdep.c (info_spu_command): Pass all_commands, not -1, to
help_list.
* serial.c (serial_set_cmd): Pass all_commands, not -1, to
help_list.
* ser-tcp.c (set_tcp_cmd, show_tcp_cmd): Pass all_commands, not
-1, to help_list.
* remote.c (remote_command, set_remote_cmd): Pass all_commands,
not -1, to help_list.
* ravenscar-thread.c (set_ravenscar_command): Pass all_commands,
not -1, to help_list.
* maint.c (maintenance_command, maintenance_info_command)
(maintenance_print_command, maintenance_set_cmd): Pass
all_commands, not -1, to help_list.
* macrocmd.c (macro_command): Pass all_commands, not -1, to
help_list.
* language.c (set_check): Pass all_commands, not -1, to help_list.
* infcmd.c (unset_command): Pass all_commands, not -1, to
help_list.
* frame.c (set_backtrace_cmd): Pass all_commands, not -1, to
help_list.
* dwarf2read.c (set_dwarf2_cmd): Pass all_commands, not -1, to
help_list.
* dcache.c (set_dcache_command): Pass all_commands, not -1, to
help_list.
* breakpoint.c (save_command): Pass all_commands, not -1, to
help_list.
* ada-lang.c (maint_set_ada_cmd, set_ada_command): Pass
all_commands, not -1, to help_list.
2014-06-05 16:25:00 +02:00
|
|
|
help_list (tcp_show_cmdlist, "show tcp ", all_commands, gdb_stdout);
|
2009-01-06 18:07:08 +01:00
|
|
|
}
|
|
|
|
|
2013-12-06 19:34:49 +01:00
|
|
|
#ifndef USE_WIN32API
|
|
|
|
|
|
|
|
/* The TCP ops. */
|
|
|
|
|
|
|
|
static const struct serial_ops tcp_ops =
|
|
|
|
{
|
|
|
|
"tcp",
|
|
|
|
net_open,
|
|
|
|
net_close,
|
|
|
|
NULL,
|
|
|
|
ser_base_readchar,
|
|
|
|
ser_base_write,
|
|
|
|
ser_base_flush_output,
|
|
|
|
ser_base_flush_input,
|
|
|
|
ser_tcp_send_break,
|
|
|
|
ser_base_raw,
|
|
|
|
ser_base_get_tty_state,
|
|
|
|
ser_base_copy_tty_state,
|
|
|
|
ser_base_set_tty_state,
|
|
|
|
ser_base_print_tty_state,
|
|
|
|
ser_base_setbaudrate,
|
|
|
|
ser_base_setstopbits,
|
2015-03-23 22:15:42 +01:00
|
|
|
ser_base_setparity,
|
2013-12-06 19:34:49 +01:00
|
|
|
ser_base_drain_output,
|
|
|
|
ser_base_async,
|
|
|
|
net_read_prim,
|
|
|
|
net_write_prim
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* USE_WIN32API */
|
2009-01-06 18:07:08 +01:00
|
|
|
|
1999-04-16 03:35:26 +02:00
|
|
|
void
|
1999-09-22 05:28:34 +02:00
|
|
|
_initialize_ser_tcp (void)
|
1999-04-16 03:35:26 +02:00
|
|
|
{
|
2005-04-21 07:34:33 +02: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-10 23:01:43 +01:00
|
|
|
/* Do nothing; the TCP serial operations will be initialized in
|
|
|
|
ser-mingw.c. */
|
|
|
|
#else
|
2013-12-06 19:34:49 +01:00
|
|
|
serial_add_interface (&tcp_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-10 23:01:43 +01:00
|
|
|
#endif /* USE_WIN32API */
|
2009-01-06 18:07:08 +01: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 17:11:12 +02: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 03:35:26 +02:00
|
|
|
}
|