1993-05-29 01:33:36 +00:00
|
|
|
/* Serial interface for raw TCP connections on Un*x like systems
|
1998-10-16 21:45:06 +00:00
|
|
|
Copyright 1992, 1993, 1998 Free Software Foundation, Inc.
|
1993-05-29 01:33:36 +00:00
|
|
|
|
|
|
|
This file is part of GDB.
|
|
|
|
|
|
|
|
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
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
1995-08-02 03:41:12 +00:00
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
1993-05-29 01:33:36 +00:00
|
|
|
|
|
|
|
#include "defs.h"
|
|
|
|
#include "serial.h"
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
#include <netdb.h>
|
|
|
|
#include <sys/socket.h>
|
1996-09-06 20:17:26 +00:00
|
|
|
|
Fri Nov 13 00:15:08 1998 Geoffrey Noer <noer@cygnus.com>
Changes to account for name change from cygwin32 to cygwin and
clean up Win32-related ifdefs.
* configure.tgt: check for cygwin* instead of cygwin32.
New cygwin gdb_target variable loses the "32".
* configure.host: check for cygwin* instead of cygwin32.
New cygwin gdb_host variable loses the "32".
* configure.in: test __CYGWIN__ instead of __CYGWIN32__,
rename gdb_cv_os_cygwin32 variable to drop the "32". Call
AM_EXEEXT instead of AC_EXEEXT since that isn't in a released
autoconf yet.
* configure: regenerate.
* main.c: drop "32" from cygwin_ funcs, include sys/cygwin.h
where
cygwin path conv protos live, instead of adding a proto here
for
them here.
* {main.c, ser-tcp.c, ser-unix.c, top.c}: check __CYGWIN__
instead of __CYGWIN32__.
* source.c: thoughout, check _WIN32 instead of WIN32.
* config/i386/cygwin32.mh: delete.
* config/i386/cygwin.mh: new file, was cygwin32.mh.
* config/i386/cygwin32.mt: delete.
* config/i386/cygwin.mt: new file, was cygwin32.mt.
* config/i386/tm-cygwin32.h: delete.
* config/i386/tm-cygwin.h: new file, was tm-cygwin32.h.
* config/i386/xm-cygwin32.h: delete.
* config/i386/xm-cygwin.h: new file, was xm-cygwin32.h.
* config/i386/xm-windows.h: #include xm-cygwin.h now.
* config/powerpc/cygwin32.mh: delete.
* config/powerpc/cygwin.mh: new file, was cygwin32.mh.
* config/powerpc/cygwin32.mt: delete.
* config/powerpc/cygwin.mt: new file, was cygwin32.mt.
* config/powerpc/tm-cygwin32.h: delete.
* config/powerpc/tm-cygwin.h: new file, was tm-cygwin32.h.
* config/powerpc/xm-cygwin32.h: delete.
* config/powerpc/xm-cygwin.h: new file, was xm-cygwin32.h.
* rdi-share/aclocal.m4: regenerate with aclocal.
* rdi-share/configure: regenerate with autoconf.
* rdi-share/{host.h, hostchan.c, hostchan.h, serdrv.c,
* serpardr.c,
unixcomm.c}: check __CYGWIN__ instead of __CYGWIN32__.
1998-11-13 08:16:08 +00:00
|
|
|
#ifndef __CYGWIN__
|
1993-05-29 01:33:36 +00:00
|
|
|
#include <netinet/tcp.h>
|
1996-09-06 20:17:26 +00:00
|
|
|
#endif
|
|
|
|
|
1993-05-29 01:33:36 +00:00
|
|
|
#include "signals.h"
|
* core-aout.c (fetch_core_registers): Cast core_reg_size to int
before testing against reg_ptr.
* eval.c (evaluate_subexp_standard): Cast type of
TYPE_FN_FIELD_VOFFSET to int.
* findvar.c (extract_signed_integer, extract_unsigned_integer,
extract_long_unsigned_integer): Cast type of sizeof to int.
* values.c (unpack_field_as_long, modify_field): Ditto.
* valops.c (value_assign, call_function_by_hand): Ditto.
* infcmd.c (do_registers_info): Ditto.
* ser-tcp.c (tcp_open): Ditto
* remote.c (putpkt): Ditto.
* dcache.c (dcache_peek): Ditto.
* dcache.c (dcache_poke): Ditto.
* m2-exp.y (yylex): Ditto.
* gnu-regex.c (re_match_2): Ditto.
* f-lang.c (ADD_BF_SYMNUM, saved_bf_list_end, tmp_bf_ptr): Ifdef
out unused macro definition and variables.
* inftarg.c (proc_wait): Move from main.c to here, and make static.
* valprint.c (val_print_string): Change bufsize from int to unsigned.
* main.c (wait.h): Include
* top.c (command_line_input): Remove unused variable "c".
* f-typeprint.c (f_type_print_varspec_prefix): Add missing enum
value TYPE_CODE_TYPEDEF to switch statement.
(f_type_print_varspec_suffix): Add missing enum value
TYPE_CODE_TYPEDEF to switch statement.
* ch-exp.c (parse_primval): Add remaining enumeration values to
switch statement, with no specific action.
(ch_lex): Add LOC_UNRESOLVED in switch statement.
(pushback_token): Ifdef out, since code using it is ifdef'd out.
* stabsread.c (cleanup_undefined_types): Remove unused label
"badtype".
* objfiles.h (print_symbol_bcache_statistics): Add prototype.
* maint.c (objfiles.h): Include.
(maintenance_print_statistics): Remove unused variable "temp".
* minsyms.c (lookup_minimal_symbol_solib_trampoline): Remove
unused variable "found_file_symbol".
* m2-exp.y (yylex): Add LOC_UNRESOLVED case to switch.
* language.c (lang_bool_type): Use existing function local type
variable rather than create block local variables.
* solib.c (disable_break): Enclose in ifndef SVR4_SHARED_LIBS.
* infptrace.c (wait.h, command.h): Include.
* ser-tcp.c (gdb_string.h): Include
* i386-tdep.c (codestream_seek): Change "place" to CORE_ADDR.
(i386_get_frame_setup): Change "pc" from int to CORE_ADDR.
* command.c (complete_on_enum): Make assignment used as truth value
explictly check against NULL.
(wait.h): Include.
* infrun.c (wait_for_inferior): Ifdef out prologue_pc since code
that uses it is ifdef'd out.
* parser-defs.h: Add prototype for write_dollar_variable.
* infrun.c: Add prototype for write_pc_pid.
* breakpoint.h: Add prototype for re_enable_breakpoints_in_shlibs.
* symmisc.c (bcache.h): Include.
* bcache.h: Add prototype for print_bcache_statistics.
* symfile.c: Include <time.h>.
* printcmd.c (print_scalar_formatted): Change len to unsigned int.
* valarith.c (value_equal): Cast result of TYPE_LENGTH to int.
* valarith.c (value_binop): Change result_len, promoted_len1,
and promoted_len2 to unsigned int.
* valarith.c (value_subscripted_rvalue): Change elt_offs and
elt_size to unsigned int.
* valops.c (value_array): Change typelength to unsigned int.
(destructor_name_p): Change len to unsigned int.
* scm-lang.h (scm_parse): Add prototype for scm_unpack.
* symfile.c (decrement_reading_symtab): Change return type to void.
* valarith.c (value_subscript): Remove unused variable "word".
(value_subscript): Remove unused variable "tint".
* valops.c (auto_abandon): Ifdef out, since code using it is also
ifdef'd out.
* eval.c (init_array_element): Remove unused variable "val".
* Makefile.in (values.o): Depends on scm-lang.h.
(command.o): Depends upon wait_h.
(ser-tcp.o): Depends upon gdb_string.h.
(infptrace.o): Depends upon wait_h and command_h.
(maint.o): Depends on objfiles.h and symfile.h.
* values.c (allocate_repeat_value): Remove unused variable
"element_type".
(scm-lang.h): Include.
* breakpoint.c (create_longjmp_breakpoint): Enclose in
GET_LONGJMP_TARGET define, unused otherwise.
* config/i386/nm-linux.h: Add prototypes for i386_insert_watchpoint,
i386_remove_watchpoint and i386_stopped_by_watchpoint.
1996-03-30 05:45:10 +00:00
|
|
|
#include "gdb_string.h"
|
1993-05-29 01:33:36 +00:00
|
|
|
|
|
|
|
struct tcp_ttystate
|
|
|
|
{
|
|
|
|
int bogus;
|
|
|
|
};
|
|
|
|
|
|
|
|
static int tcp_open PARAMS ((serial_t scb, const char *name));
|
|
|
|
static void tcp_raw PARAMS ((serial_t scb));
|
|
|
|
static int wait_for PARAMS ((serial_t scb, int timeout));
|
|
|
|
static int tcp_readchar PARAMS ((serial_t scb, int timeout));
|
|
|
|
static int tcp_setbaudrate PARAMS ((serial_t scb, int rate));
|
1995-03-07 09:03:37 +00:00
|
|
|
static int tcp_setstopbits PARAMS ((serial_t scb, int num));
|
1993-05-29 01:33:36 +00:00
|
|
|
static int tcp_write PARAMS ((serial_t scb, const char *str, int len));
|
1993-09-08 20:57:08 +00:00
|
|
|
/* FIXME: static void tcp_restore PARAMS ((serial_t scb)); */
|
1993-05-29 01:33:36 +00:00
|
|
|
static void tcp_close PARAMS ((serial_t scb));
|
|
|
|
static serial_ttystate tcp_get_tty_state PARAMS ((serial_t scb));
|
|
|
|
static int tcp_set_tty_state PARAMS ((serial_t scb, serial_ttystate state));
|
1996-07-26 03:01:51 +00:00
|
|
|
static int tcp_return_0 PARAMS ((serial_t));
|
|
|
|
static int tcp_noflush_set_tty_state PARAMS ((serial_t, serial_ttystate,
|
|
|
|
serial_ttystate));
|
|
|
|
static void tcp_print_tty_state PARAMS ((serial_t, serial_ttystate));
|
1993-05-29 01:33:36 +00:00
|
|
|
|
1998-10-16 21:45:06 +00:00
|
|
|
void _initialize_ser_tcp PARAMS ((void));
|
|
|
|
|
1993-05-29 01:33:36 +00:00
|
|
|
/* Open up a raw tcp socket */
|
|
|
|
|
|
|
|
static int
|
|
|
|
tcp_open(scb, name)
|
|
|
|
serial_t scb;
|
|
|
|
const char *name;
|
|
|
|
{
|
|
|
|
char *port_str;
|
|
|
|
int port;
|
|
|
|
struct hostent *hostent;
|
|
|
|
struct sockaddr_in sockaddr;
|
|
|
|
int tmp;
|
|
|
|
char hostname[100];
|
1993-05-29 03:14:45 +00:00
|
|
|
struct protoent *protoent;
|
1995-06-08 22:45:47 +00:00
|
|
|
int i;
|
1993-05-29 01:33:36 +00:00
|
|
|
|
|
|
|
port_str = strchr (name, ':');
|
|
|
|
|
|
|
|
if (!port_str)
|
|
|
|
error ("tcp_open: No colon in host name!"); /* Shouldn't ever happen */
|
|
|
|
|
* core-aout.c (fetch_core_registers): Cast core_reg_size to int
before testing against reg_ptr.
* eval.c (evaluate_subexp_standard): Cast type of
TYPE_FN_FIELD_VOFFSET to int.
* findvar.c (extract_signed_integer, extract_unsigned_integer,
extract_long_unsigned_integer): Cast type of sizeof to int.
* values.c (unpack_field_as_long, modify_field): Ditto.
* valops.c (value_assign, call_function_by_hand): Ditto.
* infcmd.c (do_registers_info): Ditto.
* ser-tcp.c (tcp_open): Ditto
* remote.c (putpkt): Ditto.
* dcache.c (dcache_peek): Ditto.
* dcache.c (dcache_poke): Ditto.
* m2-exp.y (yylex): Ditto.
* gnu-regex.c (re_match_2): Ditto.
* f-lang.c (ADD_BF_SYMNUM, saved_bf_list_end, tmp_bf_ptr): Ifdef
out unused macro definition and variables.
* inftarg.c (proc_wait): Move from main.c to here, and make static.
* valprint.c (val_print_string): Change bufsize from int to unsigned.
* main.c (wait.h): Include
* top.c (command_line_input): Remove unused variable "c".
* f-typeprint.c (f_type_print_varspec_prefix): Add missing enum
value TYPE_CODE_TYPEDEF to switch statement.
(f_type_print_varspec_suffix): Add missing enum value
TYPE_CODE_TYPEDEF to switch statement.
* ch-exp.c (parse_primval): Add remaining enumeration values to
switch statement, with no specific action.
(ch_lex): Add LOC_UNRESOLVED in switch statement.
(pushback_token): Ifdef out, since code using it is ifdef'd out.
* stabsread.c (cleanup_undefined_types): Remove unused label
"badtype".
* objfiles.h (print_symbol_bcache_statistics): Add prototype.
* maint.c (objfiles.h): Include.
(maintenance_print_statistics): Remove unused variable "temp".
* minsyms.c (lookup_minimal_symbol_solib_trampoline): Remove
unused variable "found_file_symbol".
* m2-exp.y (yylex): Add LOC_UNRESOLVED case to switch.
* language.c (lang_bool_type): Use existing function local type
variable rather than create block local variables.
* solib.c (disable_break): Enclose in ifndef SVR4_SHARED_LIBS.
* infptrace.c (wait.h, command.h): Include.
* ser-tcp.c (gdb_string.h): Include
* i386-tdep.c (codestream_seek): Change "place" to CORE_ADDR.
(i386_get_frame_setup): Change "pc" from int to CORE_ADDR.
* command.c (complete_on_enum): Make assignment used as truth value
explictly check against NULL.
(wait.h): Include.
* infrun.c (wait_for_inferior): Ifdef out prologue_pc since code
that uses it is ifdef'd out.
* parser-defs.h: Add prototype for write_dollar_variable.
* infrun.c: Add prototype for write_pc_pid.
* breakpoint.h: Add prototype for re_enable_breakpoints_in_shlibs.
* symmisc.c (bcache.h): Include.
* bcache.h: Add prototype for print_bcache_statistics.
* symfile.c: Include <time.h>.
* printcmd.c (print_scalar_formatted): Change len to unsigned int.
* valarith.c (value_equal): Cast result of TYPE_LENGTH to int.
* valarith.c (value_binop): Change result_len, promoted_len1,
and promoted_len2 to unsigned int.
* valarith.c (value_subscripted_rvalue): Change elt_offs and
elt_size to unsigned int.
* valops.c (value_array): Change typelength to unsigned int.
(destructor_name_p): Change len to unsigned int.
* scm-lang.h (scm_parse): Add prototype for scm_unpack.
* symfile.c (decrement_reading_symtab): Change return type to void.
* valarith.c (value_subscript): Remove unused variable "word".
(value_subscript): Remove unused variable "tint".
* valops.c (auto_abandon): Ifdef out, since code using it is also
ifdef'd out.
* eval.c (init_array_element): Remove unused variable "val".
* Makefile.in (values.o): Depends on scm-lang.h.
(command.o): Depends upon wait_h.
(ser-tcp.o): Depends upon gdb_string.h.
(infptrace.o): Depends upon wait_h and command_h.
(maint.o): Depends on objfiles.h and symfile.h.
* values.c (allocate_repeat_value): Remove unused variable
"element_type".
(scm-lang.h): Include.
* breakpoint.c (create_longjmp_breakpoint): Enclose in
GET_LONGJMP_TARGET define, unused otherwise.
* config/i386/nm-linux.h: Add prototypes for i386_insert_watchpoint,
i386_remove_watchpoint and i386_stopped_by_watchpoint.
1996-03-30 05:45:10 +00:00
|
|
|
tmp = min (port_str - name, (int) sizeof hostname - 1);
|
1993-06-26 00:22:30 +00:00
|
|
|
strncpy (hostname, name, tmp); /* Don't want colon */
|
|
|
|
hostname[tmp] = '\000'; /* Tie off host name */
|
1993-05-29 01:33:36 +00:00
|
|
|
port = atoi (port_str + 1);
|
|
|
|
|
|
|
|
hostent = gethostbyname (hostname);
|
|
|
|
|
|
|
|
if (!hostent)
|
|
|
|
{
|
1993-11-01 22:25:23 +00:00
|
|
|
fprintf_unfiltered (gdb_stderr, "%s: unknown host\n", hostname);
|
1993-05-29 01:33:36 +00:00
|
|
|
errno = ENOENT;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
1995-06-08 22:42:36 +00:00
|
|
|
for (i = 1; i <= 15; i++)
|
|
|
|
{
|
|
|
|
scb->fd = socket (PF_INET, SOCK_STREAM, 0);
|
|
|
|
if (scb->fd < 0)
|
|
|
|
return -1;
|
1993-05-29 01:33:36 +00:00
|
|
|
|
1995-06-08 22:42:36 +00:00
|
|
|
/* Allow rapid reuse of this port. */
|
|
|
|
tmp = 1;
|
|
|
|
setsockopt (scb->fd, SOL_SOCKET, SO_REUSEADDR, (char *)&tmp, sizeof(tmp));
|
1993-05-29 01:33:36 +00:00
|
|
|
|
1995-06-08 22:42:36 +00:00
|
|
|
/* Enable TCP keep alive process. */
|
|
|
|
tmp = 1;
|
|
|
|
setsockopt (scb->fd, SOL_SOCKET, SO_KEEPALIVE, (char *)&tmp, sizeof(tmp));
|
1993-05-29 01:33:36 +00:00
|
|
|
|
1995-06-08 22:42:36 +00:00
|
|
|
sockaddr.sin_family = PF_INET;
|
|
|
|
sockaddr.sin_port = htons(port);
|
|
|
|
memcpy (&sockaddr.sin_addr.s_addr, hostent->h_addr,
|
|
|
|
sizeof (struct in_addr));
|
1993-05-29 01:33:36 +00:00
|
|
|
|
1995-06-08 22:42:36 +00:00
|
|
|
if (!connect (scb->fd, (struct sockaddr *) &sockaddr, sizeof(sockaddr)))
|
|
|
|
break;
|
|
|
|
|
|
|
|
close (scb->fd);
|
1993-06-26 00:22:30 +00:00
|
|
|
scb->fd = -1;
|
1995-06-08 22:42:36 +00:00
|
|
|
|
|
|
|
/* We retry for ECONNREFUSED because that is often a temporary condition, which
|
|
|
|
happens when the server is being restarted. */
|
|
|
|
|
|
|
|
if (errno != ECONNREFUSED)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
sleep (1);
|
1993-05-29 01:33:36 +00:00
|
|
|
}
|
|
|
|
|
1993-05-29 03:14:45 +00:00
|
|
|
protoent = getprotobyname ("tcp");
|
|
|
|
if (!protoent)
|
|
|
|
return -1;
|
|
|
|
|
1993-05-29 01:33:36 +00:00
|
|
|
tmp = 1;
|
1993-05-29 03:14:45 +00:00
|
|
|
if (setsockopt (scb->fd, protoent->p_proto, TCP_NODELAY,
|
|
|
|
(char *)&tmp, sizeof(tmp)))
|
1993-05-29 01:33:36 +00:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
signal(SIGPIPE, SIG_IGN); /* If we don't do this, then GDB simply exits
|
|
|
|
when the remote side dies. */
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static serial_ttystate
|
|
|
|
tcp_get_tty_state(scb)
|
|
|
|
serial_t scb;
|
|
|
|
{
|
|
|
|
struct tcp_ttystate *state;
|
|
|
|
|
|
|
|
state = (struct tcp_ttystate *)xmalloc(sizeof *state);
|
|
|
|
|
|
|
|
return (serial_ttystate)state;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
tcp_set_tty_state(scb, ttystate)
|
|
|
|
serial_t scb;
|
|
|
|
serial_ttystate ttystate;
|
|
|
|
{
|
|
|
|
struct tcp_ttystate *state;
|
|
|
|
|
|
|
|
state = (struct tcp_ttystate *)ttystate;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
* inftarg.c: Remove unused include of terminal.h.
* signals.h: Don't undefine signals anymore.
* main.c: Use job_control from serial.h.
* fork-child.c (fork_inferior): Use gdb_setpgid.
* serial.h, ser-unix.c, ser-go32.c: Provide gdb_setpgid.
* utils.c (quit): Use current_target->to_terminal_ours to figure
out whether we care about lack of job control, rather than __GO32__.
* utils.c: Include serial.h not terminal.h
(quit): Use job_control not TIOCGPGRP.
* terminal.h: Don't undefine TIOCGPGRP.
* serial.h, ser-unix.c, ser-go32.c, ser-tcp.c: Add SERIAL_FLUSH_OUTPUT.
* utils.c (quit): Use it.
* serial.h: Add SERIAL_UN_FDOPEN.
* utils.c (quit): Use it.
* ser-unix.c: Add process group to ttystate.
[HAVE_SGTTY]: Add tchars, ltchars, and lmode to ttystate.
* inflow.c: Include serial.h not terminal.h.
Use serial.h stuff to replace most of the maze of #ifdef's.
* inflow.c, main.c, inferior.h: make gdb_has_a_terminal a function.
* serial.h: Document SERIAL_SET_TTY_STATE as being immediate.
* ser-unix.c: Use TIOCSETN not TIOCSETP so it is true.
* serial.h, ser-unix.c, ser-go32.c, ser-tcp.c:
Add SERIAL_PRINT_TTY_STATE, SERIAL_NOFLUSH_SET_TTY_STATE, and
SERIAL_SET_PROCESS_GROUP.
* inflow.c: Use them.
* config/xm-svr4.h, config/rs6000/xm-rs6000.h, config/sparc/sun4os4.h:
Define HAVE_TERMIOS.
* Various: Remove all use of TIOC*_BROKEN.
1993-06-30 22:20:53 +00:00
|
|
|
static int
|
1993-07-28 06:45:35 +00:00
|
|
|
tcp_return_0 (scb)
|
* inftarg.c: Remove unused include of terminal.h.
* signals.h: Don't undefine signals anymore.
* main.c: Use job_control from serial.h.
* fork-child.c (fork_inferior): Use gdb_setpgid.
* serial.h, ser-unix.c, ser-go32.c: Provide gdb_setpgid.
* utils.c (quit): Use current_target->to_terminal_ours to figure
out whether we care about lack of job control, rather than __GO32__.
* utils.c: Include serial.h not terminal.h
(quit): Use job_control not TIOCGPGRP.
* terminal.h: Don't undefine TIOCGPGRP.
* serial.h, ser-unix.c, ser-go32.c, ser-tcp.c: Add SERIAL_FLUSH_OUTPUT.
* utils.c (quit): Use it.
* serial.h: Add SERIAL_UN_FDOPEN.
* utils.c (quit): Use it.
* ser-unix.c: Add process group to ttystate.
[HAVE_SGTTY]: Add tchars, ltchars, and lmode to ttystate.
* inflow.c: Include serial.h not terminal.h.
Use serial.h stuff to replace most of the maze of #ifdef's.
* inflow.c, main.c, inferior.h: make gdb_has_a_terminal a function.
* serial.h: Document SERIAL_SET_TTY_STATE as being immediate.
* ser-unix.c: Use TIOCSETN not TIOCSETP so it is true.
* serial.h, ser-unix.c, ser-go32.c, ser-tcp.c:
Add SERIAL_PRINT_TTY_STATE, SERIAL_NOFLUSH_SET_TTY_STATE, and
SERIAL_SET_PROCESS_GROUP.
* inflow.c: Use them.
* config/xm-svr4.h, config/rs6000/xm-rs6000.h, config/sparc/sun4os4.h:
Define HAVE_TERMIOS.
* Various: Remove all use of TIOC*_BROKEN.
1993-06-30 22:20:53 +00:00
|
|
|
serial_t scb;
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1993-05-29 01:33:36 +00:00
|
|
|
static void
|
|
|
|
tcp_raw(scb)
|
|
|
|
serial_t scb;
|
|
|
|
{
|
|
|
|
return; /* Always in raw mode */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Wait for input on scb, with timeout seconds. Returns 0 on success,
|
|
|
|
otherwise SERIAL_TIMEOUT or SERIAL_ERROR.
|
|
|
|
|
|
|
|
For termio{s}, we actually just setup VTIME if necessary, and let the
|
|
|
|
timeout occur in the read() in tcp_read().
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int
|
1998-10-16 21:45:06 +00:00
|
|
|
wait_for (scb, timeout)
|
1993-05-29 01:33:36 +00:00
|
|
|
serial_t scb;
|
|
|
|
int timeout;
|
|
|
|
{
|
|
|
|
int numfds;
|
|
|
|
struct timeval tv;
|
1993-06-26 00:22:30 +00:00
|
|
|
fd_set readfds, exceptfds;
|
1993-05-29 01:33:36 +00:00
|
|
|
|
|
|
|
FD_ZERO (&readfds);
|
1993-06-26 00:22:30 +00:00
|
|
|
FD_ZERO (&exceptfds);
|
1993-05-29 01:33:36 +00:00
|
|
|
|
|
|
|
tv.tv_sec = timeout;
|
|
|
|
tv.tv_usec = 0;
|
|
|
|
|
|
|
|
FD_SET(scb->fd, &readfds);
|
1993-06-26 00:22:30 +00:00
|
|
|
FD_SET(scb->fd, &exceptfds);
|
1993-05-29 01:33:36 +00:00
|
|
|
|
1993-06-26 00:22:30 +00:00
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
if (timeout >= 0)
|
|
|
|
numfds = select(scb->fd+1, &readfds, 0, &exceptfds, &tv);
|
|
|
|
else
|
|
|
|
numfds = select(scb->fd+1, &readfds, 0, &exceptfds, 0);
|
|
|
|
|
|
|
|
if (numfds <= 0)
|
1998-10-16 21:45:06 +00:00
|
|
|
{
|
|
|
|
if (numfds == 0)
|
|
|
|
return SERIAL_TIMEOUT;
|
|
|
|
else if (errno == EINTR)
|
|
|
|
continue;
|
|
|
|
else
|
|
|
|
return SERIAL_ERROR; /* Got an error from select or poll */
|
|
|
|
}
|
1993-06-26 00:22:30 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
1993-05-29 01:33:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Read a character with user-specified timeout. TIMEOUT is number of seconds
|
|
|
|
to wait, or -1 to wait forever. Use timeout of 0 to effect a poll. Returns
|
|
|
|
char if successful. Returns -2 if timeout expired, EOF if line dropped
|
|
|
|
dead, or -3 for any other error (see errno in that case). */
|
|
|
|
|
|
|
|
static int
|
1998-10-16 21:45:06 +00:00
|
|
|
tcp_readchar (scb, timeout)
|
1993-05-29 01:33:36 +00:00
|
|
|
serial_t scb;
|
|
|
|
int timeout;
|
|
|
|
{
|
|
|
|
int status;
|
|
|
|
|
|
|
|
if (scb->bufcnt-- > 0)
|
|
|
|
return *scb->bufp++;
|
|
|
|
|
|
|
|
status = wait_for(scb, timeout);
|
|
|
|
|
|
|
|
if (status < 0)
|
|
|
|
return status;
|
|
|
|
|
1994-06-02 16:58:48 +00:00
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
scb->bufcnt = read(scb->fd, scb->buf, BUFSIZ);
|
|
|
|
if (scb->bufcnt != -1 || errno != EINTR)
|
|
|
|
break;
|
|
|
|
}
|
1993-05-29 01:33:36 +00:00
|
|
|
|
|
|
|
if (scb->bufcnt <= 0)
|
1998-10-16 21:45:06 +00:00
|
|
|
{
|
|
|
|
if (scb->bufcnt == 0)
|
|
|
|
return SERIAL_TIMEOUT; /* 0 chars means timeout [may need to
|
|
|
|
distinguish between EOF & timeouts
|
|
|
|
someday] */
|
|
|
|
else
|
|
|
|
return SERIAL_ERROR; /* Got an error from read */
|
|
|
|
}
|
1993-05-29 01:33:36 +00:00
|
|
|
|
|
|
|
scb->bufcnt--;
|
|
|
|
scb->bufp = scb->buf;
|
|
|
|
return *scb->bufp++;
|
|
|
|
}
|
|
|
|
|
* inftarg.c: Remove unused include of terminal.h.
* signals.h: Don't undefine signals anymore.
* main.c: Use job_control from serial.h.
* fork-child.c (fork_inferior): Use gdb_setpgid.
* serial.h, ser-unix.c, ser-go32.c: Provide gdb_setpgid.
* utils.c (quit): Use current_target->to_terminal_ours to figure
out whether we care about lack of job control, rather than __GO32__.
* utils.c: Include serial.h not terminal.h
(quit): Use job_control not TIOCGPGRP.
* terminal.h: Don't undefine TIOCGPGRP.
* serial.h, ser-unix.c, ser-go32.c, ser-tcp.c: Add SERIAL_FLUSH_OUTPUT.
* utils.c (quit): Use it.
* serial.h: Add SERIAL_UN_FDOPEN.
* utils.c (quit): Use it.
* ser-unix.c: Add process group to ttystate.
[HAVE_SGTTY]: Add tchars, ltchars, and lmode to ttystate.
* inflow.c: Include serial.h not terminal.h.
Use serial.h stuff to replace most of the maze of #ifdef's.
* inflow.c, main.c, inferior.h: make gdb_has_a_terminal a function.
* serial.h: Document SERIAL_SET_TTY_STATE as being immediate.
* ser-unix.c: Use TIOCSETN not TIOCSETP so it is true.
* serial.h, ser-unix.c, ser-go32.c, ser-tcp.c:
Add SERIAL_PRINT_TTY_STATE, SERIAL_NOFLUSH_SET_TTY_STATE, and
SERIAL_SET_PROCESS_GROUP.
* inflow.c: Use them.
* config/xm-svr4.h, config/rs6000/xm-rs6000.h, config/sparc/sun4os4.h:
Define HAVE_TERMIOS.
* Various: Remove all use of TIOC*_BROKEN.
1993-06-30 22:20:53 +00:00
|
|
|
static int
|
|
|
|
tcp_noflush_set_tty_state (scb, new_ttystate, old_ttystate)
|
|
|
|
serial_t scb;
|
|
|
|
serial_ttystate new_ttystate;
|
|
|
|
serial_ttystate old_ttystate;
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tcp_print_tty_state (scb, ttystate)
|
|
|
|
serial_t scb;
|
|
|
|
serial_ttystate ttystate;
|
|
|
|
{
|
|
|
|
/* Nothing to print. */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1993-05-29 01:33:36 +00:00
|
|
|
static int
|
|
|
|
tcp_setbaudrate(scb, rate)
|
|
|
|
serial_t scb;
|
|
|
|
int rate;
|
|
|
|
{
|
|
|
|
return 0; /* Never fails! */
|
|
|
|
}
|
|
|
|
|
1995-03-07 09:03:37 +00:00
|
|
|
static int
|
|
|
|
tcp_setstopbits(scb, num)
|
|
|
|
serial_t scb;
|
|
|
|
int num;
|
|
|
|
{
|
|
|
|
return 0; /* Never fails! */
|
|
|
|
}
|
|
|
|
|
1993-05-29 01:33:36 +00:00
|
|
|
static int
|
|
|
|
tcp_write(scb, str, len)
|
|
|
|
serial_t scb;
|
|
|
|
const char *str;
|
|
|
|
int len;
|
|
|
|
{
|
|
|
|
int cc;
|
|
|
|
|
|
|
|
while (len > 0)
|
|
|
|
{
|
|
|
|
cc = write(scb->fd, str, len);
|
|
|
|
|
|
|
|
if (cc < 0)
|
|
|
|
return 1;
|
|
|
|
len -= cc;
|
|
|
|
str += cc;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
tcp_close(scb)
|
|
|
|
serial_t scb;
|
|
|
|
{
|
|
|
|
if (scb->fd < 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
close(scb->fd);
|
|
|
|
scb->fd = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct serial_ops tcp_ops =
|
|
|
|
{
|
|
|
|
"tcp",
|
|
|
|
0,
|
|
|
|
tcp_open,
|
|
|
|
tcp_close,
|
|
|
|
tcp_readchar,
|
|
|
|
tcp_write,
|
1993-07-28 06:45:35 +00:00
|
|
|
tcp_return_0, /* flush output */
|
|
|
|
tcp_return_0, /* flush input */
|
|
|
|
tcp_return_0, /* send break */
|
1993-05-29 01:33:36 +00:00
|
|
|
tcp_raw,
|
|
|
|
tcp_get_tty_state,
|
|
|
|
tcp_set_tty_state,
|
* inftarg.c: Remove unused include of terminal.h.
* signals.h: Don't undefine signals anymore.
* main.c: Use job_control from serial.h.
* fork-child.c (fork_inferior): Use gdb_setpgid.
* serial.h, ser-unix.c, ser-go32.c: Provide gdb_setpgid.
* utils.c (quit): Use current_target->to_terminal_ours to figure
out whether we care about lack of job control, rather than __GO32__.
* utils.c: Include serial.h not terminal.h
(quit): Use job_control not TIOCGPGRP.
* terminal.h: Don't undefine TIOCGPGRP.
* serial.h, ser-unix.c, ser-go32.c, ser-tcp.c: Add SERIAL_FLUSH_OUTPUT.
* utils.c (quit): Use it.
* serial.h: Add SERIAL_UN_FDOPEN.
* utils.c (quit): Use it.
* ser-unix.c: Add process group to ttystate.
[HAVE_SGTTY]: Add tchars, ltchars, and lmode to ttystate.
* inflow.c: Include serial.h not terminal.h.
Use serial.h stuff to replace most of the maze of #ifdef's.
* inflow.c, main.c, inferior.h: make gdb_has_a_terminal a function.
* serial.h: Document SERIAL_SET_TTY_STATE as being immediate.
* ser-unix.c: Use TIOCSETN not TIOCSETP so it is true.
* serial.h, ser-unix.c, ser-go32.c, ser-tcp.c:
Add SERIAL_PRINT_TTY_STATE, SERIAL_NOFLUSH_SET_TTY_STATE, and
SERIAL_SET_PROCESS_GROUP.
* inflow.c: Use them.
* config/xm-svr4.h, config/rs6000/xm-rs6000.h, config/sparc/sun4os4.h:
Define HAVE_TERMIOS.
* Various: Remove all use of TIOC*_BROKEN.
1993-06-30 22:20:53 +00:00
|
|
|
tcp_print_tty_state,
|
|
|
|
tcp_noflush_set_tty_state,
|
1993-05-29 01:33:36 +00:00
|
|
|
tcp_setbaudrate,
|
1995-03-07 09:03:37 +00:00
|
|
|
tcp_setstopbits,
|
1998-03-06 20:38:45 +00:00
|
|
|
tcp_return_0, /* wait for output to drain */
|
1993-05-29 01:33:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void
|
|
|
|
_initialize_ser_tcp ()
|
|
|
|
{
|
|
|
|
serial_add_interface (&tcp_ops);
|
|
|
|
}
|