如何使用“目标远程”在 gdb 中重新运行该程序?
当您在同一台计算机上的可执行文件上执行常规 gdb 会话时,您可以发出 run 命令,它将再次启动程序。
当您在嵌入式系统上运行 gdb 时,就像使用命令 target localhost:3210
一样,如何在不退出并重新启动 gdb 会话的情况下重新启动程序?
When you're doing a usual gdb session on an executable file on the same computer, you can give the run command and it will start the program over again.
When you're running gdb on an embedded system, as with the command target localhost:3210
, how do you start the program over again without quitting and restarting your gdb session?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
“jump_start”是通常的方式。
"jump _start" is the usual way.
对我来说,21.2 示例 GDB 会话启动中描述的方法效果很好。 当我稍后在“(gdb)”提示符处输入
monitor Reset Halt
时,目标硬件将重置,我可以使用c
(= 继续)重新启动应用程序。在两次运行之间可以省略
load
命令,因为不需要一次又一次地刷新程序。For me the method described in 21.2 Sample GDB session startup works great. When I enter
monitor reset halt
later at the “(gdb)” prompt the target hardware is reset and I can re-start the application withc
(= continue).The
load
command can be omitted between the runs because there is no need to flash the program again and again.假设您正在嵌入式系统上运行 gdbserver。
您可以要求它重新启动程序,而不是使用 目标扩展远程
Presumably you are running gdbserver on the embedded system.
You can ask it to restart your program instead of exiting with target extended-remote
分步过程
远程:
本地:
在 Ubuntu 14.04 中测试。
也可以将 CLI 参数传递给程序:
并且
./myexec
部分消除了set Remote exec-file ./myexec
的需要,但这有以下烦恼:show args
上显示,并且不会在重新启动后持续存在:https://sourceware.org/bugzilla/show_bug.cgi?id=21980传递环境变量并更改工作目录而不重新启动:如何在不重新启动的情况下修改gdbserver --multi的环境变量和工作目录?
Step-by-step procedure
Remote:
Local:
Tested in Ubuntu 14.04.
It is also possible to pass CLI arguments to the program as:
and the
./myexec
part removes the need forset remote exec-file ./myexec
, but this has the following annoyances:show args
and does not persist across restarts: https://sourceware.org/bugzilla/show_bug.cgi?id=21980Pass environment variables and change working directory without restart: How to modify the environment variables and working directory of gdbserver --multi without restarting it?
在 EFM32 Happy Gecko 上,所有建议都不适合我,因此以下是我从有关将 GDB 集成到 Eclipse 环境的文档中学到的内容。
这使我处于从 IDE 中点击重置时所期望的状态。
On EFM32 Happy Gecko none of the suggestions would work for me, so here is what I have learned from the documentation on integrating GDB into the Eclipse environment.
This puts me in the state that I would have expected when hitting reset from the IDE.
您可以使用
jump
gdb命令。 为此,您可以检查您的启动
脚本。我的
启动脚本
有一个符号。我想跳起来开始。 这就是我使用的原因:
You can use
jump
gdb command. For that, you can check yourstartup
script.My
startup script
has a symbol.I wanted to jump to start. That's why I used:
如果您正在运行常规 gdb,您可以输入“运行”快捷方式“r”,gdb 会询问您是否要重新启动程序
If you are running regular gdb you can type 'run' shortcut 'r' and gdb asks you if you wish to restart the program
您正在寻找 gdbserver 的多进程模式 和
设置远程执行文件文件名
You are looking for Multi-Process Mode for gdbserver and
set remote exec-file filename
不幸的是,我不知道如何重新启动应用程序并仍然保持会话。 解决方法是将 PC 设置回程序的入口点。 您可以通过调用:
jump function
或
set $pc=address
来完成此操作。如果您将参数修改为
main
,您可能需要再次设置它们。编辑:
上述方法有一些警告可能会导致问题。
因此,使用跳转与重新启动程序不同。
Unfortunately, I don't know of a way to restart the application and still maintain your session. A workaround is to set the PC back to the entry point of your program. You can do this by either calling:
jump function
or
set $pc=address
.If you munged the arguments to
main
you may need set them up again.Edit:
There are a couple of caveats with the above method that could cause problems.
So, using jump isn't the same thing as restarting the program.