views:

259

answers:

1

Hi everyone.

I learned about the debug tool of "ndk-gdb" from Android NDK r4. Now I can start debugging the hello-jni sample(although some issue exists).

But, for my own Android applications, I have several so libs to use, build from a large number of c/c++ files. I used to build these so files with ndk-build, and then copy these so files under $PROJECT/libs directory, and it works fine without debugging. But now I want to debug one so lib with ndk-gdb. When I started ndk-gdb, it complains that no symbol table is loaded.

I also copy all these so files to $PROJECT/bin/ndk/local/armeabi(seems like the default directory where gdb tries to load symbol table). And still, it doesn't work.

Maybe ndk-gdb can't track my so files after I copy them? Or why it can't load any symbol tables, even after I copy them under $PROJECT/bin/ndk/local/armeabi?

Have anyone meet with this issue before?

Thanks a lot!

+1  A: 

I think you're copying them to the wrong folder. The older NDK copied files to the bin folder; the new one copies them to the obj folder, and that's where it points gdb to look for symbols.

Also, be sure that you copy the pre-stripped .so files to the obj folder, and not the same files that you copy to the libs folder: As part of the build process, the files in the libs folder have been stripped of symbols and debugging information. So you'll want to keep two copies of each of your .so files: One from the libs folder to install on the Android device, and one from the obj folder to install for GDB to get symbols from.

You could, instead of copying the debug files to the obj folder in your app tree, add the other build directory obj/ folders to gdb's symbol search path. ndk-build sets up a file, gdb.setup, that includes a line that starts with set solib-search-path. You can put a colon-separated path on that line that includes all of your target obj/local/whatever folders, and then gdb will find the symbols.

SomeCallMeTim
Thanks a lot for your reply! I will try your solution tomorrow. And, could you offer more documents about the internal build process of NDK? Something like "stripped so", I never heard of it.
MaratSafinWang
See the Unix command "strip": http://unixhelp.ed.ac.uk/CGI/man-cgi?strip -- just be careful if you type "man strip" into Google at work. Was surprised at the first links. :)
SomeCallMeTim
As for other steps of the build process, this is documented in docs/OVERVIEW.TXT in the NDK package: "The last step will copy, in case of success, the stripped shared libraries your application needs to your application's root project directory."
SomeCallMeTim
If this answer helped you, can you please mark it as accepted? Still trying to build up my StackOverflow reputation.
SomeCallMeTim