Reputation: 55
I have only access to a C executable (no source code/.c code) and I need to use gdb to debug it. But I keep getting a (no debugging symbols found) message. I have seen other questions similar to this but most of them suggest recompiling the source code (something I cannot do because I do not have it) or suggest the following fixes (see below), which have not worked for me.
gdb test
Reading symbols from /usr/bin/test...(no debugging symbols found)...done.
(gdb) b main
Function "main" not defined.
Make breakpoint pending on future shared library load? (y or [n]) n
(gdb) b 2
No symbol table is loaded. Use the "file" command.
(gdb) file test
Reading symbols from /usr/bin/test...(no debugging symbols found)...done.
(gdb) exec-file test
(gdb) file test
Reading symbols from /usr/bin/test...(no debugging symbols found)...done.
(gdb) b 2
No symbol table is loaded. Use the "file" command.
As a side note, I cannot break at main (strange because I can guarantee this is a C executable).
I'm new to using the gdb and incredibly lost and would really appreciate any help. Many thanks in advance!
EDIT:
As suggested by @Jean-François Fabre, I have changed the executable name to foobar but am still running into the same problems. The output above has been updated:
gdb foobar
Reading symbols from /usr/bin/foobar...(no debugging symbols found)...done.
(gdb) b main
Function "main" not defined.
Make breakpoint pending on future shared library load? (y or [n]) n
(gdb) b 2
No symbol table is loaded. Use the "file" command.
(gdb) file foobar
Reading symbols from /usr/bin/foobar...(no debugging symbols found)...done.
(gdb) exec-file foobar
(gdb) file foobar
Reading symbols from /usr/bin/foobar...(no debugging symbols found)...done.
(gdb) b 2
No symbol table is loaded. Use the "file" command.
Upvotes: 0
Views: 2093
Reputation: 510
Don't forget to add a -g
when you compile your code. for ex:
g++ main.cpp -o main -g
gcc main.c -o main -g
Upvotes: 0
Reputation: 213375
But I keep getting a (no debugging symbols found) message.
This message means that your executable has no debugging info.
I cannot break at main (strange because I can guarantee this is a C executable).
This likely means that your executable has been fully stripped (its symbol table has been removed; symbol table helps with debugging but is completely unnecessary at runtime).
I need to use gdb to debug it.
That's perfectly fine: you can still debug this executable, but only at assembly level. Without symbol table, you will only be able to set breakpoints on individual instruction addresses, not on any functions.
If your executable is dynamically linked, you should still be able to set breakpoints on external functions, such as printf
or malloc
(if your executable calls them).
Upvotes: 2