Hi guys. i'm trying to build a software profiler in C++. What i want for now is to get a C code as input to my program, and produce a that code but added to it some stuff.
An example is getting input "x;" and putting output "x; stmt[0]++;"
This allows me to know how many times a statement in this code as been executed.
The strategy is to insert a stmt[i]++; anywhere i see a ';', but i'm afraid it won't work if i encounter a ';' found in the for loop parameters. And if i want to solve this and check if this statement ends with a new line, then place a "stmt[i]++", i'll be missing out on lines which include more than one statement such as "x; y;" (on the same line).
Can anyone suggest a possible solution? I've been thinking about it for hours, but i'm unable to solve this problem.
Thank you.