Using GCC's code coverage tool, gcov, with udev
+Leann Ogasawara <ogasawara@osdl.org>, April 2004
+
################################################
For more information on using gcov please see:
- Make sure you've installed udev and that it is working properly.
If you are having problems, refer to the README and HOWTO-udev_for_dev
- documents in udev tarball. I've also compiled a udev_for_dev
- toubleshooting document for Red Hat which can be found in:
-
- docs/rh_udev_for_dev.txt
+ documents in udev tarball.
- execute make_gcov.sh from udev top level directory
- ./make_gcov.sh
+ make gcov-all
This will compile udev with gcov support. Basically make_gcov.sh will
run make but override the CFLAGS. It strips any optimization from
also add the -fprofile-arcs and -ftest-coverage options which are the
necessary flags needed to use gcov.
- make_gcov.sh will assume the same default parameters as the regular
- make but also accepts the same parameters. For example if you want
- to get code coverage analysis for udev with the DEBUG flag turned
- on, you would just execute:
-
- ./make_gcov.sh DEBUG=true
-
- There is one exception, gcov will not work with klibc as it does not
- compile cleanly with the -fprofile-arcs and -ftest-coverage flags.
- With this said it is pretty much useless to set the KERNEL_DIR flag
- when using make_gcov.sh as well.
-
- Don't be alarmed if you look into your udev directory and see that it
- has been polluted with a bunch of *.bb, *.bbg, *.da, and *.gcov files.
- gcov creates and uses these files to extract the code coverage info.
+ If you look into your udev directory and see that it has been polluted with
+ a bunch of *.gcno, *.gcda and *.gcov files. gcov creates and uses these files
+ to extract the code coverage info.
- After running make_gcov.sh you need to install udev again. So basically,
level directory. You need to be root to do this.
su to root
- ./run_gcov.sh
+ make udev_gcov.txt
- This creates udev_gcov.txt in the udev top level directory which holds all
the code coverage information. To see an example of the code coverage info
was never hit during execution.
- Once you are done with using gcov for udev and want to return to your
- normal use of udev. Simply,
-
- ./make_gcov.sh clean
+ normal use of udev, run a regular 'make clean' on your udev directory.
+ Then just run a regular make and make install and you are back to normal:
- This will clean out all the *.bb, *.bbg, *.da, *.gcov files produced by gcov.
- It will also run a regular make clean on your udev directory. Then just run
- a regular make and make install and you are back to normal:
-
- make
+ make clean all
su to root
- make isntall
+ make install