
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
40 lines
878 B
C
40 lines
878 B
C
#include <sys/types.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
#define _MINIX_SYSTEM 1
|
|
#include <minix/gcov.h>
|
|
|
|
/* wrappers for file system calls from gcc libgcov library.
|
|
Default calls are wrapped. In libsys, an alternative
|
|
implementation for servers is used.
|
|
*/
|
|
|
|
FILE *_gcov_fopen(const char *name, const char *mode){
|
|
return fopen(name, mode);
|
|
}
|
|
|
|
|
|
size_t _gcov_fread(void *ptr, size_t itemsize, size_t nitems
|
|
, FILE *stream){
|
|
return fread(ptr, itemsize, nitems, stream);
|
|
}
|
|
|
|
size_t _gcov_fwrite(const void *ptr, size_t itemsize, size_t nitems
|
|
, FILE *stream){
|
|
return fwrite(ptr, itemsize, nitems, stream);
|
|
}
|
|
|
|
int _gcov_fclose(FILE *stream){
|
|
return fclose(stream);
|
|
}
|
|
|
|
int _gcov_fseek(FILE *stream, long offset, int ptrname){
|
|
return fseek(stream, offset, ptrname);
|
|
}
|
|
|
|
char *_gcov_getenv(const char *name){
|
|
return getenv(name);
|
|
}
|
|
|