gcc (GCC) 4.6.0 GNU gdb (GDB) Fedora (7.2.90.20110525-38.fc15)
I recently had a problem when I was trying to debug my problem using gdb. When I loaded my binary the gdb complained "No debugging symbols were found"
So when I did the following:
nm ass1
I got the following output (only sample)
00000000006026e0 t __init_array_end
00000000006026d0 t __init_array_start
00000000004020e0 T __libc_csu_fini
0000000000402050 T __libc_csu_init
U __libc_start_main@@GLIBC_2.2.5
00000000006029ec A _edata
0000000000602b28 A _end
000000000040212c T _fini
0000000000401420 T _init
0000000000401610 T _start
U atoi@@GLIBC_2.2.5
000000000040163c t call_gmon_start
0000000000602b10 b completed.5886
00000000006029e8 W data_start
0000000000602b18 b dtor_idx.5888
00000000004016d0 t frame_dummy
00000000004016f4 T main
The problem was I forgot to add the -g. So I decided to compile with -g and ran nm again. I got a simliar output, this contains the debug symbols as I used -g, and gdb didn't complain this time:
U __libc_start_main@@GLIBC_2.2.5
00000000006029ec A _edata
0000000000602b28 A _end
000000000040212c T _fini
0000000000401420 T _init
0000000000401610 T _start
U atoi@@GLIBC_2.2.5
000000000040163c t call_gmon_start
0000000000602b10 b completed.5886
00000000006029e8 W data_start
0000000000602b18 b dtor_idx.5888
00000000004016d0 t frame_dummy
00000000004016f4 T main
w pthread_cancel
Apart from the binary being bigger in size. I could notice any different using nm. I am wondering what should I be looking for? What do the debug symbols look like?
Many thanks for any suggestions,
nm
hides the debug symbols by default. Use the -a
option to show them.
Modern systems often don't use debug symbols per se. The stabs
debug format was developed for use with a.out
format executables, which can only represent a limited amount of internal structure; this led to hiding quite a lot of stuff in the symbol table, such as the debug symbols and initializers/constructors. The COFF (now mostly obsolete) and ELF file formats allow the use of arbitrary sections, and most modern Linux distributions configure gcc
to use DWARF 2 debugging information. You should be able to use GNU objdump to examine that information.
(I don't appear to have access to a machine whose binutils
will generate stabs
or the GNU stabs+
format, so I'll defer to Google for the details.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With