implement test coverage

I have implemented the -ftest-coverage option. It works a bit different
from the gcc version. It output .tcov text file which looks almost the
same as a gcov file after a executable/so file is run.

Add lib/tcov.c file
Modify Makefiles to compile/install it
Add -ftest-coverage option in tcc.c/tcc.h/tcc-doc.texi
Add code to tccelf.c/tccgen.c/tccpe.c
Add gen_increment_tcov to tcc.h/*gen.c

unrelated changes:
Add sigemptyset in tccrun.c
Fix riscv64-gen.c tok_alloc label size
This commit is contained in:
herman ten brugge
2021-01-23 18:17:38 +01:00
parent 66de1550ab
commit bc6c0c34c1
16 changed files with 721 additions and 15 deletions

View File

@@ -1023,6 +1023,19 @@ ST_FUNC void gen_cvt_csti(int t)
);
}
/* increment tcov counter */
ST_FUNC void gen_increment_tcov (SValue *sv)
{
o(0x0583); /* addl $1, xxx */
greloc(cur_text_section, sv->sym, ind, R_386_32);
gen_le32(0);
o(1);
o(0x1583); /* addcl $0, xxx */
greloc(cur_text_section, sv->sym, ind, R_386_32);
gen_le32(4);
g(0);
}
/* computed goto support */
ST_FUNC void ggoto(void)
{