How do you add debugging information to an executable .out file?

In a Linux system, I used the terminal to create an executable file of a .c file.

However, I now require to add debugging information to said executable file. Any way to help me out here? Thanks.


You would need to recompile the executable with the appropriate flag(s) - the basic compiler flag to add debug symbols with gcc and g++ is -g:

   -g  Produce debugging information in the operating system's native
       format (stabs, COFF, XCOFF, or DWARF).  GDB can work with this
       debugging information.

If you're using the clang compiler there are some additional options:

   -g, -gline-tables-only, -gmodules

Read the relevant manual pages (man gcc, man clang) for more information.