[英]Debugging multithread application with eclipse cdt
I am developing multithread application with c++ using eclipse cdt.我正在使用 eclipse cdt 开发 c++ 的多线程应用程序。 I need to debug my code, i have tried to write to console by using printf but it is not very useful.我需要调试我的代码,我尝试使用 printf 写入控制台,但它不是很有用。 How do i debug my multithread code?我如何调试我的多线程代码?
It depends on what you're looking for, but debugging multithreaded applications can be very similar or extremely dissimilar to debugging single threaded apps.这取决于您要查找的内容,但调试多线程应用程序可能与调试单线程应用程序非常相似或极为不同。
First, some example methods you can still use:首先,您仍然可以使用一些示例方法:
I assume the issue you're running into here with printf is that it's like multiple threads writing to the same file- it's a race condition for what output you'll see on the screen.我假设您在这里遇到的问题 printf 就像多个线程写入同一个文件一样 - 这是您将在屏幕上看到的 output 的竞争条件。 I'd personally still recommend using a tool like valgrind if you're running into a multithreaded error, but if you'd like to continue using simple console output, try...如果您遇到多线程错误,我个人仍然建议使用像 valgrind 这样的工具,但如果您想继续使用简单的控制台 output,请尝试...
All in all, the exact tool you should be using here depends on the exact issue you're facing and thus no strong recommendations just yet.总而言之,您应该在此处使用的确切工具取决于您面临的具体问题,因此目前还没有强烈的建议。 Please apply the tools above (including breakpoints in Eclipse) to suit your situation.请根据您的情况应用上述工具(包括 Eclipse 中的断点)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.