eclipse - Windows 上的 Android NDK solib-search-path 使用不正确的斜杠

标签 eclipse android-ndk gdb

我正在尝试使用 Eclipse (Kepler) 在 Windows 上调试 NDK 项目,但 GDB 找不到 .so 文件的符号,因为搜索路径中斜杠的方向不正确。使用 NDK r9 和 SDK 22.2.1,当我尝试运行该应用程序时,GDB 显示:

warning: Could not load shared library symbols for 64 libraries, e.g. /system/bin/linker.

Use the "info sharedlibrary" command to see the complete listing.

Do you need "set solib-search-path" or "set sysroot"? warning: Unable to find dynamic linker breakpoint function.

GDB will retry eventurally. Meanwhile, it is likely that GDB is unable to debug shared library initializers or resolve pending breakpoints after dlopen().

No symbol table is loaded. Use the "file" command.

No symbol table is loaded. Use the "file" command.

No symbol table is loaded. Use the "file" command.

对于我的库中设置的每个断点,“未加载符号表...”行都会出现一次。问题似乎是 GDB 找不到未剥离的 .so 文件,因为搜索路径包含反斜杠而不是正斜杠。如果我暂停程序并执行以下 GDB 命令,这就是我得到的输出:

show solib-search-path

The search path for loading non-absolute shared library symbol files is C:\\Users\\Username\\Projects\\Project\\Android/obj/local/armeabi-v7a/.

info shared

From        To          Syms Read   Shared Object Library
0x4003fff0  0x4006db40  Yes         C:/Users/Username/Projects/Project/Android/obj/local/armeabi-v7a/libc.so
0x5bda8598  0x5bf5aa50  No          C:/Users/Username/Projects/Project/Android/obj/local/armeabi-v7a/libProject.so

如果我随后更新 solib-search-path 以使用正斜杠,我会得到以下结果:

set solib-search-path C:/Users/Username/Projects/Project/Android/obj/local/armeabi-v7a/
warning: Could not load shared library symbols for 74 libraries, e.g. /system/bin/linker.
Use the "info sharedlibrary" command to see the complete listing.
Do you need "set solib-search-path" or "set sysroot"?
warning: Unable to find dynamic linker breakpoint function.
GDB will retry eventurally.  Meanwhile, it is likely
that GDB is unable to debug shared library initializers
or resolve pending breakpoints after dlopen().

info shared
From        To          Syms Read   Shared Object Library
0x4003fff0  0x4006db40  Yes         C:/Users/Username/Projects/Project/Android/obj/local/armeabi-v7a/libc.so
0x5bda8598  0x5bf5aa50  Yes         C:/Users/Username/Projects/Project/Android/obj/local/armeabi-v7a/libProject.so

此后,GDB 将成功命中 native 代码中的断点。 libs\armeabi-v7a 文件夹中的 gdb.setup 文件包含以下行:

set solib-search-path ./obj/local/armeabi-v7a

但是我不确定这个路径在哪里变成了绝对路径。我猜想 GDB 就在那时使用带有反斜杠而不是正斜杠的路径,但我不确定这种情况发生在哪里。我确实尝试修改创建 gdb.setup 文件的 Android NDK 构建脚本,甚至尝试放入不同的路径,但 show solib-search-path 的输出是相同的,所以我什至不确定 GDB 是使用该搜索路径。有没有人以前遇到过这个问题,或者有谁知道当我从 Eclipse 运行时如何让 GDB 以正确的搜索路径启动?

最佳答案

我认为这可能只是 GDB 稍后才加载符号。在加载项目的 .so 之前,我确实有一个延迟,以便 GDB 有时间进行连接。我将延迟移至调用 loadLibrary 之后,现在似乎可以正常拾取符号了。

关于eclipse - Windows 上的 Android NDK solib-search-path 使用不正确的斜杠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19618362/

相关文章:

android - 对 'rindex' 的 undefined reference

c++ - 在 gdb 中打印最小堆栈

c - 没有加载调试符号时,gdb 如何解释 `main`?

java - 如何在 Eclipse 中用我自己的自定义代码包围代码?

java - Eclipse 和 Netbeans 的共存情况如何?

android-ndk - android.graphics.Canvas 中使用的算法

c++ - ndk 使用 opencv 构建

macos - gdb: mac ctrl c 使终端挂起

java - Eclipse 无法使用 sudo 运行

java - NetBeans java.lang.ClassNotFoundException