Skip to content
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

[llvm-cov] Keep the detailed error message in CoverageMappingIterator #80415

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

whentojump
Copy link
Member

Currently errors returned from CoverageMappingIterator will have their message part discarded. This commit copies that message when constructing the new CoverageMapError object, and let it displayed at the end caller (llvm-cov).

Related: #65264

Currently errors returned from CoverageMappingIterator will have their
message part discarded. This commit copies that message when
constructing the new CoverageMapError object, and let it displayed at
the end caller (llvm-cov).

Related: llvm#65264
Copy link

github-actions bot commented Feb 2, 2024

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be
notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write
permissions for the repository. In which case you can instead tag reviewers by
name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review
by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate
is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@whentojump
Copy link
Member Author

whentojump commented Feb 2, 2024

From discussions in #65264:

It seems that most message are untested?

I can add more tests for this end if that's desirable. An example would look like

#!/bin/bash

rm main *.profraw *.profdata

cat << EOF > main.c
int main(void) {
  if (1)
    return 0;
}
EOF

clang -fprofile-instr-generate -fcoverage-mapping main.c -o main
llvm-cov convert-for-testing main -o main.covmapping

# Manually corrupt the region kind
cat main.covmapping | bbe -e 's|\x20|\x48|' > main_malformed.covmapping

LLVM_PROFILE_FILE="main.profraw" ./main
llvm-profdata merge main.profraw -o main.profdata
llvm-cov show main_malformed.covmapping -instr-profile main.profdata

The result should ideally be

error: failed to load coverage: 'main_malformed.covmapping': malformed coverage data: region kind is incorrect

rather than

error: failed to load coverage: 'main_malformed.covmapping': malformed coverage data

The malformed covmapping file is generated by manipulating good ones with bbe. If this way is acceptable, I am happy to rewrite such scripts in Clang/LLVM style test suites.

@whentojump whentojump closed this Mar 6, 2024
@whentojump whentojump deleted the coverage-map-error-message branch March 6, 2024 02:59
@whentojump whentojump restored the coverage-map-error-message branch March 6, 2024 03:02
@whentojump
Copy link
Member Author

Mistakenly pressed some buttons, sorry for the mess...

@MaskRay Could you please take a look? Thanks!

@whentojump whentojump reopened this Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant