tags:

views:

64

answers:

1

We have recently downloaded, installed and compiled gcc-3.0.4 code. gcc compiler has built successfully and we where able to compile some same test cpp file. I would like to know how we can modify gcc source code so that we add additional run time debugging statements like the binary in execution compiled by my gcc should print below statement in a log file:

filename.cpp::FunctionName#linenumber-statement

or any additional information that I can insert via this tailored compiler code Any references would be highly appreciable.

+2  A: 

Have you looked at the macros __FILE__ and __LINE__? They do that for you without modifying the compiler. See here for more information.

My general understand of the GCC architecture is, that it is divided into front-end (parser), middle (optimization in a special intermediate language), and a back-end (generating platform dependent output). So, for your purposes you would have to look into the back-end part.

Space_C0wb0y
I am trying to exercise how we can modify gcc code to our requirement. Inserting macros will be painful as we have todo across hundreds of file. How can we modify gcc source code so that gcc compiler injects some additional data into binary which can be harvested when is executed.
Prakash
Added some more info after your comment. I do not know too much about this, but hopefully it gives you a starting-point.
Space_C0wb0y
Is there any book that describes how we can code gcc and avail functionality like gcov build within
Prakash
Sorry, I cannot help you there.
Space_C0wb0y
Any idea how does code coverage tools / testing tools implement their functionality. Please have a look at the BullsEye testing tool - Bullseye Testing Technology, debugging and profiling tool - valgrind etc probably could be a few in the list.
Prakash