1

I would like to debug a combined Java/C++ app which is occasionally crashing inside the C++. I am using Eclipse Kepler on a Windows-7-64 PC.

After reading this SO question I decided to try out the DS-5 CE Android Debug tool. So I went to the instructions page. I installed the things requested in the "prerequisites" section, and then came across these words:

To use the DS-5 Debugger to debug native code, update the version of gdbserver in the Android NDK ...\toolchains...\prebuilt directory with the version of gdbserver provided by DS-5. You can locate this file by selecting Help → ARM Extras... from the main menu. Ensure that you rename it to gdbserver.

Now I'm completely confused. I'm not sure what it means to replace the gdbserver. Is gdbserver a single file? multiple files? a directory? If I search for "toolchains" and "prebuilt", I see that there are multiple directories on my system that fit the bill. I have c:\android-ndk-r9c\toolchains\xxx\prebuilt\ where xxx could be a variety of things like llvm-3.3 or renderscript or x86-4.6 or x86-4.8. Which one are they talking about? If I select Help → ARM Extras... then a window pops up showing me a directory called "arm" which contains three subdirectories, one of which is "gdbserver".

I presume I new need to copy some files from one location to another... but exactly which files, and what locations, is a mystery to me.

Community
  • 1
  • 1
Mick
  • 8,284
  • 22
  • 81
  • 173
  • gdbserver is a delegate programming included in a debug apk which the gdb debugger program on the PC talks to. As it runs on the target Android device, there must be a version of it for each ABI to be supported. Try to copy files between similar directories. That said, why not use the gdb that comes with the ndk? And ultimately, strategically placing logging in suspect code is often just as effective (you can log from native code, too). – Chris Stratton Jul 24 '14 at 14:47
  • "gdbserver is a delegate programming" ? looks like a typo to me. With regard logs - yes I already log from C++, but the program is large complex and multi-threaded and it sometimes will only crash after five minutes or so. Under these circumstances a debugger would be very handy. – Mick Jul 24 '14 at 14:53
  • Yes, should be "delegate program" or helper program or "stub". I'd have to 180-degree disagree with you on the utility of a debugger for infrequent crashes - not only does it potential disturb the operation of the program (even the adb cable changes device power behavior), but it doesn't let you go back after the fact and see what happened with a crash that happened when you weren't looking. The logcat buffer in contrast often does if you are quick about it. – Chris Stratton Jul 24 '14 at 14:56
  • Mostly I'm on your side re logs vs debuggers. Over the years I've found & fixed 9 out of 10 bugs with logs/printf's... Indeed once I've found the location of the crash, if the cause is non obvious, I'll probably go on to find the cause with logs. But the crash location is a complete mystery to me right now, so a debugger would be handy. – Mick Jul 24 '14 at 15:02
  • Do you not get a native crash report in the log with the address, registers and a few stack frames? Anyway, you can either use the stock ndk gdb & gdbserver, or try to replace the ndk gdbserver files for each architecture with the corresponding ones from this alternate distribution. – Chris Stratton Jul 24 '14 at 15:08
  • I get "A/libc(1821): Fatal signal 11 (SIGSEGV) at 0xa8eb3000 (code=2), thread 1997 (Thread-3972)"... is there some way to find the code at 0xa8eb3000 ? – Mick Jul 24 '14 at 15:17
  • Yes, there is. There are both specific tools to do it, or you can get the load address of libc from /proc/pid#/maps, pull the binary off the phone objdump it and look to figure out which function it is in. Typically with a crash in libc you have called a library function with a bad pointer. Your crash report should be giving more information tool, list the address of the access which triggered the SIGSEGV... for example if it is 0 you have a null pointer, if it is something like DEADBAAD you have hit error code which is causing an intentional crash, etc. – Chris Stratton Jul 24 '14 at 15:23

0 Answers0