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/