I'm having trouble walking through emacs source code in gdb. I think I'm missing debug symbols.

Following a suggestion from https://stackoverflow.com/a/4298982/2752242, I tried:

./configure CFLAGS="-ggdb3 -O0" CXXFLAGS="-ggdb3 -O0" LDFLAGS="-ggdb3" --with-gif=no --prefix=$HOME/local/apps/emacs-24.4/

But, that didn't work.

Are there instructions on compiling with debug symbols? Thanks!

  • This is how I'm building it, if I need to debug: CFLAGS='-O0 -ggdb -g3' ./configure --enable-checking --enable-asserts. I'm not a pro, but I'm not sure you can give arguments to configure the way you did it. Usually, those come before calling the program, and configure takes those from environment it's called with, but maybe it's something new...
    – wvxvw
    Commented Dec 8, 2014 at 17:32
  • 1
    Passing via arguments is recommended in the manual: gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.69/…
    – npostavs
    Commented Mar 18, 2015 at 21:10

1 Answer 1


I was able to get line numbers in gdb if I run the emacsclient binary that is produced by make that lives in emacs/lib-src. If I do make install and try to attach a debugger to the installed binary, no line numbers.

This is what worked for me:

$ CFLAGS="-ggdb3 -O0" CXXFLAGS="-ggdb3 -O0" LDFLAGS="-ggdb3" ./configure --enable-checking --with-gif=no --prefix=$HOME/local/apps/emacs-24.4/
$ make
$ gdb lib-src/emacsclient

This doesn't work:

$ CFLAGS="-ggdb3 -O0" CXXFLAGS="-ggdb3 -O0" LDFLAGS="-ggdb3" ./configure --enable-checking --with-gif=no --prefix=$HOME/local/apps/emacs-24.4/
$ make
$ make install
$ gdb $HOME/local/apps/emacs-24.4/bin/emacsclient
  • 3
    Could very well be that the installation step invokes an utility that strips the debug symbols.
    – wasamasa
    Commented Dec 9, 2014 at 16:40
  • Why do you pass -O0? Commented Feb 15, 2018 at 13:14
  • 1
    -O0 disables optimizations. Optimizations mess up your ability to step through the code as there is no longer a mapping between the compiled code and the source file.
    – Job Evers
    Commented Feb 19, 2018 at 20:26

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.