I’m trying to debug a native shared library that my App uses through JNI. I can attach to a running app just fine with “gdbserver –attach pid” but i need to actually launch my app when i launch the gdbserver command.
There’s a million blog hits on this topic but none of them seem to be clear as to how you launch your app. They all say to just type “gdbserver 10.0.2.2:1234 ./MyProgram” but what exactly is “MyProgram”. Is that MyProgram.apk? Is it MyProgram.so? Is it some other file that gets created when the app is installed? If so, what’s its path?
While it is possible to develop free standing applications that can be launched directly from the shell as others are describing, it sounds like your code runs within the Android application framework. Therefore, you don’t have an executable and instead have an APK that contains your Dalvik class files along with other resources including your native shared object.
Launching an application in an APK involves several steps
While you can’t launch an APK directly by passing an executable to gdbserver, its fairly easy to trigger a launch it from the shell using the
amcommand.Once your application is running, use
gdbserver --attach <pid>like you have before. If you are lucky your application waits for some user interaction before calling into your native code to give you a chance to attach and set your breakpoints in GDB.