问题描述
我正在编写一个广泛使用向量的程序,并且是第一次在 Mac OS X 10.6.6 上使用 Qt Creator 2.0.1 进行开发.
I'm writing a program that makes extensive use of vectors and am developing with Qt Creator 2.0.1 on Mac OS X 10.6.6 for the first time.
当我在调试时,我可以在 Locals and Watchers
窗口中很好地看到文字和数组,但只要我去展开一个向量,在这种情况下是 Student 类型
,我得到了这棵树:
As I am debugging, I can see literals and arrays just fine in the Locals and Watchers
window, but as soon as I go to expand a vector, in this case of type Student
, I get this tree:
我与之合作的另一个人正在 Ubuntu 上使用相同版本的 Qt Creator,并且可以很好地查看向量的内容.我做错了什么?
The other person I am working with on this is using the same version of Qt Creator on Ubuntu and can see the contents of the vectors just fine. What am I doing wrong?
这是他的调试器:
推荐答案
QtCreator 2.6 支持 Mac FSF GDB (7.5) 支持.FSF GDB 支持python,可以让qtcreator正确显示QVector、QSet、QList、QString等,可以从macports下载.
QtCreator 2.6 has support for Mac FSF GDB (7.5) support. FSF GDB supports python which allows qtcreator to properly display QVector, QSet, QList, QString, etc. It can be download from macports.
- 下载并安装 macports(从这里下载 http://www.macports.org/install.php)
安装 FSF GDB 7.5:
- Download and Install macports (download it from here http://www.macports.org/install.php)
To install FSF GDB 7.5:
sudo port install gdb
授予 FSF GDB 调试应用程序的权限:
Give FSF GDB permission to debug applications:
sudo codesign -s gdb-cert /opt/local/bin/ggdb
如果未找到 gdb-cert,请单击下面的链接创建 gdb-cert,然后按照创建证书"的说明进行操作:
If gdb-cert isn't found, create a gdb-cert by clicking on the link below, and follow the directions for "Creating a certificate":
http://sourceware.org/gdb/wiki/BuildingOnDarwin
如果你不给 ggdb 权限,你会得到一个:
If you don't give permission to ggdb, you'll get a:
Unable to find Mach task port for process-id 28885: (os/kern) failure (0x5).
(please check gdb is codesigned - see taskgated(8))
在 QtCreator 中更改套件调试器
Change the kit debugger in QtCreator
将路径从/usr/bin/gdb 更改为/opt/local/bin/ggdb
Change the path from /usr/bin/gdb to /opt/local/bin/ggdb
默认情况下,FSF GDB 无法正确处理断点,因为 mac clang++ 不导出调试符号.要导出调试符号,需要手动运行 dsymutil.幸运的是,使用 qmake 链接程序后,dysmutil 命令可以自动运行.在您的 .pro 文件中添加以下行:
By default FSF GDB fails to handle breakpoints correctly because mac clang++ doesn't export debug symbols. To export the debugging symbols, dsymutil needs to be run manually. Luckly, dysmutil command can be run automatically after link the program using qmake. Add the following lines in your .pro file:
macx {
CONFIG(debug, debug|release) {
QMAKE_POST_LINK = dsymutil "MyApp.app/Contents/MacOS/MyApp"
}
}
这篇关于如何让 Qt Creator 的调试器在 OS X 中显示 C++ 向量的内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!