Open-TEE / project

Overall project configuration and documentation
Apache License 2.0
81 stars 35 forks source link

Unable to debug the TA in conn_test_app by using Qt Creator with gdb #16

Closed YangRongAtGit closed 8 years ago

YangRongAtGit commented 8 years ago

Hello :),

Thanks for your time reading this issue. By following the tutorial https://github.com/…/…/master/_posts/2015-10-10-qtcreator.md

Environment Qt 5.6.1 Qt Creator 4.0.1 gdb 7.11 Ubuntu 16.04 LTS

I am able to run test application (conn_test_app the result of the test app is successful) and debug the CA in Qt with gdb. But I am not able to debug the TA.

Here is the way I tried to debug the TA:

  1. Set breakpoints in both CA and TA;
  2. When the breakpoint is hit. I use Qt menu option "Debug"->"Start Debugging"->"Attach to running application". To try to attach the TA process.

This is the problem I am having Instead of hitting the breakpoints that I set in the TA. The gdb always hit an invisible breakpoint in function epoll_wait(). After that, if I continue (F5). The application will keep hanging without hitting any further breakpoints in TA. Unless I force stop by using the Qt debug option "Stop Debugger". The application is keep waiting. After I stopped the debugger, the CA still breaks in the original breakpoint.

It seems that Qt uses two different debuggers for different processes. I am thinking it might be caused by the CA is hanging. So the TA process is keep waiting. But I did not set any breakpoints in wrap_epoll_wait() function I am not sure why gdb breaks there. And in the Qt Debugger. I cannot find a way to switch back to CA process to let the process to continue to run. (The Qt debugger component "Threads" drop list is disabled by some reason, I can not select a different thread).

The things I tried

  1. Modified the /etc/sysctl.d/10-ptrace.conf set _kernel.yama.ptracescope value to 0
  2. Turned the debugger option "Tools->Options->Debugger->GDB Extended->Debug all children" on and off in the Qt.

None of above things changed the fact that the debugger is hanging after the debugger breaks in the function wrap_epoll_wait().

Anyone at good gdb and Qt knowledge could help me? And let me know how the gdb debug multiple processes works in Qt? How to switch the debugger between different processes and why gdb breaks on somewhere I did not set the breakpoint?

Thank you very much,

Rong

brianmcgillion commented 8 years ago

Hi,

Thank you for reporting these issues!! I fixed the site pages 404 error this morning, it appears after GitHub upgraded the blog engine that there were some semantic issues related to permanent links.

As for your debugging issues, the following bug [1] highlights the issue that you are experiencing related to trying to debug client / server applications. I have not seen that it has been addressed, so you have 2 possible options, either fire up 2 instances of qtcreator and have the CA in one and the TA in another or use plain GDB for one and qtcreator for another.

Then for your issue of not hitting the breakpoints in qtcreator, the solution that we have found is to change some default settings in the GDB settings tab in qtcreator. I have updated the documentation [2] to reflect the exact steps, hopefully, this solves your issue! I have tested the steps using QtCreator 4.0.2.

Thanks again for taking the time to report the issues!! Br, Brian

[1] https://bugreports.qt.io/browse/QTCREATORBUG-8101 [2] http://open-tee.github.io/tutorial/qtcreator/#debugging-tas

On Tue, Jun 28, 2016 at 5:18 AM, r0nG notifications@github.com wrote:

Hello :),

Thanks for your time reading this issue. By following the tutorial https://github.com/…/…/master/_posts/2015-10-10-qtcreator.md

Environment Qt 5.6.1 Qt Creator 4.0.1 gdb 7.11 Ubuntu 16.04 LTS

I am able to run test application (conn_test_app) and debug the CA in Qt with gdb. But I am not able to debug the TA.

Here is the way I tried to debug the TA:

  1. Set breakpoints in both CA and TA;
  2. When the breakpoint is hit. I use Qt menu option "Debug"->"Start Debugging"->"Attach to running application". To try to attach the TA process.

This is the problem I am having Instead of hitting the breakpoints that I set in the TA. The gdb always hit an invisible breakpoint in function epoll_wait(). After that, if I continue (F5). The application will keep hanging without hitting any further breakpoints in TA. Unless I force stop by using the Qt debug option "Stop Debugger". The application is keep waiting. After I stopped the debugger, the CA still breaks in the original breakpoint.

It seems that Qt uses two different debuggers for different processes. I am thinking it might be caused by the CA is hanging. So the TA process is keep waiting. But I did not set any breakpoints in wrap_epoll_wait() function I am not sure why gdb breaks there. And in the Qt Debugger. I cannot find a way to switch back to CA process to let the process to continue to run. (The Qt debugger component "Threads" drop list is disabled by some reason, I can not select a different thread).

The things I tried

  1. Modified the /etc/sysctl.d/10-ptrace.conf set _kernel.yama.ptracescope value to 0
  2. Turned the debugger option "Tools->Options->Debugger->GDB Extended->Debug all children" on and off in the Qt.

None of above things changed the fact that the debugger is hanging after the debugger breaks in the function wrap_epoll_wait().

Anyone at good gdb and Qt knowledge could help me? And let me know how the gdb debug multiple processes works in Qt? How to switch the debugger between different processes and why gdb breaks on somewhere I did not set the breakpoint?

Thank you very much,

Rong

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Open-TEE/project/issues/16, or mute the thread https://github.com/notifications/unsubscribe/AA_vJx1S9GtC6drXO7QBCERMSCo95ys-ks5qQISKgaJpZM4I_rhO .

YangRongAtGit commented 8 years ago

Thanks for your reply, Brian. The gdb settings solution is really helped me out :D