Sean McBride | 16 Aug 18:50 2010

clang and code coverage?

Hi all,

Is there any way to measure code coverage when using clang?

The gcov docs say: "gcov works only on code compiled with GCC."  Is this
true of code built by clang?  Or does clang's "GCC compatibility" design
goal extend to this situation?  If not, does/will the llvm project
include a replacement for gcov?

I'd like to be able to generate something not unlike what clang's own
webpage shows of clang's tests:

<http://test.minormatter.com/~ddunbar/clang-cov/>

Cheers,

--

-- 
____________________________________________________________
Sean McBride, B. Eng                 sean@...
Rogue Research                        www.rogue-research.com 
Mac Software Developer              Montréal, Québec, Canada
Douglas Gregor | 16 Aug 19:19 2010
Picon

Re: clang and code coverage?


On Aug 16, 2010, at 9:50 AM, Sean McBride wrote:

> Hi all,
> 
> Is there any way to measure code coverage when using clang?
> 
> The gcov docs say: "gcov works only on code compiled with GCC."  Is this
> true of code built by clang?  Or does clang's "GCC compatibility" design
> goal extend to this situation?  If not, does/will the llvm project
> include a replacement for gcov?

Neither Clang nor LLVM have the ability to generate coverage code for gcov. I do not know of any replacements
in the works.

	- Doug
Shawn Erickson | 18 Aug 02:48 2010
Picon

Re: clang and code coverage?

On Mon, Aug 16, 2010 at 10:19 AM, Douglas Gregor <dgregor@...> wrote:
>
> On Aug 16, 2010, at 9:50 AM, Sean McBride wrote:
>
>> Hi all,
>>
>> Is there any way to measure code coverage when using clang?
>>
>
> Neither Clang nor LLVM have the ability to generate coverage code for gcov. I do not know of any
replacements in the works.

This was something I was starting to seriously think about working on
in support of clang/llvm. At a high-level was thinking of focusing on
tracking function call coverage and branch coverage, not so much
source line code coverage. Wasn't thinking about attempting to
leverage gcov for this.

The problem is getting enough time to get my head around clang/llvm to
get this rolling.

-Shawn
Sean McBride | 30 Aug 21:27 2010

Re: clang and code coverage?

On Mon, 16 Aug 2010 10:19:04 -0700, Douglas Gregor said:

>> Is there any way to measure code coverage when using clang?
>> 
>> The gcov docs say: "gcov works only on code compiled with GCC."  Is this
>> true of code built by clang?  Or does clang's "GCC compatibility" design
>> goal extend to this situation?  If not, does/will the llvm project
>> include a replacement for gcov?
>
>Neither Clang nor LLVM have the ability to generate coverage code for
>gcov. I do not know of any replacements in the works.

Thanks Doug for your reply.

Is there a bug for this?  I searched but could not find one.  I filed
<rdar://problem/8107317> after WWDC10 but I'd like to have a bug in the
public llvm.org database too.

As more and more Objective-C features _require_ clang[1], Mac developers
will be forced to choose between these nice new features and being able
to measure code coverage.  I'm not looking forward to that choice. :(

[1] <http://www.mcubedsw.com/blog/index.php/site/comments/new_objective-
c_features/>

Cheers,

--

-- 
____________________________________________________________
Sean McBride, B. Eng                 sean@...
(Continue reading)

Douglas Gregor | 30 Aug 22:16 2010
Picon

Re: clang and code coverage?


On Aug 30, 2010, at 12:27 PM, Sean McBride wrote:

> On Mon, 16 Aug 2010 10:19:04 -0700, Douglas Gregor said:
> 
>>> Is there any way to measure code coverage when using clang?
>>> 
>>> The gcov docs say: "gcov works only on code compiled with GCC."  Is this
>>> true of code built by clang?  Or does clang's "GCC compatibility" design
>>> goal extend to this situation?  If not, does/will the llvm project
>>> include a replacement for gcov?
>> 
>> Neither Clang nor LLVM have the ability to generate coverage code for
>> gcov. I do not know of any replacements in the works.
> 
> Thanks Doug for your reply.
> 
> Is there a bug for this?  I searched but could not find one.  I filed
> <rdar://problem/8107317> after WWDC10 but I'd like to have a bug in the
> public llvm.org database too.

I don't see a bug in Bugzilla for it. 

> As more and more Objective-C features _require_ clang[1], Mac developers
> will be forced to choose between these nice new features and being able
> to measure code coverage.  I'm not looking forward to that choice. :(

The Radar is a way to prod Apple toward implementing this feature, but anyone can do it: implementing
gcov-style coverage should be relatively easy in Clang.

(Continue reading)

Sean McBride | 30 Aug 23:14 2010

Re: clang and code coverage?

On Mon, 30 Aug 2010 13:16:48 -0700, Douglas Gregor said:

>I don't see a bug in Bugzilla for it. 

<http://llvm.org/bugs/show_bug.cgi?id=8030>

Cheers,

--

-- 
____________________________________________________________
Sean McBride, B. Eng                 sean@...
Rogue Research                        www.rogue-research.com 
Mac Software Developer              Montréal, Québec, Canada
Christopher Jefferson | 16 Aug 21:56 2010
Picon

Re: clang and code coverage?


On 16 Aug 2010, at 17:50, Sean McBride wrote:

> Hi all,
> 
> Is there any way to measure code coverage when using clang?

I have used callgrind, which comes with valgrind, to do code coverage with gcc. While I haven't tried it with
clang, it makes use of debugging information so I assume it would work.

Chris

> 
> The gcov docs say: "gcov works only on code compiled with GCC."  Is this
> true of code built by clang?  Or does clang's "GCC compatibility" design
> goal extend to this situation?  If not, does/will the llvm project
> include a replacement for gcov?
> 
> I'd like to be able to generate something not unlike what clang's own
> webpage shows of clang's tests:
> 
> <http://test.minormatter.com/~ddunbar/clang-cov/>
> 
> Cheers,
> 
> -- 
> ____________________________________________________________
> Sean McBride, B. Eng                 sean@...
> Rogue Research                        www.rogue-research.com 
> Mac Software Developer              Montréal, Québec, Canada
(Continue reading)


Gmane