From patchwork Wed Apr 12 01:16:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergio Durigan Junior X-Patchwork-Id: 19983 Received: (qmail 25930 invoked by alias); 12 Apr 2017 01:17:06 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 25893 invoked by uid 89); 12 Apr 2017 01:17:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 12 Apr 2017 01:17:02 +0000 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 789C261D1C for ; Wed, 12 Apr 2017 01:17:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 789C261D1C Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=sergiodj@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 789C261D1C Received: from psique.yyz.redhat.com (unused-10-15-17-193.yyz.redhat.com [10.15.17.193]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1012977C99; Wed, 12 Apr 2017 01:16:59 +0000 (UTC) From: Sergio Durigan Junior To: GDB Patches Cc: Pedro Alves , Sergio Durigan Junior Subject: [PATCH] Create gdb_termios.h (and cleanup gdb/{, gdbserver/}terminal.h) Date: Tue, 11 Apr 2017 21:16:49 -0400 Message-Id: <20170412011649.20597-1-sergiodj@redhat.com> In-Reply-To: <8737de3216.fsf@redhat.com> References: <8737de3216.fsf@redhat.com> X-IsSubscribed: yes 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: yyyy-mm-dd Sergio Durigan Junior * 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: yyyy-mm-dd Sergio Durigan Junior * remote-utils.c: Include "gdb_termios.h" instead of "terminal.h". * terminal.h: Delete file. --- gdb/Makefile.in | 1 + gdb/common/common.m4 | 3 +- gdb/common/gdb_termios.h | 78 ++++++++++++++++++++++++++++++++++++++++++++ gdb/gdbserver/remote-utils.c | 2 +- gdb/gdbserver/terminal.h | 51 ----------------------------- gdb/inflow.c | 1 + gdb/inflow.h | 2 +- gdb/ser-unix.c | 1 + gdb/terminal.h | 57 -------------------------------- 9 files changed, 85 insertions(+), 111 deletions(-) create mode 100644 gdb/common/gdb_termios.h delete mode 100644 gdb/gdbserver/terminal.h diff --git a/gdb/Makefile.in b/gdb/Makefile.in index 23e4bed..847deb0 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -1496,6 +1496,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 \ diff --git a/gdb/common/common.m4 b/gdb/common/common.m4 index e21e6e5..45726ab 100644 --- a/gdb/common/common.m4 +++ b/gdb/common/common.m4 @@ -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 index 0000000..1d0544d --- /dev/null +++ b/gdb/common/gdb_termios.h @@ -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 . */ + +#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 +#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 + +#undef TIOCGETP +#define TIOCGETP TCGETA +#undef TIOCSETN +#define TIOCSETN TCSETA +#undef TIOCSETP +#define TIOCSETP TCSETAF +#define TERMINAL struct termio + +#else /* sgtty */ + +#include +#include +#include +#define TERMINAL struct sgttyb + +#endif /* sgtty */ +#endif + +#endif /* ! GDB_TERMIOS_H */ diff --git a/gdb/gdbserver/remote-utils.c b/gdb/gdbserver/remote-utils.c index 37a6402..25b7e41 100644 --- a/gdb/gdbserver/remote-utils.c +++ b/gdb/gdbserver/remote-utils.c @@ -17,7 +17,7 @@ along with this program. If not, see . */ #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 index 3bdd5f5..0000000 --- a/gdb/gdbserver/terminal.h +++ /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 . */ - -#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 -#else /* ! HAVE_TERMIOS_H */ -#if defined(HAVE_TERMIO_H) -#define HAVE_TERMIO -#include - -#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 -#include -#include -#define TERMINAL struct sgttyb -#endif -#endif -#endif - -#endif /* !defined (TERMINAL_H) */ diff --git a/gdb/inflow.c b/gdb/inflow.c index 7ffa83a..23dcc4d 100644 --- a/gdb/inflow.c +++ b/gdb/inflow.c @@ -31,6 +31,7 @@ #include "inflow.h" #include "gdbcmd.h" +#include "gdb_termios.h" #ifdef HAVE_SYS_IOCTL_H #include diff --git a/gdb/inflow.h b/gdb/inflow.h index 90ac4d6..428aed4 100644 --- a/gdb/inflow.h +++ b/gdb/inflow.h @@ -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 diff --git a/gdb/ser-unix.c b/gdb/ser-unix.c index 5c93891..54b0b75 100644 --- a/gdb/ser-unix.c +++ b/gdb/ser-unix.c @@ -31,6 +31,7 @@ #include "gdb_select.h" #include "gdbcmd.h" #include "filestuff.h" +#include "gdb_termios.h" #ifdef HAVE_TERMIOS diff --git a/gdb/terminal.h b/gdb/terminal.h index d8691b2..fb20ae0 100644 --- a/gdb/terminal.h +++ b/gdb/terminal.h @@ -19,63 +19,6 @@ #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 -#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 - -#undef TIOCGETP -#define TIOCGETP TCGETA -#undef TIOCSETN -#define TIOCSETN TCSETA -#undef TIOCSETP -#define TIOCSETP TCSETAF -#define TERMINAL struct termio - -#else /* sgtty */ - -#include -#include -#include -#define TERMINAL struct sgttyb - -#endif /* sgtty */ -#endif - struct inferior; extern void new_tty_prefork (const char *);