[llvm-bugs] [Bug 45850] New: llvm-cov: wrong coverage with a function pointer points to the exit() function
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri May 8 12:07:35 PDT 2020
https://bugs.llvm.org/show_bug.cgi?id=45850
Bug ID: 45850
Summary: llvm-cov: wrong coverage with a function pointer
points to the exit() function
Product: Runtime Libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: libprofile library
Assignee: unassignedbugs at nondot.org
Reporter: yangyibiao at hust.edu.cn
CC: llvm-bugs at lists.llvm.org
$ clang --version
clang version 11.0.0 (/home/yibiao/.cache/yay/llvm-git/llvm-project
871beba234a83a2a02da9dedbd59b91a1bfbd7af)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
$ clang -O0 -w -fcoverage-mapping -fprofile-instr-generate=small.profraw
small.c; ./a.out; llvm-profdata merge small.profraw -o small.profdata; llvm-cov
show a.out -instr-profile=small.profdata small.c > small.c.lcov; cat
small.c.lcov
1| |void exit(int);
2| |void (*myexit)(int);
3| |
4| |int main()
5| 1|{
6| 1| int i = 0, j = 0;
7| 1| myexit = exit;
8| 3| for (i=0;i<5;i++) {
9| 2| if (i)
10| 1| myexit(0);
11| 2| j++;
12| 2| }
13| 1|}
***
Line 11 is wrongly marked as executed twice. myexit is a function pointer. When
setting breakpoint for Line 11 in lldb, only hit one time.
When replace Line 10 with exit(0), the coverage will be correct as follow:
1| |void exit(int);
2| |void (*myexit)(int);
3| |
4| |int main()
5| 1|{
6| 1| int i = 0, j = 0;
7| 1| myexit = exit;
8| 2| for (i=0;i<5;i++) {
9| 2| if (i)
10| 1| exit(0); // myexit(0);
11| 1| j++;
12| 1| }
13| 1|}
$ cat small.c
void exit(int);
void (*myexit)(int);
int main()
{
int i = 0, j = 0;
myexit = exit;
for (i=0;i<5;i++) {
if (i)
exit(0); // myexit(0);
j++;
}
}
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200508/857262af/attachment.html>
More information about the llvm-bugs
mailing list