简体   繁体   English

在Qt Creator中访问内部项目库的调试符号?

[英]Accessing internal project library's debugging symbols in Qt Creator?

I have a project/source tree with sub-directory projects, that look as follows: 我有一个带有子目录项目的项目/源代码树,如下所示:

Qt Creator-项目源代码树

The idea is that the exec (testing) project is to make calls from the op (shared-object) library project - both being sub-projects managed by the root project gviewer . 这个想法是exec (测试)项目要从op (共享对象)库项目中进行调用-这两个项目都是由根项目gviewer管理的子项目

Despite having the gviewer project set as Debug (using GCC x86_64), anytime I try to step into a constructor or class-method/function from the op build, the debugger will just spit out disassembly immediately. 尽管已将gviewer项目设置为Debug(使用GCC x86_64),但每当我尝试从op构建中进入构造函数或类方法/函数时,调试器都会立即吐出反汇编代码。 I've been having a hard time figuring out whether the issue is the project settings ( -- of which I've looked at and had trouble figuring out which setting could be changed to solve the problem) an issue in the debugger settings (also looked at), or something going on with the project files. 我一直很难确定问题是否出在项目设置上(我已经研究过-并难以确定可以更改哪个设置来解决问题),这是调试器设置中的一个问题(也是查看),或者项目文件中发生了什么。

The common.pri file is included by op.pro. common.pri文件包含在op.pro中。

After looking here , and experimenting with various views while trying to load the symbols while debugging, I've come to the conclusion I'm doing something wrong. 看完这里并尝试各种视图并尝试在调试时加载符号后,我得出的结论是我做错了什么。 Whether this is a GDB debug configuration issue, a .pro file issue, or a QtCreator issue is beyond me. 这是GDB调试配置问题, .pro文件问题还是QtCreator问题,这超出了我的范围。

If anyone here has had experience with loading debug symbols using internal project libraries (in this case: shared objects), any insight provided would be appreciated. 如果这里的任何人都有使用内部项目库(在本例中为共享对象)加载调试符号的经验,将不胜感激。 Thanks. 谢谢。


Project Files: 项目文件:

gviewer.pro gviewer.pro

TEMPLATE = subdirs
SUBDIRS  = \
    source/op

CONFIG += ordered
SUBDIRS += source/exec

common.pri common.pri

INCLUDEPATH += . ..

TEMPLATE = lib

CONFIG -= qt app_bundle

NO_ERR_FLAGS = -Wno-write-strings -Wno-return-type -Wno-unused-parameter

debug:QMAKE_CXXFLAGS_DEBUG += -Wall -Werror -std=c++11 $$NO_ERR_FLAGS -g

DEFINES += OP_DEBUG OP_PLATFORM_X86

LIBS += -lGL -lGLU -lGLEW -lglfw

op.pro op.pro

! include(../common.pri) {
    error( Couldn't find the common.pri file! )
}

HEADERS += \
    debug/glout.hpp \
    math/matrix.hpp \
    math/math.hpp \
    math/glm_incl.hpp \
    io/log.hpp

SOURCES += \
    debug/glout.cpp \
    math/matrix.cpp \
    io/log.cpp

exec.pro 可执行文件

INCLUDEPATH += ../

TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle qt

SOURCES += main.cpp

LIBS += -L../op -lop

DESTDIR_TARGET = ../../

Some further images: 一些进一步的图像:

exec : entry point - main.cpp exec :入口点-main.cpp

主要切入点

op : disassembly - no source loaded after invoking step into op :反汇编-调用step into后,未加载任何源
on op::Log::OpenFile(...) op::Log::OpenFile(...)

拆卸

debugger source paths - fiddled with the paths here, no such luck; 调试器源路径 -在这里摆弄路径,没有运气; though I'm not sure if I was using this correctly 虽然我不确定我是否使用正确

调试设置-源路径

In your .pro file you have this: 在您的.pro文件中,您需要执行以下操作:

LIBS += -L../op -lop

If I understood you well, this is where you are linking the library you have problems with. 如果我对您的理解很好,那么这里就是链接有问题的库的地方。 You should, however, link two versions of it, the debug version for the debug build of your project, and the release version for the release version of your project. 但是,您应该链接它的两个版本,分别是项目调试版本的调试版本和项目发行版本的发行版本。 I don't know what OS are you under, but here's an example for you so you can get the idea: 我不知道您使用的是哪种操作系统,但是这里有一个示例供您使用,您可以了解一下:

unix:CONFIG(release): LIBS += -L$$PWD/../../Filters/release/ -lFilters
unix:CONFIG(debug): LIBS += -L$$PWD/../../Filters/debug/ -lFilters

Note that the first line links the release library if the current project is being built as release, and the second line is linking the debug library version if the current project is being built as debug. 请注意,如果将当前项目构建为发行版,则第一行将链接发布库,如果将当前项目构建为调试,则第二行将链接调试库版本。

As a compliment to the accepted answer, it's worth noting that if the user's configuration uses Shadow Building , we can rephrase the configuration as: 作为对已接受答案的补充,值得注意的是,如果用户的配置使用Shadow Building ,我们可以将配置改为:

unix:CONFIG(release): LIBS += -L$$PWD/../../path/to/release/folder/ -lLibrary
unix:CONFIG(debug):   LIBS += -L$$PWD/../../path/to/debug/folder/   -lLibrary

Where /path/to/release|debug/folder 's location is at the same level as the source|project file directory, and -lLibrary is the binary library to be linked which resides within the specified -L... path. /path/to/release|debug/folder的位置与source | project文件目录位于同一级别,而-lLibrary是要链接的二进制库,它位于指定的-L...路径内。

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

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