Message ID | 20171109111349.95800-6-roger.pau@citrix.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Thu, Nov 09, 2017 at 11:13:45AM +0000, Roger Pau Monne wrote: > 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> > --- > 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> Reviewed-by: 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> > --- > Changes since v1: > - Use private coverage.h header. > - Sort alphabetically the obj-y list. > --- > xen/common/coverage/Makefile | 2 +- > xen/common/coverage/coverage.c | 73 ++++++++++++++++++++++++++++++++++++++++++ > xen/common/coverage/coverage.h | 1 + > xen/common/coverage/gcov.c | 39 +--------------------- > 4 files changed, 76 insertions(+), 39 deletions(-) > create mode 100644 xen/common/coverage/coverage.c > > diff --git a/xen/common/coverage/Makefile b/xen/common/coverage/Makefile > index a7a48494ca..5387bc6429 100644 > --- a/xen/common/coverage/Makefile > +++ b/xen/common/coverage/Makefile > @@ -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 > index 0000000000..bd90f28663 > --- /dev/null > +++ b/xen/common/coverage/coverage.c > @@ -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: > + */ > diff --git a/xen/common/coverage/coverage.h b/xen/common/coverage/coverage.h > index 4613d5e6c1..003bb76950 100644 > --- a/xen/common/coverage/coverage.h > +++ b/xen/common/coverage/coverage.h > @@ -8,5 +8,6 @@ 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 > diff --git a/xen/common/coverage/gcov.c b/xen/common/coverage/gcov.c > index 8627ef3355..3cc98728bf 100644 > --- a/xen/common/coverage/gcov.c > +++ b/xen/common/coverage/gcov.c > @@ -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 > -- > 2.13.6 (Apple Git-96) > > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xen.org > https://lists.xen.org/xen-devel
diff --git a/xen/common/coverage/Makefile b/xen/common/coverage/Makefile index a7a48494ca..5387bc6429 100644 --- a/xen/common/coverage/Makefile +++ b/xen/common/coverage/Makefile @@ -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 index 0000000000..bd90f28663 --- /dev/null +++ b/xen/common/coverage/coverage.c @@ -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: + */ diff --git a/xen/common/coverage/coverage.h b/xen/common/coverage/coverage.h index 4613d5e6c1..003bb76950 100644 --- a/xen/common/coverage/coverage.h +++ b/xen/common/coverage/coverage.h @@ -8,5 +8,6 @@ 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 diff --git a/xen/common/coverage/gcov.c b/xen/common/coverage/gcov.c index 8627ef3355..3cc98728bf 100644 --- a/xen/common/coverage/gcov.c +++ b/xen/common/coverage/gcov.c @@ -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
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> --- 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> --- Changes since v1: - Use private coverage.h header. - Sort alphabetically the obj-y list. --- xen/common/coverage/Makefile | 2 +- xen/common/coverage/coverage.c | 73 ++++++++++++++++++++++++++++++++++++++++++ xen/common/coverage/coverage.h | 1 + xen/common/coverage/gcov.c | 39 +--------------------- 4 files changed, 76 insertions(+), 39 deletions(-) create mode 100644 xen/common/coverage/coverage.c