diff options
author | Pedro Alves <palves@redhat.com> | 2017-11-06 15:36:46 +0000 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2017-11-06 15:36:46 +0000 |
commit | 726e13564b615e5d8e9540b509623e58dfce2012 (patch) | |
tree | 9d7e98916b531f20dfff8612343211342d00d1ec /gdb/inflow.c | |
parent | 1cfb73dbb7503d1cfb088c14d1125a5030a1f386 (diff) | |
download | gdb-726e13564b615e5d8e9540b509623e58dfce2012.zip gdb-726e13564b615e5d8e9540b509623e58dfce2012.tar.gz gdb-726e13564b615e5d8e9540b509623e58dfce2012.tar.bz2 |
Assume termios is available, remove support for termio and sgtty
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.
Diffstat (limited to 'gdb/inflow.c')
-rw-r--r-- | gdb/inflow.c | 88 |
1 files changed, 21 insertions, 67 deletions
diff --git a/gdb/inflow.c b/gdb/inflow.c index d54b8f8..a96d4fc 100644 --- a/gdb/inflow.c +++ b/gdb/inflow.c @@ -31,7 +31,9 @@ #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 @@ -64,9 +66,9 @@ struct terminal_info 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. */ @@ -89,11 +91,11 @@ static serial_ttystate initial_gdb_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; @@ -121,25 +123,6 @@ static const char *inferior_thisrun_terminal; 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 @@ -157,8 +140,8 @@ set_initial_gdb_ttystate (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 } } @@ -187,7 +170,7 @@ child_terminal_init_with_pgrp (int pgrp) 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. */ @@ -224,7 +207,7 @@ gdb_save_tty_state (void) 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 @@ -232,7 +215,7 @@ child_terminal_init (struct target_ops *self) 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. @@ -269,11 +252,7 @@ child_terminal_inferior (struct target_ops *self) 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) @@ -298,19 +277,12 @@ child_terminal_inferior (struct target_ops *self) 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; } @@ -388,34 +360,20 @@ child_terminal_ours_1 (int output_only) 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 @@ -428,10 +386,6 @@ child_terminal_ours_1 (int output_only) safe_strerror (errno)); #endif #endif /* termios */ - -#ifdef HAVE_SGTTY - result = ioctl (0, TIOCSPGRP, &our_terminal_info.process_group); -#endif } #ifdef SIGTTOU @@ -616,7 +570,7 @@ child_terminal_info (struct target_ops *self, const char *args, int from_tty) printf_filtered ("\n"); } -#ifdef PROCESS_GROUP_TYPE +#ifdef HAVE_TERMIOS_H printf_filtered ("Process group = %d\n", (int) tinfo->process_group); #endif |