aboutsummaryrefslogtreecommitdiffstats
path: root/xen/common/gcov
diff options
context:
space:
mode:
authorFrediano Ziglio <frediano.ziglio@citrix.com>2013-02-14 12:37:14 +0000
committerKeir <keir.xen@gmail.com>2013-02-21 16:15:40 +0000
commit26c9d03dd4a7356ed697bec98fe8108a5eebd562 (patch)
treee86ed6154ac6367e4eda54d2c29303fd920289c3 /xen/common/gcov
parent68ca0bc4ba2f70d50b4c5eecbba53ce113bd8ad6 (diff)
downloadxen-26c9d03dd4a7356ed697bec98fe8108a5eebd562.tar.gz
xen-26c9d03dd4a7356ed697bec98fe8108a5eebd562.tar.bz2
xen-26c9d03dd4a7356ed697bec98fe8108a5eebd562.zip
gcov: Adding support for coverage information
This 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 excluded %.init.o files as they are used before Xen start and should not have section like .text or .data. I used a "coverage" configuration option to mimic the "debug" one. Signed-off-by: Frediano Ziglio <frediano.ziglio@citrix.com>
Diffstat (limited to 'xen/common/gcov')
-rw-r--r--xen/common/gcov/Makefile2
-rw-r--r--xen/common/gcov/gcov.c72
2 files changed, 74 insertions, 0 deletions
diff --git a/xen/common/gcov/Makefile b/xen/common/gcov/Makefile
new file mode 100644
index 0000000000..c9efe6c8a2
--- /dev/null
+++ b/xen/common/gcov/Makefile
@@ -0,0 +1,2 @@
+obj-y += gcov.o
+
diff --git a/xen/common/gcov/gcov.c b/xen/common/gcov/gcov.c
new file mode 100644
index 0000000000..4de4b58d3d
--- /dev/null
+++ b/xen/common/gcov/gcov.c
@@ -0,0 +1,72 @@
+/*
+ * This code maintains a list of active profiling data structures.
+ *
+ * Copyright IBM Corp. 2009
+ * Author(s): Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
+ *
+ * Uses gcc-internal data definitions.
+ * Based on the gcov-kernel patch by:
+ * Hubertus Franke <frankeh@us.ibm.com>
+ * Nigel Hinds <nhinds@us.ibm.com>
+ * Rajan Ravindran <rajancr@us.ibm.com>
+ * Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
+ * Paul Larson
+ */
+
+#include <xen/config.h>
+#include <xen/init.h>
+#include <xen/lib.h>
+#include <xen/hypercall.h>
+#include <xen/gcov.h>
+#include <xen/errno.h>
+
+static struct gcov_info *info_list;
+
+/*
+ * __gcov_init is called by gcc-generated constructor code for each object
+ * file compiled with -fprofile-arcs.
+ *
+ * Although this function is called only during initialization is called from
+ * a .text section which is still present after initialization so not declare
+ * as __init.
+ */
+void __gcov_init(struct gcov_info *info)
+{
+ /* add new profiling data structure to list */
+ info->next = info_list;
+ info_list = info;
+}
+
+/*
+ * These functions may be referenced by gcc-generated profiling code but serve
+ * no function for Xen.
+ */
+void __gcov_flush(void)
+{
+ /* Unused. */
+}
+
+void __gcov_merge_add(gcov_type *counters, unsigned int n_counters)
+{
+ /* Unused. */
+}
+
+void __gcov_merge_single(gcov_type *counters, unsigned int n_counters)
+{
+ /* Unused. */
+}
+
+void __gcov_merge_delta(gcov_type *counters, unsigned int n_counters)
+{
+ /* Unused. */
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-set-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */