- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 gdbserver 调试远程进程。我可以在 gdbserver 启动并等待输入后将其附加到该进程。
但是,我想在启动时将 gdbserver 附加到该进程。该进程是通过 shell 脚本启动的,我无法更改该进程的启动方式,即我无法修改 shell 脚本以通过调用 gdbserver 启动该进程。
如何在 gdbserver 启动后立即将其附加到此进程?
编辑:我能够在 main()
的开头创建一个等待循环。例如,等待直到在预定位置找到文件的循环:
#include <unistd.h>
int main() {
while( access("/home/username/CONTINUE", F_OK) == -1)
sleep(1);
/*
...all the rest of main()
*/
return 0;
}
我们可以在进程忙于此循环时附加 gdbserver,根据需要设置断点并说 touch/home/username/CONTINUE
退出循环。但这需要我们能够访问源代码,编译二进制文件并将其放置在目标机器上。我正在寻找比这更好、更简单的方法。
最佳答案
But this requires us to be able to access the source code1, compile the binary and place it on the target machine. I am looking for a better, easier way than this.
看起来您正在使用类似 linux/unix 的远程操作系统。
如果您对远程系统具有管理员访问权限,我能想到的最简单的方法是重命名原始可执行文件,并将其替换为与原始可执行文件同名的 shell 脚本,该脚本在 gdbserver
的控制下启动现在重命名的文件。
在目标机器上类似(假定可执行文件 /usr/bin/foo
):
root:# cd /usr/bin
root:# mv foo foo_
root:# echo "#!/bin/sh\ngdbserver /dev/com1 foo_ foo.txt" > foo
root:# chmod a+x foo
正如它在 gdbserver
man(1) page 中所说:
This tells gdbserver to debug foo_ with an argument of foo.txt, and to communicate with GDB via
/dev/com1
. gdbserver now waits patiently for the host GDB to communicate with it.
另一种我能想到的完全不修改原始进程的方法,可能是一个小程序,它监视 /dev/proc
目录中的更改,并在此类事件中附加 gdbserver
和相关的 pid。
尽管这有点幸运,但如果附加了 gdbserver
,则在该进程已经安排到 main()
之前。
1无论如何,您应该有权访问源代码,以便使用 gdb
进行合理调试。尽管在某些情况下您也可以使用(反)汇编代码。
关于c++ - 如何在启动时将 gdbserver 附加到进程?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45116818/
环境是: target:x86_64 client,运行 strip 化的程序 主机:x86_64服务器,有代码,工具链, strip 程序,用于调试的符号文件 在目标上运行 gdbserver: %
我为 arm 编译了 gdbserver 7.6: cd /gdb-7.6-src/gdb/gdbserver ./configure --target=arm-linux --host=arm-li
我正在尝试使用 gdbserver... 我有一个应用程序,其二进制路径 /user/bin/foo 与 pid 19767 一起运行。 远程启动 gdbserver: gdbserver --re
我有一个 ARM 设备,我想调试它。我的主机是 Linux 12.04,我使用的是 Eclipse。GDBServer 在我的目标设备上运行。 我可以调试单进程应用程序。但是当我想调试包含 pthre
例如!ls将执行ls gdb 本身中有命令,但如何在远程端执行此操作? 应该很简单,但我不明白。 Per documentation类似 target remote | ls或target remot
我正在尝试在 Android (Java/C/C++) 上调试混合代码。我的目标设备是 Vizio 1008。代码在模拟器上运行,我可以使用 GDB 从 Eclipse 调试它。但是,我无法在真实设备
我正在调试在远程目标上的 Linux 环境中运行的嵌入式应用程序。该板唯一可用的接口(interface)是一个串行接口(interface)。现在它在 init 上连接了/bin/sh。我正在连接
我正在尝试使用 gdbserver 进行调试。在我终止主机上的 gdb 客户端后,我看到 gdbserver 仍在监听: Remote side has terminated connection.
我尝试如下远程使用gdbserver进行调试 在目标机器上启动gdbserver $ gdbserver localhost:2000 hello -l 20 -b 10 --enable-targe
我正在使用 Eclipse CDT 和 GNU ARM QEMU 模拟器。 Eclipse 使用 QEMU 上运行的 gdbserver 启动自己的 gdb session 。我还希望能够从 OSX
我试图交叉编译OpenWrt-RTK gdb/gdbserver软件包,我在make menuconfig中选择了gdbserver并执行了make V=s,但我无法编译它,我收到了此错误 ../si
我正在 eclipse CodeSourcery IDE 中调试 C 项目。该项目在 linux-arm 设备中运行,因此我使用 gdbserver 交叉编译和调试它。我的项目由一个主程序和一些共享库
我正在使用 gdbserver 调试远程进程。我可以在 gdbserver 启动并等待输入后将其附加到该进程。 但是,我想在启动时将 gdbserver 附加到该进程。该进程是通过 shell 脚本启
我正在尝试调试远程主机上的 fork 进程,但每次都让 gdbserver 进程在子退出时结束。 尝试在 .gdbinit 中设置“set follow-fork-mode child”,没有帮助。
我在 Netbeans 中使用 gdbserver 插件试图连接到远程调试 session 。但是我收到一个错误:“设备的 ioctl 不合适。”我可以通过从终端启动 gdb 进行远程调试,但我希望能
1) 我通过 gdb myAppName 在远程计算机上启动 GDB 2) 然后我给出 run -p portNumber 3)然后我运行java应用程序并在上述端口上与其连接。 现在,当我尝试通过
我想在arm-Linux开发板上使用gdb调试。编译 gdbserver 时出错。 主机:Ubuntu 11 32 位目标:arm-linux-gcc(gcc版本4.4.3) root@mickeyv
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。 关闭 7 年前。
当从运行 gdb 的主机发送 step 命令到运行 gdb 服务器的远程目标(通过 TCP/IP 连接)时,我在目标上收到以下错误 ptrace: Input/output error. input_
我有一个程序出现段错误。我需要远程调试它。为此,我正在执行以下操作: 在目标板上: #gdbserver :2345 program 在 x86 主机上: $ arm-linux-gdb -q pro
我是一名优秀的程序员,十分优秀!