mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2025-01-18 12:24:38 +08:00
726e13564b
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.
87 lines
2.4 KiB
C
87 lines
2.4 KiB
C
/* Job control and terminal related functions, for GDB and gdbserver
|
|
when running under Unix.
|
|
|
|
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/>. */
|
|
|
|
#include "common-defs.h"
|
|
#include "job-control.h"
|
|
#ifdef HAVE_TERMIOS_H
|
|
#include <termios.h>
|
|
#endif
|
|
#include <unistd.h>
|
|
|
|
/* Nonzero if we have job control. */
|
|
int job_control;
|
|
|
|
/* Set the process group ID of the inferior.
|
|
|
|
Just using job_control only does part of it because setpgid or
|
|
setpgrp might not exist on a system without job control.
|
|
|
|
For a more clean implementation, in libiberty, put a setpgid which merely
|
|
calls setpgrp and a setpgrp which does nothing (any system with job control
|
|
will have one or the other). */
|
|
|
|
int
|
|
gdb_setpgid ()
|
|
{
|
|
int retval = 0;
|
|
|
|
if (job_control)
|
|
{
|
|
#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
|
|
setpgid (getpid (), getpid ()) succeeds). */
|
|
retval = setpgid (getpid (), getpid ());
|
|
#else
|
|
#ifdef HAVE_SETPGRP
|
|
#ifdef SETPGRP_VOID
|
|
retval = setpgrp ();
|
|
#else
|
|
retval = setpgrp (getpid (), getpid ());
|
|
#endif
|
|
#endif /* HAVE_SETPGRP */
|
|
#endif /* HAVE_SETPGID */
|
|
}
|
|
|
|
return retval;
|
|
}
|
|
|
|
/* See common/common-terminal.h. */
|
|
|
|
void
|
|
have_job_control ()
|
|
{
|
|
/* 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 = 1;
|
|
#else
|
|
#ifdef _SC_JOB_CONTROL
|
|
job_control = sysconf (_SC_JOB_CONTROL);
|
|
#else
|
|
job_control = 0; /* Have to assume the worst. */
|
|
#endif /* _SC_JOB_CONTROL */
|
|
#endif /* _POSIX_JOB_CONTROL */
|
|
#endif /* HAVE_TERMIOS_H */
|
|
}
|