- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我在 Xcode 中为 OS X 构建了一个大型 C/C++/Objective-C 项目。该项目链接到预构建的 Qt5 库。
一切都很好,直到出现崩溃,我得到了一个包含 Qt 函数的堆栈跟踪。如果我单击其中一个 Qt 函数的堆栈帧,Xcode/lldb 会显示程序集而不是源代码——我将 Qt 用作外部库,因此我的项目中没有任何 Qt 源代码。我怎样才能解决这个问题?
我已经尝试将 Qt5 源代码添加到项目中而不将其添加到我的可执行目标中,但是 Xcode/lldb 仍然没有“看到”源代码或弄清楚我添加到项目中的源文件是Qt 调试符号中引用的相同源文件。
我如何告诉 Xcode/lldb 在哪里可以找到我正在使用的外部库的源代码?
编辑:
只是在这里添加更多细节,当我在 Xcode/lldb 控制台中键入“target modules lookup -t QMenuBar”时,这就是我所看到的:
Best match found in /Users/ted/Documents/Projects/XXX/_build_osx/Output/Debug/XXX.app/Contents/MacOS/XXX:
id = {0x7100042d49}, name = "QMenuBar", byte-size = 48, decl = qmenubar.h:57, clang_type = "class QMenuBar : public QWidget {
static const QMetaObject staticMetaObject;
virtual const QMetaObject *metaObject() const;
virtual void *qt_metacast(const char *);
static QString tr(const char *, const char *, int);
static QString trUtf8(const char *, const char *, int);
virtual int qt_metacall(QMetaObject::Call, int, void **);
static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **);
explicit QMenuBar(QWidget *);
virtual void ~QMenuBar();
QAction *addAction(const QString &);
QAction *addAction(const QString &, const QObject *, const char *);
QAction *addMenu(QMenu *);
QMenu *addMenu(const QString &);
QMenu *addMenu(const QIcon &, const QString &);
QAction *addSeparator();
QAction *insertSeparator(QAction *);
QAction *insertMenu(QAction *, QMenu *);
void clear();
QAction *activeAction() const;
void setActiveAction(QAction *);
void setDefaultUp(bool);
bool isDefaultUp() const;
virtual QSize sizeHint() const;
virtual QSize minimumSizeHint() const;
virtual int heightForWidth(int) const;
QRect actionGeometry(QAction *) const;
QAction *actionAt(const QPoint &) const;
void setCornerWidget(QWidget *, Qt::Corner);
QWidget *cornerWidget(Qt::Corner) const;
NSMenu *toNSMenu();
bool isNativeMenuBar() const;
void setNativeMenuBar(bool);
QPlatformMenuBar *platformMenuBar();
virtual void setVisible(bool);
void triggered(QAction *);
void hovered(QAction *);
virtual void changeEvent(QEvent *);
virtual void keyPressEvent(QKeyEvent *);
virtual void mouseReleaseEvent(QMouseEvent *);
virtual void mousePressEvent(QMouseEvent *);
virtual void mouseMoveEvent(QMouseEvent *);
virtual void leaveEvent(QEvent *);
virtual void paintEvent(QPaintEvent *);
virtual void resizeEvent(QResizeEvent *);
virtual void actionEvent(QActionEvent *);
virtual void focusOutEvent(QFocusEvent *);
virtual void focusInEvent(QFocusEvent *);
virtual void timerEvent(QTimerEvent *);
virtual bool eventFilter(QObject *, QEvent *);
virtual bool event(QEvent *);
void initStyleOption(QStyleOptionMenuItem *, const QAction *) const;
QMenuBarPrivate *d_func();
const QMenuBarPrivate *d_func() const;
QMenuBar(const QMenuBar &);
QMenuBar &operator=(const QMenuBar &);
}"
很明显,我的可执行文件中包含某种符号。它说这个定义来自 qmenubar.h。我的硬盘驱动器上某处有 qmenubar.h - 我如何告诉 Xcode/lldb 在哪里可以找到它?
在 Windows 中的 Visual Studio 中,如果我单击堆栈跟踪中没有 Visual Studio 可以轻松找到的源的帧,VS 会弹出一个窗口,要求我浏览源文件 - 从那时起, Visual Studio 似乎根据您浏览的源代码的位置凭直觉判断其余源代码的位置。例如,如果我有一个包含 QMenuBar::focusInEvent() 的堆栈跟踪,然后我单击它,Visual Studio 会询问我 qmenubar.cpp 在哪里。我可以浏览到 C:\Users\ted\Downloads\qt5-everywhere-src-5.3.2\qtcore\src\qmenubar.cpp(或任何位置),然后 Visual Studio 假设其他来源可能位于附近。
这如何与 Xcode 一起工作?
最佳答案
我想我已经找到了问题的答案,但它实际上只会引出更多问题。参见 Xcode equivalent of Visual Studio's "Find Source" .
我在想,也许我的程序或我的 Qt 构建没有有符号,或者符号比必要的少。特别是,这里是 target modules lookup --address <address> --verbose
的输出( image
是 target modules
的 lldb 同义词)在那个链接的 SO 问题中:
(lldb) image lookup -va main
Address: hello[0x0000000100000f40] (hello.__TEXT.__text + 0)
Summary: hello`main at hello.c:5
Module: file = "/private/tmp/hello", arch = "x86_64"
CompileUnit: id = {0x00000000}, file = "/tmp/hello.c", language = "ISO C:1999"
Function: id = {0x00000026}, name = "main", range = [0x0000000100000f40-0x0000000100000f6d)
FuncType: id = {0x00000026}, decl = hello.c:4, clang_type = "int (void)"
Blocks: id = {0x00000026}, range = [0x100000f40-0x100000f6d)
LineEntry: [0x0000000100000f40-0x0000000100000f56): /tmp/hello.c:5
Symbol: id = {0x00000004}, range = [0x0000000100000f40-0x0000000100000f6d), name="main"
这是来自 LLVM 网页“The LLDB Debugger”(http://lldb.llvm.org/symbolication.html)的示例:
>(lldb) image lookup --address 0x100123aa3 --verbose
Address: a.out[0x0000000100000aa3] (a.out.__TEXT.__text + 110)
Summary: a.out`main + 50 at main.c:13
Module: file = "/tmp/a.out", arch = "x86_64"
CompileUnit: id = {0x00000000}, file = "/tmp/main.c", language = "ISO C:1999"
Function: id = {0x0000004f}, name = "main", range = [0x0000000100000bc0-0x0000000100000dc9)
FuncType: id = {0x0000004f}, decl = main.c:9, clang_type = "int (int, const char **, const char **, const char **)"
Blocks: id = {0x0000004f}, range = [0x100000bc0-0x100000dc9)
id = {0x000000ae}, range = [0x100000bf2-0x100000dc4)
LineEntry: [0x0000000100000bf2-0x0000000100000bfa): /tmp/main.c:13:23
Symbol: id = {0x00000004}, range = [0x0000000100000bc0-0x0000000100000dc9), name="main"
Variable: id = {0x000000bf}, name = "path", type= "char [1024]", location = DW_OP_fbreg(-1072), decl = main.c:28
Variable: id = {0x00000072}, name = "argc", type= "int", location = r13, decl = main.c:8
Variable: id = {0x00000081}, name = "argv", type= "const char **", location = r12, decl = main.c:8
Variable: id = {0x00000090}, name = "envp", type= "const char **", location = r15, decl = main.c:8
Variable: id = {0x0000009f}, name = "aapl", type= "const char **", location = rbx, decl = main.c:8
这是我的 Qt5Widgets QMenuBar 地址的输出:
(lldb) image lookup --address 0x103058d57 --verbose
Address: libQt5Widgets_debug.5.dylib[0x000000000026dd57] (libQt5Widgets_debug.5.dylib.__TEXT.__text + 2525127)
Summary: libQt5Widgets_debug.5.dylib`QMenuBar::actionEvent(QActionEvent*) + 711
Module: file = "/Users/ted/Documents/Projects/work/third_party/qt/5.3.2/osx/x86_64/lib/libQt5Widgets_debug.5.dylib", arch = "x86_64"
Symbol: id = {0x0000c190}, range = [0x0000000103058a90-0x0000000103059260), name="QMenuBar::actionEvent(QActionEvent*)", mangled="_ZN8QMenuBar11actionEventEP12QActionEvent"
确认!源文件 (CompileUnit) 引用在哪里?感谢@vsoftco 的建议以及看到此问题的任何其他人。我将不得不深入研究 Qt5 构建系统并找出这些符号的去向。
关于c++ - 在 Xcode 中,如何使用您拥有源代码的外部库进行调试?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29477206/
我正在观看来自 iTunes U. 的视频讲座,其中讲师展示了如何使用 Xcode 的调试器部分并能够将该窗口从主窗口拉开。 不幸的是,视频显示了如何在 Xcode3 中执行此操作的说明。如何在 Xc
现在我正在开发一个使用 Markdown 的静态网站。我不想在 SublimeText 中编辑文件,而是想在 Xcode 中编辑它们。我可以在 Xcode 中打开各个文件,但我想打开整个静态站点目录并
现在我正在开发一个使用 Markdown 的静态网站。我不想在 SublimeText 中编辑文件,而是想在 Xcode 中编辑它们。我可以在 Xcode 中打开各个文件,但我想打开整个静态站点目录并
我真的厌倦了其他用户的项目错误,因为 XCode 的默认类引用类型是“相对于 XCode 文件夹”。我知道您可以将其更改为“相对于封闭组”,这就是我们的项目,但是任何时候有人创建一个新的类文件并且忘记
我对 Xcode 一无所知,除了它是来自 Apple 的开发人员界面,它实际上来自 OSX CD,它也用于创建 iPhone 应用程序。 我也知道它有一个 Applications 文件夹,里面装满了
更新 Xcode(从 7.2 到 7.2.1)后,XcodeServer 无法运行 Xcode Service。当我选择更新的 Xcode 时,提示消息:Enable Accessibility ac
我很难找到有关新 XCode 布局的信息。如何查看源文件的反汇编,而不仅仅是 C++ 代码? 最佳答案 在 Xcode 4.2(和 Xcode 5)中,您可以通过以下方式查看文件的汇编或反汇编: 显示
我在 XCode 中为我的项目添加了一个文件夹并将其命名为 Themes,它将用于存储我的 iPad 应用程序的主题。在那下面我有红色、蓝色等等。 它们出现在 XCode 中。但是当我查看物理文件夹时
作为我之前 How can I create a reference cycle using dispatchQueues? 的后续: 对于强引用(会造成泄漏,但不是循环引用),例如Timer、Dis
我有一台 macbook air,我去商店安装 Xcode 7.3 并点击更新 App 按钮,然后出现了一个加载图标,但等待 30 分钟后什么也没发生。我从商店成功安装了 simple recorde
我的项目现在有一个project.xcworkspace/xcshareddata目录。 Xcode在project.xcworkspace/xcshareddata目录中存储什么? 最佳答案 xcs
我不经常使用 XCode 进行开发,最近 MacPorts 告诉我我需要获得 3.1 才能使包工作。我去了苹果,他们为我提供了最新版本,结果只适用于 OSX 6。因为我有 OSX 5,它对我没有任何帮
有谁知道如何强制 Xcode 停止运行。我更新到 6.2 但现在它不能正常工作。我需要退出 Xcode 才能完成更新或卸载并重新安装。菜单中的相当 Xcode 不可用。无法将其拖到垃圾箱,因为它说它仍
我最近从我的项目中删除了一些旧的测试类并删除了文件。正如预期的那样,文件被移到垃圾箱并在 git 中显示为已删除。 不幸的是,测试类和它们定义的测试用例继续出现在测试导航器中。我已经尝试过常见的疑点,
Xcode 中的场景编辑器显示大小但不显示单位。它是以英寸为单位的尺寸还是以米为单位的尺寸? 例如,当我选择一个节点时,例如一个盒子,当我在节点检查器中检查它的属性并在“边界框”旁边的“变换”部分检查
只想知道 xcode 项目中事件可执行文件的目的是什么? 谢谢 索拉布 最佳答案 自己找到了..希望它会帮助某人。 您可以在其中运行和测试软件产品的可执行环境。可执行环境定义了应该用来运行产品的程序。
刚回到我的办公 table ,Xcode 一直在文件中突出显示/强调空白区域。如果我输入一些东西它就会消失,但如果我切换标签并回来,它们会重新出现。 更新:这不是由“显示隐形”选项引起的。那看起来不一
我首先注意到这一点 Cmd-/偶尔拒绝为注释取消注释的代码行工作。但是现在(刚刚使用 XCode 4.1,虽然这可能无关)它发生在 Cmd-B建立。 我无法弄清楚我正在做什么导致这种情况,或者是否有任
我不太了解Xcode 4的工作区的实用程序。它们的用途是什么,它们如何帮助Xcode进行开发? 最佳答案 例如。您有一个在两个应用程序中使用的库。您很可能为此库拥有一个自己的项目,对吗?现在,您可以自
我正在关注一个应用程序教程,它说: “接下来,在 Xcode 应用程序项目目录的根目录下创建一个空文件,并调用该文件 Podfile。使用您喜欢的文本编辑器打开它,然后在其中粘贴以下行:” 我很困惑这
我是一名优秀的程序员,十分优秀!