0

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?

4
  • 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, 2015 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, 2015 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, 2015 at 14:06
  • Thanks for the suggestions. @wvxvw you were right it was an issue with the library path.
    – oLas
    May 7, 2015 at 14:06

1 Answer 1

1

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.

1
  • Had a similar problem. Fixed by running cd / which effectively turned all relative paths into absolute ones.
    – andyn
    Jan 30, 2019 at 12:59

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.