From d37ab454d4ea702df276a66d4e0ea9f73d4f6fe0 Mon Sep 17 00:00:00 2001 From: Stefan Reinauer Date: Tue, 18 Dec 2012 16:23:28 -0800 Subject: Implement GCC code coverage analysis In order to provide some insight on what code is executed during coreboot's run time and how well our test scenarios work, this adds code coverage support to coreboot's ram stage. This should be easily adaptable for payloads, and maybe even romstage. See http://gcc.gnu.org/onlinedocs/gcc/Gcov.html for more information. To instrument coreboot, select CONFIG_COVERAGE ("Code coverage support") in Kconfig, and recompile coreboot. coreboot will then store its code coverage information into CBMEM, if possible. Then, run "cbmem -CV" as root on the target system running the instrumented coreboot binary. This will create a whole bunch of .gcda files that contain coverage information. Tar them up, copy them to your build system machine, and untar them. Then you can use your favorite coverage utility (gcov, lcov, ...) to visualize code coverage. For a sneak peak of what will expect you, please take a look at http://www.coreboot.org/~stepan/coreboot-coverage/ Change-Id: Ib287d8309878a1f5c4be770c38b1bc0bb3aa6ec7 Signed-off-by: Stefan Reinauer Reviewed-on: http://review.coreboot.org/2052 Tested-by: build bot (Jenkins) Reviewed-by: David Hendricks Reviewed-by: Martin Roth Reviewed-by: Ronald G. Minnich --- src/include/cbmem.h | 1 + src/include/coverage.h | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 src/include/coverage.h (limited to 'src/include') diff --git a/src/include/cbmem.h b/src/include/cbmem.h index 21efe77b0a..08e913a855 100644 --- a/src/include/cbmem.h +++ b/src/include/cbmem.h @@ -55,6 +55,7 @@ #define CBMEM_ID_MRCDATA 0x4d524344 #define CBMEM_ID_CONSOLE 0x434f4e53 #define CBMEM_ID_ELOG 0x454c4f47 +#define CBMEM_ID_COVERAGE 0x47434f56 #define CBMEM_ID_NONE 0x00000000 #ifndef __ASSEMBLER__ diff --git a/src/include/coverage.h b/src/include/coverage.h new file mode 100644 index 0000000000..e1c50c5ee9 --- /dev/null +++ b/src/include/coverage.h @@ -0,0 +1,21 @@ +/* + * This file is part of the coreboot project. + * + * Copyright (C) 2012 Google, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * 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, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA + */ + +void coverage_init(void); +void coverage_exit(void); -- cgit v1.2.3