Kaydet (Commit) 2e8e0b21 authored tarafından Christian Lohmaier's avatar Christian Lohmaier

android: drop workarounds for ndk-gdb support (can still run manually)

packing gdbserver into apk conflicts with extractNativeLibs="false", as
the gradle pugin compresses it (which could be disabled using
aaptOptions), but furthermore it doesn't page-align it, breaking
installation.
So instead let the user manually push the gdbserver tool to device and
remove the hardcoded values that were only there to please the ndk-gdb
scripts.
Using lldb from within Android Studio is more comfortable anyway :-)

Change-Id: I31c3af4847a479c56b3fcd6b5bed114e004bf0d2
Reviewed-on: https://gerrit.libreoffice.org/41950Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarChristian Lohmaier <lohmaier+LibreOffice@googlemail.com>
üst 9a920bf9
......@@ -7,9 +7,7 @@
/source/captures/
/source/jni/Application.mk
/source/jniLibs/
/source/jniLibs_debug/
/source/liboSettings.gradle
/source/libs/*/gdb.setup
/source/local.properties
/source/native-code.cxx
/source/obj/
......
......@@ -99,8 +99,6 @@ liboSettings.gradle: $(BUILDDIR)/config_build.mk $(BUILDDIR)/config_host.mk
&& echo " liboVersionMajor = '$(LIBO_VERSION_MAJOR)'" \
&& echo " liboVersionMinor = '$(LIBO_VERSION_MINOR)'" \
&& echo " liboGitFullCommit = '$(shell cd $(SRCDIR) && git log -1 --format=%H)'" \
&& echo " liboNdkGdbserver = '$(ANDROID_NDK_GDBSERVER)'" \
&& echo " liboAndroidAppAbi = '$(ANDROID_APP_ABI)'" \
&& echo "}" \
&& echo "android.defaultConfig {" \
&& echo " applicationId '$(ANDROID_PACKAGE_NAME)'" \
......
......@@ -210,25 +210,19 @@ swap).
* Using ndk-gdb
When you have all this, install the .apk to the device, and:
cd android/source
<ndk-bundle>/ndk-gdb --adb=<android-sdk-linux>/platform-tools/adb [--start]
In case you used --with-android-package-name, add --package=your.package.name
to the invocation
If you get the error
ERROR: Could not find gdb.setup under ./libs/
(and an empty "Compatible device ABI:" when run with --verbose), you need to fix
the quoting in the ndk-gdb script:
@@ -574 +574 @@
-adb_var_shell BCFILES run-as $PACKAGE_NAME /system/bin/sh -c "ls lib/*.bc"
+adb_var_shell BCFILES run-as $PACKAGE_NAME /system/bin/sh -c \"ls lib/*.bc\"
Direct support for using ndk-gdb has been removed from the build system. It is
recommended that you give the lldb debugger a try that has the benefit of being
nicely integrated into Android Studio (see below for instructions).
If you nevertheless want to continue using ndk-gdb, use the following steps
that are described in more detail here: https://stackoverflow.com/a/10539883
- add android:debuggable="true" to AndroidManifest.xml
- push gdbserver to device, launch and attach to application
- forward debugging port from host to device
- launch matching gdb on host and run following setup commands:
- set solib-search-path obj/local/<appAbi>
- file obj/local/<appAbi>/liblo-native-code.so
- target remote :<portused>
Pretty printers aren't loaded automatically due to the single shared
object, but you can still load them manually. E.g. to have a pretty-printer for
......@@ -239,8 +233,9 @@ rtl::OString, you need:
* Using Android Studio (and thus lldb)
Note that both might not yield the same results - so if lldb doesn't show you
useful info, try with the ndk-gdb method and the other way round.
Note that lldb might not yield the same results as ndk-gdb. If you suspect a
problem with lldb, you can try to manually use ndk-gdb as described above.
Using lldb from within Android Studio is more comfortable though and works like this:
- open android/source/build.gradle in Android Studio via File|New → Import Project
- make sure you select the right build variant (strippedUIDebug is what you want)
......
......@@ -17,7 +17,6 @@
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/LibreOfficeTheme"
android:debuggable="true"
android:hardwareAccelerated="true"
android:largeHeap="false">
......
......@@ -36,4 +36,4 @@ run:
$(ANDROID_SDK_HOME)/platform-tools/adb shell am start -n $(ANDROID_PACKAGE_NAME)/.ui.LibreOfficeUIActivity
debugrun:
$(SYSBASE)/../../../ndk-gdb --start
@echo "please debug with lldb from within Android Studio, or setup ndk-gdb manually (see android/README for details)"
......@@ -40,24 +40,15 @@ android {
// ToDo move to conventional layout, so stuff can be stripped down.
sourceSets {
main.manifest.srcFile 'AndroidManifest.xml'
// override the debuggable flag that needs to be in AndroidManifest.xml
// since ndk-gdb awks for the literal string in there :-/
release.manifest.srcFile 'ReleaseManifest.xml'
main.assets.srcDirs = ['assets']
main.res.srcDirs = ['res']
main.java.srcDirs = ['../Bootstrap/src', 'src/java']
main.jniLibs.srcDirs = ['jniLibs']
main.jni.srcDirs = [] // don't attempt to build native-lib via gradle
// gdbserver for debugvariant
debug.jniLibs.srcDirs "jniLibs_debug"
// the configuration data that might be stripped or not
fullUI.assets.srcDirs 'assets_fullUI'
strippedUI.assets.srcDirs 'assets_strippedUI'
}
lintOptions {
// ndk-gdb looks for the literal value in the pre-processed manifest :-(
disable 'HardcodedDebugMode'
}
defaultConfig {
minSdkVersion 14
// openssl on x86 makes the native-code.so contain text-relocations,
......@@ -209,27 +200,6 @@ task createStrippedConfigRegistry(type: Exec) {
}
}
// ndk-gdb requires the gdb.setup to be in libs/<arch>/ folder - it's hardcoded in the script
// it should in theory also be able to copy the gdbserver binary onto the device, but the matching
// against prebuilt archs is too rudimentary and doesn't map armeabi-v7 to arm for example
task copyNdkDebugServer(type: Copy) {
description "copies gdbserver into and creates gdb.setup and Application.mk for use with ndk-gdb"
inputs.file "liboSettings.gradle"
def gdbsetup = file("libs/${liboAndroidAppAbi}/gdb.setup") // only needed on buildhost
// hardcoded path from ndk-gdb - reads the host architecture from that file
def applicationmk = file("jni/Application.mk")
outputs.files gdbsetup, applicationmk
outputs.dir 'jniLibs_debug' // own the directory, so it is removed on this task's clean
outputs.dir 'libs' // own the directory, so it is removed on this task's clean
into "jniLibs_debug/${liboAndroidAppAbi}"
from "${liboNdkGdbserver}"
doLast {
file("libs/${liboAndroidAppAbi}").mkdirs()
gdbsetup.text = "set solib-search-path ./obj/local/${liboAndroidAppAbi}\n"
applicationmk.text = "APP_ABI := ${liboAndroidAppAbi}\n"
}
}
task createRCfiles {
inputs.file "liboSettings.gradle"
dependsOn copyUnpackAssets, copyAssets
......@@ -287,10 +257,8 @@ task createRCfiles {
preBuild.dependsOn 'createRCfiles',
'createStrippedConfigMain',
'createStrippedConfigRegistry',
'createFullConfig',
'copyNdkDebugServer'
'createFullConfig'
clean.dependsOn 'cleanCopyAssets',
'cleanCreateStrippedConfig',
'cleanCreateFullConfig',
'cleanCopyNdkDebugServer'
'cleanCreateFullConfig'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment