Run time Debugging

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.

I don't think you're going to be able to do that by modifying the compiler. This is what things like debuggers are for.

If that so then 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.

Sorry, I didn't see your reply.

They didn't need to modify gcc at all to get debug info from it. These tools understand gcc's own debugging information, which it embeds in objects and executables when given the -ggdb flag. "gdb" comes from "the GNU Debugger"; again, this is what things like debuggers are for.

If what you're trying to do is profile your app, use a profiling tool.

If you're trying to come up with some auditing mechanism whereby you can record every step your application took, don't mess with the compiler.

Why? Go look at how many bugs get filed against compilers. Now, look at who writes those compilers, and how many test cases the off-the-shelf compilers have to pass.

In other words, there are a good number of bugs, but the compilers are maintained by experts in the field AND the compilers are subject to not only the test cases the maintainers put their code through but also the testing done by everyone else using that compiler.

Now, you want to modify that compiler? How much testing are you going to put it through? Anywhere near what the standard compiler code base goes through?

And then your app is going to be completely dependent upon what's now your own private compiler?

Do you really want to mess with the application that translates your source code into machine language? How would you even know if you broke it?