Wireshark-dev: Re: [Wireshark-dev] code coverage measurement for a dissector?
From: Németh Márton <[email protected]>
Date: Wed, 02 Jan 2008 21:20:03 +0100
Stephen Fisher wrote:
> On Tue, Jan 01, 2008 at 11:37:30PM +0100, Németh Márton wrote:
> 
>> I would like to write some tests for my dissector. To check how far I 
>> could cover my dissector code I could use the "--coverage" option of 
>> the gcc (see 
>> http://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html#index-coverage-375 
>> ).
>>
>> Where do I have to put the "--coverage" option?
> 
> Set the environment variable CFLAGS to "--coverage" and re-run the 
> configure script then rebuild Wireshark with make (see ./configure 
> --help for more details).
> 
>> Will this work together with Wireshark?
> 
> Not sure - this is the first I have heard of that gcc option.  Try it 
> out and let us know how it went.

Bad news: the make process was not able to finish, here is the error:

[...]
mkdir .libs
rm -f .libs/wireshark.nm .libs/wireshark.nmS .libs/wireshark.nmT
creating .libs/wiresharkS.c
(cd .libs && gcc  --coverage -c -fno-builtin "wiresharkS.c")
rm -f .libs/wiresharkS.c .libs/wireshark.nm .libs/wireshark.nmS .libs/wireshark.nmT
gcc -DINET6 "-D_U_=__attribute__((unused))" --coverage -Wall -W -Wdeclaration-after-statement -Wendif-label
s -Wpointer-arith -Wno-pointer-sign -I/usr/local/include -pthread -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0
/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/us
r/lib/glib-2.0/include -I/usr/include/freetype2 -I/usr/include/libpng12 -I/home/nmarci/usr/local/libpcap/in
clude -o .libs/wireshark capture-pcap-util-unix.o capture_errs.o capture-pcap-util.o capture_ui_utils.o cfi
le.o clopts_common.o disabled_protos.o packet-range.o print.o ps.o sync_pipe_write.o timestats.o util.o ver
sion_info.o airpcap_loader.o alert_box.o capture.o capture_info.o capture_opts.o capture_sync.o color_filte
rs.o file.o fileset.o filters.o g711.o merge.o proto_hier_stats.o summary.o tempfile.o .libs/wiresharkS.o -
pthread -DINET6 "-D_U_=__attribute__((unused))" --coverage -Wall -W -Wdeclaration-after-statement -Wendif-l
abels -Wpointer-arith -Wno-pointer-sign -I/usr/local/include -pthread -I/usr/include/gtk-2.0 -I/usr/lib/gtk
-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -
I/usr/lib/glib-2.0/include -I/usr/include/freetype2 -I/usr/include/libpng12 -I/home/nmarci/usr/local/libpca
p/include -Wl,--export-dynamic  -L/usr/local/lib -L/home/nmarci/usr/local/libpcap/lib gtk/libui.a codecs/li
bcodec.a wiretap/.libs/libwiretap.so epan/.libs/libwireshark.so -lpcap /usr/lib/libgtk-x11-2.0.so /usr/lib/
libgdk-x11-2.0.so /usr/lib/libatk-1.0.so /usr/lib/libgdk_pixbuf-2.0.so -lm /usr/lib/libpangocairo-1.0.so -l
fontconfig -lXext -lXrender -lXinerama -lXi -lXrandr -lXcursor -lXcomposite -lXdamage /usr/lib/libpango-1.0
.so /usr/lib/libcairo.so -lX11 -lXfixes /usr/lib/libgobject-2.0.so /usr/lib/libgmodule-2.0.so -ldl /usr/lib
/libgthread-2.0.so -lrt /usr/lib/libglib-2.0.so -L/usr/lib -lkrb5 -lk5crypto -lcom_err /usr/lib/libgcrypt.s
o /usr/lib/libgnutls.so -lz -Wl,--rpath -Wl,/home/nmarci/usr/local/wireshark/lib
/usr/bin/ld: .libs/wireshark: hidden symbol `__gcov_init' in /usr/lib/gcc/i486-linux-gnu/4.2.3/libgcov.a(_g
cov.o) is referenced by DSO
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: ld returned 1 exit status
make[2]: *** [wireshark] Error 1
make[2]: Leaving directory `/home/nmarci/src/wireshark/wireshark'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/nmarci/src/wireshark/wireshark'
make: *** [all] Error 2


Any idea how to fix this?

I am using the following GCC version:
$ gcc --version
gcc (GCC) 4.2.3 20071014 (prerelease) (Debian 4.2.2-3)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


	Márton Németh