GDB doesn't show function names

15,825

Solution 1

Ok this usually happens if debug symbols are missing... just to make sure run following commands

file <your_executable>

you will get info on your binary like format, arch etc.. last part of the info describes if the binary is stripped or not. For debugging in GDB the binary should not have been stripped.

nm --debug-sym <your_executable> | grep debug

If you have some valid prints as below it means debug symbols are present.

00000000 N .debug_abbrev
00000000 N .debug_aranges
00000000 N .debug_frame
00000000 N .debug_info
00000000 N .debug_line
00000000 N .debug_loc
00000000 N .debug_pubnames
00000000 N .debug_str

Further when you invoke GDB you should have follwing line

Reading symbols from <your_executable>...done.

At this point you should be able to list sources with list command.

Make sure both gdb and gdbserver have same versioninig.

arm-none-linux-gnueabi-gdb --version
./gdbserver --version

If all the above are true, and you still don't get backtrace, there is something bad going on with your stack. Try running some static analysis, valgrind on your code / newly added code.

Solution 2

You need to build your application with debug symbols enabled. The switch for gcc is -g

Share:
15,825
funkadelic
Author by

funkadelic

Updated on June 03, 2022

Comments

  • funkadelic
    funkadelic almost 2 years

    I am debugging from an embedded device using gdbserver:

    ./gdbserver HOST:5000 /home/test_app
    

    In my PC, I execute gdb in this way:

    arm-none-linux-gnueabi-gdb test_app
    

    Once the application is executing, I receive the Segfault I want to debug, but it's impossible to know what line produced it:

    Program received signal SIGSEGV, Segmentation fault.
    [Switching to Thread 715]
    0x31303030 in ?? ()
    (gdb) bt
    #0  0x31303030 in ?? ()
    #1  0x0000dff8 in ?? ()
    #2  0x0000dff8 in ?? ()
    Backtrace stopped: previous frame identical to this frame (corrupt stack?)
    

    (I must say I'm totally new to GDB)

    • Max Lybbert
      Max Lybbert over 12 years
      What flags did you compile with? Does GDB know where to get your source files from so it can display the line that it's stopped on?
    • Lightness Races in Orbit
      Lightness Races in Orbit over 12 years
      I don't understand. Your PC is ARM? And you don't appear to be connecting to the GDB server at all.
    • thiton
      thiton over 12 years
      Could you please post your compiler execution line and your full GDB commands? I concur with Tomalak Geret'kal that there is definitely something missing here, at least the connect to the GDB server and the command for setting the source directory.
  • thiton
    thiton over 12 years
    Which is definitely one aspect, but there is more to cross-debugging with gdbserver. The OP didn't yet post enough information to answer the question.
  • funkadelic
    funkadelic over 12 years
    I can't post now the full compilation options I used... but I used -g.
  • phil294
    phil294 almost 7 years
    I do not think this answer is true. I have found several stripped files with visible function names (but no source is reproducable)