1

I am trying to debug an application on a remote environment. Ofcourse running Tramp over gdb works as in https://www.gnu.org/software/emacs/manual/html_node/tramp/Remote-processes.html, but you miss out on source code linking. The frame/stacktrace buffer for example... now you can't click on a frame and go to source code on host machine.

[Host] (Source code) -> compiled binary -> scp binary to remote -> Debug On Remote.

So I tried making gdbserver work. Firstly I made both versions of gdb/gdbserver on both host and remote machine same. 8.3 latest. Now running from terminal:

In Terminal Remote:

$ cd /path/to/folder/
$ gdbserver --multi :44421 

gdbserver starts listening. Also tried entire exercise with gdbserver --no-shell-on-startup --multi :44421 but it results in same thing.

In Host machine TERMINAL:

$ gdb /file/to/executable
gdb> target extended-remote <remote>:44421
gdb> set remote exec-file ./executable
gdb> set args -c config.xml
gdb> r

^This works as expected. Or atleast it starts and i am able to get debug output.

BUT In emacs GBD mode it doesn't work: In HOST machine. EMACS:

M-x gdb RET gdb -i=mi /file/to/executable
gdb> target extended-remote <remote>:44421
gdb> set remote exec-file ./executable
gdb> set args -c config.xml
gdb> r

^This doesn't work. I get output: In Remote Machine:

$ gdbserver...
...
/bin/sh: /path/to/executable/folder/executable: No such file or directory
...

How do I solve this?

  • Emacs: 26.3
  • GDB: 8.3
  • Both machines are centos 7.
  • Using spacemacs develop branch as emacs frontend.

Since I do frequently copy executable from host to remote, I do want gdbserver to simply run forever, hence the --multi <port> use case. And I can do k from gdb when i need to copy the binary over.

1

I made this work by passing argument when launching gdb.

M-x gdb RET gdb -i=mi -ex "target extended-remote <remote>:44421" -ex "set remote exec-file ./executable" --args "-c config.xml"

Then in gdb launched i also had to set set non-stop off.

I ran gdbserver as gdbserver --multi :44421 in the folder on remote where executable was.

It worked. But the emacs bug exists though.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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