简体   繁体   English

Linux中QTCreator中dlopen打开的共享库如何设置断点

[英]How to set a breakpoint in a shared library opened with dlopen in QTCreator in Linux

I am trying to debug with QTCreator my shared library which is being called with dlopen and dlsym.我正在尝试使用 QTCreator 调试我的共享库,该库是使用 dlopen 和 dlsym 调用的。 QT debugger does not stop at breakpoints in the shared library. QT 调试器不会在共享库中的断点处停止。

When I run my app with with GDB it works correctly.当我使用 GDB 运行我的应用程序时,它可以正常工作。

The SO has debugging symbols. SO 具有调试符号。

how can I get QTCreator to debug my app?如何让 QTCreator 调试我的应用程序?

Thanks.谢谢。

Update:更新:

I created a gdb startup script with the full path to my project and it now works.我创建了一个 gdb 启动脚本,其中包含我项目的完整路径,现在它可以运行了。 Thing is, I don't want this script to run for every project using QT.问题是,我不希望使用 QT 为每个项目运行此脚本。

Is it possible to do this per project?每个项目都可以这样做吗?

It looks like GDB is unable to locate your.so file.看起来 GDB 无法找到您的 .so 文件。 You should check this post to see if the shared library can be found in your solib-search-path .您应该检查这篇文章,看看是否可以在您的solib-search-path中找到共享库。 If it's not, you should extend the "Additional Startup Commands" field in Tools/Options/Debugger/GDB with something like:如果不是,您应该使用以下内容扩展 Tools/Options/Debugger/GDB 中的“Additional Startup Commands”字段:

set solib-search-path %{CurrentProject:BuildPath}/<relative path to the folder where the .so file was built>

In my situation, working under Android, I set set solib-search-path %{CurrentProject:BuildPath}/android-build/libs/armeabi-v7a and now breakpoints work if set in shared libraries code.在我的情况下,在 Android 下工作,我设置set solib-search-path %{CurrentProject:BuildPath}/android-build/libs/armeabi-v7a如果在共享库代码中设置断点现在工作。

@ChrisF: Tried to mark Debugging a dynamically-loaded library in c++ with QtCreator as being a duplicate of this question, but I must wait to have an upvote (stackoverflow won't let me flag the duplicate because "This question does not have an upvoted or accepted answer"..." @ChrisF:试图将Debugging a dynamical-loaded library in c++ with QtCreator 标记为这个问题的副本,但我必须等待投票(stackoverflow 不会让我标记重复项,因为“这个问题没有赞成或接受的答案“......”

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

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