0

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.
2
  • 1
    Follow the rename suggestion of Jean-Francois below. There are other commands [outside of gdb] to try: objdump, readelf -s, ldd, file to tell you about the symbols in the file [which should be present even if the debug info has been stripped]. The failure of [in gdb] of b main could have been the /usr/bin/test issue Commented Jul 2, 2016 at 20:11
  • Thanks @Craig Estey ! These tools were very helpful! Commented Jul 2, 2016 at 23:00

2 Answers 2

2

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).

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for the info! I completely forgot about dynamically linked/loaded executables (rather silly of me). Is the lack of a symbol table also a sign that my executable is dynamically linked/loaded?
Aside from the comment I just posted, I can finally do what I want with the gdb, ie use x/s and info registers, etc! Thanks to you and @Craig Estey!
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.