简体   繁体   English

在 Qt creator 的发布模式下设置断点

[英]Setting breakpoints in release mode in Qt creator

I am using Qt creator and cdb debugger for my c++ project.我正在为我的 c++ 项目使用 Qt 创建者和 cdb 调试器。 I need to set some breakpoints in code and see what happens during runtime.我需要在代码中设置一些断点,看看在运行时会发生什么。 Unfortunately because of some third party library I absolutely can not use Debug mode so I have to stick to the release mode.不幸的是,由于一些第三方库,我绝对不能使用调试模式,所以我必须坚持使用发布模式。

In visual studio I always do such thing and use breakpoints in the release mode easily but how could I do that in Qt creator?在 visual studio 中,我总是做这样的事情,并在发布模式下轻松使用断点,但我怎么能在 Qt creator 中做到这一点呢?

(Versions: Qt 5.12 / Qt creator 4.8) (版本:Qt 5.12 / Qt creator 4.8)

Try using a "Profile" build in Qt Creator.尝试使用 Qt Creator 中的“配置文件”构建。 That will include separate debugging line information in a "Release" (optimized) build.这将在“发布”(优化)构建中包含单独的调试行信息。 You can then launch it using the Debug button in Qt Creator and set breakpoints as you need.然后,您可以使用 Qt Creator 中的“调试”按钮启动它,并根据需要设置断点。

Caveats:注意事项:

  • You may not be able to get the exact line you want because of optimizations by the compiler.由于编译器的优化,您可能无法获得所需的确切行。

  • You most variables will be optimized into registers, so you can't view them.您的大多数变量将被优化到寄存器中,因此您无法查看它们。 If you need to view registers, try the good, old fashion method of printing their values out with a qDebug() statement.如果您需要查看寄存器,请尝试使用 qDebug() 语句打印出它们的值的良好、老式方法。 (When in doubt, print it out.) (如有疑问,请打印出来。)

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

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