From patchwork Mon Dec 16 22:52:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Alcock X-Patchwork-Id: 36899 Received: (qmail 61894 invoked by alias); 16 Dec 2019 22:53:01 -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 61871 invoked by uid 89); 16 Dec 2019 22:53:00 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 spammy=intl, INTL X-HELO: userp2120.oracle.com Received: from userp2120.oracle.com (HELO userp2120.oracle.com) (156.151.31.85) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 16 Dec 2019 22:52:58 +0000 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id xBGMnj14096374 for ; Mon, 16 Dec 2019 22:52:56 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding; s=corp-2019-08-05; bh=QWWhG+wtYBzLpFgRg8cAxdqA4/jHbhUiXvoZt9OE27Q=; b=PiQBUWDAy++abNNg+GAA+Wl1KNR1RSIx+cpclT5aJogD8OeJER3hqkOjSao5snswgy/H vShfmNjrVuCsZZBk1f4IiHQcgTc3/fSpgCjuVgSCgK78bSAJGY+Z0I1MStjeOjvRYv7a NTrXVP8Bh+Woe701CYixR5rmF9tNVK4ZSNXcBw1tww49w98tClGua8eKBvJxuRBEOV3i BPn4VQcbNiex5dXFYiafnkSOW0DR44ihNoOU8q6Cl2vwW1iy66ML+IAbr35lsP8F2Dbi iVAQzI+CPs1TOw5DQFd0tNiw5+BXaebqsvRknfgdR2Yo3I0Hz0XXNOJ0gyaPK26VXSQr 2A== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 2wvrcr2mqb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 16 Dec 2019 22:52:55 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id xBGMmMtO059763 for ; Mon, 16 Dec 2019 22:52:55 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 2ww98trhmm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 16 Dec 2019 22:52:54 +0000 Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id xBGMqsiN011046 for ; Mon, 16 Dec 2019 22:52:54 GMT Received: from loom.srvr.nix (/81.187.191.129) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 16 Dec 2019 14:52:53 -0800 From: Nick Alcock To: gdb-patches@sourceware.org Cc: indu.bhagat@oracle.com, jose.marchesi@oracle.com, nick.alcock@oracle.com Subject: [PATCH] Fix --enable-libctf and --disable-static Date: Mon, 16 Dec 2019 22:52:43 +0000 Message-Id: <20191216225243.87096-1-nick.alcock@oracle.com> MIME-Version: 1.0 This fixes test runs and compilation when --disable-libctf, --disable-static, or --enable-shared are passed. Changes since v2: Use GCC_ENABLE and fix indentation. Fix prototype using 'void'. Use 'unsupported' and gdb_caching_proc. Changes since v3: Adapt to upstream changes providing skip_ctf_tests. gdb/ChangeLog * configure.ac: Add --enable-libctf: handle --disable-static properly. * acinclude.m4: sinclude ../config/enable.m4. * Makefile.in (aclocal_m4_deps): Adjust accordingly. (LIBCTF): Substitute in. (CTF_DEPS): New, likewise. (CLIBS): libctf needs symbols from libbfd: move earlier. (CDEPS): Use CTF_DEPS, not LIBCTF, now LIBCTF can include rpath flags. * ctfread.c: Surround in ENABLE_LIBCTF. _initialize_ctfread [ENABLE_LIBCTF]: Fix declaration to use (). _initialize_ctfread [!ENABLE_LIBCTF]: New stub. elfctf_build_psymtabs [!ENABLE_LIBCTF]: Likewise. * configure: Regenerate. * config.in: Likewise. gdb/testsuite/ChangeLog * configure.ac: Add --enable-libctf. * aclocal.m4: sinclude ../config/enable.m4. * Makefile.in (site.exp): Add enable_libctf to site.exp. * lib/gdb.exp (skip_ctf_tests): Use it. * gdb.base/ctf-constvars.exp: Error message tweak. * gdb.base/ctf-ptype.exp: Likewise. * configure: Regenerate. --- gdb/ChangeLog | 18 +++++++++++ gdb/Makefile.in | 8 +++-- gdb/acinclude.m4 | 3 ++ gdb/config.in | 3 ++ gdb/configure | 40 ++++++++++++++++++++++++ gdb/configure.ac | 21 +++++++++++++ gdb/ctfread.c | 20 +++++++++++- gdb/testsuite/ChangeLog | 10 ++++++ gdb/testsuite/Makefile.in | 2 ++ gdb/testsuite/aclocal.m4 | 1 + gdb/testsuite/configure | 18 +++++++++++ gdb/testsuite/configure.ac | 3 ++ gdb/testsuite/gdb.base/ctf-constvars.exp | 2 +- gdb/testsuite/gdb.base/ctf-ptype.exp | 3 +- gdb/testsuite/lib/gdb.exp | 9 +++++- 15 files changed, 154 insertions(+), 7 deletions(-) This is a respin of a patch Tom Tromey reviewed some months ago, that I then let languish until others had redone and pushed some of it for me. I promise I'll remember to push it this time! diff --git a/gdb/ChangeLog b/gdb/ChangeLog index ecd2124720..2fb5241b3c 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,21 @@ +2019-12-13 Nick Alcock + + * configure.ac: Add --enable-libctf: handle --disable-static + properly. + * acinclude.m4: sinclude ../config/enable.m4. + * Makefile.in (aclocal_m4_deps): Adjust accordingly. + (LIBCTF): Substitute in. + (CTF_DEPS): New, likewise. + (CLIBS): libctf needs symbols from libbfd: move earlier. + (CDEPS): Use CTF_DEPS, not LIBCTF, now LIBCTF can include rpath + flags. + * ctfread.c: Surround in ENABLE_LIBCTF. + _initialize_ctfread [ENABLE_LIBCTF]: Fix declaration to use (). + _initialize_ctfread [!ENABLE_LIBCTF]: New stub. + elfctf_build_psymtabs [!ENABLE_LIBCTF]: Likewise. + * configure: Regenerate. + * config.in: Likewise. + 2019-12-12 Tom Tromey * objfiles.h (struct objfile) : Now a diff --git a/gdb/Makefile.in b/gdb/Makefile.in index fa5c820b91..e8d0705fb4 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -154,7 +154,8 @@ INCLUDE_CFLAGS = -I$(INCLUDE_DIR) LIBIBERTY = ../libiberty/libiberty.a # Where is the CTF library? Typically in ../libctf. -LIBCTF = ../libctf/.libs/libctf.a +LIBCTF = @LIBCTF@ +CTF_DEPS = @CTF_DEPS@ # Where is the BFD library? Typically in ../bfd. BFD_DIR = ../bfd @@ -606,14 +607,14 @@ INTERNAL_LDFLAGS = \ # Libraries and corresponding dependencies for compiling gdb. # XM_CLIBS, defined in *config files, have host-dependent libs. # LIBIBERTY appears twice on purpose. -CLIBS = $(SIM) $(READLINE) $(OPCODES) $(BFD) $(LIBCTF) $(ZLIB) \ +CLIBS = $(SIM) $(READLINE) $(OPCODES) $(LIBCTF) $(BFD) $(ZLIB) \ $(INTL) $(LIBIBERTY) $(LIBDECNUMBER) \ $(XM_CLIBS) $(GDBTKLIBS) \ @LIBS@ @GUILE_LIBS@ @PYTHON_LIBS@ \ $(LIBEXPAT) $(LIBLZMA) $(LIBBABELTRACE) $(LIBIPT) \ $(LIBIBERTY) $(WIN32LIBS) $(LIBGNU) $(LIBICONV) $(LIBMPFR) \ $(SRCHIGH_LIBS) $(LIBXXHASH) $(PTHREAD_LIBS) -CDEPS = $(NAT_CDEPS) $(SIM) $(BFD) $(READLINE_DEPS) $(LIBCTF) \ +CDEPS = $(NAT_CDEPS) $(SIM) $(BFD) $(READLINE_DEPS) $(CTF_DEPS) \ $(OPCODES) $(INTL_DEPS) $(LIBIBERTY) $(CONFIG_DEPS) $(LIBGNU) DIST = gdb @@ -2064,6 +2065,7 @@ aclocal_m4_deps = \ transform.m4 \ ../bfd/bfd.m4 \ ../config/acinclude.m4 \ + ../config/enable.m4 \ ../config/plugins.m4 \ ../config/lead-dot.m4 \ ../config/override.m4 \ diff --git a/gdb/acinclude.m4 b/gdb/acinclude.m4 index 8592b6c875..b65397c909 100644 --- a/gdb/acinclude.m4 +++ b/gdb/acinclude.m4 @@ -24,6 +24,9 @@ m4_include(../bfd/bfd.m4) dnl This gets the standard macros. m4_include(../config/acinclude.m4) +dnl This gets GCC_ENABLE. +sinclude(../config/enable.m4) + dnl This gets AC_PLUGINS, needed by ACX_LARGEFILE. m4_include(../config/plugins.m4) diff --git a/gdb/config.in b/gdb/config.in index cb886ba8e1..46ff7a7932 100644 --- a/gdb/config.in +++ b/gdb/config.in @@ -36,6 +36,9 @@ /* Define to BFD's default target vector. */ #undef DEFAULT_BFD_VEC +/* Handle .ctf type-info sections */ +#undef ENABLE_LIBCTF + /* Define to 1 if translation of program messages to the user's native language is requested. */ #undef ENABLE_NLS diff --git a/gdb/configure b/gdb/configure index 324eb50944..6f0226e4b9 100755 --- a/gdb/configure +++ b/gdb/configure @@ -631,6 +631,9 @@ GDB_NM_FILE LTLIBXXHASH LIBXXHASH HAVE_LIBXXHASH +CTF_DEPS +LIBCTF +ENABLE_LIBCTF LTLIBBABELTRACE LIBBABELTRACE HAVE_LIBBABELTRACE @@ -909,6 +912,7 @@ enable_gdbserver with_babeltrace with_libbabeltrace_prefix with_xxhash +enable_libctf with_libxxhash_prefix enable_unit_tests ' @@ -1577,6 +1581,7 @@ Optional Features: --enable-sim link gdb with simulator --enable-gdbserver automatically build gdbserver (yes/no/auto, default is auto) + --enable-libctf Handle .ctf type-info sections [default=yes] --enable-unit-tests Enable the inclusion of unit tests when compiling GDB @@ -18399,6 +18404,41 @@ else fi + # Check whether --enable-libctf was given. +if test "${enable_libctf+set}" = set; then : + enableval=$enable_libctf; + case "$enableval" in + yes|no) ;; + *) as_fn_error $? "Argument to enable/disable libctf must be yes or no" "$LINENO" 5 ;; + esac + +else + enable_libctf=yes +fi + + +if test x${enable_static} = xno; then + LIBCTF="-Wl,--rpath,../libctf/.libs ../libctf/.libs/libctf.so" + CTF_DEPS="../libctf/.libs/libctf.so" +else + LIBCTF="../libctf/.libs/libctf.a" + CTF_DEPS="$LIBCTF" +fi +if test "${enable_libctf}" = yes; then + +$as_echo "#define ENABLE_LIBCTF 1" >>confdefs.h + +else + LIBCTF= + CTF_DEPS= +fi + + + + +# If nativefile (NAT_FILE) is not set in configure.nat, we link to an +# empty version. + if test "x$with_xxhash" != "xno"; then diff --git a/gdb/configure.ac b/gdb/configure.ac index 6ba7c5cfa4..633dfedfcd 100644 --- a/gdb/configure.ac +++ b/gdb/configure.ac @@ -2173,6 +2173,27 @@ AC_ARG_WITH(xxhash, AC_HELP_STRING([--with-xxhash], [use libxxhash for hashing (faster) (auto/yes/no)]), [], [with_xxhash=auto]) +GCC_ENABLE([libctf], [yes], [], [Handle .ctf type-info sections]) +if test x${enable_static} = xno; then + LIBCTF="-Wl,--rpath,../libctf/.libs ../libctf/.libs/libctf.so" + CTF_DEPS="../libctf/.libs/libctf.so" +else + LIBCTF="../libctf/.libs/libctf.a" + CTF_DEPS="$LIBCTF" +fi +if test "${enable_libctf}" = yes; then + AC_DEFINE(ENABLE_LIBCTF, 1, [Handle .ctf type-info sections]) +else + LIBCTF= + CTF_DEPS= +fi +AC_SUBST(ENABLE_LIBCTF) +AC_SUBST(LIBCTF) +AC_SUBST(CTF_DEPS) + +# If nativefile (NAT_FILE) is not set in configure.nat, we link to an +# empty version. + if test "x$with_xxhash" != "xno"; then AC_LIB_HAVE_LINKFLAGS([xxhash], [], [#include ], diff --git a/gdb/ctfread.c b/gdb/ctfread.c index c5f9130c6a..9d75dcd29a 100644 --- a/gdb/ctfread.c +++ b/gdb/ctfread.c @@ -81,6 +81,9 @@ #include "block.h" #include "ctfread.h" #include "psympriv.h" + +#if ENABLE_LIBCTF + #include "ctf.h" #include "ctf-api.h" @@ -1479,8 +1482,23 @@ elfctf_build_psymtabs (struct objfile *of) } void -_initialize_ctfread (void) +_initialize_ctfread () { ctf_file_key = register_objfile_data_with_cleanup (NULL, ctf_close_objfile); } + +#else + +void +_initialize_ctfread () +{ +} + +void +elfctf_build_psymtabs (struct objfile *of) +{ + /* Nothing to do if CTF is disabled. */ +} + +#endif /* ENABLE_LIBCTF */ diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index b31e8dd611..f8a0086715 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,13 @@ +2019-12-13 Nick Alcock + + * configure.ac: Add --enable-libctf. + * aclocal.m4: sinclude ../config/enable.m4. + * Makefile.in (site.exp): Add enable_libctf to site.exp. + * lib/gdb.exp (skip_ctf_tests): Use it. + * gdb.base/ctf-constvars.exp: Error message tweak. + * gdb.base/ctf-ptype.exp: Likewise. + * configure: Regenerate. + 2019-12-11 Tom Tromey * gdb.tui/resize.exp: Fix regexp. diff --git a/gdb/testsuite/Makefile.in b/gdb/testsuite/Makefile.in index 2beba053ee..42de3d6f22 100644 --- a/gdb/testsuite/Makefile.in +++ b/gdb/testsuite/Makefile.in @@ -28,6 +28,7 @@ program_transform_name = @program_transform_name@ build_canonical = @build@ host_canonical = @host@ target_canonical = @target@ +enable_libctf = @enable_libctf@ SHELL = @SHELL@ EXEEXT = @EXEEXT@ @@ -131,6 +132,7 @@ $(abs_builddir)/site.exp site.exp: ./config.status Makefile @echo "set build_triplet ${build_canonical}" >> ./tmp0 @echo "set srcdir ${abs_srcdir}" >> ./tmp0 @echo "set tool gdb" >> ./tmp0 + @echo "set enable_libctf ${enable_libctf}" >> ./tmp0 @echo 'source $${srcdir}/lib/append_gdb_boards_dir.exp' >> ./tmp0 @echo "## All variables above are generated by configure. Do Not Edit ##" >> ./tmp0 @cat ./tmp0 > site.exp diff --git a/gdb/testsuite/aclocal.m4 b/gdb/testsuite/aclocal.m4 index 5061eef537..c5d3ba527a 100644 --- a/gdb/testsuite/aclocal.m4 +++ b/gdb/testsuite/aclocal.m4 @@ -1,5 +1,6 @@ m4_include(../../config/acx.m4) m4_include(../../config/override.m4) +m4_include(../../config/enable.m4) m4_include(../transform.m4) # AM_CONDITIONAL -*- Autoconf -*- diff --git a/gdb/testsuite/configure b/gdb/testsuite/configure index cc00f8dfa8..0de6074460 100755 --- a/gdb/testsuite/configure +++ b/gdb/testsuite/configure @@ -638,6 +638,7 @@ LDFLAGS CFLAGS CC RPATH_ENVVAR +enable_libctf subdirs target_noncanonical target_os @@ -694,6 +695,7 @@ ac_subst_files='' ac_user_opts=' enable_option_checking enable_gdbtk +enable_libctf enable_shared ' ac_precious_vars='build_alias @@ -1323,6 +1325,7 @@ Optional Features: --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-gtk enable gdbtk graphical user interface (GUI) + --enable-libctf Handle .ctf type-info sections [default=yes] --enable-shared build shared libraries deault=yes Some influential environment variables: @@ -2189,6 +2192,21 @@ subdirs="$subdirs gdb.gdbtk" fi + # Check whether --enable-libctf was given. +if test "${enable_libctf+set}" = set; then : + enableval=$enable_libctf; + case "$enableval" in + yes|no) ;; + *) as_fn_error $? "Argument to enable/disable libctf must be yes or no" "$LINENO" 5 ;; + esac + +else + enable_libctf=yes +fi + + + + # Enable shared libraries. # Check whether --enable-shared was given. if test "${enable_shared+set}" = set; then : diff --git a/gdb/testsuite/configure.ac b/gdb/testsuite/configure.ac index 1c4dc99c47..284e498a67 100644 --- a/gdb/testsuite/configure.ac +++ b/gdb/testsuite/configure.ac @@ -43,6 +43,9 @@ if test $enable_gdbtk = yes; then AC_CONFIG_SUBDIRS(gdb.gdbtk) fi +GCC_ENABLE([libctf], [yes], [], [Handle .ctf type-info sections]) +AC_SUBST(enable_libctf) + # Enable shared libraries. AC_ARG_ENABLE(shared, [ --enable-shared build shared libraries [deault=yes]],, diff --git a/gdb/testsuite/gdb.base/ctf-constvars.exp b/gdb/testsuite/gdb.base/ctf-constvars.exp index fd46d64454..bd291fd7a1 100644 --- a/gdb/testsuite/gdb.base/ctf-constvars.exp +++ b/gdb/testsuite/gdb.base/ctf-constvars.exp @@ -25,7 +25,7 @@ # with mixed types. if [skip_ctf_tests] { - unsupported "no ctf debug format support" + unsupported "no CTF debug format support, or CTF disabled in GDB" return 0 } diff --git a/gdb/testsuite/gdb.base/ctf-ptype.exp b/gdb/testsuite/gdb.base/ctf-ptype.exp index 68a9662c89..022ffcbdfd 100644 --- a/gdb/testsuite/gdb.base/ctf-ptype.exp +++ b/gdb/testsuite/gdb.base/ctf-ptype.exp @@ -16,7 +16,7 @@ # This file is a subset of ptype.exp written by Rob Savoye. (rob@cygnus.com) if [skip_ctf_tests] { - unsupported "no ctf debug format support" + unsupported "no CTF debug format support, or CTF disabled in GDB" return 0 } @@ -24,6 +24,7 @@ standard_testfile .c # Using `-gt` generates full-fledged CTF debug information. set opts "additional_flags=-gt" + if { [prepare_for_testing "failed to prepare" ${testfile} \ [list $srcfile] [list $opts nowarnings]] } { return 0 diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 8b1ec62c9c..4c7e8aa9ca 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -6824,9 +6824,16 @@ proc cmp_file_string { file str msg } { } # Does the compiler support CTF debug output using '-gt' compiler -# flag? If not then we should skip these tests. +# flag? If not then we should skip these tests. We should also +# skip them if libctf was explicitly disabled. gdb_caching_proc skip_ctf_tests { + global enable_libctf + + if {$enable_libctf eq "no"} { + return 1 + } + return ![gdb_can_simple_compile ctfdebug { int main () { return 0;