This answer is for the GNU/Linux system that I am using. I am not sure of other OS's.
You can get the name of the .c file from a.out provided you compiled it using the -g option using gcc.You can do an objdump on the a.out to show the file names of the .c files used.
I use objdump -lDf for getting the line numbers and the file names while debugging the symbols of a core dump.
Can i know the name of the source C file from a.out file?
Not sure if this is what you are asking but try something like this
printf("%s %s %s\n", __FILE__, __FUNCTION__, __LINE___);
Those three constants are defined by the compiler (gcc any way) and can be used to extract the current file name, function name, and line number of that line of code. Very useful for debugging.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment