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

发布于 2024-10-12 23:45:21 字数 393 浏览 4 评论 0原文

我正在编写一个广泛使用向量的程序,并且是第一次在 Mac OS X 10.6.6 上使用 Qt Creator 2.0.1 进行开发。

当我调试时,我可以在 Locals and Watchers 窗口中很好地看到文字和数组,但是一旦我去扩展向量(在本例中为 Student 类型) >,我得到这棵树:

alt text

与我一起工作的另一个人正在使用相同版本的 Qt Creator在 Ubuntu 上,可以很好地看到向量的内容。我做错了什么?

这是他的调试器:

alt text

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.

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:

alt text

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?

This is his debugger:

alt text

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

避讳 2024-10-19 23:45:21

QtCreator 2.6 支持 Mac FSF GDB (7.5)。 FSF GDB支持python,可以让qtcreator正确显示QVector、QSet、QList、QString等。可以从macports下载。

  1. 下载并安装 macports(从这里下载 http://www.macports.org/install.php)
  2. 安装 FSF GDB 7.5:

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

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

    如果未找到 gdb-cert,请单击下面的链接创建 gdb-cert,然后按照“创建证书”的说明进行操作:

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

    如果您不授予 ggdb 权限,您将得到:

     无法找到进程 ID 28885 的 Mach 任务端口:(os/kern) 失败 (0x5)。
     (请检查 gdb 是否经过共同设计 - 请参阅 taskgate(8)) 
    
  4. 在 QtCreator 中更改套件调试器
    在此处输入图像描述

    将路径从 /usr/bin/gdb 更改为 /opt/local/bin/ggdb

  5. 默认情况下,FSF GDB 无法正确处理断点,因为 mac clang++ 不导出调试符号。要导出调试符号,需要手动运行 dsymutil。幸运的是,使用 qmake 链接程序后,dysmutil 命令可以自动运行。在 .pro 文件中添加以下行:

    <前><代码>macx {
    配置(调试,调试|发布){
    QMAKE_POST_LINK = dsymutil \"MyApp.app/Contents/MacOS/MyApp\"
    }
    }

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.

  1. Download and Install macports (download it from here http://www.macports.org/install.php)
  2. To install FSF GDB 7.5:

         sudo port install gdb
    
  3. Give FSF GDB permission to debug applications:

    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":

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

    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)) 
    
  4. Change the kit debugger in QtCreator
    enter image description here

    Change the path from /usr/bin/gdb to /opt/local/bin/ggdb

  5. 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\"
        }
    }   
    
空城缀染半城烟沙 2024-10-19 23:45:21

您需要构建调试助手。应该在“工具”->“工具”下选项...

构建调试助手后,您还可以可视化 std::string、QString 和容器。

在您选择要使用的 Qt 版本的同一位置应该有一个重建按钮。

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

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.

There should be a rebuild button in same the place as where you choose which version of Qt to use.

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

亚希 2024-10-19 23:45:21

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

The two answers are sort of right: one cannot use the python based debugging helpers on mac, still there is a C++ version of it that works with Apple's gdb.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文