2

Before each debugging cycle I have to run gdbserver on remote target (Linux). So I was thinking to make script that would call python program that would connect over ssh and would run gdbserver.

I cant find any options to run command before debug and I also try to change .gdbinit file but I am unable tu run python script whit that. Since I am using crosscompiler I cant to get other gdb whit such support.

Luka Rahne
  • 10,041
  • 3
  • 31
  • 56

3 Answers3

1

If you can't get any external program called from your gdbinit, I see one way of doing it within Eclipse that might work (I didn't tested) but it is not really straightforward...

  • Create an External Tool configuration that launches your gdbserver program (Python or whatever command line script)
  • Create a C/C++ application launcher that launch your application to debug
  • Create a launch group that will call the two previously configured configurations.
  • Launch the group in debug mode
AndyG
  • 38,029
  • 8
  • 100
  • 134
greydet
  • 5,399
  • 3
  • 30
  • 51
1

You don't need to run Python to invoke an external command from GDB. This (in .gdbinit) should work:

shell ssh remote-host gdbserver :12345 /path/to/binary/on/remote &
target remote remote-host:12345

If you do need more complicated ssh setup and need Python for that, you can certainly get it with

shell python your_script.py
Employed Russian
  • 182,696
  • 29
  • 267
  • 329
0

Eclipse 4.7.0 can connect to SSH and launch gdbserver automatically with the automatic launcher set when creating a new debug connection, without the need for any custom scripts.

I have explained the setup in great detail at: Remote debugging C++ applications with Eclipse CDT/RSE/RDT