SConstruct.... gcov on V8

202 views
Skip to first unread message

Nipu...@gmail.com

unread,
Dec 14, 2008, 9:39:36 PM12/14/08
to v8-users
Hi

I was planning to use gcov for showing coverage using the tests
provided in V8 source code repository for a project I am doing. I was
wondering if someone could help me out? I need to change
configurations in the SConstruct file. The following arguments are
required for executing gcov.

// The source files need to be compiled with the following arguments
gcc -fprofile-arcs -ftest-coverage

and linked with -lgcov argument.....

Could someone tell me what arguments do i need change in the
Sconstruct file to add these arguments.

Thanks
Nipun Arora
Research Student
Columbia University

PS. I would also appreciate if someone could direct me to instructions
on running the test cases, and any prerequisites for that... is there
any page with the testing documentation?

Søren Gjesse

unread,
Dec 15, 2008, 2:39:57 AM12/15/08
to v8-u...@googlegroups.com
Hi,

All the flags for the different configurations are in the SConstruct file. There are different sections of flags, and the ones you are interested in are probably LIBRARY_FLAGS, CCTEST_EXTRA_FLAGS and SAMPLE_FLAGS. What is in LIBRARY_FLAGS is used to build the V8 library. CCTEST_EXTRA_FLAGS are used to build and link the cctest executable used to run all the tests written in C++. SAMPLE_FLAGS are used to build and link the shell sample used to run all the tests written in JavaScript.

You should think of adding a new flag to the SCons build to control this (e.g scons coverage=on). Look for the SIMPLE_OPTIONS definition in the SConstruct file, and see how the flags are used to control the compiler and linker options.

When looking at coverage you should think of including the Mozilla tests. See http://code.google.com/p/v8/wiki/Testing for how to run them.

Please share your findings when done.

Regards,
Søren

Nipu...@gmail.com

unread,
Dec 15, 2008, 4:15:22 AM12/15/08
to v8-users
Hi Soren

Thanks for the quick response. This is the problem I am having. I am
probably missing out putting my coverage option some place.
Although most of the files are being executed with the-fprofile-arcs -
ftest-coverage option. Some of the files are not: each g++ option
should be executed with these options: -fprofile-arcs -ftest-coverage

I can't find them in the output given by Scons starting from the
following lines....
g++ -o shell obj/sample/shell/release/shell.o -L. -lv8 -lpthread
obj/sample/shell/release/shell.o: In function `global constructors
keyed to 0_main':
shell.cc:(.text+0x2c06): undefined reference to `__gcov_init'
obj/sample/shell/release/shell.o:(.data+0x204): undefined reference to
`__gcov_merge_add'
./libv8.a(api.o): In function `global constructors keyed to
0__ZN2v88internal2V823FatalProcessOutOfMemoryEPKc':
api.cc:(.text+0x293ab): undefined reference to `__gcov_init'

This is resulting in a build error.

Could you help me out? I have my flags set in all the 3 u mentioned
earlier. which flags are used for these shells and libv8.a?

Thanks
Nipun

On Dec 15, 2:39 am, Søren Gjesse <sgje...@chromium.org> wrote:
> Hi,
>
> All the flags for the different configurations are in the SConstruct file.
> There are different sections of flags, and the ones you are interested in
> are probably LIBRARY_FLAGS, CCTEST_EXTRA_FLAGS and SAMPLE_FLAGS. What is
> in LIBRARY_FLAGS is used to build the V8 library. CCTEST_EXTRA_FLAGS are
> used to build and link the cctest executable used to run all the tests
> written in C++. SAMPLE_FLAGS are used to build and link the shell sample
> used to run all the tests written in JavaScript.
> You should think of adding a new flag to the SCons build to control
> this (e.g scons coverage=on). Look for the SIMPLE_OPTIONS definition in the
> SConstruct file, and see how the flags are used to control the compiler and
> linker options.
>
> When looking at coverage you should think of including the Mozilla tests.
> Seehttp://code.google.com/p/v8/wiki/Testingfor how to run them.
>
> Please share your findings when done.
>
> Regards,
> Søren
>

Nipu...@gmail.com

unread,
Dec 15, 2008, 4:15:38 AM12/15/08
to v8-users
Hi Soren

Thanks for the quick response. This is the problem I am having. I am
probably missing out putting my coverage option some place.
Although most of the files are being executed with the-fprofile-arcs -
ftest-coverage option. Some of the files are not: each g++ option
should be executed with these options: -fprofile-arcs -ftest-coverage

I can't find them in the output given by Scons starting from the
following lines....
g++ -o shell obj/sample/shell/release/shell.o -L. -lv8 -lpthread
obj/sample/shell/release/shell.o: In function `global constructors
keyed to 0_main':
shell.cc:(.text+0x2c06): undefined reference to `__gcov_init'
obj/sample/shell/release/shell.o:(.data+0x204): undefined reference to
`__gcov_merge_add'
./libv8.a(api.o): In function `global constructors keyed to
0__ZN2v88internal2V823FatalProcessOutOfMemoryEPKc':
api.cc:(.text+0x293ab): undefined reference to `__gcov_init'

This is resulting in a build error.

Could you help me out? I have my flags set in all the 3 u mentioned
earlier. which flags are used for these shells and libv8.a?

Thanks
Nipun

On Dec 15, 2:39 am, Søren Gjesse <sgje...@chromium.org> wrote:
> Hi,
>
> All the flags for the different configurations are in the SConstruct file.
> There are different sections of flags, and the ones you are interested in
> are probably LIBRARY_FLAGS, CCTEST_EXTRA_FLAGS and SAMPLE_FLAGS. What is
> in LIBRARY_FLAGS is used to build the V8 library. CCTEST_EXTRA_FLAGS are
> used to build and link the cctest executable used to run all the tests
> written in C++. SAMPLE_FLAGS are used to build and link the shell sample
> used to run all the tests written in JavaScript.
> You should think of adding a new flag to the SCons build to control
> this (e.g scons coverage=on). Look for the SIMPLE_OPTIONS definition in the
> SConstruct file, and see how the flags are used to control the compiler and
> linker options.
>
> When looking at coverage you should think of including the Mozilla tests.
> Seehttp://code.google.com/p/v8/wiki/Testingfor how to run them.
>
> Please share your findings when done.
>
> Regards,
> Søren
>

Nipu...@gmail.com

unread,
Dec 15, 2008, 4:21:37 AM12/15/08
to v8-users
also there are 2 types of files generated for gcov these are .gcno
while compiling and .gcda while running the tests.
I already have .gcno compile time files... the problem is that a
linker flag is not set some place...

-Nipun
> > Seehttp://code.google.com/p/v8/wiki/Testingforhow to run them.

Nipu...@gmail.com

unread,
Dec 15, 2008, 4:21:49 AM12/15/08
to v8-users
also there are 2 types of files generated for gcov these are .gcno
while compiling and .gcda while running the tests.
I already have .gcno compile time files... the problem is that a
linker flag is not set some place...

-Nipun

On Dec 15, 4:15 am, Nipun2...@gmail.com wrote:
> > Seehttp://code.google.com/p/v8/wiki/Testingforhow to run them.

Nipu...@gmail.com

unread,
Dec 15, 2008, 4:33:34 AM12/15/08
to v8-users
also there are 2 types of files generated for gcov these are .gcno
while compiling and .gcda while running the tests.
I already have .gcno compile time files... the problem is that a
linker flag is not set some place...

-Nipun

On Dec 15, 4:15 am, Nipun2...@gmail.com wrote:
> > Seehttp://code.google.com/p/v8/wiki/Testingforhow to run them.

Søren Gjesse

unread,
Dec 15, 2008, 4:50:48 AM12/15/08
to v8-u...@googlegroups.com
Hi,

It looks like it is the SAMPLE_FLAGS which are missing the options. Applying the patch below caused my building of the sample shell (scons sample=shell) to do

  g++ -o obj/sample/shell/release/shell.o -c -fprofile-arcs -ftest-coverage -O2 -m32 -Iinclude samples/shell.cc
  g++ -o shell -m32 obj/sample/shell/release/shell.o -L. -lv8 -lpthread -lgcov

===================================================================
--- SConstruct  (revision 947)
+++ SConstruct  (working copy)
@@ -198,7 +198,8 @@
   },
   'gcc': {
     'all': {
-      'LIBS': ['pthread'],
+      'CCFLAGS': ['-fprofile-arcs', '-ftest-coverage'],
+      'LIBS': ['pthread', 'gcov'],
       'LIBPATH': ['.']
     },
     'os:freebsd': {

Regards,
Søren

Nipu...@gmail.com

unread,
Dec 17, 2008, 6:05:37 AM12/17/08
to v8-users
Hi,

I tried this and it works, gcda files are being generated.

Could you tell me if when the Scons is executed are all gcc compile
commands executed from the same directory from where the Scons file
is. Essentially gcov must be called from the same directory as it
mantains traces of relative paths to source files and object files

Thanks
Nipun

On Dec 15, 4:50 am, Søren Gjesse <sgje...@chromium.org> wrote:
> Hi,
>
> It looks like it is the SAMPLE_FLAGS which are missing the options. Applying
> the patch below caused my building of the sample shell (scons sample=shell)
> to do
>
>   g++ -o obj/sample/shell/release/shell.o -c -fprofile-arcs
> -ftest-coverage-O2 -m32 -Iinclude samples/shell.cc
>   g++ -o shell -m32 obj/sample/shell/release/shell.o -L. -lv8 -lpthread
> -lgcov
>
> ===================================================================
> --- SConstruct  (revision 947)
> +++ SConstruct  (working copy)
> @@ -198,7 +198,8 @@
>    },
>    'gcc': {
>      'all': {
> -      'LIBS': ['pthread'],
> +      'CCFLAGS': ['-fprofile-arcs', '-ftest-coverage'],
> +      'LIBS': ['pthread', 'gcov'],
>        'LIBPATH': ['.']
>      },
>      'os:freebsd': {
>
> Regards,Søren
>
> > > > Seehttp://code.google.com/p/v8/wiki/Testingforhowto run them.

Søren Gjesse

unread,
Dec 17, 2008, 6:58:17 AM12/17/08
to v8-u...@googlegroups.com
When the SCons build is running the current directory is the directory where scons is executed. This can be overridden using the -C option which changes current directory before searching for the SConstruct file.

Regards,
Søren
Reply all
Reply to author
Forward
0 new messages