This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
How to modify GCC so to insert some code for debug?
- From: John <kkxkkx at gmail dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Fri, 23 Mar 2007 21:38:05 +0800
- Subject: How to modify GCC so to insert some code for debug?
Hi,
I use GCC to compile the code that runs in a very resouse-limited embed system,
so I can't use the usual debug tools, such as GDB. And there are thousands of
lagacy code already, in which there is no debug code, sth like
PRINT(__FILE__, __LINE__).
So I want to modify the GCC to meet the requirement below:
1. In each funtion entry and exit, print out some info, such as the
funtion name, time, etc.
2. Before each loop(for/while/until) and branch selection, print out
the condition info.
For exmaple:
for(i = ...) while(j < ...), if(i > ...), print out the value of i.
3. More advanced, when a variable is accessed, its value is printed.
Like the watch command in GDB.
Could some gurus give me some suggestions? Such as is there a project
aimed at this? How long/difficult
does it take if I make it from scratch?
Thanks,
John