From 9978f0a865d61cbbdc27593044d4128d8bf56239 Mon Sep 17 00:00:00 2001 From: David Benjamin Date: Wed, 30 Jan 2019 16:56:54 -0600 Subject: [PATCH] Add instructions for debugging on Android with gdb. Android's official documentation seems to assume you're using the NDK build system or Android Studio. I extracted this from one of their scripts a while back. May as well put it somewhere we can easily find it. Change-Id: I259abc54e6935ab537956a7cbf9f80e924a60b7a Reviewed-on: https://boringssl-review.googlesource.com/c/34724 Reviewed-by: Adam Langley --- BUILDING.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/BUILDING.md b/BUILDING.md index ba988b76..4fc1615c 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -106,6 +106,21 @@ higher to build aarch64 binaries. For other options, see the documentation in the toolchain file. +To debug the resulting binaries on an Android device with `gdb`, run the +commands below. Replace `ARCH` with the architecture of the target device, e.g. +`arm` or `arm64`. + + adb push ${ANDROID_NDK}/prebuilt/android-ARCH/gdbserver/gdbserver \ + /data/local/tmp + adb forward tcp:5039 tcp:5039 + adb shell /data/local/tmp/gdbserver :5039 /path/on/device/to/binary + +Then run the following in a separate shell. Replace `HOST` with the OS and +architecture of the host machine, e.g. `linux-x86_64`. + + ${ANDROID_NDK}/prebuilt/HOST/bin/gdb + target remote :5039 # in gdb + ### Building for iOS To build for iOS, pass `-DCMAKE_OSX_SYSROOT=iphoneos` and