All, dbx has a feature called 'trace' where it outputs your program execution, a line at a time, and I've found it very useful for debugging/figuring out programs (you run it once, make a change, run it again, and do a diff to see exactly how your change affects the programming run).
However, it is exceedingly slow - as is the analogue in gdb - so I've written a very ugly hack in perl that basically does the same thing by instrumenting the source code with macros to print out each step. So: int main() { fprintf(stderr, "HERE"); } becomes: int main() __pl1({) __pf1(fprintf(stderr, "HERE");); __pf1(}) where each macro calls a hook to print out the text inside of it, after mirroring it for the compiler, (ie: the above expands to:): int main() { fprintf(log, "{\n"); fprintf(stderr, "HERE"); fprintf(log, "fprintf(stderr, \"HERE\");\n"); fprintf(log, "}\n"); } This works - it is incredibly fast, and you can basically debug any size application this way - but it is horrendously ugly, doesn't work seamlessly and requires a lot of elbow grease (macros in particular are a real pain). What I'd prefer is a compiler flag that does basically the same thing, ie: puts hooks in the code such that after each step, a special, user defined function is called which takes as an argument the relevant source code that is to be executed (and whether or not a subroutine is being exited or entered), and lets the user do whatever they want with it. Would this be possible to do with changes to gcc? If so, what would be involved? I'm assuming the file and line information are already stored inside the executable when '-g' is run, how easy would it be to make gcc create an executable that runs a user specified function on each step given this input? Thanks, Ed