LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Tracing C program (https://www.linuxquestions.org/questions/programming-9/tracing-c-program-637736/)

neutrino17 04-25-2008 05:58 AM

Tracing C program
 
The idea is to automatically modify C source (or maybe binary) so it would print the source code line as soon as it is about to execute with maximum possible info about values of particular variables, arguments to functions, addresses and etc. Yet it should run as in normal mode (w/o debugging) and should not break for example on receiving signal as gdb does. Can I somehow do that?

duryodhan 04-25-2008 08:13 AM

Yet it should run as in normal mode (w/o debugging)

w/o the debugging symbols .. there is no way you can print line no. etc. thats for sure.

Other than that, I really don't have much of an idea.

marquardl 04-25-2008 09:24 AM

__file__
 
GCC has some built-in macros like __FILE__ and similar to print debugging info using printf statements. I have used this sometimes to print information, though I do nothave examples available right now. Have a look at the GCC documentation. I don't think this is portable among compilers.

Linux

graemef 04-25-2008 06:33 PM

would you also like it to automatically fix any bugs that it comes across?


All times are GMT -5. The time now is 09:22 AM.