Skip to contentSkip to conversation

NO .gcda files ERROR while running LCOV for LTP coverage

LTP [email protected] 3 participants 3 messages Jul 14, 2014

Subsystems (8)
lore
Share & tools
lore
#0 lore raw

From 228323627c7c16296839bcfb643f9977201073d1 Mon Sep 17 00:00:00 2001
Date: Wed, 9 Apr 2014 16:23:58 +0530
Subject: [PATCH] GCOV enabled for ARM

arch/arm/boot/Makefile +1 -1
index bedc651..33826d9 100644
@@ -14,7 +14,8 @@
 ifneq ($(MACHINE),)
 include $(srctree)/$(MACHINE)/Makefile.boot
 endif
-
 
+GCOV_PROFILE := n
 # Note: the following conditions must always be true:
 #   ZRELADDR == virt_to_phys(PAGE_OFFSET + TEXT_OFFSET)

# PARAMS_PHYS must be within 4MB of ZRELADDR

arch/arm/boot/bootp/Makefile +1 -0
index c394e30..99c5201 100644
@@ -4,6 +4,7 @@
 # This file is included by the global makefile so that you can add your own
 # architecture-specific flags and dependencies.
 #
+GCOV_PROFILE        := n
 
 LDFLAGS_bootp	:=-p --no-undefined -X \
 		 --defsym initrd_phys=$(INITRD_PHYS) \
arch/arm/boot/compressed/Makefile +1 -2
index 5cad8a6..74eecc2 100644
@@ -20,12 +20,10 @@ ifeq ($(CONFIG_ZBOOT_ROM_SH_MOBILE_SDHI),y)
 OBJS		+= sdhi-shmobile.o
 OBJS		+= sdhi-sh7372.o
 endif
-
 AFLAGS_head.o += -DTEXT_OFFSET=$(TEXT_OFFSET)
 HEAD	= head.o
 OBJS	+= misc.o decompress.o
 FONTC	= $(srctree)/drivers/video/console/font_acorn_8x8.c
-
 # string library code (-Os is enforced to keep it much smaller)
 OBJS		+= string.o
 CFLAGS_string.o	:= -Os
@@ -33,6 +31,7 @@ CFLAGS_string.o	:= -Os
 ifeq ($(CONFIG_ARM_VIRT_EXT),y)
 OBJS		+= hyp-stub.o
 endif
+GCOV_PROFILE                := n
 
 #
 # Architecture dependencies
arch/arm/boot/dts/Makefile +2 -0
index 9da016f..2cfb87a 100644
@@ -1,3 +1,6 @@
+
+GCOV_PROFILE := n
 ifeq ($(CONFIG_OF),y)
 
 # Keep at91 dtb files sorted alphabetically for each SoC
arch/arm/configs/omap2plus_defconfig +6 -1
index d322dec..52b85d9 100644
@@ -168,7 +168,12 @@ CONFIG_CLONE_BACKWARDS=y
 
 #
 # GCOV-based kernel profiling
-#
+CONFIG_GCOV_KERNEL=y
+CONFIG_GCOV_PROFILE_ALL=y
+CONFIG_GCOV_FORMAT_AUTODETECT=y
+CONFIG_GCOV_FORMAT_4_7=y
+CONFIG_GCOV_PROC=y
+
 # CONFIG_GCOV_KERNEL is not set
 CONFIG_HAVE_GENERIC_DMA_COHERENT=y
 CONFIG_SLABINFO=y
arch/arm/include/asm/elf.h +1 -0
index 38050b1..40c3cfe 100644
@@ -52,6 +52,7 @@ typedef struct user_fp elf_fpregset_t;
 #define R_ARM_ABS32		2
 #define R_ARM_CALL		28
 #define R_ARM_JUMP24		29
+#define R_ARM_TARGET1           38 
 #define R_ARM_V4BX		40
 #define R_ARM_PREL31		42
 #define R_ARM_MOVW_ABS_NC	43
arch/arm/kernel/Makefile +1 -1
index 5bbec7b..3473137 100644
@@ -10,7 +10,9 @@ CFLAGS_REMOVE_ftrace.o = -pg
 CFLAGS_REMOVE_insn.o = -pg
 CFLAGS_REMOVE_patch.o = -pg
 endif
-
 
+GCOV_PROFILE := n
 CFLAGS_REMOVE_return_address.o = -pg
 

# Object file lists.

arch/arm/kernel/module.c +1 -0
index 1e9be5d..7172a0c 100644
@@ -89,6 +89,7 @@ apply_relocate(Elf32_Shdr *sechdrs, const char *strtab, unsigned int symindex,
 			break;
 
 		case R_ARM_ABS32:
+                case R_ARM_TARGET1:
 			*(u32 *)loc += sym->st_value;
 			break;
 
include/asm-generic/vmlinux.lds.h +1 -1
index d1ea7ce..7c5453d 100644
@@ -473,7 +473,7 @@
 #ifdef CONFIG_CONSTRUCTORS
 #define KERNEL_CTORS()	. = ALIGN(8);			   \
 			VMLINUX_SYMBOL(__ctors_start) = .; \
-			*(.ctors)			   \
+			*(CONFIG_CONSTRUCTORS_NAME)	   \
 			VMLINUX_SYMBOL(__ctors_end) = .;
 #else
 #define KERNEL_CTORS()
init/Kconfig +6 -0
index be8b7f5..fc665f9 100644
@@ -20,6 +20,12 @@ config CONSTRUCTORS
 	bool
 	depends on !UML
 
+config CONSTRUCTORS_NAME
+        string
+        depends on CONSTRUCTORS
+        default ".init_array" if ARM && AEABI
+        default ".ctors" 
+
 config HAVE_IRQ_WORK
 	bool
 
kernel/gcov/Kconfig +31 -1
index a920281..cf66c5c 100644
@@ -35,7 +35,7 @@ config GCOV_KERNEL
 config GCOV_PROFILE_ALL
 	bool "Profile entire Kernel"
 	depends on GCOV_KERNEL
-	depends on SUPERH || S390 || X86 || (PPC && EXPERIMENTAL) || MICROBLAZE
+	depends on SUPERH || S390 || X86 || PPC || MICROBLAZE || ARM
 	default n
 	---help---
 	This options activates profiling for the entire kernel.
@@ -46,4 +46,34 @@ config GCOV_PROFILE_ALL
 	larger and run slower. Also be sure to exclude files from profiling
 	which are not linked to the kernel image to prevent linker errors.
 
+choice
+	prompt "Specify GCOV format"
+	depends on GCOV_KERNEL
+	default GCOV_FORMAT_AUTODETECT
+	---help---
+	The gcov format is usually determined by the GCC version, but there are
+	exceptions where format changes are integrated in lower-version GCCs.
+	In such a case use this option to adjust the format used in the kernel
+	accordingly.
+
+	If unsure, choose "Autodetect".
+
+config GCOV_FORMAT_AUTODETECT
+	bool "Autodetect"
+	---help---
+	Select this option to use the format that corresponds to your GCC
+	version.
+
+config GCOV_FORMAT_3_4
+	bool "GCC 3.4 format"
+	---help---
+	Select this option to use the format defined by GCC 3.4.
+
+config GCOV_FORMAT_4_7
+	bool "GCC 4.7 format"
+	---help---
+	Select this option to use the format defined by GCC 4.7.
+
+endchoice
+
 endmenu
kernel/gcov/Makefile +31 -1
index e97ca59..52aa7e8 100644
@@ -1,3 +1,33 @@
 ccflags-y := -DSRCTREE='"$(srctree)"' -DOBJTREE='"$(objtree)"'
 
-obj-$(CONFIG_GCOV_KERNEL) := base.o fs.o gcc_3_4.o
+# if-lt
+# Usage VAR := $(call if-lt, $(a), $(b))
+# Returns 1 if (a < b)
+if-lt = $(shell [ $(1) -lt $(2) ] && echo 1)
+
+ifeq ($(CONFIG_GCOV_FORMAT_3_4),y)
+  cc-ver := 0304
+else ifeq ($(CONFIG_GCOV_FORMAT_4_7),y)
+  cc-ver := 0407
+else
+# Use cc-version if available, otherwise set 0
+#
+# scripts/Kbuild.include, which contains cc-version function, is not included
+# during make clean "make -f scripts/Makefile.clean obj=kernel/gcov"
+# Meaning cc-ver is empty causing if-lt test to fail with
+# "/bin/sh: line 0: [: -lt: unary operator expected" error mesage.
+# This has no affect on the clean phase, but the error message could be
+# confusing/annoying. So this dummy workaround sets cc-ver to zero if cc-version
+# is not available. We can probably move if-lt to Kbuild.include, so it's also
+# not defined during clean or to include Kbuild.include in
+# scripts/Makefile.clean. But the following workaround seems least invasive.
+  cc-ver := $(if $(call cc-version),$(call cc-version),0)
+endif
+
+obj-$(CONFIG_GCOV_KERNEL) := base.o fs.o
+
+ifeq ($(call if-lt, $(cc-ver), 0407),1)
+  obj-$(CONFIG_GCOV_KERNEL) += gcc_3_4.o
+else
+  obj-$(CONFIG_GCOV_KERNEL) += gcc_4_7.o
+endif
kernel/gcov/base.c +18 -14
index 9b22d03..f45b75b 100644
@@ -20,7 +20,6 @@
 #include <linux/mutex.h>
 #include "gcov.h"
 
-static struct gcov_info *gcov_info_head;
 static int gcov_events_enabled;
 static DEFINE_MUTEX(gcov_lock);
 
@@ -34,7 +33,7 @@ void __gcov_init(struct gcov_info *info)
 
 	mutex_lock(&gcov_lock);
 	if (gcov_version == 0) {
-		gcov_version = info->version;
+		gcov_version = gcov_info_version(info);
 		/*
 		 * Printing gcc's version magic may prove useful for debugging
 		 * incompatibility reports.
@@ -45,8 +44,7 @@ void __gcov_init(struct gcov_info *info)
 	 * Add new profiling data structure to list and inform event
 	 * listener.
 	 */
-	info->next = gcov_info_head;
-	gcov_info_head = info;
+	gcov_info_link(info);
 	if (gcov_events_enabled)
 		gcov_event(GCOV_ADD, info);
 	mutex_unlock(&gcov_lock);
@@ -81,6 +79,12 @@ void __gcov_merge_delta(gcov_type *counters, unsigned int n_counters)
 }
 EXPORT_SYMBOL(__gcov_merge_delta);
 
+void __gcov_merge_ior(gcov_type *counters, unsigned int n_counters)
+{
+	/* Unused. */
+}
+EXPORT_SYMBOL(__gcov_merge_ior);
+
 /**
  * gcov_enable_events - enable event reporting through gcov_event()
  *
@@ -91,13 +95,15 @@ EXPORT_SYMBOL(__gcov_merge_delta);
  */
 void gcov_enable_events(void)
 {
-	struct gcov_info *info;
+	struct gcov_info *info = NULL;
 
 	mutex_lock(&gcov_lock);
 	gcov_events_enabled = 1;
+
 	/* Perform event callback for previously registered entries. */
-	for (info = gcov_info_head; info; info = info->next)
+	while ((info = gcov_info_next(info)))
 		gcov_event(GCOV_ADD, info);
+
 	mutex_unlock(&gcov_lock);
 }
 
@@ -112,25 +118,23 @@ static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
 				void *data)
 {
 	struct module *mod = data;
-	struct gcov_info *info;
-	struct gcov_info *prev;
+	struct gcov_info *info = NULL;
+	struct gcov_info *prev = NULL;
 
 	if (event != MODULE_STATE_GOING)
 		return NOTIFY_OK;
 	mutex_lock(&gcov_lock);
-	prev = NULL;
+
 	/* Remove entries located in module from linked list. */
-	for (info = gcov_info_head; info; info = info->next) {
+	while ((info = gcov_info_next(info))) {
 		if (within(info, mod->module_core, mod->core_size)) {
-			if (prev)
-				prev->next = info->next;
-			else
-				gcov_info_head = info->next;
+			gcov_info_unlink(prev, info);
 			if (gcov_events_enabled)
 				gcov_event(GCOV_REMOVE, info);
 		} else
 			prev = info;
 	}
+
 	mutex_unlock(&gcov_lock);
 
 	return NOTIFY_OK;
kernel/gcov/fs.c +28 -26

147 lines not on this page · raw message

kernel/gcov/gcc_3_4.c +115 -0

121 lines not on this page · raw message

kernel/gcov/gcc_4_7.c new file +560 -0

560 lines not on this page · raw message

kernel/gcov/gcov.h +11 -54

78 lines not on this page · raw message

kernel/module.c +1 -1
index eab0827..a21463c 100644
@@ -2743,7 +2743,7 @@ static void find_module_sections(struct module *mod, struct load_info *info)
 	mod->unused_gpl_crcs = section_addr(info, "__kcrctab_unused_gpl");
 #endif
 #ifdef CONFIG_CONSTRUCTORS
-	mod->ctors = section_objs(info, ".ctors",
+	mod->ctors = section_objs(info, CONFIG_CONSTRUCTORS_NAME,
 				  sizeof(*mod->ctors), &mod->num_ctors);
 #endif
 
mm/Makefile +1 -1
index 3a46287..be1305b 100644
@@ -1,7 +1,8 @@
 #
 # Makefile for the linux memory manager.
 #
-
 
+GCOV_PROFILE := n
 mmu-y			:= nommu.o
 mmu-$(CONFIG_MMU)	:= fremap.o highmem.o madvise.o memory.o mincore.o \

mlock.o mmap.o mprotect.o mremap.o msync.o rmap.o \

Signature · 1 line
1.7.9.5

------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and search up to 200,000 lines of code with a free copy of Black Duck&#174; Code Sight&#153; - the same software that powers the world's largest code search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds

_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#1 lore raw
Quoted 11 lines · On 14.07.2014 12:59, [email protected] wrote:

Kernel version: 3.8.13

I am sending this mail to get your valuable inputs regarding an issue i am facing while running LCOV as part of an LTP activity.

Currently i am working on LTP and GCOV integration on TI J6 board.

I have enabled the GCOV in kernel using attached patch.

This patch works fine for Beagle bone black with same kernel version 3.8.13 and coverage results are captured for LTP.

The attached patch looks like it's a mix of ARM-enabling parts together with an older version of the upstream version of the Linux kernel gcov patch. It might be an idea to replace those latter parts with the current upstream version (that is copy over all source files under kernel/gcov from a current upstream kernel).

Quoted 11 lines

Now in J6 i face below issue.

root@dra7xx-evm:/home/coverage# lcov -c -o coverage.info
Auto-detecting gcov kernel support.
Found upstream gcov kernel support at /sys/kernel/debug/gcov
Copying data to temporary directory /tmp/D5EuajnqI8
Capturing coverage data from /tmp/D5EuajnqI8
Found gcov version: 4.7.2
Scanning /tmp/D5EuajnqI8 for .gcda files ...
*geninfo: ERROR: no .gcda files found in /tmp/D5EuajnqI8!*
Quoted 2 lines

But when i checked /sys/kernel/debug/gcov/, i could see .gcda and .gcno files in all the kernel folders. for eg

I don't see a situation in which lcov would silently fail to copy .gcda files. Some ideas to try out:
1. Upgrade to the latest version of lcov [1]
2. Try to run gcov manually on one of the .gcda files [2]
3. Modify the lcov program to emit additional debugging output that might help in identifying the cause of the problem. For this, add the following statement as the last line of function lcov_copy_single() in the lcov program:

     print("from=$from to=$to len=".length($content)."\n");
Quoted 7 lines

ls -l /sys/kernel/debug/gcov/home/dattatraya.patil/dar7xx/board-support/linux/kernel/wait.*

-rw-------    1 root     root             0 Jan  1  1970 wait.gcda
lrwxrwxrwx    1 root     root             0 Jan  1  1970 wait.gcno ->

/home/dattatraya.patil/dar7xx/board-support/linux/kernel/.tmp_wait.gcno

Quoted 7 lines

ls -l /home/dattatraya.patil/dar7xx/board-support/linux/kernel/.tmp_wait.gcno
-rw-rw-r-- 1 1001 1003 10748 Jul 14 2014
/home/dattatraya.patil/dar7xx/board-support/linux/kernel/.tmp_wait.gcno

In /sys/kernel/debug/gcov folder, the .gcda and .gcno files looks empty with 0kb.

A size of 0kb is expected since the files in debugfs are virtual (content is only created when read from).

Quoted 1 line

can you please share your valid inputs to point out the possible issue?

Regards,
Peter Oberparleiter

[1] http://ltp.sourceforge.net/coverage/lcov.php
[2] https://www.kernel.org/doc/Documentation/gcov.txt

Signature · 14 lines
Peter Oberparleiter
Linux on System z Development - IBM Germany


------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck&#174;
Code Sight&#153; - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#2 lore raw
In reply to [email protected]

Hi!

Quoted 5 lines

<font face="arial" size="3"><p style="margin:0;padding:0;font-family: arial; font-size: 12pt;">Hi Peter/Naresh/All,</p>
<p style="margin:0;padding:0;font-family: arial; font-size: 12pt;">&nbsp;</p>
<p style="margin:0;padding:0;font-family: arial; font-size: 12pt;">Kernel version: 3.8.13</p>
<p style="margin:0;padding:0;font-family: arial; font-size: 12pt;">&nbsp;</p>
<p style="margin:0;padding:0;font-family: arial; font-size: 12pt;">I am sending this mail to get your valuable inputs regarding an issue i am facing while running LCOV as part of an LTP activity.</p>

...

Please do not send HTML emails to the list; use plain text instead.

Signature · 13 lines
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck&#174;
Code Sight&#153; - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list