How to set the current working directory of the program when remote debugging with gdbserver Automatic Launcher in Eclipse CDT?

房东的猫 提交于 2020-01-06 04:50:06

问题


I tried to change it with Debug configurations > Arguments > Working directory, but that only changes the location of the host gdb.

This can be observed by either:

  • creating a test program that prints pwd
  • pwdx on the process
  • pwd on the Eclipse Debugger Console

When using CLI gdb and gdbserver, we observe that the pwd of the program is always the same as where gdbserver was launched, and the pwd and cd commands on host only change host settings.

The Automatic Launcher SSHs into the target and launches gdbserver for us, which automates the re-run process: Remote debugging C++ applications with Eclipse CDT/RSE/RDT

Eclipse 4.7.0.


回答1:


The best method I could find was to go:

  • Debug configurations
  • Main
  • Commands to execute before application
  • cd /directory/that/I/want

If you want to set it to the same directory as the executable without duplication, this unsolved question is related: How to set the working directory when running an executable in Eclipse CDT to be the same as the executable?

Alternatively, you could also use the Manual Launcher, in which you launch gdbserver manually on the target. Then just cd to the directory you want before running it.



来源:https://stackoverflow.com/questions/45784188/how-to-set-the-current-working-directory-of-the-program-when-remote-debugging-wi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!