From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9058 invoked by alias); 24 Apr 2013 18:23:59 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 9045 invoked by uid 89); 24 Apr 2013 18:23:59 -0000 X-Spam-SWARE-Status: No, score=-7.2 required=5.0 tests=AWL,BAYES_00,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.1 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Wed, 24 Apr 2013 18:23:57 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r3OINu4i024763 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 24 Apr 2013 14:23:56 -0400 Received: from barimba (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r3OHUEeo025597 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Wed, 24 Apr 2013 13:30:15 -0400 From: Tom Tromey To: gdb-patches@sourceware.org Subject: RFC: introduce common.m4 Date: Wed, 24 Apr 2013 20:51:00 -0000 Message-ID: <871u9zomzd.fsf@fleche.redhat.com> MIME-Version: 1.0 Content-Type: text/plain X-SW-Source: 2013-04/txt/msg00752.txt.bz2 It has bothered me for a while that files in common/ use macros defined via autoconf checks, but rely on each configure.ac doing the proper checks independently. This patch introduces common/common.m4 which consolidates the checks assumed by code in common. The rule I propose is that if something is needed or used by common, it should be checked for by common.m4; but that code outside this directory also be free to use these results. This means that removing checks from common.m4 must first be preceded by looking at uses in gdb and gdbserver. I think this is pretty easy to do -- easier than what we are doing now -- and I have documented the requirement. This process revealed a few things not checked for in gdbserver (nothing too crucial I think) and also that the decl check for getopt was dead. I wrote GDB_AC_COMMON by looking for HAVE_ symbols in common/*.[ch]. I did not look for library dependencies, so it is possible that something is missing. I think it is worthwhile to have this in place now, even if it is not perfect, because it gives us a place to make future improvements. Built and regtested on x86-64 Fedora 18 (though this is hardly the most strenuous case) and using the Fedora 18 mingw cross compilers. I also examined the config.in diffs to ensure that symbols did not go missing. Tom gdb: * acinclude.m4: Include common.m4. * common/common.m4: New file. * configure, config.in: Rebuild. * configure: Move some checks to common.m4. Use GDB_AC_COMMON. gdbserver: * acinclude.m4: Include common.m4, codeset.m4. * configure, config.in: Rebuild. * configure: Move some checks to common.m4. Use GDB_AC_COMMON. --- gdb/acinclude.m4 | 2 + gdb/common/common.m4 | 37 +++ gdb/config.in | 4 - gdb/configure | 591 ++++++++++++++++++++++++++++++++++++++++----- gdb/configure.ac | 23 +- gdb/gdbserver/acinclude.m4 | 2 + gdb/gdbserver/config.in | 18 ++ gdb/gdbserver/configure | 574 +++++++++++++++++++++++++++++++++++++++++-- gdb/gdbserver/configure.ac | 16 +- 9 files changed, 1166 insertions(+), 101 deletions(-) create mode 100644 gdb/common/common.m4 diff --git a/gdb/acinclude.m4 b/gdb/acinclude.m4 index 25caddd..21d1013 100644 --- a/gdb/acinclude.m4 +++ b/gdb/acinclude.m4 @@ -49,6 +49,8 @@ sinclude([../config/codeset.m4]) sinclude([../config/zlib.m4]) +m4_include([common/common.m4]) + ## ----------------------------------------- ## ## ANSIfy the C compiler whenever possible. ## ## From Franc,ois Pinard ## diff --git a/gdb/common/common.m4 b/gdb/common/common.m4 new file mode 100644 index 0000000..facaaa8 --- /dev/null +++ b/gdb/common/common.m4 @@ -0,0 +1,37 @@ +dnl Autoconf configure snippets for common. +dnl Copyright (C) 1995-2013 Free Software Foundation, Inc. +dnl +dnl This file is part of GDB. +dnl +dnl This program is free software; you can redistribute it and/or modify +dnl it under the terms of the GNU General Public License as published by +dnl the Free Software Foundation; either version 3 of the License, or +dnl (at your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with this program. If not, see . + +dnl Invoke configury needed by the files in 'common'. +dnl Note that if something is not needed here, you must +dnl first check whether it is also needed by gdb or gdbserver. +dnl They are free to reuse results from tests performed here. +AC_DEFUN([GDB_AC_COMMON], [ + AC_HEADER_STDC + AC_HEADER_DIRENT + AC_FUNC_ALLOCA + + AM_LANGINFO_CODESET + + AC_CHECK_HEADERS(linux/perf_event.h locale.h memory.h signal.h dnl + string.h strings.h sys/resource.h sys/un.h sys/wait.h dnl + thread_db.h wait.h) + + AC_CHECK_FUNCS([fdwalk getrlimit pipe pipe2 socketpair]) + + AC_CHECK_DECLS([strerror, strstr]) +]) diff --git a/gdb/configure.ac b/gdb/configure.ac index bb7fbdd..3873e4b 100644 --- a/gdb/configure.ac +++ b/gdb/configure.ac @@ -1083,14 +1083,12 @@ AC_HEADER_DIRENT AC_HEADER_STDC # elf_hp.h is for HP/UX 64-bit shared library support. AC_CHECK_HEADERS([nlist.h machine/reg.h poll.h sys/poll.h proc_service.h \ - thread_db.h signal.h stddef.h \ - stdlib.h string.h memory.h strings.h sys/fault.h \ + stddef.h stdlib.h sys/fault.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/procfs.h sys/ptrace.h ptrace.h \ sys/reg.h sys/debugreg.h sys/select.h sys/syscall.h \ - sys/types.h sys/wait.h wait.h termios.h termio.h \ - sgtty.h unistd.h elf_hp.h locale.h \ - dlfcn.h sys/un.h linux/perf_event.h]) + sys/types.h termios.h termio.h \ + sgtty.h unistd.h elf_hp.h dlfcn.h]) AC_CHECK_HEADERS(link.h, [], [], [#if HAVE_SYS_TYPES_H # include @@ -1132,8 +1130,7 @@ AC_CHECK_HEADERS(term.h, [], [], # Checks for declarations. # # ------------------------- # -AC_CHECK_DECLS([free, malloc, realloc, strerror, strstr, getopt, - snprintf, vsnprintf]) +AC_CHECK_DECLS([free, malloc, realloc, snprintf, vsnprintf]) AM_LC_MESSAGES # ----------------------- # @@ -1168,13 +1165,13 @@ AC_FUNC_ALLOCA AC_FUNC_MMAP AC_FUNC_VFORK AC_CHECK_FUNCS([canonicalize_file_name realpath getrusage getuid getgid \ - pipe poll pread pread64 pwrite readlink resize_term \ + poll pread pread64 pwrite readlink resize_term \ sbrk setpgid setpgrp setsid \ - sigaction sigprocmask sigsetmask socketpair syscall \ + sigaction sigprocmask sigsetmask syscall \ ttrace wborder wresize setlocale iconvlist libiconvlist btowc \ - setrlimit getrlimit posix_madvise waitpid lstat \ - fdwalk pipe2]) -AM_LANGINFO_CODESET + setrlimit posix_madvise waitpid lstat]) + +GDB_AC_COMMON # Check the return and argument types of ptrace. No canned test for # this, so roll our own. diff --git a/gdb/gdbserver/acinclude.m4 b/gdb/gdbserver/acinclude.m4 index 0e0bdc8..6d7b0e2 100644 --- a/gdb/gdbserver/acinclude.m4 +++ b/gdb/gdbserver/acinclude.m4 @@ -9,8 +9,10 @@ sinclude(../../config/override.m4) dnl For ACX_PKGVERSION and ACX_BUGURL. sinclude(../../config/acx.m4) +m4_include(../../config/codeset.m4) m4_include(../../config/depstand.m4) m4_include(../../config/lead-dot.m4) +m4_include(../common/common.m4) dnl Check for existence of a type $1 in libthread_db.h dnl Based on BFD_HAVE_SYS_PROCFS_TYPE in bfd/bfd.m4. diff --git a/gdb/gdbserver/configure.ac b/gdb/gdbserver/configure.ac index b9928d7..0b479f3 100644 --- a/gdb/gdbserver/configure.ac +++ b/gdb/gdbserver/configure.ac @@ -63,16 +63,16 @@ AC_PROG_MAKE_SET # build it in the same directory, when building in the source dir. ACX_CONFIGURE_DIR(["../gnulib"], ["build-gnulib-gdbserver"]) -AC_CHECK_HEADERS(sgtty.h termio.h termios.h sys/reg.h string.h dnl - proc_service.h sys/procfs.h thread_db.h linux/elf.h dnl - stdlib.h unistd.h dnl - errno.h fcntl.h signal.h sys/file.h malloc.h dnl +AC_CHECK_HEADERS(sgtty.h termio.h termios.h sys/reg.h dnl + proc_service.h sys/procfs.h linux/elf.h dnl + stdlib.h unistd.h errno.h fcntl.h sys/file.h malloc.h dnl sys/ioctl.h netinet/in.h sys/socket.h netdb.h dnl - netinet/tcp.h arpa/inet.h sys/wait.h wait.h sys/un.h dnl - linux/perf_event.h) -AC_CHECK_FUNCS(pread pwrite pread64 readlink fdwalk pipe2) + netinet/tcp.h arpa/inet.h) +AC_CHECK_FUNCS(pread pwrite pread64 readlink) AC_REPLACE_FUNCS(vasprintf vsnprintf) +GDB_AC_COMMON + # Check for UST ustlibs="" ustinc="" @@ -188,7 +188,7 @@ AC_TRY_LINK([ [AC_MSG_RESULT(no)]) fi -AC_CHECK_DECLS([strerror, strstr, perror, vasprintf, vsnprintf]) +AC_CHECK_DECLS([perror, vasprintf, vsnprintf]) AC_CHECK_TYPES(socklen_t, [], [], [#include -- 1.8.1.4