简体   繁体   English

设置 Qt Creator 以调试到 Qt 类

[英]Setup of Qt Creator to debug into Qt classes

I want to setup Qt Creator (3.0) in a way, that I can debug into the Qt classes.我想以某种方式设置 Qt Creator (3.0),以便我可以调试到 Qt 类中。 So I download the corresponding src code ( http://gitorious.org/qt/qt5 ) and install it in a directory (eg c:\\Qt5\\src ).所以我下载了相应的 src 代码( http://gitorious.org/qt/qt5 )并将其安装在一个目录中(例如c:\\Qt5\\src )。

Then I have my own project.然后我有我自己的项目。 Where do I need to set the source code path of Qt ( c:\\Qt5\\src ), so I can debug my code, but also into a Qt class where necessary.我需要在哪里设置 Qt 的源代码路径( c:\\Qt5\\src ),以便我可以调试我的代码,但也可以在必要时进入 Qt 类。

-- Edit:Pavel's comment -- -- 编辑:Pavel 的评论 --

Pavel has given a good hint: But I am using a precompiled version of Qt/Qt Creator. Pavel 给出了一个很好的提示:但我使用的是 Qt/Qt Creator 的预编译版本。 So I am basically looking for a solution which does not require me to compile from source.所以我基本上是在寻找一个不需要我从源代码编译的解决方案。 Nevertheless a useful hint.然而,一个有用的提示。 Thanks.谢谢。

If you are using a prebuilded version just remap the source code location as described in http://doc.qt.io/qtcreator/creator-debugger-engines.html如果您使用的是预构建版本,只需按照http://doc.qt.io/qtcreator/creator-debugger-engines.html 中所述重新映射源代码位置

Mapping Source Paths映射源路径

To enable the debugger to step into the code and display the source code when using a copy of the source tree at a location different from the one at which the libraries where built, map the source paths to target paths:为了使调试器能够在与构建库所在位置不同的位置使用源树的副本时进入代码并显示源代码,请将源路径映射到目标路径:

  • Select Tools > Options > Debugger > General > Add.选择工具 > 选项 > 调试器 > 常规 > 添加。
  • In the Source path field, specify the source path in the debug information of the executable as reported by the debugger.在源路径字段中,指定调试器报告的可执行文件的调试信息中的源路径。
  • In the Target path field, specify the actual location of the source tree on the local machine.在目标路径字段中,指定源树在本地机器上的实际位置。

To get " the source path in the debug information of the executable as reported by the debugger ", you can activate the " Use Tooltips in Stack-View when Debugging " option by right-clicking in the Stack View and move the mouse over a specific function call.要获得“调试器报告的可执行文件的调试信息中的源路径”,您可以通过在堆栈视图中右键单击并将鼠标移动到特定位置来激活“调试时在堆栈视图中使用工具提示”选项函数调用。

If you look into the tooltips, you will see references to /Users/qt/work , the Mac deployed debug symbols are pointing there.如果您查看工具提示,您将看到对/Users/qt/work引用,Mac 部署的调试符号指向那里。 Of course, this is not documented, as these folks want you to buy enterprise.当然,这没有记录,因为这些人希望您购买企业。

If you create the /Users/qt/work directory (as root), then make a soft link to your source directory named qt, everything will work.如果您创建/Users/qt/work目录(以 root 身份),然后创建一个到名为 qt 的源目录的软链接,一切都会正常进行。 No need to build anything from source (under Mac that would result in tens of gigs wasted).无需从源代码构建任何东西(在 Mac 下会导致数十场演出浪费)。 Same considerations about plugins关于插件的相同考虑

Example:例子:

sudo -s
mkdir /Users/qt
cd /Users/qt
mkdir work
cd work
ln -s /Users/your_user_name/Qt/your_qt_release/Src qt

Everything will work.一切都会好起来的。 Any source mapping failed here, so leave those alone.任何源映射在这里都失败了,所以不要管它们。 Hope this helps希望这可以帮助

You have to compile your own Qt.你必须编译你自己的Qt。 That's the only way of getting this functionality.这是获得此功能的唯一方法。 You're free to use any IDE you want, including a precompiled one.您可以随意使用任何您想要的 IDE,包括预编译的。 Simply register your self-compiled Qt as a kit in Qt Creator.只需在 Qt Creator 中将您自己编译的 Qt 注册为套件即可。

Precompiled Qt simply doesn't ship with files with debug information.预编译的 Qt 根本不附带带有调试信息的文件。 You can waste an unbounded amount of time trying to debug into precompiled Qt.尝试调试到预编译的 Qt 中可能会浪费大量时间。 It's not possible on Unix platforms since the required debug-information-containing objects are not shipped.这在 Unix 平台上是不可能的,因为没有提供所需的包含调试信息的对象。 Neither is it available on Windows, for the same reason - the .pdb files aren't there for MSVC builds, and the object files aren't there for mingw builds.出于同样的原因,它在 Windows 上也不可用 - MSVC 构建没有 .pdb 文件,并且 mingw 构建没有目标文件。 That's seriously all there's to it.这就是它的全部内容。

When building a -debug-and-release build of Qt, you must retain all of the following trees (folders) in order for debugging to work:在构建 Qt 的-debug-and-release构建时,您必须保留以下所有树(文件夹)以便调试工作:

  • source,来源,
  • build,建造,
  • install prefix.安装前缀。

I don't really know what prebuilt Qt is for.我真的不知道预构建的 Qt 是干什么用的。 As far as I'm concerned, it shouldn't be offered: it just confuses the heck out of everyone.就我而言,不应该提供它:它只会让每个人都感到困惑。 It's of no use to end users, and it's of no use to developers - I just can't see debugging seriously without access to Qt sources.它对最终用户没有用,对开发人员也没有用 - 我只是无法在没有访问 Qt 源代码的情况下认真地看到调试。 It defeats the purpose of there being the sources, in a way.在某种程度上,它违背了存在来源的目的。 Sure, there should be a prebuilt Qt Creator with the prebuilt Qt libraries that it needs, but this shouldn't be exposed outside of it.当然,应该有一个预建的 Qt Creator 和它需要的预建 Qt 库,但这不应该暴露在它之外。

With Xcode, before you step into the Qt library the first time, enter the following command in the LLDB window:使用 Xcode,在第一次进入 Qt 库之前,在 LLDB 窗口中输入以下命令:

settings set target.source-map /Users/qt/work/qt /path/to/Qt/5.10.1/Src

(Obviously you'll want to change the version number, as relevant). (显然,您需要更改相关的版本号)。

But suppose Trolltech changes its build directory, what to do then?但是假设奇趣科技改变了它的构建目录,那该怎么办呢? (Or, how did the community wiki that gave the /Users/qt/work/qt path find it?) You can guess what the path needs to be by editing /path/to/Qt/5.10.1/clang_64/lib/QtCore.framework.dSYM/Contents/Resources/DWARF/QtCore_debug (or any other Qt library) and searching for some paths. (或者,提供/Users/qt/work/qt路径的社区 wiki 是如何找到它的?)您可以通过编辑/path/to/Qt/5.10.1/clang_64/lib/QtCore.framework.dSYM/Contents/Resources/DWARF/QtCore_debug猜测路径需要是什么/path/to/Qt/5.10.1/clang_64/lib/QtCore.framework.dSYM/Contents/Resources/DWARF/QtCore_debug (或任何其他 Qt 库)并搜索一些路径。 "/Users" seems like a good guess. "/Users" 似乎是一个很好的猜测。 About 2% into the library you'll start seeing sections with a lot of paths like:大约 2% 到库中,您将开始看到包含许多路径的部分,例如:

../../include/QtCore/../../src/corelib/kernel^@../../include/QtCore       
/../../src/corelib/tools^@global^@/Users/qt/work/qt/qtbase/src/corelib
/../../include/QtCore/../../src/corelib/arch^@/Applications/Xcode.app
/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/<etc>

Look for an absolute path that looks like it could be writable.寻找看起来可写的绝对路径。 ( /Applications/... would not be a likely build path, for example) (例如, /Applications/...不会是一个可能的构建路径)

In recent Qt creator (v 4.11) press button "Add Qt Sources" in Tools > Options > Debugger > General and select Qt sources file.在最近的 Qt creator (v 4.11) 中,在 Tools > Options > Debugger > General 中按下按钮“Add Qt Sources”,然后选择 Qt 源文件。 Qt5 should be installed by online installer with checked "Qt Debug Information files". Qt5 应该由在线安装程序安装,并选中“Qt 调试信息文件”。

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

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