system: Add gcov command
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
0e9946956a
commit
385603666b
29
system/gcov/Kconfig
Normal file
29
system/gcov/Kconfig
Normal file
@ -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
|
23
system/gcov/Make.defs
Normal file
23
system/gcov/Make.defs
Normal file
@ -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
|
29
system/gcov/Makefile
Normal file
29
system/gcov/Makefile
Normal file
@ -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
|
82
system/gcov/gcov.c
Normal file
82
system/gcov/gcov.c
Normal file
@ -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 <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/****************************************************************************
|
||||
* 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;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user