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 Dec 8 '14 at 17:32
  • 1
    Passing via arguments is recommended in the manual: gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.69/… – npostavs Mar 18 '15 at 21:10

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 Dec 9 '14 at 16:40
  • Why do you pass -O0? – Heinrich Hartmann Feb 15 at 13:14
  • -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. – jobevers Feb 19 at 20:26

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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