From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 111211 invoked by alias); 27 Feb 2019 12:32:12 -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 111186 invoked by uid 89); 27 Feb 2019 12:32:12 -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=sitting, lineo, Follow 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; Wed, 27 Feb 2019 12:32:10 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 7C27EAFF0 for ; Wed, 27 Feb 2019 12:32:08 +0000 (UTC) From: =?UTF-8?Q?Martin_Li=c5=a1ka?= Subject: [PATCH] Improve JSON format for group functions. To: gcc-patches@gcc.gnu.org Message-ID: Date: Wed, 27 Feb 2019 13:23:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------70293F6D13AF532D75B070AD" X-IsSubscribed: yes X-SW-Source: 2019-02/txt/msg02053.txt.bz2 This is a multi-part message in MIME format. --------------70293F6D13AF532D75B070AD Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-length: 731 Hi. The patch adds missing information into JSON intermediate format. Before the patch one can't assign 'lines' to 'functions' in case one has a group function (e.g. a template function). Patch can bootstrap on x86_64-linux-gnu and survives regression tests. I will install it if not objections. Thanks, Martin gcc/ChangeLog: 2019-02-27 Martin Liska * gcov.c (output_intermediate_json_line): When a line belongs to a group of functions, print function name for each of such line entry. (output_json_intermediate_file): Add new argument. * doc/gcov.texi: Document the change. --- gcc/doc/gcov.texi | 5 +++++ gcc/gcov.c | 14 ++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) --------------70293F6D13AF532D75B070AD Content-Type: text/x-patch; name="0001-Improve-JSON-format-for-group-functions.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-Improve-JSON-format-for-group-functions.patch" Content-length: 2349 diff --git a/gcc/doc/gcov.texi b/gcc/doc/gcov.texi index a128f5f4f83..bbb1941246b 100644 --- a/gcc/doc/gcov.texi +++ b/gcc/doc/gcov.texi @@ -276,6 +276,7 @@ Each @var{line} has the following form: "count": @var{count}, "line_number": @var{line_number}, "unexecuted_block": @var{unexecuted_block} + "function_name": @var{function_name}, @} @end smallexample @@ -294,6 +295,10 @@ Fields of the @var{line} element have following semantics: (not all statements on the line are executed) @end itemize +@item +@var{function_name}: when a @var{line} contains multiple functions, each +such @var{line} entry contains name of the function + Each @var{branch} has the following form: @smallexample diff --git a/gcc/gcov.c b/gcc/gcov.c index 9e27a826ea4..9c372356eb5 100644 --- a/gcc/gcov.c +++ b/gcc/gcov.c @@ -1041,17 +1041,21 @@ process_args (int argc, char **argv) return optind; } -/* Output intermediate LINE sitting on LINE_NUM to JSON OBJECT. */ +/* Output intermediate LINE sitting on LINE_NUM to JSON OBJECT. + When FUNCTION_NAME is non null, add the name to the LINE. */ static void output_intermediate_json_line (json::array *object, - line_info *line, unsigned line_num) + line_info *line, unsigned line_num, + const char *function_name) { if (!line->exists) return; json::object *lineo = new json::object (); lineo->set ("line_number", new json::number (line_num)); + if (function_name != NULL) + lineo->set ("function_name", new json::string (function_name)); lineo->set ("count", new json::number (line->count)); lineo->set ("unexecuted_block", new json::literal (line->has_unexecuted_block)); @@ -1154,13 +1158,15 @@ output_json_intermediate_file (json::array *json_files, source_info *src) for (unsigned i = 0; i < lines.size (); i++) { line_info *line = &lines[i]; - output_intermediate_json_line (lineso, line, line_num + i); + output_intermediate_json_line (lineso, line, line_num + i, + (*it2)->m_name); } } /* Follow with lines associated with the source file. */ if (line_num < src->lines.size ()) - output_intermediate_json_line (lineso, &src->lines[line_num], line_num); + output_intermediate_json_line (lineso, &src->lines[line_num], line_num, + NULL); } } --------------70293F6D13AF532D75B070AD--