I am working with 4-5 .c files (around 2000 to 5000 lines each) which include several headers.Currently I do not have any debug prints which would help me debug the program during its course of execution.
My question is :- Is there a way (or some existing tool) to parse the .c files and add new set of print statements for all the variables in the current scope in the .c file ? Just the same way as VC++ allows us to see Locals and globals etc. I need them printed at each step. Also, pointers should be dereferenced.
For ex. lets say at one point in the .c file, there are 10 global variables and 3 locals.
I need to generate the smart printfs to print these 13 variables at that point. Later in
the program if there are 20 variables, i should be able to print the 20 variables etc.
The included header files contain all the relevant declarations for each of these
variables (which can be structures/pointers/arrays or some combinations etc etc.)
I was trying to achieve this via perl script.
What I did is, I generated the preprocessed file (.i file) and i tried parsing it via perl and then generate individual print functions specific to each variable, but after half a days' effort i realized that its just too time consuming. Is there a tool that already does that ? If not this, anything close to it should be good enough (On which i can apply some perl processing etc) My goal is that after the program execution,at each step during the program execution, I should be able to see the variables(valid at that scope) without having to invoke the debugger.
I am allowed to process the .c files and re-write them again etc. etc. Hope my question is clear and thanks for your replies.