Skip to content

How to debug crashes on Android using addr2line

Henrik Rydgård edited this page Sep 8, 2022 · 3 revisions

NOTE: The below assumes that your crash is locally reproducible. For debugging crashes from Google Play, you could go and extract the binary from the APK but I'm going to archive pre-stripped binaries in the future.

Say you get a stacktrace from ADB logging and you need to know what code is at address "pc".

Recommended ADB command line, by the way:

adb logcat -s AndroidRuntime DEBUG PPSSPPNativeActivity PPSSPP NativeGLView NativeRenderer NativeSurfaceView PowerSaveModeReceiver InputDeviceState PpssppActivity

After building and running from Android Studio, and then crashing to make sure the binary you have locally is the same as on the Android device, first find the addr2line binary, which should be here, adjusting the paths as necessary:

C:\Android\sdk\ndk\21.4.7075529\toolchains\aarch64-linux-android-4.9\prebuilt\windows-x86_64\bin\aarch64-linux-android-addr2line.exe

Then, to find the correct libppsspp.jni binary (that's PPSSPP), follow these steps (there might be an easier way):

(Replace Debug with your actual configuration, although if you're this deep, that's probably the one you want)

  • Find the newest directory under C:\dev\ppsspp\android\build\intermediates\cxx\Debug

  • Inside, find obj\arm64-v8a\libppsspp.jni

That will make your full path. In my case, the full command line becomes:

C:\dev\ppsspp>C:\Android\sdk\ndk\21.4.7075529\toolchains\aarch64-linux-android-4.9\prebuilt\windows-x86_64\bin\aarch64-linux-android-addr2line.exe -C -f -e C:\dev\ppsspp\android\build\intermediates\cxx\Debug\14531q1l\obj\arm64-v8a\libppsspp_jni.so 000000000186224c

And the output was:

get_bits
C:\dev\ppsspp\ffmpeg/libavcodec/get_bits.h:266