1 /** 2 * \file gcov_support.h 3 * \brief Support helpers to use gcov for embedded targets. 4 * \author Erich Styger 5 * \copyright 6 * Web: https://mcuoneclipse.com 7 * SourceForge: https://sourceforge.net/projects/mcuoneclipse 8 * Git: https://github.com/ErichStyger/McuOnEclipse_PEx 9 * All rights reserved. 10 * 11 * Redistribution and use in source and binary forms, with or without modification, 12 * are permitted provided that the following conditions are met: 13 * 14 * - Redistributions of source code must retain the above copyright notice, this list 15 * of conditions and the following disclaimer. 16 * 17 * - Redistributions in binary form must reproduce the above copyright notice, this 18 * list of conditions and the following disclaimer in the documentation and/or 19 * other materials provided with the distribution. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 25 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 28 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 * ###################################################################*/ 32 33 #ifndef GCOV_SUPPORT_H_ 34 #define GCOV_SUPPORT_H_ 35 36 #ifndef GCOV_DO_COVERAGE 37 #define GCOV_DO_COVERAGE (1) 38 #endif 39 /*<! 1: to enable coverage; 0: to disable it */ 40 41 /* if setting the one below to 1, then it uses the standard gcov from newlib and newlib-nano. 42 * Add --coverage to the source files which shall be tested. 43 * Add --coverage to the linker flags 44 * */ 45 #define GCOV_USE_STANDARD_GCOV_LIB (1 && GCOV_DO_COVERAGE) 46 /*<! 1: using standard gcov library inside newlib/newlib nano; 0: using custom gcov library */ 47 48 /* tcov is a tiny coverage implementation, see gcov/tcov directory. It writes the internal coverage info to the console. 49 * Add --coverage to the source files which shall be tested. 50 * Do *not* add --coverage to the linker flags as tcov implements its own library 51 * */ 52 #define GCOV_USE_TCOV (0 && !GCOV_USE_STANDARD_GCOV_LIB) 53 /*<! 1: to enable tiny coverage module (do *not* add --coverage to the linker flags!); 0: to disable it */ 54 55 /* gcov is another tiny implementation of gcov, which implements the GNU gcov outside the library 56 * Add --coverage to the source files which shall be tested. 57 * Do *not* add --coverage to the linker flags as tcov implements its own library 58 * */ 59 #define GCOV_USE_GCOV_EMBEDDED (1 && !GCOV_USE_STANDARD_GCOV_LIB) 60 /*<! 1: Use libgcov-embedded port (do *not* add --coverage to the linker flags!); 0: to disable it */ 61 #define GCOV_EMBEDDED_FILE_IO (0 && GCOV_USE_GCOV_EMBEDDED) 62 /*!< 1: use semihosting file I/O, 0: use gdb commands */ 63 64 /* EXPERIMENTAL ONLY */ 65 #define GCOV_USE_GCOV_4_7 (0 && !GCOV_USE_STANDARD_GCOV_LIB) 66 /*<! 1: Use gcc 4.7 port (experimental!) (do *not* add --coverage to the linker flags!); 0: to disable it */ 67 68 #if GCOV_USE_GCOV_EMBEDDED 69 #define ENABLE_LIBGCOV_PORT (1) 70 #else 71 #define ENABLE_LIBGCOV_PORT (0) 72 #endif 73 74 /*! 75 * \brief Test function to verify file I/O needed for gcov information generation. 76 * \return 1 if file I/O does work, 0 otherwise 77 */ 78 int gcov_check(void); 79 80 /*! 81 * \brief Flush and write the coverage information collected so far 82 */ 83 void gcov_write(void); 84 85 /*! 86 * \brief Initialize the coverage information/constructors. Need to call this at the start of main(). 87 */ 88 void gcov_init(void); 89 90 #endif /* GCOV_SUPPORT_H_ */ 91