public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* GCC GCOV
@ 2012-02-10  0:59 Satya Prakash Prasad
  2012-02-10 16:23 ` David Malcolm
  0 siblings, 1 reply; 4+ messages in thread
From: Satya Prakash Prasad @ 2012-02-10  0:59 UTC (permalink / raw)
  To: gcc

Hi All,

I am a new joinee to this group and a C/C++ developer for around 2
yrs. What interest me most is gcc / gcov combination output. It list
the code execution details.

Is there a possibility that gcc build binaries can print file
name:line number <code> of the code it is executing at run time.
Something like gcov produces after code execution but has to be in
order of execution to benefit projects build from more than one source
code unit. So can the gcov part be built by default and results be
available at runtime in sequence of execution.

Does this requires modification of gcc code - any pointers would help me a lot?

Regards,
Prakash

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: GCC GCOV
  2012-02-10  0:59 GCC GCOV Satya Prakash Prasad
@ 2012-02-10 16:23 ` David Malcolm
  2012-02-10 20:59   ` Satya Prakash Prasad
  0 siblings, 1 reply; 4+ messages in thread
From: David Malcolm @ 2012-02-10 16:23 UTC (permalink / raw)
  To: Satya Prakash Prasad; +Cc: gcc

On Thu, 2012-02-09 at 15:52 -0800, Satya Prakash Prasad wrote:
> Hi All,
> 
> I am a new joinee to this group and a C/C++ developer for around 2
> yrs. What interest me most is gcc / gcov combination output. It list
> the code execution details.
> 
> Is there a possibility that gcc build binaries can print file
> name:line number <code> of the code it is executing at run time.
> Something like gcov produces after code execution but has to be in
> order of execution to benefit projects build from more than one source
> code unit. So can the gcov part be built by default and results be
> available at runtime in sequence of execution.
> 
> Does this requires modification of gcc code - any pointers would help me a lot?

If I'm understanding you correctly, this seems like a nice feature to
have for people learning to program in C/C++, but an unacceptably high
speed cost for most other uses.  For example, it's nice to be able to
watch the order in which constructors and destructors get invoked when
learning C++.

A GCC plugin is probably the most appropriate way to implement this: you
could write a new pass that walks the gimple statements, and injects new
print statements to add the diagnostics that you want.

I would shamelessly promote my python plugin at this point [1] :) which
in theory would make doing this perhaps a 20-30 line python script, but
it doesn't yet support modifying gcc's internal representation, merely
reading it - but that could change.

Hope this is helpful
Dave

[1] https://fedorahosted.org/gcc-python-plugin/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: GCC GCOV
  2012-02-10 16:23 ` David Malcolm
@ 2012-02-10 20:59   ` Satya Prakash Prasad
  2012-02-10 21:10     ` David Malcolm
  0 siblings, 1 reply; 4+ messages in thread
From: Satya Prakash Prasad @ 2012-02-10 20:59 UTC (permalink / raw)
  To: David Malcolm; +Cc: gcc

Thanks for the info Dave. I downloaded the tar ball but facing issues
while building it:

prompt:>~/shared_scripts/bin/gcc-py-plugin/gcc-python-plugin-6f960cf 1020> make
python generate-config-h.py -o autogenerated-config.h --gcc=gcc
Traceback (most recent call last):
  File "generate-config-h.py", line 21, in <module>
    from configbuilder import ConfigBuilder
  File "/x/home/satprasad/shared_scripts/bin/gcc-py-plugin/gcc-python-plugin-6f960cf/configbuilder.py",
line 20, in <module>
    from subprocess import Popen, PIPE, check_output
ImportError: cannot import name check_output
make: *** [autogenerated-config.h] Error 1
hyper66:~/shared_scripts/bin/gcc-py-plugin/gcc-python-plugin-6f960cf 1021>

I am not that familiar with Python - can you please help me out?

Also please let me know some references on how to write a new PASS
within GCC codebase?

Regards,
Prakash


On Fri, Feb 10, 2012 at 7:58 AM, David Malcolm <dmalcolm@redhat.com> wrote:
> On Thu, 2012-02-09 at 15:52 -0800, Satya Prakash Prasad wrote:
>> Hi All,
>>
>> I am a new joinee to this group and a C/C++ developer for around 2
>> yrs. What interest me most is gcc / gcov combination output. It list
>> the code execution details.
>>
>> Is there a possibility that gcc build binaries can print file
>> name:line number <code> of the code it is executing at run time.
>> Something like gcov produces after code execution but has to be in
>> order of execution to benefit projects build from more than one source
>> code unit. So can the gcov part be built by default and results be
>> available at runtime in sequence of execution.
>>
>> Does this requires modification of gcc code - any pointers would help me a lot?
>
> If I'm understanding you correctly, this seems like a nice feature to
> have for people learning to program in C/C++, but an unacceptably high
> speed cost for most other uses.  For example, it's nice to be able to
> watch the order in which constructors and destructors get invoked when
> learning C++.
>
> A GCC plugin is probably the most appropriate way to implement this: you
> could write a new pass that walks the gimple statements, and injects new
> print statements to add the diagnostics that you want.
>
> I would shamelessly promote my python plugin at this point [1] :) which
> in theory would make doing this perhaps a 20-30 line python script, but
> it doesn't yet support modifying gcc's internal representation, merely
> reading it - but that could change.
>
> Hope this is helpful
> Dave
>
> [1] https://fedorahosted.org/gcc-python-plugin/
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: GCC GCOV
  2012-02-10 20:59   ` Satya Prakash Prasad
@ 2012-02-10 21:10     ` David Malcolm
  0 siblings, 0 replies; 4+ messages in thread
From: David Malcolm @ 2012-02-10 21:10 UTC (permalink / raw)
  To: Satya Prakash Prasad; +Cc: gcc

On Fri, 2012-02-10 at 12:14 -0800, Satya Prakash Prasad wrote:
> Thanks for the info Dave. I downloaded the tar ball but facing issues
> while building it:

This is probably more appropriate for the plugin's mailing list:
  https://fedorahosted.org/mailman/listinfo/gcc-python-plugin
rather than the general gcc list...

> ImportError: cannot import name check_output

...but to answer the question, it looks like I accidentally added a
python 2.7 requirement here [subprocess.check_output was added in 2.7]


> I am not that familiar with Python - can you please help me out?
If you're not particularly familiar with Python, then it may be easier
to write the pass directly in C.

> Also please let me know some references on how to write a new PASS
> within GCC codebase?
If you're new, it's probably easiest to do it within a plugin, see:
  http://gcc.gnu.org/wiki/plugins
  http://gcc.gnu.org/onlinedocs/gccint/Plugins.html

LWN had an excellent tutorial on creating a new gcc pass via a plugin
here: https://lwn.net/Articles/457543/   [1]


Hope this is helpful
Dave

[1] fwiw I ported the example from the tutorial to Python here:
http://gcc-python-plugin.readthedocs.org/en/latest/working-with-c.html#spell-checking-string-constants-within-source-code

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-02-10 21:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-10  0:59 GCC GCOV Satya Prakash Prasad
2012-02-10 16:23 ` David Malcolm
2012-02-10 20:59   ` Satya Prakash Prasad
2012-02-10 21:10     ` David Malcolm

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).