All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wei Liu <wei.liu2@citrix.com>
To: Xen-devel <xen-devel@lists.xenproject.org>
Cc: Stefano Stabellini <sstabellini@kernel.org>,
	Wei Liu <wei.liu2@citrix.com>,
	George Dunlap <George.Dunlap@eu.citrix.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Ian Jackson <ian.jackson@eu.citrix.com>, Tim Deegan <tim@xen.org>,
	Jan Beulich <jbeulich@suse.com>
Subject: [PATCH 5/5] gcov: split out gcc version specific stuff
Date: Fri, 2 Sep 2016 12:47:09 +0100	[thread overview]
Message-ID: <1472816829-15551-6-git-send-email-wei.liu2@citrix.com> (raw)
In-Reply-To: <1472816829-15551-1-git-send-email-wei.liu2@citrix.com>

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@citrix.com>
---
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: George Dunlap <George.Dunlap@eu.citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Tim Deegan <tim@xen.org>
Cc: Wei Liu <wei.liu2@citrix.com>
---
 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@linux.vnet.ibm.com>
+ *
+ *    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@linux.vnet.ibm.com>
- *
- *    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@lists.xen.org
https://lists.xen.org/xen-devel

  parent reply	other threads:[~2016-09-02 11:47 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-02 11:47 [PATCH 0/5] gcov: more cleanup Wei Liu
2016-09-02 11:47 ` [PATCH 1/5] xen: add tainted state and show warning is gcov is enabled Wei Liu
2016-09-02 11:56   ` Jan Beulich
2016-09-02 12:01     ` Wei Liu
2016-09-02 12:06       ` Jan Beulich
2016-09-02 12:13         ` Andrew Cooper
2016-09-02 12:26           ` Jan Beulich
2016-09-02 12:30             ` Andrew Cooper
2016-09-02 13:34               ` Wei Liu
2016-09-02 13:21       ` Julien Grall
2016-09-02 13:34         ` Wei Liu
2016-09-02 11:47 ` [PATCH 2/5] gcov: collect more sections to constructor list Wei Liu
2016-09-02 11:58   ` Jan Beulich
2016-09-02 12:12     ` Wei Liu
2016-09-05 10:10   ` Julien Grall
2016-09-02 11:47 ` [PATCH 3/5] xen: replace TEST_COVERAGE with CONFIG_GCOV Wei Liu
2016-09-02 11:59   ` Jan Beulich
2016-09-19 14:30   ` Ian Jackson
2016-09-02 11:47 ` [PATCH 4/5] gcov: add option to determine gcov format Wei Liu
2016-09-02 12:01   ` Jan Beulich
2016-09-02 12:08     ` Wei Liu
2016-09-02 15:43       ` Wei Liu
2016-09-06  8:34   ` Wei Liu
2016-09-02 11:47 ` Wei Liu [this message]
2016-09-02 12:04 ` [PATCH 0/5] gcov: more cleanup Andrew Cooper
2016-09-02 12:06   ` Wei Liu
2016-09-02 12:15     ` Andrew Cooper

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1472816829-15551-6-git-send-email-wei.liu2@citrix.com \
    --to=wei.liu2@citrix.com \
    --cc=George.Dunlap@eu.citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=jbeulich@suse.com \
    --cc=sstabellini@kernel.org \
    --cc=tim@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.