前言：说真的Android NDK debug还是推荐lldb，gdb经常莫名其妙的不成功。不过下面的这个流程是谷歌官方建议的，还是有参考价值的。尤其是在App启动时Debug的流程。
Sometimes you want to debug an app as it starts, such as when there's a crash and you want to step through code to see what happened before the crash. Attaching works in some cases, but in other cases is impossible because the app crashes before you can attach. The
logwrapper approach (used for
strace) doesn't always work because the app might not have permissions to open a port, and
gdbserver inherits that restriction.
To debug app startup, use the developer options in Settings to instruct the app to wait for a Java debugger to attach:
gdbclientnormally, set breakpoints, then continue the process.
To let the app run, attach a Java Debug Wire Protocol (JDWP) debugger such as Java Debugger (jdb):
adb forward tcp:12345 jdwp:XXX # (Where XXX is the PID of the debugged process.) jdb -attach localhost:12345
If you want
debuggerd to suspend crashed processes so that you can attach
gdb, set the appropriate property:
At the end of the usual crash output,
debuggerd provides instructions on how to connect
gdb using the command:
gdbclient.py -p PID
For 32-bit ARM, if you don’t have symbols,
gdb can't determine which instruction set it's disassembling (ARM or Thumb). To specify the instruction set chosen as the default when symbol information is missing, set the following property:
set arm fallback-mode arm # or thumb
GDB supports debugging platform code on Visual Studio Code. You can use the VS Code debugger frontend instead of the GDB CLI interface to control and debug native code running on devices.
Before using VS Code for debugging, install the C/C++ extension.
To debug code using VS Code:
gdbclient.pycontinues running. This is expected; don't kill the
launch.jsonfile and adds a new JSON object to a list.
gdbclient.pyand paste it into the object you just deleted. Save the changes.
gdbclient.pyand press Enter to end the
After setting up the debugger configuration for the first time, you can skip steps 3 through 6.
在 Android NDK 开发中，排查问题遇到的最熟悉的关键字非 backtrace 莫属，Linux 系统中进程 crash 后通过 backtrace 输...
前两天, 没修改什么, 打开Android Studio编so, 忽然就不成功了.
最近升级Android Studio和sdk后, gradle同步项目时忽然报错, Error:Failed to notify project evalu...