简体   繁体   English

如何让Qt Creator的调试器显示OS X中C ++向量的内容?

[英]How do I make Qt Creator's debugger show the contents of C++ vectors in OS X?

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. 我正在编写一个广泛使用向量的程序,并且是第一次在Mac OS X 10.6.6上使用Qt Creator 2.0.1进行开发。

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: 在调试时,我可以在Locals and Watchers窗口中看到文字和数组,但是一旦我扩展了一个向量,在这种类型为Student情况下,我得到了这个树:

替代文字

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. 我正在使用的另一个人是在Ubuntu上使用相同版本的Qt Creator,可以很好地看到向量的内容。 What am I doing wrong? 我究竟做错了什么?

This is his debugger: 这是他的调试器:

替代文字

QtCreator 2.6 has support for Mac FSF GDB (7.5) support. QtCreator 2.6支持Mac FSF GDB(7.5)支持。 FSF GDB supports python which allows qtcreator to properly display QVector, QSet, QList, QString, etc. It can be download from macports. FSF GDB支持python,它允许qtcreator正确显示QVector,QSet,QList,QString等。它可以从macports下载。

  1. Download and Install macports (download it from here http://www.macports.org/install.php ) 下载并安装macports(从这里下载http://www.macports.org/install.php
  2. To install FSF GDB 7.5: 要安装FSF GDB 7.5:

      sudo port install gdb 
  3. Give FSF GDB permission to debug applications: 授予FSF GDB调试应用程序的权限:

     sudo codesign -s gdb-cert /opt/local/bin/ggdb 

    If gdb-cert isn't found, create a gdb-cert by clicking on the link below, and follow the directions for "Creating a certificate": 如果找不到gdb-cert,请单击下面的链接创建gdb-cert,然后按照“创建证书”的说明进行操作:

    http://sourceware.org/gdb/wiki/BuildingOnDarwin http://sourceware.org/gdb/wiki/BuildingOnDarwin

    If you don't give permission to ggdb, you'll get a: 如果您不授予ggdb权限,您将获得:

      Unable to find Mach task port for process-id 28885: (os/kern) failure (0x5). (please check gdb is codesigned - see taskgated(8)) 
  4. Change the kit debugger in QtCreator 在QtCreator中更改工具包调试程序 在此输入图像描述

    Change the path from /usr/bin/gdb to /opt/local/bin/ggdb 将路径从/ usr / bin / gdb更改为/ opt / local / bin / ggdb

  5. By default FSF GDB fails to handle breakpoints correctly because mac clang++ doesn't export debug symbols. 默认情况下,FSF GDB无法正确处理断点,因为mac clang ++不会导出调试符号。 To export the debugging symbols, dsymutil needs to be run manually. 要导出调试符号,需要手动运行dsymutil。 Luckly, dysmutil command can be run automatically after link the program using qmake. 幸运的是,在使用qmake链接程序后,可以自动运行dysmutil命令。 Add the following lines in your .pro file: 在.pro文件中添加以下行:

     macx { CONFIG(debug, debug|release) { QMAKE_POST_LINK = dsymutil \\"MyApp.app/Contents/MacOS/MyApp\\" } } 

You need to build the debugging helper. 您需要构建调试助手。 Should be under Tools -> Options ... 应该在工具 - >选项下...

Once the debugging helper is built, you can visualize std::string, QString and containers as well. 构建调试助手后,您还可以可视化std :: string,QString和容器。

There should be a rebuild button in same the place as where you choose which version of Qt to use. 在您选择使用哪个版本的Qt的位置应该有一个重建按钮。

http://www.qtcentre.org/threads/31862-quot-No-valid-Qt-version-set.-Set-one-in-Tools-Options-quot-Windows-QtCreator http://www.qtcentre.org/threads/31862-quot-No-valid-Qt-version-set.-Set-one-in-Tools-Options-quot-Windows-QtCreator

这两个答案是正确的:一个人不能在mac上使用基于python的调试助手,仍然有一个与Apple的gdb一起使用的C ++版本。

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

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