gcov: Coverage support
v10 cover gcov: Coverage support
Updated set of patches for coverage.
Changes:
- remove small outdated note on commit text
- add signature where missing
- rebased
Frediano Ziglio (5):
gcov: Call constructors during initialization
gcov: Adding support for coverage information
gcov: Implement code to read coverage informations
gcov: Add small utility to deal with test coverage information from
Xen
gcov: Add documentation for coverage
.gitignore | 3 + .hgignore | 3 + Config.mk | 3 + docs/misc/coverage.markdown | 39 ++++++++ tools/misc/Makefile | 8 +- tools/misc/xencov.c | 152 +++++++++++++++++++++++++++++ xen/Rules.mk | 2 + xen/arch/arm/setup.c | 2 + xen/arch/arm/xen.lds.S | 7 ++ xen/arch/x86/setup.c | 2 + xen/arch/x86/xen.lds.S | 7 ++ xen/common/Makefile | 2 + xen/common/gcov/Makefile | 2 + xen/common/gcov/gcov.c | 225 +++++++++++++++++++++++++++++++++++++++++++ xen/common/lib.c | 14 +++ xen/common/sysctl.c | 6 ++ xen/include/public/gcov.h | 115 ++++++++++++++++++++++ xen/include/public/sysctl.h | 38 ++++++++ xen/include/xen/gcov.h | 93 ++++++++++++++++++ xen/include/xen/lib.h | 2 + 20 files changed, 723 insertions(+), 2 deletions(-) create mode 100644 docs/misc/coverage.markdown create mode 100644 tools/misc/xencov.c create mode 100644 xen/common/gcov/Makefile create mode 100644 xen/common/gcov/gcov.c create mode 100644 xen/include/public/gcov.h create mode 100644 xen/include/xen/gcov.h
Signature · 1 line
1.7.9.5
PATCH v10 1/5 gcov: Call constructors during initialization
This allow modules to set initializer functions.
This is used by Gcc instrumentation code for profiling arcs and test coverage.
--- xen/arch/arm/setup.c | 2 ++ xen/arch/arm/xen.lds.S | 7 +++++++ xen/arch/x86/setup.c | 2 ++ xen/arch/x86/xen.lds.S | 7 +++++++ xen/common/lib.c | 14 ++++++++++++++ xen/include/xen/lib.h | 2 ++ 6 files changed, 34 insertions(+)
xen/arch/arm/setup.c +2 -0
@@ -442,6 +442,8 @@ void __init start_xen(unsigned long boot_phys_offset,scrub_heap_pages(); */ +init_constructors (); +console_endboot ();/* Hide UART from DOM0 if we're using it */
xen/arch/arm/xen.lds.S +7 -0
@@ -84,6 +84,13 @@ SECTIONS *(.init.data) *(.init.data.rel) *(.init.data.rel.*) + + . = ALIGN(4); + __CTOR_LIST__ = .; + LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2) + *(.ctors) + LONG(0) + __CTOR_END__ = .; } :text . = ALIGN(32); .init.setup : {
xen/arch/x86/setup.c +2 -0
@@ -1378,6 +1378,8 @@ void __init __start_xen(unsigned long mbi_p)init_trace_bufs (); +init_constructors (); +console_endboot ();/* Hide UART from DOM0 if we're using it */
xen/arch/x86/xen.lds.S +7 -0
@@ -108,6 +108,13 @@ SECTIONS __trampoline_seg_start = .; *(.trampoline_seg) __trampoline_seg_stop = .; + + . = ALIGN(8); + __CTOR_LIST__ = .; + QUAD((__CTOR_END__ - __CTOR_LIST__) / 8 - 2) + *(.ctors) + QUAD(0) + __CTOR_END__ = .; } :text . = ALIGN(32); .init.setup : {
xen/common/lib.c +14 -0
@@ -2,6 +2,7 @@#include <xen/ctype.h> #include <xen/lib.h> #include <xen/types.h> +#include <xen/init.h> #include <asm/byteorder.h> /* for ctype.h */
@@ -478,6 +479,19 @@ unsigned long long parse_size_and_unit(const char *s, const char **ps)return ret; } +extern const struct +{ +unsigned long count; +void (*funcs[1 ])(void ); +} __CTOR_LIST__; + +void __init init_constructors (void ) +{ +unsigned long n; +for ( n =0 ; n < __CTOR_LIST__.count; ++n ) + __CTOR_LIST__.funcs[n](); +} +/* * Local variables: * mode: C
xen/include/xen/lib.h +2 -0
@@ -127,4 +127,6 @@ extern void add_taint(unsigned);struct cpu_user_regs ;void dump_execstate (struct cpu_user_regs *); +void init_constructors (void ); +#endif /* __LIB_H__ */
Signature · 1 line
1.7.9.5
Re: [PATCH v10 1/5] gcov: Call constructors during initialization
Quoted 8 lines · Frediano Ziglio
xen/arch/arm/xen.lds.S +0
-0@@ -84,6 +84,13 @@ SECTIONS *(.init.data) *(.init.data.rel) *(.init.data.rel.*)
xen/arch/arm/xen.lds.S SECTIONS · line 96
Quoted 10 lines
xen/arch/arm/xen.lds.S +7
-0+ + . = ALIGN(4); + __CTOR_LIST__ = .; + LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2) + *(.ctors) + LONG(0) + __CTOR_END__ = .; } :text . = ALIGN(32); .init.setup : {
This broke my 64-bit branch (not your fault, it's not merged yet, but I
was planning to commit it shortly):
prelink.o: In function `init_constructors':
/local/scratch/ianc/devel/arm/xen.git/xen/common/lib.c:491:(.init.text+0xc44): relocation truncated to fit: R_AARCH64_LDST64_ABS_LO12_NC against symbol `__CTOR_LIST__' defined in .init.data section in /local/scratch/ianc/devel/arm/xen.git/xen/.xen-arm64-syms.0
To fixup I intend to add the following to my "xen: arm64: initial build
+ config changes, start of day code".
Xen doesn't have a xen/xen.lds.h header, but perhaps adding that and using it to define common things like this as macros might be an interesting future cleanup.
8<--------------------------------------
xen/arch/arm/xen.lds.S +2 -2
@@ -91,9 +91,9 @@ SECTIONS *(.init.data.rel) *(.init.data.rel.*) - . = ALIGN(4); + . = ALIGN(BYTES_PER_LONG); __CTOR_LIST__ = .; - LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2) + LONG((__CTOR_END__ - __CTOR_LIST__) / BYTES_PER_LONG - 2) *(.ctors) LONG(0) __CTOR_END__ = .;
Re: [PATCH v10 1/5] gcov: Call constructors during initialization
Quoted 45 lines · Ian Campbell
Quoted 8 lines · Frediano Ziglio
xen/arch/arm/xen.lds.S +0
-0@@ -84,6 +84,13 @@ SECTIONS *(.init.data) *(.init.data.rel) *(.init.data.rel.*)xen/arch/arm/xen.lds.S SECTIONS · line 96
Quoted 10 lines
xen/arch/arm/xen.lds.S +7
-0+ + . = ALIGN(4); + __CTOR_LIST__ = .; + LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2) + *(.ctors) + LONG(0) + __CTOR_END__ = .; } :text . = ALIGN(32); .init.setup : {This broke my 64-bit branch (not your fault, it's not merged yet, but I
was planning to commit it shortly):
prelink.o: In function `init_constructors':
/local/scratch/ianc/devel/arm/xen.git/xen/common/lib.c:491:(.init.text+0xc44): relocation truncated to fit:R_AARCH64_LDST64_ABS_LO12_NCagainst symbol `__CTOR_LIST__' defined in .init.data section in /local/scratch/ianc/devel/arm/xen.git/xen/.xen-arm64-syms.0To fixup I intend to add the following to my "xen: arm64: initial build
+ config changes, start of day code".Xen doesn't have a
xen/xen.lds.hheader, but perhaps adding that and using it to define common things like this as macros might be an interesting future cleanup.8<--------------------------------------
xen/arch/arm/xen.lds.S +0
-0@@ -91,9 +91,9 @@ SECTIONS *(.init.data.rel)
xen/arch/arm/xen.lds.S SECTIONS · line 99
Quoted 10 lines
xen/arch/arm/xen.lds.S +2
-2*(.init.data.rel.*) - . = ALIGN(4); + . = ALIGN(BYTES_PER_LONG); __CTOR_LIST__ = .; - LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2) + LONG((__CTOR_END__ - __CTOR_LIST__) / BYTES_PER_LONG - 2) *(.ctors) LONG(0) __CTOR_END__ = .;
Hi,
this does not work, LONG is always 32 bit but if you use pointers
should be QUAD. Or I can change structure to be just a range of pointers addressed by start and end, so in ld script
. = ALIGN(8);
__CTOR_LIST__ = .;
*(.ctors)
__CTOR_END__ = .;In code:
typedef void (*ctor_func_t)(void);
extern const ctor_func_t __CTOR_LIST__[1], __CTOR_END__[1];
void __init init_constructors(void)
{
const ctor_func_t pf = __CTOR_LIST__;
for ( ; pf < __CTOR_END__; ++pf )
pf();
}This will work for both 32 and 64 bit. At this point I would rename __CTOR_LIST__ with a more "Xen" name.
Frediano
Re: [PATCH v10 1/5] gcov: Call constructors during initialization
Quoted 44 lines · Frediano Ziglio
Quoted 43 lines · Ian Campbell
Quoted 8 lines · Frediano Ziglio
xen/arch/arm/xen.lds.S +0
-0@@ -84,6 +84,13 @@ SECTIONS *(.init.data) *(.init.data.rel) *(.init.data.rel.*)xen/arch/arm/xen.lds.S SECTIONS · line 96
Quoted 10 lines
xen/arch/arm/xen.lds.S +7
-0+ + . = ALIGN(4); + __CTOR_LIST__ = .; + LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2) + *(.ctors) + LONG(0) + __CTOR_END__ = .; } :text . = ALIGN(32); .init.setup : {This broke my 64-bit branch (not your fault, it's not merged yet, but I
was planning to commit it shortly):
prelink.o: In function `init_constructors':
/local/scratch/ianc/devel/arm/xen.git/xen/common/lib.c:491:(.init.text+0xc44): relocation truncated to fit:R_AARCH64_LDST64_ABS_LO12_NCagainst symbol `__CTOR_LIST__' defined in .init.data section in /local/scratch/ianc/devel/arm/xen.git/xen/.xen-arm64-syms.0To fixup I intend to add the following to my "xen: arm64: initial build
+ config changes, start of day code".Xen doesn't have a
xen/xen.lds.hheader, but perhaps adding that and using it to define common things like this as macros might be an interesting future cleanup.8<--------------------------------------
xen/arch/arm/xen.lds.S +0
-0@@ -91,9 +91,9 @@ SECTIONS *(.init.data.rel) *(.init.data.rel.*)
Quoted 15 lines
xen/arch/arm/xen.lds.S SECTIONS · line 99
Quoted 12 lines
xen/arch/arm/xen.lds.S +2
-2- . = ALIGN(4); + . = ALIGN(BYTES_PER_LONG); __CTOR_LIST__ = .; - LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2) + LONG((__CTOR_END__ - __CTOR_LIST__) / BYTES_PER_LONG - 2) *(.ctors) LONG(0) __CTOR_END__ = .;Hi,
this does not work, LONG is always 32 bit
Yes, I'm just discovering that ;-)
Quoted 13 lines
but if you use pointers should be QUAD. Or I can change structure to be just a range of pointers addressed by start and end, so in ld script
. = ALIGN(8); __CTOR_LIST__ = .; *(.ctors) __CTOR_END__ = .;In code:
typedef void (*ctor_func_t)(void);
extern constctor_func_t__CTOR_LIST__[1], __CTOR_END__[1];
Quoted 8 lines
void
__initinit_constructors(void){ const ctor_func_t pf = __CTOR_LIST__; for ( ; pf < __CTOR_END__; ++pf ) pf(); }This will work for both 32 and 64 bit. At this point I would rename
__CTOR_LIST__with a more "Xen" name.
Let me play with something along these lines. I'll send out a patch.
Ian.
PATCH v10 2/5 gcov: Adding support for coverage information
In reply to Frediano ZiglioThis patch introduce coverage support to Xen.
Currently it allows to compile Xen with coverage support but there is no way to extract them.
The declarations came from Linux source files (as you can see from file headers).
The idea is to have some operations mainly
- get coverage information size
- read coverage information
- reset coverage counters
Linux use a file system to export these information. The information will be a blob to handle with some tools (as usually tools require a bunch of files but Xen does not handle files at all). I'll pack them to make things simpler as possible.
These information cannot be put in a specific section (allowing a safe mapping) as gcc use .rodata, .data, .text and .ctors sections.
I added code to handle constructors used in this case to initialize a linked list of files.
I used a "coverage" configuration option to mimic the "debug" one.
--- .gitignore | 2 ++ .hgignore | 2 ++ Config.mk | 3 ++ xen/Rules.mk | 2 ++ xen/common/Makefile | 2 ++ xen/common/gcov/Makefile | 2 ++ xen/common/gcov/gcov.c | 72 +++++++++++++++++++++++++++++++++++++++ xen/include/xen/gcov.h | 84 ++++++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 169 insertions(+) create mode 100644 xen/common/gcov/Makefile create mode 100644 xen/common/gcov/gcov.c create mode 100644 xen/include/xen/gcov.h
.gitignore +2 -0
@@ -13,6 +13,8 @@ *.tmp *.spot *.spit +*.gcno +*.gcda TAGS GTAGS GRTAGS
.hgignore +2 -0
@@ -17,6 +17,8 @@ .*\.rej$ .*\.spot$ .*\.spit$ +.*\.gcno$ +.*\.gcda$ .*/a\.out$ .*/Modules\.symvers$ .*/cscope\..*$
Config.mk +3 -0
@@ -13,6 +13,9 @@ realpath = $(wildcard $(foreach file,$(1),$(shell cd -P $(dir $(file)) && echo " debug ?= y debug_symbols ?= $(debug) +# Test coverage support +coverage ?= n + XEN_COMPILE_ARCH ?= $(shell uname -m | sed -e s/i.86/x86_32/ \ -e s/i86pc/x86_32/ -e s/amd64/x86_64/ \ -e s/armv7.*/arm32/)
xen/Rules.mk +2 -0
@@ -103,6 +103,8 @@ subdir-all := $(subdir-y) $(subdir-n) $(filter %.init.o,$(obj-y) $(obj-bin-y)): CFLAGS += -DINIT_SECTIONS_ONLY +$(obj-$(coverage)): CFLAGS += -fprofile-arcs -ftest-coverage -DTEST_COVERAGE + ifeq ($(lto),y) # Would like to handle all object files as bitcode, but objects made from # pure asm are in a different format and have to be collected separately.
xen/common/Makefile +2 -0
@@ -59,5 +59,7 @@ subdir-$(CONFIG_COMPAT) += compat subdir-$(x86_64) += hvm +subdir-$(coverage) += gcov + subdir-y += libelf subdir-$(HAS_DEVICE_TREE) += libfdt
xen/common/gcov/Makefile new file +2 -0
@@ -0,0 +1,2 @@ +obj-y += gcov.o +
xen/common/gcov/gcov.c new file +72 -0
72 lines not on this page · raw message
xen/include/xen/gcov.h new file +84 -0
84 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH v10 3/5 gcov: Implement code to read coverage informations
In reply to Frediano ZiglioOperations are handled by a sysctl specific operation.
Implement 4 operations
- check if coverage is compiled in
- read size of coverage information
- read coverage information
- reset coverage counters
Information are stored in a single blob in a format specific to Xen designed to make code that generate coverage as small as possible.
This patch add a public header with the structure of blob exported by Xen. This avoid problems distributing header which is GPL2.
--- xen/common/gcov/gcov.c | 153 +++++++++++++++++++++++++++++++++++++++++++ xen/common/sysctl.c | 6 ++ xen/include/public/gcov.h | 115 ++++++++++++++++++++++++++++++++ xen/include/public/sysctl.h | 38 +++++++++++ xen/include/xen/gcov.h | 9 +++ 5 files changed, 321 insertions(+) create mode 100644 xen/include/public/gcov.h
xen/common/gcov/gcov.c +153 -0
@@ -19,6 +19,9 @@#include <xen/hypercall.h> #include <xen/gcov.h> #include <xen/errno.h> +#include <xen/guest_access.h> +#include <public/xen.h> +#include <public/gcov.h> static struct gcov_info *info_list;
@@ -61,6 +64,156 @@ void __gcov_merge_delta(gcov_type *counters, unsigned int n_counters)/* Unused. */ } +static inline int counter_active (const struct gcov_info *info,unsigned int type) +{ +return (1 << type) & info->ctr_mask; +} + +typedef struct write_iter_t +{ +XEN_GUEST_HANDLE (uint8) ptr; +int real; +uint32_t write_offset; +}write_iter_t ; + +static int write_raw (struct write_iter_t *iter,const void *data, +size_t data_len) +{ +if ( iter->real && +copy_to_guest_offset (iter->ptr, iter->write_offset, + (const unsigned char *) data, data_len) ) +return -EFAULT ; + + iter->write_offset += data_len; +return 0 ; +} + +#define chk (v) do { ret=(v); if ( ret ) return ret; } while(0) + +static inline int write32 (write_iter_t *iter,uint32_t val) +{ +return write_raw (iter, &val,sizeof (val)); +} + +static int write_string (write_iter_t *iter,const char *s) +{ +int ret; +size_t len =strlen (s); + +chk (write32 (iter, len)); +return write_raw (iter, s, len); +} + +static inline int next_type (const struct gcov_info *info,int *type) +{ +while ( ++*type <XENCOV_COUNTERS && !counter_active (info, *type) ) +continue ; +return *type; +} + +static inline void align_iter (write_iter_t *iter) +{ + iter->write_offset = + (iter->write_offset +sizeof (uint64_t ) -1 ) & -sizeof (uint64_t ); +} + +static int write_gcov (write_iter_t *iter) +{ +struct gcov_info *info; +int ret; + +/* reset offset */ + iter->write_offset =0 ; + +/* dump all files */ +for ( info = info_list ; info; info = info->next ) + { +const struct gcov_ctr_info *ctr; +int type; +size_t size_fn =sizeof (struct gcov_fn_info ); + +align_iter (iter); +chk (write32 (iter,XENCOV_TAG_FILE )); +chk (write32 (iter, info->version)); +chk (write32 (iter, info->stamp)); +chk (write_string (iter, info->filename)); + +/* dump counters */ + ctr = info->counts; +for ( type =-1 ;next_type (info, &type) <XENCOV_COUNTERS ; ++ctr ) + { +align_iter (iter); +chk (write32 (iter,XENCOV_TAG_COUNTER (type))); +chk (write32 (iter, ctr->num)); +chk (write_raw (iter, ctr->values, + ctr->num *sizeof (ctr->values[0 ]))); + + size_fn +=sizeof (unsigned ); + } + +/* dump all functions together */ +align_iter (iter); +chk (write32 (iter,XENCOV_TAG_FUNC )); +chk (write32 (iter, info->n_functions)); +chk (write_raw (iter, info->functions, info->n_functions * size_fn)); + } + +/* stop tag */ +align_iter (iter); +chk (write32 (iter,XENCOV_TAG_END )); +return 0 ; +} + +static int reset_counters (void ) +{ +struct gcov_info *info; + +for ( info = info_list ; info; info = info->next ) + { +const struct gcov_ctr_info *ctr; +int type; + +/* reset counters */ + ctr = info->counts; +for ( type =-1 ;next_type (info, &type) <XENCOV_COUNTERS ; ++ctr ) +memset (ctr->values,0 , ctr->num *sizeof (ctr->values[0 ])); + } + +return 0 ; +} + +int sysctl_coverage_op (xen_sysctl_coverage_op_t *op) +{ +int ret = -EINVAL ; +write_iter_t iter; + +switch ( op->cmd ) + { +case XEN_SYSCTL_COVERAGE_get_total_size: + iter.real =0 ; + +write_gcov (&iter); + op->u.total_size = iter.write_offset; + ret =0 ; +break ; + +case XEN_SYSCTL_COVERAGE_read_and_reset: +case XEN_SYSCTL_COVERAGE_read: + iter.ptr = op->u.raw_info; + iter.real =1 ; + + ret =write_gcov (&iter); +if ( ret || op->cmd != XEN_SYSCTL_COVERAGE_read_and_reset ) +break ; + +/* fall through */ +case XEN_SYSCTL_COVERAGE_reset: + ret =reset_counters (); +break ; + } +return ret; +} +/* * Local variables: * mode: C
xen/common/sysctl.c +6 -0
@@ -26,6 +26,7 @@#include <xen/nodemask.h> #include <xsm/xsm.h> #include <xen/pmstat.h> +#include <xen/gcov.h> long do_sysctl (XEN_GUEST_HANDLE_PARAM (xen_sysctl_t) u_sysctl) {
@@ -357,6 +358,11 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl) }break ; +#ifdef TEST_COVERAGE +case XEN_SYSCTL_coverage_op: + ret =sysctl_coverage_op (&op->u.coverage_op); +break ; +#endif default : ret =arch_do_sysctl (op, u_sysctl);
xen/include/public/gcov.h new file +115 -0
115 lines not on this page · raw message
xen/include/public/sysctl.h +38 -0
@@ -596,6 +596,42 @@ struct xen_sysctl_scheduler_op {typedef struct xen_sysctl_scheduler_op xen_sysctl_scheduler_op_t ;DEFINE_XEN_GUEST_HANDLE (xen_sysctl_scheduler_op_t); +/* XEN_SYSCTL_coverage_op */ +/* +* Get total size of information, to help allocate +* the buffer. The pointer points to a 32 bit value. +*/ +#define XEN_SYSCTL_COVERAGE_get_total_size 0 + +/* +* Read coverage information in a single run +* You must use a tool to split them. +*/ +#define XEN_SYSCTL_COVERAGE_read 1 + +/* +* Reset all the coverage counters to 0 +* No parameters. +*/ +#define XEN_SYSCTL_COVERAGE_reset 2 + +/* +* Like XEN_SYSCTL_COVERAGE_read but reset also +* counters to 0 in a single call. +*/ +#define XEN_SYSCTL_COVERAGE_read_and_reset 3 + +struct xen_sysctl_coverage_op { +uint32_t cmd;/* XEN_SYSCTL_COVERAGE_* */ +union { +uint32_t total_size;/* OUT */ +XEN_GUEST_HANDLE_64 (uint8) raw_info;/* OUT */ + } u; +}; +typedef struct xen_sysctl_coverage_op xen_sysctl_coverage_op_t ; +DEFINE_XEN_GUEST_HANDLE (xen_sysctl_coverage_op_t); + +struct xen_sysctl {uint32_t cmd;#define XEN_SYSCTL_readconsole 1
@@ -616,6 +652,7 @@ struct xen_sysctl {#define XEN_SYSCTL_numainfo 17#define XEN_SYSCTL_cpupool_op 18#define XEN_SYSCTL_scheduler_op 19 +#define XEN_SYSCTL_coverage_op 20uint32_t interface_version;/* XEN_SYSCTL_INTERFACE_VERSION */ union {struct xen_sysctl_readconsole readconsole;
@@ -636,6 +673,7 @@ struct xen_sysctl {struct xen_sysctl_lockprof_op lockprof_op;struct xen_sysctl_cpupool_op cpupool_op;struct xen_sysctl_scheduler_op scheduler_op; +struct xen_sysctl_coverage_op coverage_op;uint8_t pad[128 ]; } u; };
xen/include/xen/gcov.h +9 -0
@@ -14,6 +14,8 @@#ifndef __XEN_GCOV_H__#define __XEN_GCOV_H__ __XEN_GCOV_H__ +#include <public/sysctl.h> +/* * Profiling data types used for gcc 3.4 and above - these are defined by * gcc and need to be kept as close to the original definition as possible to
@@ -81,4 +83,11 @@ struct gcov_info }; +/** +* Sysctl operations for coverage +*/ +#ifdef TEST_COVERAGE +int sysctl_coverage_op (xen_sysctl_coverage_op_t *op); +#endif +#endif /* __XEN_GCOV_H__ */
Signature · 1 line
1.7.9.5
PATCH v10 4/5 gcov: Add small utility to deal with test coverage information from Xen
In reply to Frediano ZiglioCurrently the utility can read and reset coverage informations.
--- .gitignore | 1 + .hgignore | 1 + tools/misc/Makefile | 8 ++- tools/misc/xencov.c | 152 +++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 160 insertions(+), 2 deletions(-) create mode 100644 tools/misc/xencov.c
.gitignore +1 -0
@@ -229,6 +229,7 @@ tools/misc/gtraceview tools/misc/gtracestat tools/misc/xenlockprof tools/misc/lowmemd +tools/misc/xencov tools/pygrub/build/* tools/python/build/* tools/python/xen/util/path.py
.hgignore +1 -0
@@ -224,6 +224,7 @@ ^tools/misc/gtraceview$ ^tools/misc/gtracestat$ ^tools/misc/xenlockprof$ +^tools/misc/xencov$ ^tools/pygrub/build/.*$ ^tools/python/build/.*$ ^tools/python/xen/util/path\.py$
tools/misc/Makefile +6 -2
@@ -9,7 +9,7 @@ CFLAGS += $(CFLAGS_libxenstore) HDRS = $(wildcard *.h) -TARGETS-y := xenperf xenpm xen-tmem-list-parse gtraceview gtracestat xenlockprof xenwatchdogd +TARGETS-y := xenperf xenpm xen-tmem-list-parse gtraceview gtracestat xenlockprof xenwatchdogd xencov TARGETS-$(CONFIG_X86) += xen-detect xen-hvmctx xen-hvmcrash xen-lowmemd TARGETS-$(CONFIG_MIGRATE) += xen-hptool TARGETS := $(TARGETS-y)
@@ -22,7 +22,8 @@ INSTALL_BIN-y := xencons INSTALL_BIN-$(CONFIG_X86) += xen-detect INSTALL_BIN := $(INSTALL_BIN-y) -INSTALL_SBIN-y := xm xen-bugtool xen-python-path xend xenperf xsview xenpm xen-tmem-list-parse gtraceview gtracestat xenlockprof xenwatchdogd xen-ringwatch +INSTALL_SBIN-y := xm xen-bugtool xen-python-path xend xenperf xsview xenpm xen-tmem-list-parse gtraceview \ + gtracestat xenlockprof xenwatchdogd xen-ringwatch xencov INSTALL_SBIN-$(CONFIG_X86) += xen-hvmctx xen-hvmcrash xen-lowmemd INSTALL_SBIN-$(CONFIG_MIGRATE) += xen-hptool INSTALL_SBIN := $(INSTALL_SBIN-y)
@@ -85,4 +86,7 @@ xen-lowmemd: xen-lowmemd.o gtraceview: gtraceview.o $(CC) $(LDFLAGS) -o $@ $< $(CURSES_LIBS) $(APPEND_LDFLAGS) +xencov: xencov.o + $(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl) $(APPEND_LDFLAGS) + -include $(DEPS)
tools/misc/xencov.c new file +152 -0
152 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH v10 5/5 gcov: Add documentation for coverage
In reply to Frediano Ziglio--- docs/misc/coverage.markdown | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 docs/misc/coverage.markdown
docs/misc/coverage.markdown new file +39 -0
@@ -0,0 +1,39 @@ +# Coverage support for Xen + +Coverare support allow you to get coverage information from Xen execution. +You can see how many times a line is executed. + +The compiler have specific options that enable the collection of these +information. Every basic block in the code will be instructed by the compiler +to compute these statistics. It should not be used in production as it slow +down your hypervisor. + +## Enable coverage + +Test coverage support can be turned on compiling Xen with coverage option set +to y. + +Something like: + cd xen + make coverage=y + +(or change your `Config.mk` file). + +## Extract coverage data + +The way GCC and other tools deal with coverage information is to use some files +created during build phase (.gcno) and some files produced by executing the +*program* (.gcda). The program in this case is Xen but Xen cannot write files +so the way you can use coverage from Xen is extract coverage data from Xen and +then split these information into files. + +To extract data you use a simple utility called `xencov`. Mainly `xencore` +allow you to do 3 operations: + +* `xencov read` extract data +* `xencov reset` reset all coverage counters +* `xencov read-reset` extract data and reset counters at the same time. + +Another utility (**TODO**) is used to split extracted data file into files +needed by userspace tools. +
Signature · 1 line
1.7.9.5
Whose ACKs do you need for this to be checked in?
-George
Quoted 43 lines · Frediano Ziglio
Updated set of patches for coverage.
Changes:
- remove small outdated note on commit text
- add signature where missing
- rebasedFrediano Ziglio (5):
gcov: Call constructors during initialization
gcov: Adding support for coverage information
gcov: Implement code to read coverage informations
gcov: Add small utility to deal with test coverage information from
Xen
gcov: Add documentation for coverage.gitignore | 3 + .hgignore | 3 + Config.mk | 3 + docs/misc/coverage.markdown | 39 ++++++++ tools/misc/Makefile | 8 +- tools/misc/xencov.c | 152 +++++++++++++++++++++++++++++ xen/Rules.mk | 2 + xen/arch/arm/setup.c | 2 + xen/arch/arm/xen.lds.S | 7 ++ xen/arch/x86/setup.c | 2 + xen/arch/x86/xen.lds.S | 7 ++ xen/common/Makefile | 2 + xen/common/gcov/Makefile | 2 + xen/common/gcov/gcov.c | 225 +++++++++++++++++++++++++++++++++++++++++++ xen/common/lib.c | 14 +++ xen/common/sysctl.c | 6 ++ xen/include/public/gcov.h | 115 ++++++++++++++++++++++ xen/include/public/sysctl.h | 38 ++++++++ xen/include/xen/gcov.h | 93 ++++++++++++++++++ xen/include/xen/lib.h | 2 + 20 files changed, 723 insertions(+), 2 deletions(-)create mode 100644 docs/misc/coverage.markdown
create mode 100644tools/misc/xencov.c
create mode 100644 xen/common/gcov/Makefile
create mode 100644xen/common/gcov/gcov.c
create mode 100644xen/include/public/gcov.h
create mode 100644xen/include/xen/gcov.h
Quoted 1 line · George Dunlap
Whose ACKs do you need for this to be checked in?
It's in now.
Ian.
I don't know.
Frediano
Quoted 49 lines · George Dunlap
Whose ACKs do you need for this to be checked in?
-George
Quoted 43 lines · Frediano Ziglio
Updated set of patches for coverage.
Changes:
- remove small outdated note on commit text
- add signature where missing
- rebasedFrediano Ziglio (5):
gcov: Call constructors during initialization
gcov: Adding support for coverage information
gcov: Implement code to read coverage informations
gcov: Add small utility to deal with test coverage information from
Xen
gcov: Add documentation for coverage.gitignore | 3 + .hgignore | 3 + Config.mk | 3 + docs/misc/coverage.markdown | 39 ++++++++ tools/misc/Makefile | 8 +- tools/misc/xencov.c | 152 +++++++++++++++++++++++++++++ xen/Rules.mk | 2 + xen/arch/arm/setup.c | 2 + xen/arch/arm/xen.lds.S | 7 ++ xen/arch/x86/setup.c | 2 + xen/arch/x86/xen.lds.S | 7 ++ xen/common/Makefile | 2 + xen/common/gcov/Makefile | 2 + xen/common/gcov/gcov.c | 225 +++++++++++++++++++++++++++++++++++++++++++ xen/common/lib.c | 14 +++ xen/common/sysctl.c | 6 ++ xen/include/public/gcov.h | 115 ++++++++++++++++++++++ xen/include/public/sysctl.h | 38 ++++++++ xen/include/xen/gcov.h | 93 ++++++++++++++++++ xen/include/xen/lib.h | 2 + 20 files changed, 723 insertions(+), 2 deletions(-)create mode 100644 docs/misc/coverage.markdown
create mode 100644tools/misc/xencov.c
create mode 100644 xen/common/gcov/Makefile
create mode 100644xen/common/gcov/gcov.c
create mode 100644xen/include/public/gcov.h
create mode 100644xen/include/xen/gcov.h
Quoted 2 lines
Quoted 1 line
Quoted 1 line · George Dunlap
Whose ACKs do you need for this to be checked in?
Keir committed these already.
Jan