I'm trying to build GNU binutils in debug mode as:
$ mkdir debug
$ cd debug
$ ../configure --prefix=/dbg CPPFLAGS=-DDEBUG CFLAGS="-g -O0" CXXFLAGS="-g -O0" --disable-gdb --disable-ld
$ make -j8
I debug objdump as:
$ gdb --args ./binutils/objdump.exe -D a.exe
GNU gdb (GDB) (Cygwin 12.1-1) 12.1
Reading symbols from ./binutils/objdump.exe...
(No debugging symbols found in ./binutils/objdump.exe)
Here we see that gdb found no debugging symbols. Why? The -g -O0
was specified. How to fix?
I'm on Cygwin:
$ uname -a
CYGWIN_NT-10.0-19043 xxx 3.4.6-1.x86_64 2023-02-14 13:23 UTC x86_64 Cygwin
UPD. There are actually two objdump.exe
:
$ find -name objdump.exe
./binutils/.libs/objdump.exe
./binutils/objdump.exe
If the first one is passed to gdb, then the symbols are found:
$ gdb --args ./binutils/.libs/objdump.exe -D a.exe
Reading symbols from ./binutils/.libs/objdump.exe...
These files differ in size:
$ find -name objdump.exe | xargs ls -sh
14M ./binutils/.libs/objdump.exe 24K ./binutils/objdump.exe