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 @@ ...@@ -7,9 +7,7 @@
/source/captures/ /source/captures/
/source/jni/Application.mk /source/jni/Application.mk
/source/jniLibs/ /source/jniLibs/
/source/jniLibs_debug/
/source/liboSettings.gradle /source/liboSettings.gradle
/source/libs/*/gdb.setup
/source/local.properties /source/local.properties
/source/native-code.cxx /source/native-code.cxx
/source/obj/ /source/obj/
......
...@@ -99,8 +99,6 @@ liboSettings.gradle: $(BUILDDIR)/config_build.mk $(BUILDDIR)/config_host.mk ...@@ -99,8 +99,6 @@ liboSettings.gradle: $(BUILDDIR)/config_build.mk $(BUILDDIR)/config_host.mk
&& echo " liboVersionMajor = '$(LIBO_VERSION_MAJOR)'" \ && echo " liboVersionMajor = '$(LIBO_VERSION_MAJOR)'" \
&& echo " liboVersionMinor = '$(LIBO_VERSION_MINOR)'" \ && echo " liboVersionMinor = '$(LIBO_VERSION_MINOR)'" \
&& echo " liboGitFullCommit = '$(shell cd $(SRCDIR) && git log -1 --format=%H)'" \ && echo " liboGitFullCommit = '$(shell cd $(SRCDIR) && git log -1 --format=%H)'" \
&& echo " liboNdkGdbserver = '$(ANDROID_NDK_GDBSERVER)'" \
&& echo " liboAndroidAppAbi = '$(ANDROID_APP_ABI)'" \
&& echo "}" \ && echo "}" \
&& echo "android.defaultConfig {" \ && echo "android.defaultConfig {" \
&& echo " applicationId '$(ANDROID_PACKAGE_NAME)'" \ && echo " applicationId '$(ANDROID_PACKAGE_NAME)'" \
......
...@@ -210,25 +210,19 @@ swap). ...@@ -210,25 +210,19 @@ swap).
* Using ndk-gdb * Using ndk-gdb
When you have all this, install the .apk to the device, and: 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
cd android/source nicely integrated into Android Studio (see below for instructions).
<ndk-bundle>/ndk-gdb --adb=<android-sdk-linux>/platform-tools/adb [--start] 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
In case you used --with-android-package-name, add --package=your.package.name
to the invocation - add android:debuggable="true" to AndroidManifest.xml
- push gdbserver to device, launch and attach to application
If you get the error - forward debugging port from host to device
- launch matching gdb on host and run following setup commands:
ERROR: Could not find gdb.setup under ./libs/ - set solib-search-path obj/local/<appAbi>
- file obj/local/<appAbi>/liblo-native-code.so
(and an empty "Compatible device ABI:" when run with --verbose), you need to fix - target remote :<portused>
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\"
Pretty printers aren't loaded automatically due to the single shared 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 object, but you can still load them manually. E.g. to have a pretty-printer for
...@@ -239,8 +233,9 @@ rtl::OString, you need: ...@@ -239,8 +233,9 @@ rtl::OString, you need:
* Using Android Studio (and thus lldb) * Using Android Studio (and thus lldb)
Note that both might not yield the same results - so if lldb doesn't show you Note that lldb might not yield the same results as ndk-gdb. If you suspect a
useful info, try with the ndk-gdb method and the other way round. 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 - 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) - make sure you select the right build variant (strippedUIDebug is what you want)
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
android:label="@string/app_name" android:label="@string/app_name"
android:theme="@style/LibreOfficeTheme" android:theme="@style/LibreOfficeTheme"
android:debuggable="true"
android:hardwareAccelerated="true" android:hardwareAccelerated="true"
android:largeHeap="false"> android:largeHeap="false">
......
...@@ -36,4 +36,4 @@ run: ...@@ -36,4 +36,4 @@ run:
$(ANDROID_SDK_HOME)/platform-tools/adb shell am start -n $(ANDROID_PACKAGE_NAME)/.ui.LibreOfficeUIActivity $(ANDROID_SDK_HOME)/platform-tools/adb shell am start -n $(ANDROID_PACKAGE_NAME)/.ui.LibreOfficeUIActivity
debugrun: 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 { ...@@ -40,24 +40,15 @@ android {
// ToDo move to conventional layout, so stuff can be stripped down. // ToDo move to conventional layout, so stuff can be stripped down.
sourceSets { sourceSets {
main.manifest.srcFile 'AndroidManifest.xml' 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.assets.srcDirs = ['assets']
main.res.srcDirs = ['res'] main.res.srcDirs = ['res']
main.java.srcDirs = ['../Bootstrap/src', 'src/java'] main.java.srcDirs = ['../Bootstrap/src', 'src/java']
main.jniLibs.srcDirs = ['jniLibs'] main.jniLibs.srcDirs = ['jniLibs']
main.jni.srcDirs = [] // don't attempt to build native-lib via gradle 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 // the configuration data that might be stripped or not
fullUI.assets.srcDirs 'assets_fullUI' fullUI.assets.srcDirs 'assets_fullUI'
strippedUI.assets.srcDirs 'assets_strippedUI' strippedUI.assets.srcDirs 'assets_strippedUI'
} }
lintOptions {
// ndk-gdb looks for the literal value in the pre-processed manifest :-(
disable 'HardcodedDebugMode'
}
defaultConfig { defaultConfig {
minSdkVersion 14 minSdkVersion 14
// openssl on x86 makes the native-code.so contain text-relocations, // openssl on x86 makes the native-code.so contain text-relocations,
...@@ -209,27 +200,6 @@ task createStrippedConfigRegistry(type: Exec) { ...@@ -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 { task createRCfiles {
inputs.file "liboSettings.gradle" inputs.file "liboSettings.gradle"
dependsOn copyUnpackAssets, copyAssets dependsOn copyUnpackAssets, copyAssets
...@@ -287,10 +257,8 @@ task createRCfiles { ...@@ -287,10 +257,8 @@ task createRCfiles {
preBuild.dependsOn 'createRCfiles', preBuild.dependsOn 'createRCfiles',
'createStrippedConfigMain', 'createStrippedConfigMain',
'createStrippedConfigRegistry', 'createStrippedConfigRegistry',
'createFullConfig', 'createFullConfig'
'copyNdkDebugServer'
clean.dependsOn 'cleanCopyAssets', clean.dependsOn 'cleanCopyAssets',
'cleanCreateStrippedConfig', 'cleanCreateStrippedConfig',
'cleanCreateFullConfig', 'cleanCreateFullConfig'
'cleanCopyNdkDebugServer'
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