]> xenbits.xensource.com Git - people/dariof/xen.git/commitdiff
coverage: introduce generic file
authorRoger Pau Monné <roger.pau@citrix.com>
Thu, 25 Jan 2018 11:30:01 +0000 (12:30 +0100)
committerJan Beulich <jbeulich@suse.com>
Thu, 25 Jan 2018 11:30:01 +0000 (12:30 +0100)
It will contain the generic implementation of sysctl_cov_op, which
will be shared between all the coverage implementations.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
xen/common/coverage/Makefile
xen/common/coverage/coverage.c [new file with mode: 0644]
xen/common/coverage/coverage.h
xen/common/coverage/gcov.c

index a7a48494caaf82367e670558670c5abd99d99513..5387bc6429c86bfbe44b7a2fdd60dc006e4b0c72 100644 (file)
@@ -1,4 +1,4 @@
-obj-y += gcov_base.o gcov.o
+obj-y += coverage.o gcov_base.o gcov.o
 obj-y += $(call cc-ifversion,lt,0x040700, \
                gcc_3_4.o, $(call cc-ifversion,lt,0x040900, \
                gcc_4_7.o, $(call cc-ifversion,lt,0x050000, \
diff --git a/xen/common/coverage/coverage.c b/xen/common/coverage/coverage.c
new file mode 100644 (file)
index 0000000..bd90f28
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * Generic functionality for coverage analysis.
+ *
+ * Copyright (C) 2017 Citrix Systems R&D
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms and conditions of the GNU General Public
+ * License, version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <xen/errno.h>
+#include <xen/guest_access.h>
+#include <xen/types.h>
+#include <xen/coverage.h>
+
+#include <public/sysctl.h>
+
+#include "coverage.h"
+
+int sysctl_cov_op(struct xen_sysctl_coverage_op *op)
+{
+    int ret;
+
+    switch ( op->cmd )
+    {
+    case XEN_SYSCTL_COVERAGE_get_size:
+        op->size = cov_ops.get_size();
+        ret = 0;
+        break;
+
+    case XEN_SYSCTL_COVERAGE_read:
+    {
+        XEN_GUEST_HANDLE_PARAM(char) buf;
+        uint32_t size = op->size;
+
+        buf = guest_handle_cast(op->buffer, char);
+
+        ret = cov_ops.dump(buf, &size);
+        op->size = size;
+
+        break;
+    }
+
+    case XEN_SYSCTL_COVERAGE_reset:
+        cov_ops.reset_counters();
+        ret = 0;
+        break;
+
+    default:
+        ret = -EOPNOTSUPP;
+        break;
+    }
+
+    return ret;
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
index 9991939b707d2f895d8fdd5b8735cd12354e0429..aa66396c085fb0ff8ba701d41a514e8484a877b5 100644 (file)
@@ -8,6 +8,7 @@ struct cov_sysctl_ops {
     void     (*reset_counters)(void);
     int      (*dump)(XEN_GUEST_HANDLE_PARAM(char), uint32_t *);
 };
+extern const struct cov_sysctl_ops cov_ops;
 
 #endif
 
index 8627ef3355c1e101d55b338c28dd1b74421adf4a..3cc98728bfcef8d1839a0ff0cbeaf4ed78ad323e 100644 (file)
@@ -210,49 +210,12 @@ static int gcov_dump_all(XEN_GUEST_HANDLE_PARAM(char) buffer,
     return ret;
 }
 
-static const struct cov_sysctl_ops cov_ops = {
+const struct cov_sysctl_ops cov_ops = {
     .get_size = gcov_get_size,
     .reset_counters = gcov_reset_all_counters,
     .dump = gcov_dump_all,
 };
 
-int sysctl_cov_op(struct xen_sysctl_coverage_op *op)
-{
-    int ret;
-
-    switch ( op->cmd )
-    {
-    case XEN_SYSCTL_COVERAGE_get_size:
-        op->size = cov_ops.get_size();
-        ret = 0;
-        break;
-
-    case XEN_SYSCTL_COVERAGE_read:
-    {
-        XEN_GUEST_HANDLE_PARAM(char) buf;
-        uint32_t size = op->size;
-
-        buf = guest_handle_cast(op->buffer, char);
-
-        ret = cov_ops.dump(buf, &size);
-        op->size = size;
-
-        break;
-    }
-
-    case XEN_SYSCTL_COVERAGE_reset:
-        cov_ops.reset_counters();
-        ret = 0;
-        break;
-
-    default:
-        ret = -EOPNOTSUPP;
-        break;
-    }
-
-    return ret;
-}
-
 /*
  * Local variables:
  * mode: C