From: David van Moolenbroek Date: Sat, 24 Sep 2016 15:20:54 +0000 (+0000) Subject: Add LLVM GCOV coverage support X-Git-Url: http://zhaoyanbai.com/repos/man.host.html?a=commitdiff_plain;h=refs%2Fchanges%2F62%2F3362%2F1;p=minix.git Add LLVM GCOV coverage support With this patch, it is now possible to generate coverage information for MINIX3 system services with LLVM. In particular, the system can be built with MKCOVERAGE=yes, either with a native "make build" or with crosscompilation. Either way, MKCOVERAGE=yes will build the MINIX3 system services with coverage profiling support, generating a .gcno file for each source module. After a reboot it is possible to obtain runtime coverage data (.gcda files) for individual system services using gcov-pull(8). The combination of the .gcno and .gcda files can then be inspected with llvm-cov(1). For reasons documented in minix.gcov.mk, only system service program modules are supported for now; system service libraries (libsys etc.) are not included. Userland programs are not affected by MKCOVERAGE. The heart of this patch is the libsys code that writes data generated by the LLVM coverage hooks into a serialized format using the routines we already had for GCC GCOV. Unfortunately, the new llvm_gcov.c code is LLVM ABI dependent, and may therefore have to be updated later when we upgrade LLVM. The current implementation should support all LLVM versions 3.x with x >= 4. The rest of this patch is mostly a light cleanup of our existing GCOV infrastructure, with as most visible change that gcov-pull(8) now takes a service label string rather than a PID number. Change-Id: I6de055359d3d2b3f53e426f3fffb17af7877261f --- diff --git a/.gitignore b/.gitignore index b5ae5ebb9..4740358fa 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,8 @@ lib*.so* *.so.* *.d .depend +*.gcno +*.gcda TAGS tags GPATH diff --git a/minix/commands/gcov-pull/gcov-pull.c b/minix/commands/gcov-pull/gcov-pull.c index 361dc8206..11b626390 100644 --- a/minix/commands/gcov-pull/gcov-pull.c +++ b/minix/commands/gcov-pull/gcov-pull.c @@ -32,11 +32,11 @@ int main(int argc, char *argv[]) { FILE *fd = NULL; int server_nr, command, size, result; - char buff[BUFF_SZ]; /* Buffer for all the metadata and file data sent */ + static char buff[BUFF_SZ]; /* Buffer for all the metadata and file data */ - if(argc!=2 || sscanf(argv[1], "%d", &server_nr)!=1) { - fprintf(stderr, "Usage: %s \n", argv[0]); - return 1; + if (argc != 2) { + fprintf(stderr, "Usage: %s