Can use local source files in a different directory while I use gdb over ssh in emacs?

396 views Asked by At

I have a 32-bit desktop, where my copy of emacs is running.

I'd like to be able to debug a program running on a very stripped down qemu 64 bit virtual machine.

The virtual machine has an ssh port 24054, which gives me passwordless root access, and it does have gdb installed.

And it has the directory which my desktop calls ~/myco/chip_test mounted as /9p

So if I make a hello.c file in ~/myco/chip_test, then go to the 64 bit machine in which the VM will run, and compile it with:

$ gcc -o hello -g hello.c

then start the virtual machine, and on my 32-bit desktop run

$ ssh -p 24054 root@anvil 'cd /9p && gdb ./hello'

Then gdb runs perfectly in command line mode in a window on my desktop.

So now of course I want it to run under emacs, because the command line gdb is a bit hard to read, and I'd like to see my cursor stepping through the file, and have windows with watch variables and so on.

So I try M-x gdb Run gdb(like this): ssh -p 24054 root@anvil cd /9p && gdb --annotate=3 ./hello

And I get a debugger window up in emacs and everything looks right, in fact I can even set and remove breakpoints by clicking in the fringe of the ~/myco/chip_test/hello.c file in my local emacs, which is the same file as what gdb sees as /9p/hello.c, but the moving cursor doesn't appear or move around, so the whole thing is fairly useless.

So I think that emacs/Gud doesn't quite realise that ~/myco/chip_test/hello.c is the file that the debugger thinks is /9p/hello.c, although obviously something interesting is happening since I can set breakpoints, and so I wonder if there is a way to get one or another programs in the loop to translate the filenames so that everything just works.

Any ideas, or am I just going about this all wrong?

1

There are 1 answers

0
Employed Russian On BEST ANSWER

You'll get much better results if you either

  • mount /home/<user>/myco/chip_test on /home/<user>/myco/chip_test in the VM (so the source paths match exactly), or
  • run gdbserver in the VM, and connect local GDB to it.