Thursday, November 13, 2014

using gcov/lcov with the linux kernel

Enable the following in your kernel configuration:

Build the kernel and install headers/debug/images to your machine. Note there may be issues if you run this on a separate machine so consult the official documentation for additional information [1].

Reboot the machine and use the following to see it things work:
sudo apt-get install lcov gcc
SRC_PATH=~/src/linux # or whatever your path to your kernel tree is
gcov ${SRC_PATH}/kernel/sched/core.c -o /sys/kernel/debug/gcov/${SRC_PATH}/kernel/sched/

Obviously this would be useful for quick tests, but perhaps we want to test coverage after a test, and display results graphically. We can use lcov [2] to accomplish this using the following:
# reset counters
sudo lcov --zerocounters
# run test
# generate coverage info and generate webpage
sudo lcov -c -o
sudo genhtml -o /var/www/html

1 comment:

  1. Now a days cloud based technologies are getting popular like wild fire. So as the training programs related to these technologies. Thanks for providing an useful information.

    openstack deployment tools