GDB Debug Symbols

Debugging symbols or Debug Symbol Table are necessary information of symbols present in binary executable required by gdb for debugging. Without debug symbols gdb doesn't know which address in binary executable is mapped to which function/variable of source code. So gdb can't set breakpoint/watchpoint on function/variable unless debugging symbol information is provided.
Debug symbol table is like dictionary which gives following information about symbols present in executable.

  • Address mapped to symbol ( e.g. address of variable or function )
  • Type of symbol ( e.g. data type of variable )
  • File name where symbol is defined
  • Line number in file where symbol is defined

Why debugging symbols are needed?
As explained above, debug symbols are key information related to all symbols ( e.g. function, variable ) of program. It is mapping binary program with source code. So debug symbols are necessary to debug program by referring source code. 
For any language debugger, debug symbols are useful and necessary information.

What message gdb gives if no debugging symbols provided in binary executable?
If loaded executable file in gdb doesn't contain any debugging symbols,
it will display message (no debugging symbols found)
This means executable file is not having any debug symbols, so you won't be able to refer functions and variables by its names for debugging purpose.

How to generate debugging symbols?
As mentioned in step 1 of how to use gdb, by compiling program with -g option in gcc or g++, it will generate debugging symbol information embedded in binary executable output.

Few important points about debugging symbols.

  • Debugging symbols information varies from one build version to other build of your program.
  • Each time you make change in program, you should regenerate debugging symbols.
  • It is advisable not to generate debugging symbols for Production release of your program, as it may increase size of your program and  slow down program performance.

Thats all about gdb debugging symbols!