From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26008 invoked by alias); 18 Jan 2019 10:04:07 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 25962 invoked by uid 89); 18 Jan 2019 10:04:06 -0000 Authentication-Results: sourceware.org; auth=none 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,SPF_PASS autolearn=ham version=3.3.2 spammy=PTR X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 18 Jan 2019 10:04:05 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id DB3CCAD33; Fri, 18 Jan 2019 10:04:02 +0000 (UTC) From: =?UTF-8?Q?Martin_Li=c5=a1ka?= Subject: [PATCH] Describe better version mismatch in libgcov driver. To: gcc-patches@gcc.gnu.org Cc: Jan Hubicka Message-ID: <8fca37bb-1498-8b6d-9bde-731419dff0e4@suse.cz> Date: Fri, 18 Jan 2019 10:04:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.3 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------57662BCCBE9B7F6A3DD60B58" X-IsSubscribed: yes X-SW-Source: 2019-01/txt/msg01058.txt.bz2 This is a multi-part message in MIME format. --------------57662BCCBE9B7F6A3DD60B58 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-length: 607 Hi. The patch is about better explanation of version mismatch in libgcov driver. Now we'll print: profiling:/tmp/main.gcda:Version mismatch - expected 9.0 (experimental) (A90e) got 8.2 (release) (A82*) Patch can bootstrap on x86_64-linux-gnu and survives regression tests. It's approved by Honza. Thanks, Martin libgcc/ChangeLog: 2019-01-17 Martin Liska * libgcov-driver.c (gcov_version_string): New function. (gcov_version): Convert version integer into string. --- libgcc/libgcov-driver.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) --------------57662BCCBE9B7F6A3DD60B58 Content-Type: text/x-patch; name="0001-Describe-better-version-mismatch-in-libgcov-driver.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-Describe-better-version-mismatch-in-libgcov-driver.patc"; filename*1="h" Content-length: 1851 diff --git a/libgcc/libgcov-driver.c b/libgcc/libgcov-driver.c index 44f43e6e9af..41d28ace926 100644 --- a/libgcc/libgcov-driver.c +++ b/libgcc/libgcov-driver.c @@ -157,6 +157,27 @@ fail: return (struct gcov_fn_buffer **)free_fn_data (gi_ptr, fn_buffer, ix); } +/* Convert VERSION into a string description and return the it. + BUFFER is used for storage of the string. The code should be + aligned wit gcov-iov.c. */ + +static char * +gcov_version_string (char *buffer, char version[4]) +{ + if (version[0] < 'A' || version[0] > 'Z' + || version[1] < '0' || version[1] > '9' + || version[2] < '0' || version[2] > '9') + sprintf (buffer, "(unknown)"); + else + { + unsigned major = 10 * (version[0] - 'A') + (version[1] - '0'); + unsigned minor = version[2] - '0'; + sprintf (buffer, "%u.%u (%s)", major, minor, + version[3] == '*' ? "release" : "experimental"); + } + return buffer; +} + /* Check if VERSION of the info block PTR matches libgcov one. Return 1 on success, or zero in case of versions mismatch. If FILENAME is not NULL, its value used for reporting purposes @@ -169,12 +190,16 @@ gcov_version (struct gcov_info *ptr, gcov_unsigned_t version, if (version != GCOV_VERSION) { char v[4], e[4]; + char version_string[128], expected_string[128]; GCOV_UNSIGNED2STRING (v, version); GCOV_UNSIGNED2STRING (e, GCOV_VERSION); - gcov_error ("profiling:%s:Version mismatch - expected %.4s got %.4s\n", - filename? filename : ptr->filename, e, v); + gcov_error ("profiling:%s:Version mismatch - expected %s (%.4s) " + "got %s (%.4s)\n", + filename? filename : ptr->filename, + gcov_version_string (expected_string, e), e, + gcov_version_string (version_string, v), v); return 0; } return 1; --------------57662BCCBE9B7F6A3DD60B58--