diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-07-15 07:35:55 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-09-06 12:49:42 +0200 |
commit | e335730967711d404fc7223904187c30696873ee (patch) | |
tree | 92feca15b63cee65a6e9849ed71a25299bb351a1 /cpukit | |
parent | 701dc5c705a3591d6c118890506b94f97ce70600 (diff) |
Add RTEMS_COVERAGE build option
Diffstat (limited to 'cpukit')
-rw-r--r-- | cpukit/include/rtems/score/io.h | 10 | ||||
-rw-r--r-- | cpukit/libtest/testextension.c | 1 | ||||
-rw-r--r-- | cpukit/libtest/wrapcpufatalhalt.c | 54 | ||||
-rw-r--r-- | cpukit/posix/src/_execve.c | 43 | ||||
-rw-r--r-- | cpukit/posix/src/fork.c | 10 | ||||
-rw-r--r-- | cpukit/score/src/iodumpgcovinfo.c | 100 |
6 files changed, 217 insertions, 1 deletions
diff --git a/cpukit/include/rtems/score/io.h b/cpukit/include/rtems/score/io.h index 5cc946bba8..e7375cf895 100644 --- a/cpukit/include/rtems/score/io.h +++ b/cpukit/include/rtems/score/io.h @@ -120,6 +120,16 @@ int _IO_Base64url( int wordlen ); +/* + * @brief Dumps the gcov info sections using _IO_Printf(). + * + * @param put_char is the put character handler used to dump the gcov info + * sections. + * + * @param arg is the argument passed to the put character handler. + */ +void _IO_Dump_gcov_info( IO_Put_char put_char, void *arg ); + /** * @brief Issues a couple of no-operation instructions. * diff --git a/cpukit/libtest/testextension.c b/cpukit/libtest/testextension.c index ee9681a847..d0a9e37b67 100644 --- a/cpukit/libtest/testextension.c +++ b/cpukit/libtest/testextension.c @@ -19,6 +19,7 @@ #include <rtems/test-info.h> #include <rtems/profiling.h> #include <rtems/bspIo.h> +#include <rtems/score/io.h> #if defined(RTEMS_PROFILING) static bool report_done; diff --git a/cpukit/libtest/wrapcpufatalhalt.c b/cpukit/libtest/wrapcpufatalhalt.c new file mode 100644 index 0000000000..0b41dc0480 --- /dev/null +++ b/cpukit/libtest/wrapcpufatalhalt.c @@ -0,0 +1,54 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSTest + * + * @brief This source file contains the implementation of a wrapper for + * _CPU_Fatal_halt() which dumps the gcov information using + * _IO_Dump_gcov_info() before the real _CPU_Fatal_halt() is called. + */ + +/* + * Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <rtems/score/cpu.h> +#include <rtems/score/io.h> +#include <rtems/bspIo.h> + +void __real__CPU_Fatal_halt( uint32_t source, CPU_Uint32ptr error ); + +void __wrap__CPU_Fatal_halt( uint32_t source, CPU_Uint32ptr error ); + +void __wrap__CPU_Fatal_halt( uint32_t source, CPU_Uint32ptr error ) +{ + _IO_Dump_gcov_info( rtems_put_char, NULL ); + __real__CPU_Fatal_halt( source, error ); +} diff --git a/cpukit/posix/src/_execve.c b/cpukit/posix/src/_execve.c index 2c8b436889..f1125f1bdf 100644 --- a/cpukit/posix/src/_execve.c +++ b/cpukit/posix/src/_execve.c @@ -28,9 +28,11 @@ */ #define _COMPILING_NEWLIB +#include <sys/unistd.h> #include <errno.h> + +#include <rtems/score/cpuopts.h> #include <rtems/seterr.h> -#include <sys/unistd.h> int _execve( const char *path, @@ -43,3 +45,42 @@ int _execve( (void) envp; rtems_set_errno_and_return_minus_one( ENOSYS ); } + +#if defined(RTEMS_COVERAGE) +int __gcov_execl( const char *path, char *arg, ... ); +int __gcov_execlp( const char *path, char *arg, ... ); +int __gcov_execle( const char *path, char *arg, ... ); +int __gcov_execv( const char *path, char *const argv[] ); +int __gcov_execvp( const char *path, char *const argv[] ); +int __gcov_execve( const char *path, char *const argv[], char *const envp[] ); + +int __gcov_execl( const char *path, char *arg, ... ) +{ + rtems_set_errno_and_return_minus_one( ENOSYS ); +} + +int __gcov_execlp( const char *path, char *arg, ... ) +{ + rtems_set_errno_and_return_minus_one( ENOSYS ); +} + +int __gcov_execle( const char *path, char *arg, ... ) +{ + rtems_set_errno_and_return_minus_one( ENOSYS ); +} + +int __gcov_execv( const char *path, char *const argv[] ) +{ + rtems_set_errno_and_return_minus_one( ENOSYS ); +} + +int __gcov_execvp( const char *path, char *const argv[] ) +{ + rtems_set_errno_and_return_minus_one( ENOSYS ); +} + +int __gcov_execve( const char *path, char *const argv[], char *const envp[] ) +{ + rtems_set_errno_and_return_minus_one( ENOSYS ); +} +#endif diff --git a/cpukit/posix/src/fork.c b/cpukit/posix/src/fork.c index 252f240515..7ef98212b8 100644 --- a/cpukit/posix/src/fork.c +++ b/cpukit/posix/src/fork.c @@ -24,9 +24,19 @@ #include <unistd.h> #include <errno.h> +#include <rtems/score/cpuopts.h> #include <rtems/seterr.h> int fork( void ) { rtems_set_errno_and_return_minus_one( ENOSYS ); } + +#if defined(RTEMS_COVERAGE) +pid_t __gcov_fork( void ); + +pid_t __gcov_fork( void ) +{ + rtems_set_errno_and_return_minus_one( ENOSYS ); +} +#endif diff --git a/cpukit/score/src/iodumpgcovinfo.c b/cpukit/score/src/iodumpgcovinfo.c new file mode 100644 index 0000000000..ecf780f9d7 --- /dev/null +++ b/cpukit/score/src/iodumpgcovinfo.c @@ -0,0 +1,100 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSScoreIO + * + * @brief This source file contains the implementation of _IO_Dump_gcov_info(). + */ + +/* + * Copyright (C) 2021 embedded brains GmbH (http://www.embedded-brains.de) + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <rtems/score/io.h> +#include <rtems/score/interr.h> +#include <rtems/linkersets.h> + +#include <gcov.h> + +RTEMS_LINKER_ROSET( gcov_info, const struct gcov_info * ); + +typedef struct { + IO_Put_char put_char; + void *arg; +} IO_Dump_gcov_context; + +static void _IO_Gcov_filename( const char *f, void *arg ) +{ + const IO_Dump_gcov_context *ctx; + + ctx = arg; + _IO_Printf( ctx->put_char, ctx->arg, "Emitting gcda bytes for %s\n", f ); +} + +static void _IO_Gcov_dump( const void *d, unsigned n, void *arg ) +{ + const IO_Dump_gcov_context *ctx; + const unsigned char *c; + unsigned i; + + ctx = arg; + c = d; + + for (i = 0; i < n; ++i) { + _IO_Printf( ctx->put_char, ctx->arg, "%02x", c[ i ] ); + } +} + +static void *_IO_Gcov_allocate( unsigned length, void *arg ) +{ + (void) length; + (void) arg; + return NULL; +} + +void _IO_Dump_gcov_info( IO_Put_char put_char, void *arg ) +{ + IO_Dump_gcov_context ctx; + const struct gcov_info * const *item; + + ctx.put_char = put_char; + ctx.arg = arg; + + RTEMS_LINKER_SET_FOREACH( gcov_info, item ) { + __gcov_info_to_gcda( + *item, + _IO_Gcov_filename, + _IO_Gcov_dump, + _IO_Gcov_allocate, + &ctx + ); + ( *put_char )( '\n', arg ); + } +} |