android-ndk-r7b\docs\NDK-GDB.html
Usage: --------- The Android NDK r4 introduced a helper shell script named 'ndk-gdb' to easily launch a native debugging session for your NDK-generated machine code.
IMPORTANT: Native debugging can only work if *all* these conditions are met: 1. Your application is built with the 'ndk-build' script: 2. Your application is debuggable: 3. You are running your application on Android 2.2 (or higher):
You can set breakpoints with 'b <location>' and resume execution with 'c' (for 'continue'). See the GDB manual for a list of commands.
Options: ------------ To see a list of options, type 'ndk-gdb --help'. Notable ones are: --verbose: Print verbose information about the native debugging session setup. Only needed to debug problems when you can't connect and that the error messages printed by ndk-gdb are not enough. --force: By default, ndk-gdb aborts if it finds that another native debugging session is running on the same device. Using --force will kill the session, and replace it with a new one. Note that the debugged program is *not* killed and will be stopped again. --start: By default, ndk-gdb will try to attach to an existing running instance of your application on the target device. You can use --start to explicitly launch your application before the debugging session. NOTE: This launches the first launchable activity listed from your application manifest. Use --launch=<name> to start another one. See --launch-list to dump the list of such activities. --launch=<name>: This is similar to --start, except that it allows you to start a specific activity from your application. This is only useful if your manifest defines several launchable activities. --launch-list: Convenience option that prints the list of all launchable activity names found in your application manifest. The first one will be used by --start --project=<path>: Specify application project directory. Useful if you want to launch the script without cd-ing to the directory before that. --port=<port>: By default, ndk-gdb will use local TCP port 5039 to communicate with the debugged application. By using a different port, it is possible to natively debug programs running on different devices/emulators connected to the same development machine. --adb=<file>: Specify the adb tool executable, in case it is not in your path. -d, -e, -s <serial>: These flags are similar to the ADB ones and allow you to handle the case where you have several devices/emulators connected to your development machine. -d: Connect to a single physical device -e: Connect to a single emulator device -s <serial>: Connect to a specific device or emulator where <serial> is the device's name as listed by the "adb devices" command. Alternatively, you can define the ADB_SERIAL environment variable to list a specific device, without the need for a specific option. --exec=<file>: -x <file>: After connecting to the debugged process, run the GDB initialization commands found in <file>. This is useful if you want to do something repeatedly, e.g. setting up a list of breakpoints then resuming execution automatically.
Requirements: ------------------ At the moment 'ndk-gdb' requires a Unix shell to run. This means that Cygwin is required to run it on Windows.
Thread Support: ------------------- If your application runs on a platform older than Android 2.3, ndk-gdb will not be able to debug native threads properly. Instead, the debugger will only be able to put breakpoints on the main thread, completely ignoring the execution of other ones.
If you place a breakpoint on a function executed on a non-main thread, the program will exit with the following message in GDB: Program terminated with signal SIGTRAP, Trace/breakpoint trap. The program no longer exists.