From patchwork Wed Oct 16 19:09:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Alcock X-Patchwork-Id: 35057 Received: (qmail 129441 invoked by alias); 16 Oct 2019 19:10:03 -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 129392 invoked by uid 89); 16 Oct 2019 19:10:02 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.7 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=dist, graphical X-HELO: aserp2120.oracle.com Received: from aserp2120.oracle.com (HELO aserp2120.oracle.com) (141.146.126.78) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 16 Oct 2019 19:10:00 +0000 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x9GIs1ft164833; Wed, 16 Oct 2019 19:09:58 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2019-08-05; bh=chhk+lVfjecfIpAz1Hq/P3VvaTYSZiHEGNtaZW/aWAk=; b=ldEnEow1zAEZe+oI3kjO2+daALdySv7GBzkqXQlYfsCME7lzHaLbGkXET/s/TyfmBlaz hDgSvsggpNvxDPwpahvGBx4AZsarkZkcSdHrPpzA7nOfCvYls91LFqGQo7eLNcU6CTrG c9SB5ZjB4Os7ZavczhA5jG7rkOp4tdcWP952gz/pwUx2q8/qt9l/2j8dHH9m/pAo09Pk zt0u6phId1oWCq030FhND8PlgIHgnTlWqS/iDwpJdCJ9lr6fT7uL6b3uTEIXycsf2neg J86YX6Yv6wJfk4QuHc4KHg+LO4pKKnsy6ttVm1e9Mf+qZ17nTlFayJx+OQEj4lr3CafO uA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 2vk6sqsam0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2019 19:09:58 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x9GIrvOl035523; Wed, 16 Oct 2019 19:09:57 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3020.oracle.com with ESMTP id 2vnxvabvqq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2019 19:09:57 +0000 Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x9GJ9usU014510; Wed, 16 Oct 2019 19:09:57 GMT Received: from loom.srvr.nix (/81.187.191.129) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 16 Oct 2019 19:09:56 +0000 From: Nick Alcock To: binutils@sourceware.org, gdb-patches@sourceware.org Cc: Nick Alcock Subject: [PATCH v3 2/2] Fix --enable-libctf, --disable-static, and tests sans CTF-capable toolchain Date: Wed, 16 Oct 2019 20:09:48 +0100 Message-Id: <20191016190948.450957-2-nick.alcock@oracle.com> In-Reply-To: <20191016190948.450957-1-nick.alcock@oracle.com> References: <20191016190948.450957-1-nick.alcock@oracle.com> MIME-Version: 1.0 This fixes test runs with a non-CTF-capable toolchain, and 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. 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. * Makefile.in (site.exp): Add enable_libctf to site.exp. * aclocal.m4: sinclude ../config/enable.m4. * lib/gdb.exp (skip_ctf_tests): New. * gdb.base/ctf-constvars.exp: Use it. * gdb.base/ctf-cvexpr.exp: Likewise. * gdb.base/ctf-ptype.exp: Likewise. * gdb.base/ctf-whatis.exp: Likewise. * configure: Regenerate. --- gdb/Makefile.in | 8 +++-- gdb/acinclude.m4 | 3 ++ gdb/config.in | 3 ++ gdb/configure | 37 ++++++++++++++++++++++++ gdb/configure.ac | 18 ++++++++++++ gdb/ctfread.c | 20 ++++++++++++- 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 | 5 ++++ gdb/testsuite/gdb.base/ctf-cvexpr.exp | 5 ++++ gdb/testsuite/gdb.base/ctf-ptype.exp | 5 ++++ gdb/testsuite/gdb.base/ctf-whatis.exp | 5 ++++ gdb/testsuite/lib/gdb.exp | 17 +++++++++++ 15 files changed, 146 insertions(+), 4 deletions(-) diff --git a/gdb/Makefile.in b/gdb/Makefile.in index af4b14d6e6..db9f99d5ea 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 @@ -591,14 +592,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) -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 @@ -2045,6 +2046,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 6e81aaed3b..991a3983f4 100644 --- a/gdb/acinclude.m4 +++ b/gdb/acinclude.m4 @@ -24,6 +24,9 @@ sinclude(../bfd/bfd.m4) dnl This gets the standard macros. sinclude(../config/acinclude.m4) +dnl This gets GCC_ENABLE. +sinclude(../config/enable.m4) + dnl This gets AC_PLUGINS, needed by ACX_LARGEFILE. sinclude(../config/plugins.m4) diff --git a/gdb/config.in b/gdb/config.in index 26ca02f6a3..5d6737b874 100644 --- a/gdb/config.in +++ b/gdb/config.in @@ -33,6 +33,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 22a5f6051d..353d5569e7 100755 --- a/gdb/configure +++ b/gdb/configure @@ -627,6 +627,9 @@ GCORE_TRANSFORM_NAME GDB_TRANSFORM_NAME XSLTPROC GDB_NM_FILE +CTF_DEPS +LIBCTF +ENABLE_LIBCTF LTLIBBABELTRACE LIBBABELTRACE HAVE_LIBBABELTRACE @@ -897,6 +900,7 @@ enable_sim enable_gdbserver with_babeltrace with_libbabeltrace_prefix +enable_libctf enable_unit_tests ' ac_precious_vars='build_alias @@ -1564,6 +1568,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 @@ -17556,6 +17561,38 @@ $as_echo "$as_me: WARNING: babeltrace is missing or unusable; GDB is unable to r fi 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. diff --git a/gdb/configure.ac b/gdb/configure.ac index 9da8818fb5..c16bb0dd2f 100644 --- a/gdb/configure.ac +++ b/gdb/configure.ac @@ -2217,6 +2217,24 @@ else fi fi +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. diff --git a/gdb/ctfread.c b/gdb/ctfread.c index 44ccff62ae..2b73d58c68 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/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 d40c3a9fc6..a7320620aa 100644 --- a/gdb/testsuite/aclocal.m4 +++ b/gdb/testsuite/aclocal.m4 @@ -1,5 +1,6 @@ sinclude(../../config/acx.m4) sinclude(../../config/override.m4) +sinclude(../../config/enable.m4) sinclude(../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 4a81a94ddb..08dd12ceb5 100644 --- a/gdb/testsuite/gdb.base/ctf-constvars.exp +++ b/gdb/testsuite/gdb.base/ctf-constvars.exp @@ -32,6 +32,11 @@ standard_testfile .c set opts "additional_flags=-gt" +if {[skip_ctf_tests]} { + unsupported "No compiler CTF support, or CTF disabled in GDB" + return +} + if { [prepare_for_testing "failed to prepare" ${testfile} \ [list $srcfile] [list $opts nowarnings]] } { return 0 diff --git a/gdb/testsuite/gdb.base/ctf-cvexpr.exp b/gdb/testsuite/gdb.base/ctf-cvexpr.exp index 67ceb21f52..ab72980ebe 100644 --- a/gdb/testsuite/gdb.base/ctf-cvexpr.exp +++ b/gdb/testsuite/gdb.base/ctf-cvexpr.exp @@ -27,6 +27,11 @@ standard_testfile cvexpr.c set opts "additional_flags=-gt" +if {[skip_ctf_tests]} { + unsupported "No compiler CTF support, or CTF disabled in GDB" + return +} + if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { untested "failed to compile" return -1 diff --git a/gdb/testsuite/gdb.base/ctf-ptype.exp b/gdb/testsuite/gdb.base/ctf-ptype.exp index 9f54582422..c3861032e8 100644 --- a/gdb/testsuite/gdb.base/ctf-ptype.exp +++ b/gdb/testsuite/gdb.base/ctf-ptype.exp @@ -23,6 +23,11 @@ standard_testfile .c set opts "additional_flags=-gt" +if {[skip_ctf_tests]} { + unsupported "No compiler CTF support, or CTF disabled in GDB" + return +} + if { [prepare_for_testing "failed to prepare" ${testfile} \ [list $srcfile] [list $opts nowarnings]] } { return 0 diff --git a/gdb/testsuite/gdb.base/ctf-whatis.exp b/gdb/testsuite/gdb.base/ctf-whatis.exp index 3f26fc326e..f30e0d9793 100644 --- a/gdb/testsuite/gdb.base/ctf-whatis.exp +++ b/gdb/testsuite/gdb.base/ctf-whatis.exp @@ -23,6 +23,11 @@ standard_testfile .c set opts "additional_flags=-gt" +if {[skip_ctf_tests]} { + unsupported "No compiler CTF support, or CTF disabled in GDB" + return +} + 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 fed46ec83c..00d4e077b5 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -2017,6 +2017,23 @@ proc skip_tui_tests {} { return 0 } +# Return 1 if we should skip CTF-related tests. + +gdb_caching_proc skip_ctf_tests { + set me "skip_ctf_tests" + set src { int main () {return 0;} } + set compile_flags "additional_flags=-gt" + global enable_libctf + + if {$enable_libctf eq "no"} { + return 1 + } + if {![gdb_simple_compile $me $src executable $compile_flags]} { + return 1 + } + return 0 +} + # Test files shall make sure all the test result lines in gdb.sum are # unique in a test run, so that comparing the gdb.sum files of two # test runs gives correct results. Test files that exercise