5

I'm trying to use some test scenarios from Linux test Project and get the Kernel source code coverage.

I'm using GCOV/LCOV to do so.

here are the things I have so far:

  • GCOV flags in the build config

GCOV-based kernel profiling

CONFIG_GCOV_KERNEL=y

CONFIG_GCOV_PROFILE_ALL=y

On Linux kernel version: 2.6.32.60+drm33.26

  • After building the kernel I have all the .gcov files in the source folder
  • GCOV/LCOV works when I use a source file as the input

Things that I should have but I don't

  • /Proc/GCOV folder
  • GCOV Kernel Module (gcov.o?)

Now what I want is to run the test scenarios and with LCOV get which portion of Linux Kernel Code has been used so far. but when I call LCOV -c this is what I get even though all the build flags are ok.

Loading required gcov kernel module.

lcov: ERROR: cannot load required gcov kernel module!

There is a kernel patch for < 2.6.30 and afterwards it is built in.

Community
  • 1
  • 1
Shayan
  • 548
  • 6
  • 24

2 Answers2

3

please read this document

http://www.mjmwired.net/kernel/Documentation/gcov.txt

Here is answer to your questions:

  1. There is no proc fs for kernel coverage. After booting from the new kenrel, you had to mount the debug-fs via command: "mount -t debugfs none /sys/kernel/debug" and read coverage log of kernel from this file

  2. Kernel coverage can not be built as module. As you see, the CONFIG option is 'Y', not 'M'

Houcheng
  • 2,674
  • 25
  • 32
  • the thing is when I run "mount -t debugfs none /sys/kernel/debug" it says that it is already mounted and when I check it after boot it is really mounted with the specific attributions, although it stays empty. – Shayan Jan 14 '13 at 16:57
  • from the default kernel of ubuntu 12.04, the debug-fs is also already mounted after booting. – Houcheng Jan 15 '13 at 05:07
3

below is my try on the ubuntu 12.04 default kernel. thought the gcov is not enabled, but the debug fs is mounted and some kvm debug inforation can be found in it.

ubuntu:/sys/kernel# mount -t debugfs none /sys/kernel/debug
mount: none already mounted or /sys/kernel/debug busy
mount: according to mtab, none is already mounted on /sys/kernel/debug
ubuntu:/sys/kernel# umount /sys/kernel/debug
ubuntu:/sys/kernel# mount -t debugfs none /sys/kernel/debug
ubuntu:/sys/kernel# ls debug
acpi  bdi  bluetooth  extfrag  gpio  hid  kprobes  kvm  mce  regmap  regulator  sched_features  suspend_stats  tracing  usb  wakeup_sources  x86
ubuntu:/sys/kernel# cat debug/kvm/
efer_reload          host_state_reload    io_exits             mmio_exits           mmu_pte_write        nmi_window           signal_exits
exits                hypercalls           irq_exits            mmu_cache_miss       mmu_recycled         pf_fixed             tlb_flush
fpu_reload           insn_emulation       irq_injections       mmu_flooded          mmu_shadow_zapped    pf_guest
halt_exits           insn_emulation_fail  irq_window           mmu_pde_zapped       mmu_unsync           remote_tlb_flush
halt_wakeup          invlpg               largepages           mmu_pte_updated      nmi_injections       request_irq
ubuntu:/sys/kernel# cat debug/kvm/io_exits
467789515
ubuntu:/sys/kernel#
Houcheng
  • 2,674
  • 25
  • 32