* [PATCH] Improve JSON format for group functions.
@ 2019-02-27 13:23 Martin Liška
2019-03-11 11:54 ` Martin Liška
0 siblings, 1 reply; 2+ messages in thread
From: Martin Liška @ 2019-02-27 13:23 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 731 bytes --]
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 <mliska@suse.cz>
* 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(-)
[-- Attachment #2: 0001-Improve-JSON-format-for-group-functions.patch --]
[-- Type: text/x-patch, Size: 2349 bytes --]
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);
}
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Improve JSON format for group functions.
2019-02-27 13:23 [PATCH] Improve JSON format for group functions Martin Liška
@ 2019-03-11 11:54 ` Martin Liška
0 siblings, 0 replies; 2+ messages in thread
From: Martin Liška @ 2019-03-11 11:54 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 894 bytes --]
On 2/27/19 1:32 PM, Martin Liška wrote:
> 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 <mliska@suse.cz>
>
> * 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(-)
>
>
This is final version of the patch I'm going to install.
Martin
[-- Attachment #2: 0001-Improve-JSON-format-add-function-names-for-lines.patch --]
[-- Type: text/x-patch, Size: 3563 bytes --]
From 90a136a54501ee4f8f4da4c21b44bb1399985688 Mon Sep 17 00:00:00 2001
From: marxin <mliska@suse.cz>
Date: Wed, 27 Feb 2019 09:16:40 +0100
Subject: [PATCH] Improve JSON format: add function names for lines.
gcc/ChangeLog:
2019-03-05 Martin Liska <mliska@suse.cz>
* gcov.c (output_intermediate_json_line): Print function
name of each line.
(output_json_intermediate_file): Add new argument.
* doc/gcov.texi: Document the change.
---
gcc/doc/gcov.texi | 5 +++++
gcc/gcov.c | 20 ++++++++++++++++----
2 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/gcc/doc/gcov.texi b/gcc/doc/gcov.texi
index eaac2f69409..0960e4acb26 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}: a name of a function this @var{line} belongs to
+(for a line with an inlined statements can be not set)
+
Each @var{branch} has the following form:
@smallexample
diff --git a/gcc/gcov.c b/gcc/gcov.c
index 9e27a826ea4..37e787a1823 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.
+ Add FUNCTION_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));
@@ -1141,6 +1145,8 @@ output_json_intermediate_file (json::array *json_files, source_info *src)
json::array *lineso = new json::array ();
root->set ("lines", lineso);
+ function_info *last_non_group_fn = NULL;
+
for (unsigned line_num = 1; line_num <= src->lines.size (); line_num++)
{
vector<function_info *> *fns = src->get_functions_at_location (line_num);
@@ -1150,17 +1156,23 @@ output_json_intermediate_file (json::array *json_files, source_info *src)
for (vector<function_info *>::iterator it2 = fns->begin ();
it2 != fns->end (); it2++)
{
+ if (!(*it2)->is_group)
+ last_non_group_fn = *it2;
+
vector<line_info> &lines = (*it2)->lines;
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,
+ (last_non_group_fn != NULL
+ ? last_non_group_fn->m_name : NULL));
}
}
--
2.21.0
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-03-11 11:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-27 13:23 [PATCH] Improve JSON format for group functions Martin Liška
2019-03-11 11:54 ` Martin Liška
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).