New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support GCOV intermediate format #282
Comments
Thank you, this looks great! There's nothing wrong with the previous intermediate format, but moving to JSON will make future improvements easier (both for GCC and downstream users like gcovr). I look forward to implementing support for it, because it's much easier to work with than the human-readable output we are currently parsing…. Unfortunately I won't be able to move to your JSON format because old GCC versions and A few concerns/questions/observations: ❓ It is great that you are including a 💡 These JSON files can get quite big, but gcov and any parsers will have to load them into memory entirely. Please consider whether a mixed line-based/JSON format would work, i.e. something like JsonLines.org with one "file" JSON document per line and perhaps a header with metadata. That's technically not true JSON but much more Unixy. Line-based output would be more valuable than compressed output to me. 👍 🙏 No format is self-describing. The source code in your patch makes the format clear, but real documentation would avoid misunderstandings. E.g. the intermediate format shows a vaguely BNF-ish example in the docs. I'd consider writing:
(and so on for function, line, and branch objects). ❓ How will the JSON format ensure forward compatibility, i.e. deal with future changes? There tend to be three choices:
E.g. would it make sense to version the JSON format separately (preferably using a SemVer-compatible number), or do I have to extract the GCC version from the version-key to find out which format variant I'm dealing with? (Assuming a future with GCC 12 😄.) Some forward compatibility story would be great, particularly because you are deprecating the existing machine-readable format. ❓ GCC 8 introduced additional information about line coverage per template specialization in the human-readable output. Will this information be available in the JSON output? Gcovr does not currently make use of that info, but if it's more easily available that might change. |
Thanks for very useful feedback!
I understand that, but hopefully in the future it will be main format used for GCC.
current_working_directory is taken from .gcno file and file names as well. That should be enough to locate source files.
Well you will have one JSON per object file. Even if you have very many object files, then it's expected that one can load into memory JSON for one of them. Then you can release it.
Yes.
Got it, I was bit lazy to do that but I will document it properly.
Agree that semantic version is much better that version of compiler (that can be added too but with a different key name).
Yes. One another new feature are unexecuted blocks:
Martin |
I addressed the requests in version 2 of the patch: |
Note that the format change has landed into GCC's trunk and will be part of next release (9.1). |
Thanks for the new JSON format, but why use same "-i" option? should you keep "-i" same means to output intermediate format and use new option to output JSON format like "--json" ? breaking the backward compatible is not a good news for exists apps |
@xiaoliangwu I don't get your problem. The JSON from gcc has nothing to do with the JSON from gcovr. |
OK, maybe I file on wrong place |
I'm all for it! I think the format seems quite stable. |
How does this issue relate to #326? I was looking into #282 (i.e. this issue) because I have a software simulator which generates the gcov intermediate JSON directly. As such, I was interested in implemented support for using the gcov JSON intermediate file as in input format in gcovr. However, it seems to be me that this was already done in #326. With #326, it seems to be possible to generate gcovr HTML files etc. from a JSON intermediate input file using |
@nmeum the JSON format from #326 is a internal format of gcovr and not gcov. This format can be written by several calls and then merged together to get an overall report. |
I am aware of that.
Yes, I would like to add support for the standard gcov format.
For now I would simply suggesting using the standard gcov JSON format as an additional input format. |
That would be fine. I wanted to clarify that changing the options of the gcov call. |
It seems that they do not belong to the same source file or same run. in the JSON file I see data until line 37 and in the TXT file are 47 lines. In the TXT file the blocks for each line start with |
All right, so there's a part of both for normal mode, I'm planning to remove indices for blocks and calls as the numbering is stupid, and for blocks I'm using IDs (similar to JSON output). What do you think about it now? |
Using IDs for the flocks in the legacy format is OK for me but I strongly advice to not remove the indices since other tools like ourselves rely on the presence of them. Even |
Ok, understood. So I'm going to commit a change for GCC 14.1 that will only replace block "index" with block ID in legacy format. |
One can test it using the
|
@marxin Currently I'm adding gcc-12 and gcc-13 to the test matrix because of the proper exit codes when files can't be written (see #775 ). |
Yes, you can easily do that by looking at |
But I need this info before creating a JSON output. We only have the help output of gcov to detect this. |
You are right, so do you prefer a JSON Note one can workaround it right now:
|
This or document it in the help of |
Good, I've just pushed a change to |
Output example:
|
@marxin Will this change be backported to gcc 13? |
No. |
Ok, then I need to wait for the official release to test this in a docker container. |
@marxin Do you know when gcc-14 will be released? In this opens use still format version 1 is generated. |
At the end of April I guess. |
@Spacetown if you want to test with gcc 14, you can use these snapshots from trunk for the time being. |
@Pesa Thanks for this. I'll give it a try. |
@Pesa I get the following error:
|
The package is built for amd64, are you using an arm machine? If so, the error is expected. Personally, I've used the |
I'm working on a Mac with M1 chip. |
@marxin I continue work on reading the JSON format. Meanwhile gcovr also added the function coverage data from the gcov text report ( {
'name': '_Z3fooi',
'demangled_name': 'foo(int)',
'start_line': 3,
'start_column': 5,
'end_line': 13,
'end_column': 1,
'blocks': 4,
'blocks_executed': 3,
'execution_count': 1
} |
Please file a bug report to the official GCC bugzilla: https://gcc.gnu.org/bugzilla/. |
The branches are listed under the line in the JSON but the relationship to which block in the line the branch belongs to is missing. |
For GCC 9.1 I'm planning to come up with JSON format of the intermediate representation.
It's feasible for consumers of the information like lcov and gcovr
Feel free to comment my patch request:
https://gcc.gnu.org/ml/gcc-patches/2018-09/msg01628.html
Example output:
https://users.suse.com/~mliska/tmp/tramp.json
The text was updated successfully, but these errors were encountered: