Message ID | f6495eb4c02f6539c5b95d2850d4a834f2ea94e8.1694189143.git.javi.merino@cloud.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | update gcov info for newer versions of gcc | expand |
On 08.09.2023 18:20, Javi Merino wrote: > Shamelessly copy changes to gcov_info structures from linux so that we > can capture coverage for xen built with newer compilers. > > Signed-off-by: Javi Merino <javi.merino@cloud.com> > --- > xen/common/coverage/gcc_4_7.c | 24 +++++++++++++++++++++--- > 1 file changed, 21 insertions(+), 3 deletions(-) > > diff --git a/xen/common/coverage/gcc_4_7.c b/xen/common/coverage/gcc_4_7.c > index ddbc9f4bb0..8f6e287474 100644 > --- a/xen/common/coverage/gcc_4_7.c > +++ b/xen/common/coverage/gcc_4_7.c > @@ -24,14 +24,23 @@ > #define GCOV_COUNTERS 9 > #elif GCC_VERSION >= 50000 && GCC_VERSION < 70000 > #define GCOV_COUNTERS 10 > -#elif GCC_VERSION >= 70000 > +#elif GCC_VERSION >= 70000 && GCC_VERSION < 100000 > #define GCOV_COUNTERS 9 > +#elif GCC_VERSION >= 100000 > +#define GCOV_COUNTERS 8 > #else > #error "Wrong version of GCC used to compile gcov" > #endif This would need adjustment if patch 1 is adjusted as suggested, then ... > #define GCOV_TAG_FUNCTION_LENGTH 3 > > +#if GCC_VERSION >= 120000 > +/* Since GCC 12.1, sizes are in BYTES and not in WORDS (4B). */ > +#define GCOV_UNIT_SIZE 4 > +#else > +#define GCOV_UNIT_SIZE 1 > +#endif ... making the earlier group also match this one (which already works downwards in version number space). As to the comments (here and below): Since the version check is for 12.0, may I suggest to simply say "gcc 12" everywhere? > @@ -89,6 +98,10 @@ struct gcov_info { > unsigned int version; > struct gcov_info *next; > unsigned int stamp; > +#if (GCC_VERSION >= 120000) Nit: Here any below parentheses likely want omitting, to match there being none further up. Preferably with the adjustments (which again I'd be okay doing while committing, so long as you agree) Acked-by: Jan Beulich <jbeulich@suse.com> Jan
On Mon, Sep 11, 2023 at 10:00:14AM +0200, Jan Beulich wrote: > On 08.09.2023 18:20, Javi Merino wrote: > > Shamelessly copy changes to gcov_info structures from linux so that we > > can capture coverage for xen built with newer compilers. > > > > Signed-off-by: Javi Merino <javi.merino@cloud.com> > > --- > > xen/common/coverage/gcc_4_7.c | 24 +++++++++++++++++++++--- > > 1 file changed, 21 insertions(+), 3 deletions(-) > > > > diff --git a/xen/common/coverage/gcc_4_7.c b/xen/common/coverage/gcc_4_7.c > > index ddbc9f4bb0..8f6e287474 100644 > > --- a/xen/common/coverage/gcc_4_7.c > > +++ b/xen/common/coverage/gcc_4_7.c > > @@ -24,14 +24,23 @@ > > #define GCOV_COUNTERS 9 > > #elif GCC_VERSION >= 50000 && GCC_VERSION < 70000 > > #define GCOV_COUNTERS 10 > > -#elif GCC_VERSION >= 70000 > > +#elif GCC_VERSION >= 70000 && GCC_VERSION < 100000 > > #define GCOV_COUNTERS 9 > > +#elif GCC_VERSION >= 100000 > > +#define GCOV_COUNTERS 8 > > #else > > #error "Wrong version of GCC used to compile gcov" > > #endif > > This would need adjustment if patch 1 is adjusted as suggested, then ... > > > #define GCOV_TAG_FUNCTION_LENGTH 3 > > > > +#if GCC_VERSION >= 120000 > > +/* Since GCC 12.1, sizes are in BYTES and not in WORDS (4B). */ > > +#define GCOV_UNIT_SIZE 4 > > +#else > > +#define GCOV_UNIT_SIZE 1 > > +#endif > > ... making the earlier group also match this one (which already works > downwards in version number space). True > As to the comments (here and below): Since the version check is for > 12.0, may I suggest to simply say "gcc 12" everywhere? > > > @@ -89,6 +98,10 @@ struct gcov_info { > > unsigned int version; > > struct gcov_info *next; > > unsigned int stamp; > > +#if (GCC_VERSION >= 120000) > > Nit: Here any below parentheses likely want omitting, to match there > being none further up. Preferably with the adjustments (which again > I'd be okay doing while committing, so long as you agree) > Acked-by: Jan Beulich <jbeulich@suse.com> I'm ok with those changes and I'm fine with you doing them. Cheers, Javi
diff --git a/xen/common/coverage/gcc_4_7.c b/xen/common/coverage/gcc_4_7.c index ddbc9f4bb0..8f6e287474 100644 --- a/xen/common/coverage/gcc_4_7.c +++ b/xen/common/coverage/gcc_4_7.c @@ -24,14 +24,23 @@ #define GCOV_COUNTERS 9 #elif GCC_VERSION >= 50000 && GCC_VERSION < 70000 #define GCOV_COUNTERS 10 -#elif GCC_VERSION >= 70000 +#elif GCC_VERSION >= 70000 && GCC_VERSION < 100000 #define GCOV_COUNTERS 9 +#elif GCC_VERSION >= 100000 +#define GCOV_COUNTERS 8 #else #error "Wrong version of GCC used to compile gcov" #endif #define GCOV_TAG_FUNCTION_LENGTH 3 +#if GCC_VERSION >= 120000 +/* Since GCC 12.1, sizes are in BYTES and not in WORDS (4B). */ +#define GCOV_UNIT_SIZE 4 +#else +#define GCOV_UNIT_SIZE 1 +#endif + static struct gcov_info *gcov_info_head; /** @@ -89,6 +98,10 @@ struct gcov_info { unsigned int version; struct gcov_info *next; unsigned int stamp; +#if (GCC_VERSION >= 120000) + /* GCC 12.1 introduced a checksum field */ + unsigned int checksum; +#endif const char *filename; void (*merge[GCOV_COUNTERS])(gcov_type *, unsigned int); unsigned int n_functions; @@ -161,13 +174,18 @@ size_t gcov_info_to_gcda(char *buffer, const struct gcov_info *info) pos += gcov_store_uint32(buffer, pos, info->version); pos += gcov_store_uint32(buffer, pos, info->stamp); +#if (GCC_VERSION >= 120000) + /* Use zero as checksum of the compilation unit. */ + pos += gcov_store_uint32(buffer, pos, 0); +#endif + for ( fi_idx = 0; fi_idx < info->n_functions; fi_idx++ ) { fi_ptr = info->functions[fi_idx]; /* Function record. */ pos += gcov_store_uint32(buffer, pos, GCOV_TAG_FUNCTION); - pos += gcov_store_uint32(buffer, pos, GCOV_TAG_FUNCTION_LENGTH); + pos += gcov_store_uint32(buffer, pos, GCOV_TAG_FUNCTION_LENGTH * GCOV_UNIT_SIZE); pos += gcov_store_uint32(buffer, pos, fi_ptr->ident); pos += gcov_store_uint32(buffer, pos, fi_ptr->lineno_checksum); pos += gcov_store_uint32(buffer, pos, fi_ptr->cfg_checksum); @@ -182,7 +200,7 @@ size_t gcov_info_to_gcda(char *buffer, const struct gcov_info *info) /* Counter record. */ pos += gcov_store_uint32(buffer, pos, GCOV_TAG_FOR_COUNTER(ct_idx)); - pos += gcov_store_uint32(buffer, pos, ci_ptr->num * 2); + pos += gcov_store_uint32(buffer, pos, ci_ptr->num * 2 * GCOV_UNIT_SIZE); for ( cv_idx = 0; cv_idx < ci_ptr->num; cv_idx++ ) pos += gcov_store_uint64(buffer, pos, ci_ptr->values[cv_idx]);
Shamelessly copy changes to gcov_info structures from linux so that we can capture coverage for xen built with newer compilers. Signed-off-by: Javi Merino <javi.merino@cloud.com> --- xen/common/coverage/gcc_4_7.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-)