diff --git a/system/gcov/Kconfig b/system/gcov/Kconfig new file mode 100644 index 000000000..6c951954d --- /dev/null +++ b/system/gcov/Kconfig @@ -0,0 +1,29 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +config SYSTEM_GCOV + tristate "gcov tool" + depends on ARCH_COVERAGE + ---help--- + Enable support for the 'gcov' command. + +if SYSTEM_GCOV + +config SYSTEM_GCOV_PROGNAME + string "gcov program name" + default "gcov" + ---help--- + This is the name of the program that will be used when the NSH ELF + program is installed. + +config SYSTEM_GCOV_PRIORITY + int "gcov task priority" + default 100 + +config SYSTEM_GCOV_STACKSIZE + int "gcov stack size" + default DEFAULT_TASK_STACKSIZE + +endif diff --git a/system/gcov/Make.defs b/system/gcov/Make.defs new file mode 100644 index 000000000..bd791d37b --- /dev/null +++ b/system/gcov/Make.defs @@ -0,0 +1,23 @@ +############################################################################ +# apps/system/gcov/Make.defs +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +############################################################################ + +ifneq ($(CONFIG_SYSTEM_GCOV),) +CONFIGURED_APPS += $(APPDIR)/system/gcov +endif diff --git a/system/gcov/Makefile b/system/gcov/Makefile new file mode 100644 index 000000000..c839707e2 --- /dev/null +++ b/system/gcov/Makefile @@ -0,0 +1,29 @@ +############################################################################ +# apps/system/gcov/Makefile +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +############################################################################ + +include $(APPDIR)/Make.defs + +PROGNAME = $(CONFIG_SYSTEM_GCOV_PROGNAME) +PRIORITY = $(CONFIG_SYSTEM_GCOV_PRIORITY) +STACKSIZE = $(CONFIG_SYSTEM_GCOV_STACKSIZE) +MODULE = $(CONFIG_SYSTEM_GCOV) +MAINSRC = gcov.c + +include $(APPDIR)/Application.mk diff --git a/system/gcov/gcov.c b/system/gcov/gcov.c new file mode 100644 index 000000000..6e8caace5 --- /dev/null +++ b/system/gcov/gcov.c @@ -0,0 +1,82 @@ +/**************************************************************************** + * apps/system/gcov/gcov.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: show_usage + ****************************************************************************/ + +static void show_usage(FAR const char *progname) +{ + printf("\nUsage: %s [-d] [-r] [-h]\n", progname); + printf("\nWhere:\n"); + printf(" -d dump the coverage.\n"); + printf(" -r reset the coverage\n"); + printf(" -h show this text and exits.\n"); +} + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +void __gcov_dump(void); +void __gcov_reset(void); + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +int main(int argc, FAR char *argv[]) +{ + int option; + + while ((option = getopt(argc, argv, "drh")) != ERROR) + { + switch (option) + { + case 'd': + __gcov_dump(); + break; + + case 'r': + __gcov_reset(); + break; + + case '?': + default: + fprintf(stderr, "ERROR: Unrecognized option\n"); + + case 'h': + show_usage(argv[0]); + } + } + + return 0; +}