From patchwork Wed Aug 20 04:02:45 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 2445 Received: (qmail 2945 invoked by alias); 20 Aug 2014 04:06:47 -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 2924 invoked by uid 89); 20 Aug 2014 04:06:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.3 required=5.0 tests=AWL, BAYES_00, URIBL_BLACK autolearn=no version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 20 Aug 2014 04:06:42 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1XJxAU-0007Qy-MM from Yao_Qi@mentor.com ; Tue, 19 Aug 2014 21:06:38 -0700 Received: from SVR-ORW-FEM-06.mgc.mentorg.com ([147.34.97.120]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Tue, 19 Aug 2014 21:06:38 -0700 Received: from qiyao.dyndns.org (147.34.91.1) by SVR-ORW-FEM-06.mgc.mentorg.com (147.34.97.120) with Microsoft SMTP Server id 14.2.247.3; Tue, 19 Aug 2014 21:06:37 -0700 Message-ID: <53F41DE5.1010406@codesourcery.com> Date: Wed, 20 Aug 2014 12:02:45 +0800 From: Yao Qi User-Agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.7.0 MIME-Version: 1.0 To: Jan Kratochvil CC: "gdb-patches@sourceware.org" Subject: Re: --with-babeltrace generates many FAILs References: <20140816204614.GA7000@host2.jankratochvil.net> <53F3457E.5030205@codesourcery.com> <20140819140755.GA30208@host2.jankratochvil.net> In-Reply-To: <20140819140755.GA30208@host2.jankratochvil.net> X-IsSubscribed: yes On 08/19/2014 10:07 PM, Jan Kratochvil wrote: > * '#if HAVE_LIBBABELTRACE1_1_0' could have a comment that >=1.1.1 rejects the > faked packet (what you described in the mail but not in the patch). Fixed. To be precise, >= 1.1.2 rejects the faked packet, 1.1.1 doesn't. See the table I posted. > * It is always better to check for feature/defect than to check for version. > For example because various distros backport various fixes (unfortunately > including their possible regressions/defects) and so version checks may be > misleading then. At least in this case it seems to me as possible to check > how libbacktrace behaves from configure; although maybe it is not easy > enough, not sure. In order to check libbabeltrace's behaviour in configure, we have to write a c program to generate CTF data and read the trace data via babeltrace or any program (using libbabeltrace) written by ourselves. It is not easy to do so. The patch is updated. OK to apply? diff --git a/gdb/config.in b/gdb/config.in index b853412..54152cd 100644 --- a/gdb/config.in +++ b/gdb/config.in @@ -183,6 +183,9 @@ /* Define if you have the babeltrace library. */ #undef HAVE_LIBBABELTRACE +/* Define to 1 if you have libbabeltrace 1.1.0 */ +#undef HAVE_LIBBABELTRACE1_1_0 + /* Define to 1 if you have the `dl' library (-ldl). */ #undef HAVE_LIBDL diff --git a/gdb/configure b/gdb/configure index 9253e28..d4e2c6e 100755 --- a/gdb/configure +++ b/gdb/configure @@ -14817,6 +14817,11 @@ $as_echo "$with_babeltrace" >&6; } if test "x$with_babeltrace" = "xno"; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: babletrace support disabled; GDB is unable to read CTF data." >&5 $as_echo "$as_me: WARNING: babletrace support disabled; GDB is unable to read CTF data." >&2;} +elif test "${pkg_config_prog_path}" = "missing"; then + # pkg-config is used to check the version of libbabeltrace. If pkg-config + # is missing, we have to disable babeltrace support. + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: pkg-config not found, babletrace support disabled" >&5 +$as_echo "$as_me: WARNING: pkg-config not found, babletrace support disabled" >&2;} else # Append -Werror to CFLAGS so that configure can catch the warning # "assignment from incompatible pointer type", which is related to @@ -15307,6 +15312,26 @@ $as_echo "$LIBBABELTRACE" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: babeltrace is missing or unusable; GDB is unable to read CTF data." >&5 $as_echo "$as_me: WARNING: babeltrace is missing or unusable; GDB is unable to read CTF data." >&2;} fi + else + # Need to know whether libbabeltrace is 1.1.0. + pkg_config_path= + for x in $LTLIBBABELTRACE; do + case "$x" in + -L*) + dir=`echo "X$x" | sed -e 's/^X-L//'` + if test -d "$dir/pkgconfig"; then + pkg_config_path="${pkg_config_path}${pkg_config_path:+:}$dir/pkgconfig" + fi + ;; + esac + done + + `PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$pkg_config_path ${pkg_config_prog_path} babeltrace = 1.1.0` + if test "$?" -eq 0 ; then + +$as_echo "#define HAVE_LIBBABELTRACE1_1_0 1" >>confdefs.h + + fi fi fi diff --git a/gdb/configure.ac b/gdb/configure.ac index 61919b4..1d8d400 100644 --- a/gdb/configure.ac +++ b/gdb/configure.ac @@ -2420,6 +2420,10 @@ AC_MSG_RESULT([$with_babeltrace]) if test "x$with_babeltrace" = "xno"; then AC_MSG_WARN([babletrace support disabled; GDB is unable to read CTF data.]) +elif test "${pkg_config_prog_path}" = "missing"; then + # pkg-config is used to check the version of libbabeltrace. If pkg-config + # is missing, we have to disable babeltrace support. + AC_MSG_WARN([pkg-config not found, babletrace support disabled]) else # Append -Werror to CFLAGS so that configure can catch the warning # "assignment from incompatible pointer type", which is related to @@ -2450,6 +2454,24 @@ else else AC_MSG_WARN([babeltrace is missing or unusable; GDB is unable to read CTF data.]) fi + else + # Need to know whether libbabeltrace is 1.1.0. + pkg_config_path= + for x in $LTLIBBABELTRACE; do + case "$x" in + -L*) + dir=`echo "X$x" | sed -e 's/^X-L//'` + if test -d "$dir/pkgconfig"; then + pkg_config_path="${pkg_config_path}${pkg_config_path:+:}$dir/pkgconfig" + fi + ;; + esac + done + + `PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$pkg_config_path ${pkg_config_prog_path} babeltrace = 1.1.0` + if test "$?" -eq 0 ; then + AC_DEFINE([HAVE_LIBBABELTRACE1_1_0], [1], [Define to 1 if you have libbabeltrace 1.1.0]) + fi fi fi diff --git a/gdb/ctf.c b/gdb/ctf.c index df645c0..684da50 100644 --- a/gdb/ctf.c +++ b/gdb/ctf.c @@ -623,11 +623,6 @@ ctf_write_definition_end (struct trace_file_writer *self) self->ops->frame_ops->end (self); } -/* The minimal file size of data stream. It is required by - babeltrace. */ - -#define CTF_FILE_MIN_SIZE 4096 - /* This is the implementation of trace_file_write_ops method end. */ @@ -637,10 +632,21 @@ ctf_end (struct trace_file_writer *self) struct ctf_trace_file_writer *writer = (struct ctf_trace_file_writer *) self; gdb_assert (writer->tcs.content_size == 0); - /* The babeltrace requires or assumes that the size of datastream - file is greater than 4096 bytes. If we don't generate enough - packets and events, create a fake packet which has zero event, - to use up the space. */ + +#if HAVE_LIBBABELTRACE1_1_0 + /* The babeltrace-1.1.0 requires or assumes that the size of datastream + file is greater than 4096 bytes. This was fixed after 1.1.0 release. + See https://bugs.lttng.org/issues/450 + If we don't generate enough packets and events, create a fake packet + which has zero event, to use up the space. However, babeltrace + release (since 1.1.2) starts to complain about such faked packet, + we include this workaround only for babeltrace 1.1.0. */ + + /* The minimal file size of data stream. It is required by + babeltrace. */ + +#define CTF_FILE_MIN_SIZE 4096 + if (writer->tcs.packet_start < CTF_FILE_MIN_SIZE) { uint32_t u32; @@ -681,6 +687,7 @@ ctf_end (struct trace_file_writer *self) ctf_save_write (&writer->tcs, &b, 1); } } +#endif /* HAVE_LIBBABELTRACE1_1_0 */ } /* This is the implementation of trace_frame_write_ops method