gdb: "No symbol table is loaded" gdb: "No symbol table is loaded" c c

gdb: "No symbol table is loaded"


You have to add extra parameter -g, which generates source level debug information. It will look like:

gcc -g prog.c

After that you can use gdb in common way.


First of all, what you have is a fully compiled program, not an object file, so drop the .o extension. Now, pay attention to what the error message says, it tells you exactly how to fix your problem: "No symbol table is loaded. Use the "file" command."

(gdb) exec-file test(gdb) b 2No symbol table is loaded.  Use the "file" command.(gdb) file testReading symbols from /home/user/test/test...done.(gdb) b 2Breakpoint 1 at 0x80483ea: file test.c, line 2.(gdb) 

Or just pass the program on the command line.

$ gdb testGNU gdb (GDB) 7.4Copyright (C) 2012 Free Software Foundation, Inc.License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>[...]Reading symbols from /home/user/test/test...done.(gdb) b 2Breakpoint 1 at 0x80483ea: file test.c, line 2.(gdb) 


I have the same problem and I followed this Post, it solved my problem.

Follow the following 2 steps:

  1. Make sure the optimization level is -O0
  2. Add -ggdb flag when compiling your program

Good luck!