[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 5/5] gcov: split out gcc version specific stuff
Gcov record format is tied to specific gcc versions. The current code in tree conforms to gcc 3.4 format. Move structure definitions to a specific file and factor out some version specific functions. No functional change. Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx> --- Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> Cc: George Dunlap <George.Dunlap@xxxxxxxxxxxxx> Cc: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> Cc: Jan Beulich <jbeulich@xxxxxxxx> Cc: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx> Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx> Cc: Tim Deegan <tim@xxxxxxx> Cc: Wei Liu <wei.liu2@xxxxxxxxxx> --- xen/common/gcov/gcov.c | 64 ++++++++++++++++++++++------------- xen/common/gcov/gcov_3_4.h | 84 ++++++++++++++++++++++++++++++++++++++++++++++ xen/include/xen/gcov.h | 80 ------------------------------------------- 3 files changed, 125 insertions(+), 103 deletions(-) create mode 100644 xen/common/gcov/gcov_3_4.h diff --git a/xen/common/gcov/gcov.c b/xen/common/gcov/gcov.c index 6d18729..2c2f05a 100644 --- a/xen/common/gcov/gcov.c +++ b/xen/common/gcov/gcov.c @@ -22,6 +22,11 @@ #include <xen/guest_access.h> #include <public/xen.h> #include <public/gcov.h> +#if defined(CONFIG_GCOV_FORMAT_3_4) +#include "gcov_3_4.h" +#else +# error Gcov format not supported +#endif const char __initconst warning_gcov[] = "WARNING: GCOV SUPPORT IS ENABLED\n" @@ -69,10 +74,13 @@ 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) +#if defined(CONFIG_GCOV_FORMAT_3_4) +static inline int counter_active(const struct gcov_info *info, + unsigned int type) { return (1 << type) & info->ctr_mask; } +#endif typedef struct write_iter_t { @@ -122,6 +130,37 @@ static inline void align_iter(write_iter_t *iter) (iter->write_offset + sizeof(uint64_t) - 1) & -sizeof(uint64_t); } +#if defined(CONFIG_GCOV_FORMAT_3_4) +static int dump(write_iter_t *iter, const struct gcov_info *info) +{ + const struct gcov_ctr_info *ctr; + size_t size_fn = sizeof(struct gcov_fn_info); + int type; + int ret; + + /* 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)); + + return 0; +} +#endif + static int write_gcov(write_iter_t *iter) { struct gcov_info *info; @@ -133,34 +172,13 @@ static int write_gcov(write_iter_t *iter) /* 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)); + chk(dump(iter, info)); } /* stop tag */ diff --git a/xen/common/gcov/gcov_3_4.h b/xen/common/gcov/gcov_3_4.h new file mode 100644 index 0000000..e10c568 --- /dev/null +++ b/xen/common/gcov/gcov_3_4.h @@ -0,0 +1,84 @@ +/* + * Profiling infrastructure declarations. + * + * This file is based on gcc-internal definitions. Data structures are + * defined to be compatible with gcc counterparts. For a better + * understanding, refer to gcc source: gcc/gcov-io.h. + * + * Copyright IBM Corp. 2009 + * Author(s): Peter Oberparleiter <oberpar@xxxxxxxxxxxxxxxxxx> + * + * Uses gcc-internal data definitions. + */ + +#ifndef __XEN_GCOV_3_4_H__ +#define __XEN_GCOV_3_4_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 + * remain compatible. + */ + +typedef uint64_t gcov_type; + +/** + * struct gcov_fn_info - profiling meta data per function + * @ident: object file-unique function identifier + * @checksum: function checksum + * @n_ctrs: number of values per counter type belonging to this function + * + * This data is generated by gcc during compilation and doesn't change + * at run-time. + */ +struct gcov_fn_info +{ + unsigned int ident; + unsigned int checksum; + unsigned int n_ctrs[0]; +}; + +/** + * struct gcov_ctr_info - profiling data per counter type + * @num: number of counter values for this type + * @values: array of counter values for this type + * @merge: merge function for counter values of this type (unused) + * + * This data is generated by gcc during compilation and doesn't change + * at run-time with the exception of the values array. + */ +struct gcov_ctr_info +{ + unsigned int num; + gcov_type *values; + void (*merge)(gcov_type *, unsigned int); +}; + +/** + * struct gcov_info - profiling data per object file + * @version: gcov version magic indicating the gcc version used for compilation + * @next: list head for a singly-linked list + * @stamp: time stamp + * @filename: name of the associated gcov data file + * @n_functions: number of instrumented functions + * @functions: function data + * @ctr_mask: mask specifying which counter types are active + * @counts: counter data per counter type + * + * This data is generated by gcc during compilation and doesn't change + * at run-time with the exception of the next pointer. + */ +struct gcov_info +{ + unsigned int version; + struct gcov_info *next; + unsigned int stamp; + const char *filename; + unsigned int n_functions; + const struct gcov_fn_info *functions; + unsigned int ctr_mask; + struct gcov_ctr_info counts[0]; +}; + + +#endif /* __XEN_GCOV_3_4_H__ */ diff --git a/xen/include/xen/gcov.h b/xen/include/xen/gcov.h index a7d4a35..f6a1ac7 100644 --- a/xen/include/xen/gcov.h +++ b/xen/include/xen/gcov.h @@ -1,88 +1,8 @@ -/* - * Profiling infrastructure declarations. - * - * This file is based on gcc-internal definitions. Data structures are - * defined to be compatible with gcc counterparts. For a better - * understanding, refer to gcc source: gcc/gcov-io.h. - * - * Copyright IBM Corp. 2009 - * Author(s): Peter Oberparleiter <oberpar@xxxxxxxxxxxxxxxxxx> - * - * Uses gcc-internal data definitions. - */ - #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 - * remain compatible. - */ - -typedef uint64_t gcov_type; - -/** - * struct gcov_fn_info - profiling meta data per function - * @ident: object file-unique function identifier - * @checksum: function checksum - * @n_ctrs: number of values per counter type belonging to this function - * - * This data is generated by gcc during compilation and doesn't change - * at run-time. - */ -struct gcov_fn_info -{ - unsigned int ident; - unsigned int checksum; - unsigned int n_ctrs[0]; -}; - -/** - * struct gcov_ctr_info - profiling data per counter type - * @num: number of counter values for this type - * @values: array of counter values for this type - * @merge: merge function for counter values of this type (unused) - * - * This data is generated by gcc during compilation and doesn't change - * at run-time with the exception of the values array. - */ -struct gcov_ctr_info -{ - unsigned int num; - gcov_type *values; - void (*merge)(gcov_type *, unsigned int); -}; - -/** - * struct gcov_info - profiling data per object file - * @version: gcov version magic indicating the gcc version used for compilation - * @next: list head for a singly-linked list - * @stamp: time stamp - * @filename: name of the associated gcov data file - * @n_functions: number of instrumented functions - * @functions: function data - * @ctr_mask: mask specifying which counter types are active - * @counts: counter data per counter type - * - * This data is generated by gcc during compilation and doesn't change - * at run-time with the exception of the next pointer. - */ -struct gcov_info -{ - unsigned int version; - struct gcov_info *next; - unsigned int stamp; - const char *filename; - unsigned int n_functions; - const struct gcov_fn_info *functions; - unsigned int ctr_mask; - struct gcov_ctr_info counts[0]; -}; - - /** * Sysctl operations for coverage */ -- 2.1.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |