android - 在 Eclipse 中查看变量时 gdb 进程崩溃

标签 android c++ eclipse android-ndk gdb

简而言之,我正在使用 Eclipse 插件作为 gdb 的前端,并试图找出 gdb 崩溃的原因。完整的 gdb 日志很长,但相关部分在这里:

(gdb)
915 whatis this
&"whatis this\n"
~"type = Director * const\n"
915^done,time={wallclock="0.01200",user="0.01200",system="0.00000"}
(gdb)
916 ptype Director * const
&"ptype Director * const\n"
&"A syntax error in expression, near `const'.\n"
916^error,msg="A syntax error in expression, near `const'."
(gdb)
917 ptype this
&"ptype this\n"
~"type = struct Director : public Ref {\n"
~" public:\n"
~" static const char *EVENT_PROJECTION_CHANGED;\n"
~" static const char *EVENT_AFTER_UPDATE;\n"
~" static const char *EVENT_AFTER_VISIT;\n"
~" static const char *EVENT_AFTER_DRAW;\n"
~" protected:\n"
~" bool _purgeDirectorInNextLoop;\n"
~" struct Scheduler *_scheduler;\n"
~" struct ActionManager *_actionManager;\n"
918 whatis prevCalls
919 whatis prevVerts
920-var-create - * this
921-var-create - * prevCalls
922-var-create - * prevVerts
923-gdb-exit

每次我停在这个特定断点并打开变量 View 时都会发生崩溃(只要我不查看变量,它就不会崩溃)。

Problem signature:
Problem Event Name: APPCRASH
Application Name:   arm-eabi-gdb.exe
Application Version:    0.0.0.0
Application Timestamp:  50ee5128
Fault Module Name:  arm-eabi-gdb.exe
Fault Module Version:   0.0.0.0
Fault Module Timestamp: 50ee5128
Exception Code: c0000005
Exception Offset:   000dacc4
OS Version: 6.1.7601.2.1.0.256.1
Locale ID:  1033
Additional Information 1:   0a9e
Additional Information 2:   0a9e372d3b4ad19135b953a78882e789
Additional Information 3:   0a9e
Additional Information 4:   0a9e372d3b4ad19135b953a78882e789

gdb 可执行文件是插件附带的文件 (eclipse/plugins/com.nvidia.ndklaunch_21.0.0.201307250029/gdb/windows/arm-eabi-gdb.exe)。我还尝试了来自 NDK 工具链的两个 gdb 版本(4.6 和 4.8),结果相同。

使用 Windows 任务管理器获取的 android-ndk-r9d\toolchains\arm-linux-androideabi-4.6\prebuilt\windows\bin\arm-linux-androideabi-gdb-orig.exe 转储文件:https://docs.google.com/file/d/0B6bp7nCoOK_peTNIMDVpN0QtTjA/

正在调试的源文件:https://github.com/cocos2d/cocos2d-x/blob/v3/cocos/base/CCDirector.cpp

如果需要更多上下文,这里是完整的故事。我正在尝试在 Windows 中设置一个新的 NDK 项目。到目前为止,我已经能够使用 Eclipse 的 NVidia 调试管理器插件进行调试器工作。然而,几乎在我开始工作后,我就遇到了这个问题,变量 View 导致 gdb 崩溃。我对 gdb 命令行没有任何经验,插件也不允许我输入自己的命令。我不能绕过插件直接使用调试器,因为插件处理连接到设备上的 gdbserver 和解析调试符号的复杂部分(我已经能够在没有插件的情况下连接到 gdbserver,但我无法调试符号适用于我的代码正在使用的静态库)。

最佳答案

这是我学到的:

  1. gdb 崩溃的原因是我将过时的 -gstab+ 标志传递给 g++(-gstab 导致相同的问题)
  2. 没有 -gstab+ 或 -gstab,调试器(包括 Eclipse 前端)可以工作,但不显示局部变量(例如 C++“this”)
  3. 调试器不显示局部变量的原因在于 NDK r9d 工具链使用不兼容的 gdb 7.3 和 g++ 4.8(是的,一个巨大的 WTF 时刻)。也就是说,默认情况下,g++ 4.8 以 dwarf-4 格式生成调试信息,而 gdb 7.3 仅支持 dwarf 到版本 2。
  4. (3) 的解决方法是将 -gdwarf-2 传递给编译器
  5. 但 (3) 也有最终解决方案 - 用更新版本 (7.6) 替换 gdb,可以从 Linaro 工具链版本中提取:https://releases.linaro.org/13.10/components/toolchain/binaries/gcc-linaro-arm-linux-gnueabihf-4.8-2013.10_win32.zip

关于android - 在 Eclipse 中查看变量时 gdb 进程崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23717079/

相关文章:

android - 如何在Android应用程序的 GridView 中加载图像时显示进度条

Android 自定义键盘 - 如何获取浏览器 InputType?

android - api在浏览器中工作但在android phonegap中不工作

c++ - 2 QOpenGLWidget共享上下文导致崩溃

c++ - `pthread`的run函数如何修改外部变量?

android - 无法检查我的textview在Kotlin中是否可见数组内部

java.lang.SecurityException : Invalid signature file digest for Manifest main attributes 错误

java - 从android中的url加载图像

Java Eclipse 使内容辅助变得透明

c++ - 将多个数组传递给一个函数