简体   繁体   English

远程gdb在每次事件时都会停止

[英]Remote gdb stops at every event

I'm having remote ARM Linux box which I need to debug. 我有需要调试的远程ARM Linux机器。

The server is started: 服务器已启动:

gdbserver :12345 ./my_app

The client: 客户端:

./arm-am3354-linux-gnueabihf-gdb ~/
 (gdb) target remote dev_r:12345
 (gdb) continue

Then I'm trying to pause the app with Ctrl+C, but the gdb stops with: 然后,我尝试使用Ctrl + C暂停应用程序,但是gdb停止了:

[Inferior 1 (process 2766) exited with code 01] [下级1(过程2766)以代码01退出]

And on server: 在服务器上:

Child exited with status 1 GDBserver exiting 子级退出,状态为1 GDBserver退出

Story: I was trying to use remote debugging in QtCreator, but when setting breakpoints in run-time the gdb was crashing in the same way. 故事:我试图在QtCreator中使用远程调试,但是在运行时设置断点时,gdb崩溃的原因相同。 Also the breakpoints and pause is not working in QtCreator. 此外,断点和暂停在QtCreator中不起作用。 I was trying also another gdb like gdb-multiarch and the one from android-sdk. 我也在尝试另一个gdb,例如gdb-multiarch和android-sdk中的一个。

Update: Debugging small program aka Hello World works. 更新:调试小程序,又名Hello World工作。 Local Debugging (on x86) works too. 本地调试(在x86上)也可以使用。 The app itself has hundred thousand lines of code, shared and static libraries. 该应用程序本身具有数十万行代码,共享库和静态库。

Partial solution: Probably the sysroot for embedded platform that I've got was invalid. 部分解决方案:可能我安装的嵌入式平台的sysroot无效。 After copying /lib/ and /usr/ from the target device and setting it as 从目标设备复制/ lib /和/ usr /并将其设置为

set sysroot /home/karel/sysroot

I'm able to set breakpoints and the app stops at them. 我能够设置断点,应用程序会在这些断点处停止。 The pause however is still stopping the remote app. 但是暂停仍在停止远程应用程序。 The same for QtCreator: Tools->Options->Debugger->GDB->Additional Attach Commands 对于QtCreator相同:工具->选项->调试器-> GDB->其他附加命令

I had a similar (or even exactly the same?) issue with debugging my application running on the EGLFS platform. 在调试在EGLFS平台上运行的应用程序时,我遇到了类似(甚至完全相同)的问题。 Debugging when built with Qt 5.4 was working perfectly fine, debugging with Qt 5.5 did behave as you describe. 使用Qt 5.4进行构建时的调试工作正常,使用Qt 5.5进行调试的确如您所述。

After hours of searching, I found that my application on Qt 5.5 exited when receiving a SIGINT, whereas on Qt 5.4, the debugger could pause the application as expected. 经过数小时的搜索,我发现在Qt 5.5上的应用程序在收到SIGINT时退出,而在Qt 5.4上,调试器可以按预期的方式暂停应用程序。 Since GDB sends SIGINT when trying to pause the application or setting / removing a breakpoint, this was where trouble started. 由于GDB在尝试暂停应用程序或设置/删除断点时会发送SIGINT,因此这就是麻烦所在。

After some more research, I finally found the following commit to Qt 5.5: Fix up signal handling in QFbVtHandler . 经过更多研究之后,我终于找到了对Qt 5.5的以下承诺: 修复QFbVtHandler中的信号处理 At the very end, you see that when receiving SIGINT or SIGTERM, the handleInt() handler is called where we finally run into _exit(1) . 最后,您看到在接收SIGINT或SIGTERM时,在最终遇到_exit(1)地方调用了handleInt()处理函数。 Setting a breakpoint there confirmed that this is exactly what happens when trying to pause or set a breakpoint with GDB. 在此处设置断点可以确认,这正是尝试在GDB中暂停或设置断点时发生的情况。

Solution that worked for me : I have created a patch to qfbvthandler.cpp, simply removing the #define VTH_ENABLED line. 对我有用的解决方案 :我创建了一个qfbvthandler.cpp补丁,只需删除#define VTH_ENABLED行。

GDB debugging is now again working like a charm. 现在,GDB调试再次像魅力一样工作。

Note: Even though qfbvthandler.cpp has been updated in Qt5.6 and upwards, I suspect the behaviour would still be the same. 注意:即使在Qt5.6及更高版本中已更新qfbvthandler.cpp,我怀疑其行为仍然相同。 I however don't have a workspace set up in order to test this. 但是,我没有设置工作空间来进行测试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM