在Eclipse CDT中使用gdbserver Automatic Launcher进行远程调试时,如何设置程序的当前工作目录? [英] How to set the current working directory of the program when remote debugging with gdbserver Automatic Launcher in Eclipse CDT?
问题描述
我试图通过调试配置>参数>工作目录对其进行更改,但这仅更改了主机gdb的位置。
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:
- 创建一个打印
pwd
-
pwdx
在进程上 -
pwd
在Eclipse调试器控制台上
的测试程序
- creating a test program that prints
pwd
pwdx
on the processpwd
on the Eclipse Debugger Console
使用CLI时 gdb
和 gdbserver
,我们注意到程序的 pwd
始终与启动 gdbserver
的位置相同,主机上的 pwd
和 cd
命令仅更改主机设置。
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.
自动启动器通过SSH进入目标并为我们启动 gdbserver
,这将自动执行重新运行过程:使用Eclipse CDT / RSE /远程调试C ++应用程序/ RDT
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。
Eclipse 4.7.0.
推荐答案
我能找到的最好方法是:
The best method I could find was to go:
- 调试配置
- Main
- 在应用程序之前执行的命令
-
cd / directory / that / I / want
- 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?
或者,您也可以使用手动启动器,在其中启动 gdbserver
手动定位到目标。然后只需 cd
到要运行的目录即可。
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.
这篇关于在Eclipse CDT中使用gdbserver Automatic Launcher进行远程调试时,如何设置程序的当前工作目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!