1
votes

In a nutshell, I am using an Eclipse plugin as a frontend to gdb, and trying to figure out why gdb is crashing. The full gdb log is very long, but the relevant part of it is here:

(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

The crash happens every time I stop on this specific breakpoint and open the variables view (it does not crash as long as I am not viewing the variables).

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

The gdb executable is the one that comes with the plugin (eclipse/plugins/com.nvidia.ndklaunch_21.0.0.201307250029/gdb/windows/arm-eabi-gdb.exe). I also tried two gdb versions from the NDK toolchains (4.6 and 4.8) with the same results.

A dump file of android-ndk-r9d\toolchains\arm-linux-androideabi-4.6\prebuilt\windows\bin\arm-linux-androideabi-gdb-orig.exe taken with the Windows Task Manager: https://docs.google.com/file/d/0B6bp7nCoOK_peTNIMDVpN0QtTjA/

Source file being debugged: https://github.com/cocos2d/cocos2d-x/blob/v3/cocos/base/CCDirector.cpp

If more context is needed, here is the full story. I am trying to set up a new NDK project in Windows. So far I was able to get to the point where the debugger kind of works using the NVidia Debug Manager plugin for Eclipse. However, almost immediately after I got it working, I ran into this issue with variables view causing gdb to crash. I do not have any experience with gdb command line, nor will the plugin allow me to input my own commands. I cannot bypass the plugin and use the debugger directly, as the plugin handles the complicated part of connecting to the gdbserver on the device and resolving the debugging symbols (I have been able to connect to the gdbserver without the plugin, but I could not make debugging symbols work for the static library that my code is using).

1
Best option might be to build a debugging version of gdb and look at the backtrace - Paul Beusterien

1 Answers

2
votes

Here is what I learned:

  1. the reason gdb crashed was that I passed the outdated -gstab+ flag to g++ (-gstab results in the same issue)
  2. without -gstab+ or -gstab, the debugger (including the Eclipse frontend) works, but doesn't show local variables (e.g. C++ "this")
  3. the reason why the debugger doesn't show local variables lies in the fact that NDK r9d toolchain uses gdb 7.3 and g++ 4.8, which are incompatible (yes, a huge WTF moment). Namely, by default g++ 4.8 generates debugging information in dwarf-4 format, whereas gdb 7.3 only supports dwarf up to version 2.
  4. a workaround for (3) is to pass -gdwarf-2 to the compiler
  5. but there is also the ultimate solution for (3) - replacing gdb with a newer version (7.6), which can be extracted from a Linaro toolchain release: https://releases.linaro.org/13.10/components/toolchain/binaries/gcc-linaro-arm-linux-gnueabihf-4.8-2013.10_win32.zip