I am trying to debug a C/MPI library that I have built. All objects are compiled using GCC and -ggdb, they are also linked using -ggdb.

When I try to attach a gdb session to the process with the -p PID flag from a standard shell, I have no problems. I can debug and access all source file info.

However, when I invoke a GDB session in Emacs 24.3.1, GDB reports that it cannot load my shared library:

 warning: Could not load shared library symbols for ./libllg.so.

I noticed that Emacs called GDB with the flag -i=mi is this causing the problem?

Everything is exactly the same, the symbol is found from a normal bash shell but not from the emacs GDB implementation. Any ideas?

  • Does your shell configuration file have any customizatins of where shared libraries are stored? Like LD_LIBRARY_PATH? If so, Emacs may not be loading your configuration and you would need to do that yourself, for example via (setenv "LD_LIBRARY_PATH" ...). – wvxvw Apr 17 '15 at 11:57
  • Given that it says "./libllg.so", I would suspect that the pwd differs and that this makes a difference. – Tom Tromey Apr 18 '15 at 1:53
  • Did you try running gdb by doing: C-U M-x gdb ? That way you can pass your own flag, including the -p PID. Also did you try with gud-gdb? – xmonk Apr 18 '15 at 14:06
  • Thanks for the suggestions. @wvxvw you were right it was an issue with the library path. – oLas May 7 '15 at 14:06
up vote 0 down vote accepted

As suggested in the comments, this was an issue with my LD_LIBRARY_PATH, which contained a relative path.

Emacs GDB launches with the working directory equal to that of the buffer you are in when you call the file.

That means that in order to load a library from ./ I had to make sure that I was in that directory when launching the debugger. The shared library was then loaded correctly.

Your Answer

 
discard

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.