Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm trying to get gcov coverage for a simple Linux driver. The driver code is very basic with just init() and exit() routines.

/*
** Module Init function
*/
static int __init hello_world_init(void)
{
    printk(KERN_INFO "Welcome to AXeno Driver
");
    printk(KERN_INFO "This is the Simple Module
");
    printk(KERN_INFO "Kernel Module Inserted Successfully...
");
    return 0;
}

/*
** Module Exit function
*/
static void __exit hello_world_exit(void)
{
    printk(KERN_INFO "Kernel Module Removed Successfully...
");
}
 
module_init(hello_world_init);
module_exit(hello_world_exit);
 
MODULE_LICENSE("GPL");
MODULE_AUTHOR("AXeno");
MODULE_DESCRIPTION("A simple hello world driver");
MODULE_VERSION("2:1.0");

I'm cross compiling this to install this on a ARM device. Here's my Makefile.

CROSS_COMPILER = aarch64-tizen-linux-gnu-
ARCH = arm64

TDIR = $(PWD)

KDIR = /home/axeno/Perforce/MAIN/ONEPROD_Prj/SOC/Soc/tester/kernel/linux-4.1.12
VDIR = /home/axeno/Perforce/MAIN/ONEPROD_Prj/SYSPLATFORM/Sysplatform/peri-drivers/vd_kernel-interfaces/include

ccflags-y += -Wall -fprofile-arcs -ftest-coverage -fPIC
GCOV_PROFILE := y
GCOV_PREFIX_testDriver.o := y

include $(KDIR)/.config

export KDIR ARCH CROSS_COMPILER TDIR CFLAGS LDFLAGS

obj-m += testDriver.o

all:
    make -C $(KDIR) M=$(PWD) $(CFLAGS) modules CROSS_COMPILE="$(CROSS_COMPILER)" 

Now when I build this, it properly creates the *.ko and the *.gcno files. Now I moved the *.ko to my target and before insmod, I set

export GCOV_PREFIX="/mnt/gcda"
export GCOV_PREFIX_STRIP=15

to write the *.gcda files to my mounted flash drive. I do insmod, rmmod everything works fine from dmesg logs.

I also compiled the target kernel using the following setup.

CONFIG_DEBUG_FS=y
CONFIG_GCOV_KERNEL=y
CONFIG_GCOV_FORMAT_AUTODETECT=y
CONFIG_ARCH_HAS_GCOV_PROFILE_ALL=n

But when I try to find the *.gcda files it defaults to /sys/kernel/debug/gcov and underneath forming the entire path structure from my host machine. The *.gcda files created do not have any information except for some 10 characters of garbage. It also creates symbolic links for *.gcno files. So it neither redirects to the $GCOV_PREFIX folder, not it produces meaningful *.gcda files. Can anyone help me find out what I'm missing?

P.S. On the same target, when I run a simple app other than driver, it works perfectly fine. It creates proper *.gcda files in the proper directory.

question from:https://stackoverflow.com/questions/65679929/only-psuedo-gcda-files-and-gcno-symlinks-are-created-when-doing-kernel-insmod

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
914 views
Welcome To Ask or Share your Answers For Others

1 Answer

Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...