-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsetup-asan-for-debugging.sh
executable file
·59 lines (48 loc) · 2.13 KB
/
setup-asan-for-debugging.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/bash
# This shell script is to set up ASAN for debugging native libs.
# Specify your own path in those variables below.
# Note that ASAN is *deprecated in Android 14 or later (use HWAsan instead).
# They have to be adjusted to your environment and NDK version.
# Although note that whenever we use AAP the NDK version has to be fixed to
# this one otherwise libc++_shared.so version mismatch may bite you.
#
# Also note that you need below in build.gradle:
# > android.packagingOptions.jniLibs.useLegacyPackaging = true
#
if [ "$ANDROID_NDK_PATH" == "" ]; then
if [ `uname` == "Darwin" ]; then
ANDROID_NDK_PATH=~/Library/Android/Sdk/ndk/26.1.10909125
else
ANDROID_NDK_PATH=~/Android/Sdk/ndk/26.1.10909125
fi
fi
UNAMEXX=`uname | tr '[:upper:]' '[:lower:]'`
# Note that these paths may not work depending on the NDK versions. Always make sure that the resulting paths exist
HOST_ARCH_LIB=$UNAMEXX-x86_64/lib
CLANG_VER=17
CLANG_LIB=$ANDROID_NDK_PATH/toolchains/llvm/prebuilt/$HOST_ARCH_LIB/clang/$CLANG_VER/lib
echo "UNAME: $UNAMEXX"
echo "CLANG_LIB: $CLANG_LIB"
ALL_ABIS=("x86" "x86_64" "armeabi-v7a" "arm64-v8a")
ALL_APPS=("samples/aaphostsample" "samples/aapbarebonepluginsample" "samples/aapinstrumentsample" "samples/aapxssample")
for sample in "${ALL_APPS[@]}"; do
echo "APP: $sample"
SAMPLE=$sample/src/main
SAMPLE_RES=$SAMPLE/resources/lib
for a in "${ALL_ABIS[@]}"; do
echo " ABI: $a"
mkdir -p $SAMPLE/jniLibs/$a ;
# This is causing unresponsive debugger. Do not use it. Load asan so at using System.loadLibrary() instead.
mkdir -p $SAMPLE_RES/$a
cp -R asan-wrap-bugfixed.sh $SAMPLE_RES/$a/wrap.sh
dos2unix $SAMPLE_RES/$a/wrap.sh
chmod +x $SAMPLE_RES/$a/wrap.sh
done
chmod +x $CLANG_LIB/linux/libclang_rt.asan-*.so
cp $CLANG_LIB/linux/libclang_rt.asan-i686*.so $SAMPLE/jniLibs/x86
cp $CLANG_LIB/linux/libclang_rt.asan-x86_64*.so $SAMPLE/jniLibs/x86_64
cp $CLANG_LIB/linux/libclang_rt.asan-arm*.so $SAMPLE/jniLibs/armeabi-v7a
cp $CLANG_LIB/linux/libclang_rt.asan-aarch64*.so $SAMPLE/jniLibs/arm64-v8a
done
echo "done."
echo "NOTE: do not forget to set "enable_asan" in the root build.gradle.kts."