[Skiboot] [PATCH 04/11] Enable SKIBOOT_GCOV build option for building with profiling

Stewart Smith stewart at linux.vnet.ibm.com
Thu May 7 17:11:43 AEST 2015


Enable build options for building skiboot with GCOV profiling,
including a skeleton -lgcov replacement in the form of core/gcov-profiling.c

We don't actually have to do anything as part of the gcov routines,
gcov auto generates everything we need.

Signed-off-by: Stewart Smith <stewart at linux.vnet.ibm.com>
---
 Makefile.main         |    4 +++
 core/Makefile.inc     |    6 ++++
 core/gcov-profiling.c |   76 +++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 86 insertions(+)
 create mode 100644 core/gcov-profiling.c

diff --git a/Makefile.main b/Makefile.main
index cf41a22..bd03ff4 100644
--- a/Makefile.main
+++ b/Makefile.main
@@ -52,6 +52,10 @@ CPPFLAGS += -ffreestanding
 
 CFLAGS := -fno-strict-aliasing -fstack-protector-all -pie -mbig-endian -m64
 
+ifeq ($(SKIBOOT_GCOV),1)
+CFLAGS += -fprofile-arcs -ftest-coverage
+endif
+
 ifeq ($(STACK_CHECK),1)
 CFLAGS += -fstack-protector-all -pg
 CPPFLAGS += -DSTACK_CHECK_ENABLED
diff --git a/core/Makefile.inc b/core/Makefile.inc
index 5f5fe04..d808cc9 100644
--- a/core/Makefile.inc
+++ b/core/Makefile.inc
@@ -8,9 +8,15 @@ CORE_OBJS += device.o exceptions.o trace.o affinity.o vpd.o
 CORE_OBJS += hostservices.o platform.o nvram.o hmi.o
 CORE_OBJS += console-log.o ipmi.o time-utils.o pel.o pool.o errorlog.o
 CORE_OBJS += timer.o i2c.o rtc.o flash.o sensor.o
+
+ifeq ($(SKIBOOT_GCOV),1)
+CORE_OBJS += gcov-profiling.o
+endif
+
 CORE=core/built-in.o
 
 CFLAGS_SKIP_core/relocate.o = -pg -fstack-protector-all
 CFLAGS_SKIP_core/relocate.o += -fstack-protector -fstack-protector-strong
+CFLAGS_SKIP_core/relocate.o += -fprofile-arcs -ftest-coverage
 
 $(CORE): $(CORE_OBJS:%=core/%)
diff --git a/core/gcov-profiling.c b/core/gcov-profiling.c
new file mode 100644
index 0000000..453ae7f
--- /dev/null
+++ b/core/gcov-profiling.c
@@ -0,0 +1,76 @@
+/* Copyright 2013-2014 IBM Corp.
+ *
+ * Licensed 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 <compiler.h>
+
+typedef long gcov_type;
+
+void __gcov_init(void* f) __attrconst;
+void __gcov_flush(void) __attrconst;
+void __gcov_merge_add(gcov_type *counters, unsigned int n_counters) __attrconst;
+void __gcov_merge_single(gcov_type *counters, unsigned int n_counters) __attrconst;
+void __gcov_merge_delta(gcov_type *counters, unsigned int n_counters) __attrconst;
+void __gcov_merge_ior(gcov_type *counters, unsigned int n_counters) __attrconst;
+void __gcov_merge_time_profile(gcov_type *counters, unsigned int n_counters) __attrconst;
+
+void __gcov_init(void* f)
+{
+	(void)f;
+
+	return;
+}
+
+void __gcov_merge_add(gcov_type *counters, unsigned int n_counters)
+{
+	(void)counters;
+	(void)n_counters;
+
+	return;
+}
+
+void __gcov_flush(void)
+{
+	return;
+}
+
+void __gcov_merge_single(gcov_type *counters, unsigned int n_counters)
+{
+	(void)counters;
+	(void)n_counters;
+
+	return;
+}
+
+void __gcov_merge_delta(gcov_type *counters, unsigned int n_counters)
+{
+	(void)counters;
+	(void)n_counters;
+
+	return;
+}
+
+void __gcov_merge_ior(gcov_type *counters, unsigned int n_counters)
+{
+	(void)counters;
+	(void)n_counters;
+	return;
+}
+
+void __gcov_merge_time_profile(gcov_type *counters, unsigned int n_counters)
+{
+	(void)counters;
+	(void)n_counters;
+}
-- 
1.7.10.4



More information about the Skiboot mailing list