This commit garbage collects the termio and sgtty support.
GDB's terminal handling code still has support for the old termio and
sgtty interfaces in addition to termios. However, I think it's pretty
safe to assume that for a long, long time, Unix-like systems provide
termios. GNU/Linux, Solaris, Cygwin, AIX, DJGPP, macOS and the BSDs
all have had termios.h for many years. Looking around the web, I
found discussions about FreeBSD folks trying to get rid of old sgtty.h
a decade ago:
https://lists.freebsd.org/pipermail/freebsd-hackers/2007-March/019983.html
So I think support for termio and sgtty in GDB is just dead code that
is never compiled anywhere and is just getting in the way. For
example, serial_noflush_set_tty_state and the raw<->cooked concerns
mentioned in inflow.c only exist because of sgtty (see
hardwire_noflush_set_tty_state).
Regtested on GNU/Linux.
Confirmed that I can still build Solaris, DJGPP and AIX GDB and that
the resulting GDBs still include the termios.h-guarded code.
Confirmed mingw-w64 GDB still builds and skips the termios.h-guarded
code.
gdb/ChangeLog:
2017-11-06 Pedro Alves <palves@redhat.com>
* Makefile.in (SER_HARDWIRE): Update comment.
(HFILES_NO_SRCDIR): Remove gdb_termios.h.
* common/gdb_termios.h: Delete file.
* common/job-control.c: Include termios.h and unistd.h instead of
gdb_termios.h.
(gdb_setpgid): Remove HAVE_TERMIOS || TIOCGPGRP preprocessor
check.
(have_job_control): Check HAVE_TERMIOS_H instead of HAVE_TERMIOS.
Remove sgtty code.
* configure.ac: No longer check for termio.h and sgtty.h.
* configure: Regenerate.
* inflow.c: Include termios.h instead of gdb_termios.h. Replace
PROCESS_GROUP_TYPE checks with HAVE_TERMIOS_H checks throughout.
Replace PROCESS_GROUP_TYPE references with pid_t references
throughout.
(gdb_getpgrp): Delete.
(set_initial_gdb_ttystate): Use tcgetpgrp instead of gdb_getpgrp.
(child_terminal_inferior): Remove comment. Remove sgtty code.
(child_terminal_ours_1): Use tcgetpgrp directly instead of
gdb_getpgrp. Use serial_set_tty_state instead aof
serial_noflush_set_tty_state. Remove sgtty code.
* inflow.h: Include unistd.h instead of gdb_termios.h. Replace
PROCESS_GROUP_TYPE check with HAVE_TERMIOS_H check.
(inferior_process_group): Now returns pid_t.
* ser-base.c (ser_base_noflush_set_tty_state): Delete.
* ser-base.h (ser_base_noflush_set_tty_state): Delete.
* ser-event.c (serial_event_ops): Update.
* ser-go32.c (dos_noflush_set_tty_state): Delete.
(dos_ops): Update.
* ser-mingw.c (hardwire_ops, tty_ops, pipe_ops, tcp_ops): Update.
* ser-pipe.c (pipe_ops): Update.
* ser-tcp.c (tcp_ops): Update.
* ser-unix.c: Include termios.h instead of gdb_termios.h. Remove
HAVE_TERMIOS checks.
[HAVE_TERMIO] (struct hardwire_ttystate): Delete.
[HAVE_SGTTY] (struct hardwire_ttystate): Delete.
(get_tty_state, set_tty_state): Drop termio and sgtty code, and
assume termios.
(hardwire_noflush_set_tty_state): Delete.
(hardwire_print_tty_state, hardwire_drain_output)
(hardwire_flush_output, hardwire_flush_input)
(hardwire_send_break, hardwire_raw, hardwire_setbaudrate)
(hardwire_setstopbits, hardwire_setparity): Drop termio and sgtty
code, and assume termios.
(hardwire_ops): Update.
(_initialize_ser_hardwire): Remove HAVE_TERMIOS check.
* serial.c (serial_noflush_set_tty_state): Delete.
* serial.h (serial_noflush_set_tty_state): Delete.
(serial_ops::noflush_set_tty_state): Delete.
gdb/gdbserver/ChangeLog:
2017-11-06 Pedro Alves <palves@redhat.com>
* configure.ac: No longer check for termio.h and sgtty.h.
* configure: Regenerate.
* remote-utils.c: Include termios.h instead of gdb_termios.h.
(remote_open): Check HAVE_TERMIOS_H instead of HAVE_TERMIOS.
Remove termio and sgtty code.
+2017-11-06 Pedro Alves <palves@redhat.com>
+
+ * Makefile.in (SER_HARDWIRE): Update comment.
+ (HFILES_NO_SRCDIR): Remove gdb_termios.h.
+ * common/gdb_termios.h: Delete file.
+ * common/job-control.c: Include termios.h and unistd.h instead of
+ gdb_termios.h.
+ (gdb_setpgid): Remove HAVE_TERMIOS || TIOCGPGRP preprocessor
+ check.
+ (have_job_control): Check HAVE_TERMIOS_H instead of HAVE_TERMIOS.
+ Remove sgtty code.
+ * configure.ac: No longer check for termio.h and sgtty.h.
+ * configure: Regenerate.
+ * inflow.c: Include termios.h instead of gdb_termios.h. Replace
+ PROCESS_GROUP_TYPE checks with HAVE_TERMIOS_H checks throughout.
+ Replace PROCESS_GROUP_TYPE references with pid_t references
+ throughout.
+ (gdb_getpgrp): Delete.
+ (set_initial_gdb_ttystate): Use tcgetpgrp instead of gdb_getpgrp.
+ (child_terminal_inferior): Remove comment. Remove sgtty code.
+ (child_terminal_ours_1): Use tcgetpgrp directly instead of
+ gdb_getpgrp. Use serial_set_tty_state instead aof
+ serial_noflush_set_tty_state. Remove sgtty code.
+ * inflow.h: Include unistd.h instead of gdb_termios.h. Replace
+ PROCESS_GROUP_TYPE check with HAVE_TERMIOS_H check.
+ (inferior_process_group): Now returns pid_t.
+ * ser-base.c (ser_base_noflush_set_tty_state): Delete.
+ * ser-base.h (ser_base_noflush_set_tty_state): Delete.
+ * ser-event.c (serial_event_ops): Update.
+ * ser-go32.c (dos_noflush_set_tty_state): Delete.
+ (dos_ops): Update.
+ * ser-mingw.c (hardwire_ops, tty_ops, pipe_ops, tcp_ops): Update.
+ * ser-pipe.c (pipe_ops): Update.
+ * ser-tcp.c (tcp_ops): Update.
+ * ser-unix.c: Include termios.h instead of gdb_termios.h. Remove
+ HAVE_TERMIOS checks.
+ [HAVE_TERMIO] (struct hardwire_ttystate): Delete.
+ [HAVE_SGTTY] (struct hardwire_ttystate): Delete.
+ (get_tty_state, set_tty_state): Drop termio and sgtty code, and
+ assume termios.
+ (hardwire_noflush_set_tty_state): Delete.
+ (hardwire_print_tty_state, hardwire_drain_output)
+ (hardwire_flush_output, hardwire_flush_input)
+ (hardwire_send_break, hardwire_raw, hardwire_setbaudrate)
+ (hardwire_setstopbits, hardwire_setparity): Drop termio and sgtty
+ code, and assume termios.
+ (hardwire_ops): Update.
+ (_initialize_ser_hardwire): Remove HAVE_TERMIOS check.
+ * serial.c (serial_noflush_set_tty_state): Delete.
+ * serial.h (serial_noflush_set_tty_state): Delete.
+ (serial_ops::noflush_set_tty_state): Delete.
+
2017-11-06 Ulrich Weigand <uweigand@de.ibm.com>
* Makefile.in (SFILES): Remove doublest.c and dfp.c.
$(srcdir)/features/traceframe-info.dtd \
$(srcdir)/features/xinclude.dtd
-# This is ser-unix.o for any system which supports a v7/BSD/SYSV/POSIX
-# interface to the serial port. Hopefully if get ported to OS/2, VMS,
-# etc., then there will be (as part of the C library or perhaps as
-# part of libiberty) a POSIX interface. But at least for now the
-# host-dependent makefile fragment might need to use something else
-# besides ser-unix.o
+# Build the ser-*.o files the host supports. This includes ser-unix.o
+# for any system that supports a POSIX interface to the serial port.
+# See configure.ac.
SER_HARDWIRE = @SER_HARDWIRE@
# The `remote' debugging target is supported for most architectures,
common/gdb_setjmp.h \
common/gdb_signals.h \
common/gdb_sys_time.h \
- common/gdb_termios.h \
common/gdb_vecs.h \
common/gdb_wait.h \
common/common-inferior.h \
+++ /dev/null
-/* Common terminal interface definitions for GDB and gdbserver.
- Copyright (C) 1986-2017 Free Software Foundation, Inc.
-
- 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 3 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, see <http://www.gnu.org/licenses/>. */
-
-#ifndef GDB_TERMIOS_H
-#define GDB_TERMIOS_H
-
-/* If we're using autoconf, it will define HAVE_TERMIOS_H,
- HAVE_TERMIO_H and HAVE_SGTTY_H for us. One day we can rewrite
- ser-unix.c and inflow.c to inspect those names instead of
- HAVE_TERMIOS, HAVE_TERMIO and the implicit HAVE_SGTTY (when neither
- HAVE_TERMIOS or HAVE_TERMIO is set). Until then, make sure that
- nothing has already defined the one of the names, and do the right
- thing. */
-
-#if !defined (HAVE_TERMIOS) && !defined(HAVE_TERMIO) && !defined(HAVE_SGTTY)
-#if defined(HAVE_TERMIOS_H)
-#define HAVE_TERMIOS
-#else /* ! defined (HAVE_TERMIOS_H) */
-#if defined(HAVE_TERMIO_H)
-#define HAVE_TERMIO
-#else /* ! defined (HAVE_TERMIO_H) */
-#if defined(HAVE_SGTTY_H)
-#define HAVE_SGTTY
-#endif /* ! defined (HAVE_SGTTY_H) */
-#endif /* ! defined (HAVE_TERMIO_H) */
-#endif /* ! defined (HAVE_TERMIOS_H) */
-#endif /* !defined (HAVE_TERMIOS) && !defined (HAVE_TERMIO) &&
- !defined (HAVE_SGTTY) */
-
-#if defined(HAVE_TERMIOS)
-#include <termios.h>
-#endif
-
-#if !defined(_WIN32) && !defined (HAVE_TERMIOS)
-
-/* Define a common set of macros -- BSD based -- and redefine whatever
- the system offers to make it look like that. FIXME: serial.h and
- ser-*.c deal with this in a much cleaner fashion; as soon as stuff
- is converted to use them, can get rid of this crap. */
-
-#ifdef HAVE_TERMIO
-
-#include <termio.h>
-
-#undef TIOCGETP
-#define TIOCGETP TCGETA
-#undef TIOCSETN
-#define TIOCSETN TCSETA
-#undef TIOCSETP
-#define TIOCSETP TCSETAF
-#define TERMINAL struct termio
-
-#else /* sgtty */
-
-#include <fcntl.h>
-#include <sgtty.h>
-#include <sys/ioctl.h>
-#define TERMINAL struct sgttyb
-
-#endif /* sgtty */
-#endif
-
-#endif /* ! GDB_TERMIOS_H */
#include "common-defs.h"
#include "job-control.h"
-#include "gdb_termios.h"
+#ifdef HAVE_TERMIOS_H
+#include <termios.h>
+#endif
+#include <unistd.h>
/* Nonzero if we have job control. */
int job_control;
if (job_control)
{
-#if defined (HAVE_TERMIOS) || defined (TIOCGPGRP)
#ifdef HAVE_SETPGID
/* The call setpgid (0, 0) is supposed to work and mean the same
thing as this, but on Ultrix 4.2A it fails with EPERM (and
#endif
#endif /* HAVE_SETPGRP */
#endif /* HAVE_SETPGID */
-#endif /* defined (HAVE_TERMIOS) || defined (TIOCGPGRP) */
}
return retval;
void
have_job_control ()
{
- /* OK, figure out whether we have job control. If neither termios nor
- sgtty (i.e. termio or go32), leave job_control 0. */
-#if defined (HAVE_TERMIOS)
+ /* OK, figure out whether we have job control. If termios is not
+ available, leave job_control 0. */
+#if defined (HAVE_TERMIOS_H)
/* Do all systems with termios have the POSIX way of identifying job
control? I hope so. */
#ifdef _POSIX_JOB_CONTROL
job_control = 0; /* Have to assume the worst. */
#endif /* _SC_JOB_CONTROL */
#endif /* _POSIX_JOB_CONTROL */
-#endif /* HAVE_TERMIOS */
-
-#ifdef HAVE_SGTTY
-#ifdef TIOCGPGRP
- job_control = 1;
-#else
- job_control = 0;
-#endif /* TIOCGPGRP */
-#endif /* sgtty */
+#endif /* HAVE_TERMIOS_H */
}
sys/file.h sys/filio.h sys/ioctl.h sys/param.h \
sys/resource.h sys/procfs.h sys/ptrace.h ptrace.h \
sys/reg.h sys/debugreg.h sys/select.h sys/syscall.h \
- termios.h termio.h \
- sgtty.h elf_hp.h \
+ termios.h elf_hp.h \
dlfcn.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
sys/file.h sys/filio.h sys/ioctl.h sys/param.h \
sys/resource.h sys/procfs.h sys/ptrace.h ptrace.h \
sys/reg.h sys/debugreg.h sys/select.h sys/syscall.h \
- termios.h termio.h \
- sgtty.h elf_hp.h \
+ termios.h elf_hp.h \
dlfcn.h])
AC_CHECK_HEADERS(sys/proc.h, [], [],
[#if HAVE_SYS_PARAM_H
cd "$ac_popdir"
-for ac_header in sgtty.h termio.h termios.h sys/reg.h string.h proc_service.h sys/procfs.h linux/elf.h fcntl.h signal.h sys/file.h sys/ioctl.h netinet/in.h sys/socket.h netdb.h netinet/tcp.h arpa/inet.h
+for ac_header in termios.h sys/reg.h string.h proc_service.h sys/procfs.h linux/elf.h fcntl.h signal.h sys/file.h sys/ioctl.h netinet/in.h sys/socket.h netdb.h netinet/tcp.h arpa/inet.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
ACX_CONFIGURE_DIR(["../../libiberty"], ["build-libiberty-gdbserver"])
-AC_CHECK_HEADERS(sgtty.h termio.h termios.h sys/reg.h string.h dnl
+AC_CHECK_HEADERS(termios.h sys/reg.h string.h dnl
proc_service.h sys/procfs.h linux/elf.h dnl
fcntl.h signal.h sys/file.h dnl
sys/ioctl.h netinet/in.h sys/socket.h netdb.h dnl
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "server.h"
-#include "gdb_termios.h"
+#if HAVE_TERMIOS_H
+#include <termios.h>
+#endif
#include "target.h"
#include "gdbthread.h"
#include "tdesc.h"
if (remote_desc < 0)
perror_with_name ("Could not open remote device");
-#ifdef HAVE_TERMIOS
+#if HAVE_TERMIOS_H
{
struct termios termios;
tcgetattr (remote_desc, &termios);
}
#endif
-#ifdef HAVE_TERMIO
- {
- struct termio termio;
- ioctl (remote_desc, TCGETA, &termio);
-
- termio.c_iflag = 0;
- termio.c_oflag = 0;
- termio.c_lflag = 0;
- termio.c_cflag &= ~(CSIZE | PARENB);
- termio.c_cflag |= CLOCAL | CS8;
- termio.c_cc[VMIN] = 1;
- termio.c_cc[VTIME] = 0;
-
- ioctl (remote_desc, TCSETA, &termio);
- }
-#endif
-
-#ifdef HAVE_SGTTY
- {
- struct sgttyb sg;
-
- ioctl (remote_desc, TIOCGETP, &sg);
- sg.sg_flags = RAW;
- ioctl (remote_desc, TIOCSETP, &sg);
- }
-#endif
-
fprintf (stderr, "Remote debugging using %s\n", name);
enable_async_notification (remote_desc);
#include "inflow.h"
#include "gdbcmd.h"
-#include "gdb_termios.h"
+#ifdef HAVE_TERMIOS_H
+#include <termios.h>
+#endif
#include "job-control.h"
#ifdef HAVE_SYS_IOCTL_H
it when it resumes. */
serial_ttystate ttystate;
-#ifdef PROCESS_GROUP_TYPE
+#ifdef HAVE_TERMIOS_H
/* Process group. Saved and restored just like ttystate. */
- PROCESS_GROUP_TYPE process_group;
+ pid_t process_group;
#endif
/* fcntl flags. Saved and restored just like ttystate. */
static struct terminal_info *get_inflow_inferior_data (struct inferior *);
-#ifdef PROCESS_GROUP_TYPE
+#ifdef HAVE_TERMIOS_H
/* Return the process group of the current inferior. */
-PROCESS_GROUP_TYPE
+pid_t
inferior_process_group (void)
{
return get_inflow_inferior_data (current_inferior ())->process_group;
int terminal_is_ours;
-#ifdef PROCESS_GROUP_TYPE
-static PROCESS_GROUP_TYPE
-gdb_getpgrp (void)
-{
- int process_group = -1;
-
-#ifdef HAVE_TERMIOS
- process_group = tcgetpgrp (0);
-#endif
-#ifdef HAVE_TERMIO
- process_group = getpgrp ();
-#endif
-#ifdef HAVE_SGTTY
- ioctl (0, TIOCGPGRP, &process_group);
-#endif
- return process_group;
-}
-#endif
-
/* See terminal.h. */
void
#ifdef F_GETFL
our_terminal_info.tflags = fcntl (0, F_GETFL, 0);
#endif
-#ifdef PROCESS_GROUP_TYPE
- our_terminal_info.process_group = gdb_getpgrp ();
+#ifdef HAVE_TERMIOS_H
+ our_terminal_info.process_group = tcgetpgrp (0);
#endif
}
}
struct inferior *inf = current_inferior ();
struct terminal_info *tinfo = get_inflow_inferior_data (inf);
-#ifdef PROCESS_GROUP_TYPE
+#ifdef HAVE_TERMIOS_H
/* Store the process group even without a terminal as it is used not
only to reset the tty foreground process group, but also to
interrupt the inferior. */
void
child_terminal_init (struct target_ops *self)
{
-#ifdef PROCESS_GROUP_TYPE
+#ifdef HAVE_TERMIOS_H
/* This is for Lynx, and should be cleaned up by having Lynx be a
separate debugging target with a version of target_terminal::init
which passes in the process group to a generic routine which does
pass in inferior_ptid to the same routine). */
/* We assume INFERIOR_PID is also the child's process group. */
child_terminal_init_with_pgrp (ptid_get_pid (inferior_ptid));
-#endif /* PROCESS_GROUP_TYPE */
+#endif /* HAVE_TERMIOS_H */
}
/* Put the inferior's terminal settings into effect.
OOPSY ("fcntl F_SETFL");
#endif
- /* Because we were careful to not change in or out of raw mode in
- terminal_ours, we will not change in our out of raw mode with
- this call, so we don't flush any input. */
- result = serial_set_tty_state (stdin_serial,
- tinfo->ttystate);
+ result = serial_set_tty_state (stdin_serial, tinfo->ttystate);
OOPSY ("setting tty state");
if (!job_control)
if (job_control)
{
-#ifdef HAVE_TERMIOS
+#ifdef HAVE_TERMIOS_H
result = tcsetpgrp (0, tinfo->process_group);
if (!inf->attach_flag)
OOPSY ("tcsetpgrp");
#endif
-
-#ifdef HAVE_SGTTY
- result = ioctl (0, TIOCSPGRP, &tinfo->process_group);
- if (!inf->attach_flag)
- OOPSY ("TIOCSPGRP");
-#endif
}
-
}
terminal_is_ours = 0;
}
xfree (tinfo->ttystate);
tinfo->ttystate = serial_get_tty_state (stdin_serial);
-#ifdef PROCESS_GROUP_TYPE
+#ifdef HAVE_TERMIOS_H
if (!inf->attach_flag)
- /* If setpgrp failed in terminal_inferior, this would give us
+ /* If tcsetpgrp failed in terminal_inferior, this would give us
our process group instead of the inferior's. See
terminal_inferior for details. */
- tinfo->process_group = gdb_getpgrp ();
+ tinfo->process_group = tcgetpgrp (0);
#endif
- /* Here we used to set ICANON in our ttystate, but I believe this
- was an artifact from before when we used readline. Readline sets
- the tty state when it needs to.
- FIXME-maybe: However, query() expects non-raw mode and doesn't
- use readline. Maybe query should use readline (on the other hand,
- this only matters for HAVE_SGTTY, not termio or termios, I think). */
-
- /* Set tty state to our_ttystate. We don't change in our out of raw
- mode, to avoid flushing input. We need to do the same thing
- regardless of output_only, because we don't have separate
- terminal_is_ours and terminal_is_ours_for_output flags. It's OK,
- though, since readline will deal with raw mode when/if it needs
- to. */
-
- serial_noflush_set_tty_state (stdin_serial, our_terminal_info.ttystate,
- tinfo->ttystate);
+ /* Set tty state to our_ttystate. */
+ serial_set_tty_state (stdin_serial, our_terminal_info.ttystate);
if (job_control)
{
-#ifdef HAVE_TERMIOS
+#ifdef HAVE_TERMIOS_H
result = tcsetpgrp (0, our_terminal_info.process_group);
#if 0
/* This fails on Ultrix with EINVAL if you run the testsuite
safe_strerror (errno));
#endif
#endif /* termios */
-
-#ifdef HAVE_SGTTY
- result = ioctl (0, TIOCSPGRP, &our_terminal_info.process_group);
-#endif
}
#ifdef SIGTTOU
printf_filtered ("\n");
}
-#ifdef PROCESS_GROUP_TYPE
+#ifdef HAVE_TERMIOS_H
printf_filtered ("Process group = %d\n", (int) tinfo->process_group);
#endif
#ifndef INFLOW_H
#define INFLOW_H
-#include "gdb_termios.h"
+#include <unistd.h>
-#ifdef HAVE_TERMIOS
-# define PROCESS_GROUP_TYPE pid_t
-#elif defined (HAVE_TERMIO) || defined (HAVE_SGTTY)
-# define PROCESS_GROUP_TYPE int
-#endif
-
-#ifdef PROCESS_GROUP_TYPE
/* Process group of the current inferior. */
-extern PROCESS_GROUP_TYPE inferior_process_group (void);
+#ifdef HAVE_TERMIOS_H
+extern pid_t inferior_process_group (void);
#endif
#endif /* inflow.h */
return 0;
}
-int
-ser_base_noflush_set_tty_state (struct serial *scb,
- serial_ttystate new_ttystate,
- serial_ttystate old_ttystate)
-{
- return 0;
-}
-
void
ser_base_print_tty_state (struct serial *scb,
serial_ttystate ttystate,
extern void ser_base_print_tty_state (struct serial *scb,
serial_ttystate ttystate,
struct ui_file *stream);
-extern int ser_base_noflush_set_tty_state (struct serial *scb,
- serial_ttystate new_ttystate,
- serial_ttystate old_ttystate);
extern int ser_base_setbaudrate (struct serial *scb, int rate);
extern int ser_base_setstopbits (struct serial *scb, int num);
extern int ser_base_setparity (struct serial *scb, int parity);
NULL, /* copy_tty_state */
NULL, /* set_tty_state */
NULL, /* print_tty_state */
- NULL, /* noflush_set_tty_state */
NULL, /* setbaudrate */
NULL, /* setstopbits */
NULL, /* setparity */
return 0;
}
-static int
-dos_noflush_set_tty_state (struct serial *scb, serial_ttystate new_ttystate,
- serial_ttystate old_ttystate)
-{
- struct dos_ttystate *state;
-
- state = (struct dos_ttystate *) new_ttystate;
- dos_setbaudrate (scb, state->baudrate);
- return 0;
-}
-
static int
dos_flush_input (struct serial *scb)
{
dos_copy_tty_state,
dos_set_tty_state,
dos_print_tty_state,
- dos_noflush_set_tty_state,
dos_setbaudrate,
dos_setstopbits,
dos_setparity,
ser_base_copy_tty_state,
ser_base_set_tty_state,
ser_base_print_tty_state,
- ser_base_noflush_set_tty_state,
ser_windows_setbaudrate,
ser_windows_setstopbits,
ser_windows_setparity,
ser_base_copy_tty_state,
ser_base_set_tty_state,
ser_base_print_tty_state,
- ser_base_noflush_set_tty_state,
NULL,
NULL,
NULL,
ser_base_copy_tty_state,
ser_base_set_tty_state,
ser_base_print_tty_state,
- ser_base_noflush_set_tty_state,
ser_base_setbaudrate,
ser_base_setstopbits,
ser_base_setparity,
ser_base_copy_tty_state,
ser_base_set_tty_state,
ser_base_print_tty_state,
- ser_base_noflush_set_tty_state,
ser_base_setbaudrate,
ser_base_setstopbits,
ser_base_setparity,
ser_base_copy_tty_state,
ser_base_set_tty_state,
ser_base_print_tty_state,
- ser_base_noflush_set_tty_state,
ser_base_setbaudrate,
ser_base_setstopbits,
ser_base_setparity,
ser_base_copy_tty_state,
ser_base_set_tty_state,
ser_base_print_tty_state,
- ser_base_noflush_set_tty_state,
ser_base_setbaudrate,
ser_base_setstopbits,
ser_base_setparity,
#include "gdb_select.h"
#include "gdbcmd.h"
#include "filestuff.h"
-#include "gdb_termios.h"
-
-#ifdef HAVE_TERMIOS
+#include <termios.h>
struct hardwire_ttystate
{
}
#endif
-#endif /* termios */
-
-#ifdef HAVE_TERMIO
-
-/* It is believed that all systems which have added job control to SVR3
- (e.g. sco) have also added termios. Even if not, trying to figure out
- all the variations (TIOCGPGRP vs. TCGETPGRP, etc.) would be pretty
- bewildering. So we don't attempt it. */
-
-struct hardwire_ttystate
- {
- struct termio termio;
- };
-#endif /* termio */
-
-#ifdef HAVE_SGTTY
-struct hardwire_ttystate
- {
- struct sgttyb sgttyb;
- struct tchars tc;
- struct ltchars ltc;
- /* Line discipline flags. */
- int lmode;
- };
-#endif /* sgtty */
-
static int hardwire_open (struct serial *scb, const char *name);
static void hardwire_raw (struct serial *scb);
static int rate_to_code (int rate);
struct hardwire_ttystate * state);
static serial_ttystate hardwire_get_tty_state (struct serial *scb);
static int hardwire_set_tty_state (struct serial *scb, serial_ttystate state);
-static int hardwire_noflush_set_tty_state (struct serial *, serial_ttystate,
- serial_ttystate);
static void hardwire_print_tty_state (struct serial *, serial_ttystate,
struct ui_file *);
static int hardwire_drain_output (struct serial *);
static int
get_tty_state (struct serial *scb, struct hardwire_ttystate *state)
{
-#ifdef HAVE_TERMIOS
if (tcgetattr (scb->fd, &state->termios) < 0)
return -1;
return 0;
-#endif
-
-#ifdef HAVE_TERMIO
- if (ioctl (scb->fd, TCGETA, &state->termio) < 0)
- return -1;
- return 0;
-#endif
-
-#ifdef HAVE_SGTTY
- if (ioctl (scb->fd, TIOCGETP, &state->sgttyb) < 0)
- return -1;
- if (ioctl (scb->fd, TIOCGETC, &state->tc) < 0)
- return -1;
- if (ioctl (scb->fd, TIOCGLTC, &state->ltc) < 0)
- return -1;
- if (ioctl (scb->fd, TIOCLGET, &state->lmode) < 0)
- return -1;
-
- return 0;
-#endif
}
static int
set_tty_state (struct serial *scb, struct hardwire_ttystate *state)
{
-#ifdef HAVE_TERMIOS
if (tcsetattr (scb->fd, TCSANOW, &state->termios) < 0)
return -1;
return 0;
-#endif
-
-#ifdef HAVE_TERMIO
- if (ioctl (scb->fd, TCSETA, &state->termio) < 0)
- return -1;
- return 0;
-#endif
-
-#ifdef HAVE_SGTTY
- if (ioctl (scb->fd, TIOCSETN, &state->sgttyb) < 0)
- return -1;
- if (ioctl (scb->fd, TIOCSETC, &state->tc) < 0)
- return -1;
- if (ioctl (scb->fd, TIOCSLTC, &state->ltc) < 0)
- return -1;
- if (ioctl (scb->fd, TIOCLSET, &state->lmode) < 0)
- return -1;
-
- return 0;
-#endif
}
static serial_ttystate
return set_tty_state (scb, state);
}
-static int
-hardwire_noflush_set_tty_state (struct serial *scb,
- serial_ttystate new_ttystate,
- serial_ttystate old_ttystate)
-{
- struct hardwire_ttystate new_state;
-#ifdef HAVE_SGTTY
- struct hardwire_ttystate *state = (struct hardwire_ttystate *) old_ttystate;
-#endif
-
- new_state = *(struct hardwire_ttystate *) new_ttystate;
-
- /* Don't change in or out of raw mode; we don't want to flush input.
- termio and termios have no such restriction; for them flushing input
- is separate from setting the attributes. */
-
-#ifdef HAVE_SGTTY
- if (state->sgttyb.sg_flags & RAW)
- new_state.sgttyb.sg_flags |= RAW;
- else
- new_state.sgttyb.sg_flags &= ~RAW;
-
- /* I'm not sure whether this is necessary; the manpage just mentions
- RAW not CBREAK. */
- if (state->sgttyb.sg_flags & CBREAK)
- new_state.sgttyb.sg_flags |= CBREAK;
- else
- new_state.sgttyb.sg_flags &= ~CBREAK;
-#endif
-
- return set_tty_state (scb, &new_state);
-}
-
static void
hardwire_print_tty_state (struct serial *scb,
serial_ttystate ttystate,
struct hardwire_ttystate *state = (struct hardwire_ttystate *) ttystate;
int i;
-#ifdef HAVE_TERMIOS
fprintf_filtered (stream, "c_iflag = 0x%x, c_oflag = 0x%x,\n",
(int) state->termios.c_iflag,
(int) state->termios.c_oflag);
for (i = 0; i < NCCS; i += 1)
fprintf_filtered (stream, "0x%x ", state->termios.c_cc[i]);
fprintf_filtered (stream, "\n");
-#endif
-
-#ifdef HAVE_TERMIO
- fprintf_filtered (stream, "c_iflag = 0x%x, c_oflag = 0x%x,\n",
- state->termio.c_iflag, state->termio.c_oflag);
- fprintf_filtered (stream, "c_cflag = 0x%x, c_lflag = 0x%x, c_line = 0x%x.\n",
- state->termio.c_cflag, state->termio.c_lflag,
- state->termio.c_line);
- fprintf_filtered (stream, "c_cc: ");
- for (i = 0; i < NCC; i += 1)
- fprintf_filtered (stream, "0x%x ", state->termio.c_cc[i]);
- fprintf_filtered (stream, "\n");
-#endif
-
-#ifdef HAVE_SGTTY
- fprintf_filtered (stream, "sgttyb.sg_flags = 0x%x.\n",
- state->sgttyb.sg_flags);
-
- fprintf_filtered (stream, "tchars: ");
- for (i = 0; i < (int) sizeof (struct tchars); i++)
- fprintf_filtered (stream, "0x%x ", ((unsigned char *) &state->tc)[i]);
- fprintf_filtered (stream, "\n");
-
- fprintf_filtered (stream, "ltchars: ");
- for (i = 0; i < (int) sizeof (struct ltchars); i++)
- fprintf_filtered (stream, "0x%x ", ((unsigned char *) &state->ltc)[i]);
- fprintf_filtered (stream, "\n");
-
- fprintf_filtered (stream, "lmode: 0x%x\n", state->lmode);
-#endif
}
/* Wait for the output to drain away, as opposed to flushing
static int
hardwire_drain_output (struct serial *scb)
{
-#ifdef HAVE_TERMIOS
return tcdrain (scb->fd);
-#endif
-
-#ifdef HAVE_TERMIO
- return ioctl (scb->fd, TCSBRK, 1);
-#endif
-
-#ifdef HAVE_SGTTY
- /* Get the current state and then restore it using TIOCSETP,
- which should cause the output to drain and pending input
- to be discarded. */
- {
- struct hardwire_ttystate state;
-
- if (get_tty_state (scb, &state))
- {
- return (-1);
- }
- else
- {
- return (ioctl (scb->fd, TIOCSETP, &state.sgttyb));
- }
- }
-#endif
}
static int
hardwire_flush_output (struct serial *scb)
{
-#ifdef HAVE_TERMIOS
return tcflush (scb->fd, TCOFLUSH);
-#endif
-
-#ifdef HAVE_TERMIO
- return ioctl (scb->fd, TCFLSH, 1);
-#endif
-
-#ifdef HAVE_SGTTY
- /* This flushes both input and output, but we can't do better. */
- return ioctl (scb->fd, TIOCFLUSH, 0);
-#endif
}
static int
{
ser_base_flush_input (scb);
-#ifdef HAVE_TERMIOS
return tcflush (scb->fd, TCIFLUSH);
-#endif
-
-#ifdef HAVE_TERMIO
- return ioctl (scb->fd, TCFLSH, 0);
-#endif
-
-#ifdef HAVE_SGTTY
- /* This flushes both input and output, but we can't do better. */
- return ioctl (scb->fd, TIOCFLUSH, 0);
-#endif
}
static int
hardwire_send_break (struct serial *scb)
{
-#ifdef HAVE_TERMIOS
return tcsendbreak (scb->fd, 0);
-#endif
-
-#ifdef HAVE_TERMIO
- return ioctl (scb->fd, TCSBRK, 0);
-#endif
-
-#ifdef HAVE_SGTTY
- {
- int status;
-
- status = ioctl (scb->fd, TIOCSBRK, 0);
-
- /* Can't use usleep; it doesn't exist in BSD 4.2. */
- /* Note that if this gdb_select() is interrupted by a signal it will not
- wait the full length of time. I think that is OK. */
- gdb_usleep (250000);
- status = ioctl (scb->fd, TIOCCBRK, 0);
- return status;
- }
-#endif
}
static void
fprintf_unfiltered (gdb_stderr, "get_tty_state failed: %s\n",
safe_strerror (errno));
-#ifdef HAVE_TERMIOS
state.termios.c_iflag = 0;
state.termios.c_oflag = 0;
state.termios.c_lflag = 0;
#endif
state.termios.c_cc[VMIN] = 0;
state.termios.c_cc[VTIME] = 0;
-#endif
-
-#ifdef HAVE_TERMIO
- state.termio.c_iflag = 0;
- state.termio.c_oflag = 0;
- state.termio.c_lflag = 0;
- state.termio.c_cflag &= ~CSIZE;
- state.termio.c_cflag |= CLOCAL | CS8;
- state.termio.c_cc[VMIN] = 0;
- state.termio.c_cc[VTIME] = 0;
-#endif
-
-#ifdef HAVE_SGTTY
- state.sgttyb.sg_flags |= RAW | ANYP;
- state.sgttyb.sg_flags &= ~(CBREAK | ECHO);
-#endif
if (set_tty_state (scb, &state))
fprintf_unfiltered (gdb_stderr, "set_tty_state failed: %s\n",
if (get_tty_state (scb, &state))
return -1;
-#ifdef HAVE_TERMIOS
cfsetospeed (&state.termios, baud_code);
cfsetispeed (&state.termios, baud_code);
-#endif
-
-#ifdef HAVE_TERMIO
-#ifndef CIBAUD
-#define CIBAUD CBAUD
-#endif
-
- state.termio.c_cflag &= ~(CBAUD | CIBAUD);
- state.termio.c_cflag |= baud_code;
-#endif
-
-#ifdef HAVE_SGTTY
- state.sgttyb.sg_ispeed = baud_code;
- state.sgttyb.sg_ospeed = baud_code;
-#endif
return set_tty_state (scb, &state);
}
return 1;
}
-#ifdef HAVE_TERMIOS
if (!newbit)
state.termios.c_cflag &= ~CSTOPB;
else
state.termios.c_cflag |= CSTOPB; /* two bits */
-#endif
-
-#ifdef HAVE_TERMIO
- if (!newbit)
- state.termio.c_cflag &= ~CSTOPB;
- else
- state.termio.c_cflag |= CSTOPB; /* two bits */
-#endif
-
-#ifdef HAVE_SGTTY
- return 0; /* sgtty doesn't support this */
-#endif
return set_tty_state (scb, &state);
}
return -1;
}
-#ifdef HAVE_TERMIOS
state.termios.c_cflag &= ~(PARENB | PARODD);
state.termios.c_cflag |= newparity;
-#endif
-#ifdef HAVE_TERMIO
- state.termio.c_cflag &= ~(PARENB | PARODD);
- state.termio.c_cflag |= newparity;
-#endif
-
-#ifdef HAVE_SGTTY
- return 0; /* sgtty doesn't support this */
-#endif
return set_tty_state (scb, &state);
}
hardwire_copy_tty_state,
hardwire_set_tty_state,
hardwire_print_tty_state,
- hardwire_noflush_set_tty_state,
hardwire_setbaudrate,
hardwire_setstopbits,
hardwire_setparity,
{
serial_add_interface (&hardwire_ops);
-#ifdef HAVE_TERMIOS
#ifdef CRTSCTS
add_setshow_boolean_cmd ("remoteflow", no_class,
&serial_hwflow, _("\
show_serial_hwflow,
&setlist, &showlist);
#endif
-#endif
}
int
scb->ops->print_tty_state (scb, ttystate, stream);
}
-int
-serial_noflush_set_tty_state (struct serial *scb,
- serial_ttystate new_ttystate,
- serial_ttystate old_ttystate)
-{
- return scb->ops->noflush_set_tty_state (scb, new_ttystate, old_ttystate);
-}
-
int
serial_setbaudrate (struct serial *scb, int rate)
{
serial_ttystate ttystate,
struct ui_file *);
-/* Set the tty state to NEW_TTYSTATE, where OLD_TTYSTATE is the
- current state (generally obtained from a recent call to
- serial_get_tty_state()), but be careful not to discard any input.
- This means that we never switch in or out of raw mode, even if
- NEW_TTYSTATE specifies a switch. */
-
-extern int serial_noflush_set_tty_state (struct serial *scb,
- serial_ttystate new_ttystate,
- serial_ttystate old_ttystate);
-
/* Set the baudrate to the decimal value supplied. Returns 0 for
success, -1 for failure. */
int (*set_tty_state) (struct serial *, serial_ttystate);
void (*print_tty_state) (struct serial *, serial_ttystate,
struct ui_file *);
- int (*noflush_set_tty_state) (struct serial *, serial_ttystate,
- serial_ttystate);
int (*setbaudrate) (struct serial *, int rate);
int (*setstopbits) (struct serial *, int num);
/* Set the value PARITY as parity setting for serial object.
+2017-11-06 Pedro Alves <palves@redhat.com>
+
+ * configure.ac: No longer check for termio.h and sgtty.h.
+ * configure: Regenerate.
+ * remote-utils.c: Include termios.h instead of gdb_termios.h.
+ (remote_open): Check HAVE_TERMIOS_H instead of HAVE_TERMIOS.
+ Remove termio and sgtty code.
+
2017-11-03 Yao Qi <yao.qi@linaro.org>
* gdb.mi/list-thread-groups-available.exp: Skip it if XML parsing