wyb2ug
Last Updated: July 28, 2017
·
31.56K
· JoeyButler

How fix the "No symbol table is loaded." gdb issue on Mountain Lion

When attempting to debug a C program on Mountain Lion you may encounter the "No symbol table is loaded.".

Let's say we have a hello_world program, when we attempt to debug with gdb like the following:

$ gdb hello_world
(gdb) break 5
No symbol table is loaded.  Use the "file" command.

Hmm, okay it didn't take. Hopefully gdb's feedback will work.

(gdb) file hello_world
Load new symbol table from "/Users/you/c/hello_world"? (y or n) 

Then we enter "y" to load in the symbol table.

Reading symbols from /Users/you/c/hello_world...done.

We attempt to set the breakpoint again.

(gdb) break 5
No symbol table is loaded.  Use the "file" command.

Weaksauce, following gdb's advice didn't help.

Turns out we need to specify an option when compiling our program, -ggdb should get us what we need. The full command for our example looks like gcc hello_world.c -o hello_world -ggdb.

Now when we set a breakpoint we should see the following.

$ gdb hello_world
(gdb) break 72
Breakpoint 1 at 0x100000de5: file hello_word.c, line 5.

Woot, we can now debug our program! Hopefully this saved you some time and frustration. For more info on what debugging options that gcc supports look at the docs at gcc.gnu.org.

4 Responses
Add your response

14156

If the modification time of your symbol file has changed since the last time gdb read its
symbols, gdb discards its symbol table, and reads it again. When it does this, gdb tries to
retain your current breakpoints.

you can try: (gdb) start

The ‘start’ command does the equivalent of setting a temporary breakpoint
at the beginning of the main procedure and then invoking the ‘run’ command.

over 1 year ago ·
17018

thank you soo much

over 1 year ago ·
21215

Thank you a lot. -rupanu

over 1 year ago ·
29140

Thanks, its very helpful!!

over 1 year ago ·