]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Create gdb_termios.h (and cleanup gdb/{,gdbserver/}terminal.h)
authorSergio Durigan Junior <sergiodj@redhat.com>
Wed, 12 Apr 2017 01:05:12 +0000 (21:05 -0400)
committerSergio Durigan Junior <sergiodj@redhat.com>
Wed, 12 Apr 2017 21:59:45 +0000 (17:59 -0400)
As requested, I'm sending this as a separate patch because it is ready
to be included as-is.

The idea here is that both gdb/terminal.h and gdb/gdbserver/terminal.h
share the same code, which is responsible for setting a bunch of
defines on based on the presence of termios.h and a few other headers.
This simple patch just moves this common code to common/gdb_termios.h
and makes the necessary adjustments on both GDB and gdbserver so that
they can use this new header.  It also implements the some header
checks on common/common.m4.

As a bonus, gdb/gdbserver/terminal.h can be removed because it's now
empty.

Built on x86_64, no regressions found.

gdb/ChangeLog:
2017-04-12  Sergio Durigan Junior  <sergiodj@redhat.com>

* Makefile.in (HFILES_NO_SRCDIR): Add "common/gdb_termios.h".
* common/common.m4: Check headers 'termios.h', 'termio.h' and
'sgtty.h'.
* common/gdb_termios.h: New file, with parts of "terminal.h".
* inflow.c: Include "gdb_termios.h".
* ser-unix.c: Include "gdb_termios.h".
* terminal.h: Move terminal-related defines to
"common/gdb_termios.h".

gdb/gdbserver/ChangeLog:
2017-04-12  Sergio Durigan Junior  <sergiodj@redhat.com>

* remote-utils.c: Include "gdb_termios.h" instead of
"terminal.h".
* terminal.h: Delete file.

gdb/ChangeLog
gdb/Makefile.in
gdb/common/common.m4
gdb/common/gdb_termios.h [new file with mode: 0644]
gdb/gdbserver/ChangeLog
gdb/gdbserver/remote-utils.c
gdb/gdbserver/terminal.h [deleted file]
gdb/inflow.c
gdb/inflow.h
gdb/ser-unix.c
gdb/terminal.h

index cf3e1442368a126a2e3d10bb03795b5dc8aaa860..f5f76f87491a6f45c23f91e547214871050673df 100644 (file)
@@ -1,3 +1,14 @@
+2017-04-12  Sergio Durigan Junior  <sergiodj@redhat.com>
+
+       * Makefile.in (HFILES_NO_SRCDIR): Add "common/gdb_termios.h".
+       * common/common.m4: Check headers 'termios.h', 'termio.h' and
+       'sgtty.h'.
+       * common/gdb_termios.h: New file, with parts of "terminal.h".
+       * inflow.c: Include "gdb_termios.h".
+       * ser-unix.c: Include "gdb_termios.h".
+       * terminal.h: Move terminal-related defines to
+       "common/gdb_termios.h".
+
 2017-04-12  Tom Tromey  <tom@tromey.com>
 
        * probe.c (parse_probes): Update.
index a5a5b429a19ba3814884126012fa14ed534a2139..291b1a04cc844fa8758f57f6189975485cd4c92d 100644 (file)
@@ -1497,6 +1497,7 @@ HFILES_NO_SRCDIR = \
        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/host-defs.h \
index e21e6e54b902cbea07a88d6b7cca90774d4b2357..45726abe9a4dd8bc0012efabcd5e942b58354137 100644 (file)
@@ -28,7 +28,8 @@ AC_DEFUN([GDB_AC_COMMON], [
   AC_CHECK_HEADERS(linux/perf_event.h locale.h memory.h signal.h dnl
                   sys/resource.h sys/socket.h sys/syscall.h dnl
                   sys/un.h sys/wait.h dnl
-                  thread_db.h wait.h)
+                  thread_db.h wait.h dnl
+                  termios.h termio.h sgtty.h)
 
   AC_CHECK_FUNCS([fdwalk getrlimit pipe pipe2 socketpair sigaction])
 
diff --git a/gdb/common/gdb_termios.h b/gdb/common/gdb_termios.h
new file mode 100644 (file)
index 0000000..1d0544d
--- /dev/null
@@ -0,0 +1,78 @@
+/* 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 */
index 1f8c5938b79ca8d3084fccae769536cc84413d01..2060d25703bd7c6801fbd366314389ed771a94e9 100644 (file)
@@ -1,3 +1,9 @@
+2017-04-12  Sergio Durigan Junior  <sergiodj@redhat.com>
+
+       * remote-utils.c: Include "gdb_termios.h" instead of
+       "terminal.h".
+       * terminal.h: Delete file.
+
 2017-04-12  Sergio Durigan Junior  <sergiodj@redhat.com>
 
        * server.c: Include <vector>.
index 37a64022578abe5b468a02eb3ee6e126eab65745..25b7e41a91b18b97bb63ab473bc3d10a960bbb80 100644 (file)
@@ -17,7 +17,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "server.h"
-#include "terminal.h"
+#include "gdb_termios.h"
 #include "target.h"
 #include "gdbthread.h"
 #include "tdesc.h"
diff --git a/gdb/gdbserver/terminal.h b/gdb/gdbserver/terminal.h
deleted file mode 100644 (file)
index 3bdd5f5..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/* Terminal interface definitions for the GDB remote server.
-   Copyright (C) 2002-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/>.  */
-
-#if !defined (TERMINAL_H)
-#define TERMINAL_H 1
-
-/* Autoconf will have defined HAVE_TERMIOS_H, HAVE_TERMIO_H,
-   and HAVE_SGTTY_H for us as appropriate.  */
-
-#if defined(HAVE_TERMIOS_H)
-#define HAVE_TERMIOS
-#include <termios.h>
-#else /* ! HAVE_TERMIOS_H */
-#if defined(HAVE_TERMIO_H)
-#define 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 /* ! HAVE_TERMIO_H */
-#ifdef HAVE_SGTTY_H
-#define HAVE_SGTTY
-#include <fcntl.h>
-#include <sgtty.h>
-#include <sys/ioctl.h>
-#define TERMINAL struct sgttyb
-#endif
-#endif
-#endif
-
-#endif /* !defined (TERMINAL_H) */
index 7ffa83a17fb5b1b87e3eb49fa1c0f29abe7f3819..23dcc4dc0c80690a746f2574cb1f03992c89dbc5 100644 (file)
@@ -31,6 +31,7 @@
 
 #include "inflow.h"
 #include "gdbcmd.h"
+#include "gdb_termios.h"
 
 #ifdef HAVE_SYS_IOCTL_H
 #include <sys/ioctl.h>
index 90ac4d6bd24fceb3c768694f913380e17b31d1d8..428aed41b1ab298aea97b2d49da4aa0d58225f16 100644 (file)
@@ -20,7 +20,7 @@
 #ifndef INFLOW_H
 #define INFLOW_H
 
-#include "terminal.h"          /* For HAVE_TERMIOS et.al.  */
+#include "gdb_termios.h"
 
 #ifdef HAVE_TERMIOS
 # define PROCESS_GROUP_TYPE pid_t
index 5c93891c15273e210d46fa741259e99ed12ab77f..54b0b75c174bb2085b0aff00619ed55fd03c4f08 100644 (file)
@@ -31,6 +31,7 @@
 #include "gdb_select.h"
 #include "gdbcmd.h"
 #include "filestuff.h"
+#include "gdb_termios.h"
 
 #ifdef HAVE_TERMIOS
 
index d8691b2fd0657b32aa18e72e28786b3b510e4973..fb20ae03dffe920b097b8fd8b3db93ad10bc4afd 100644 (file)
 #if !defined (TERMINAL_H)
 #define TERMINAL_H 1
 
-
-/* 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
-
 struct inferior;
 
 extern void new_tty_prefork (const char *);