Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ndk-gdb with multiple so libs

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!

like image 819
MaratSafinWang Avatar asked Sep 09 '10 08:09

MaratSafinWang


1 Answers

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.

like image 147
SomeCallMeTim Avatar answered Sep 22 '22 02:09

SomeCallMeTim