Cannot Debug App When Using Wrapper Script
I have activated address sanitizer for my app's native codes in order to detect some memory leak. But I have a strange problem. Before activating address sanitizer, app just runs n
Solution 1:
Finally with help of people in my bug's thread, I were able to create a working wrapper script for android 27+. I'm almost sure you cannot find any other working wrapper script in internet right now and this is the only working one.
Here is full script:
#!/system/bin/sh
processname=$1shift
sdkversion=$(getprop ro.build.version.sdk)
if [ "$sdkversion" -gt "28" ]; then
fullpath="$processname -XjdwpProvider:adbconnection $@"elif [ "$sdkversion" -eq "28" ]; then
fullpath="$processname -XjdwpProvider:adbconnection -XjdwpOptions:suspend=n,server=y -Xcompiler-option --debuggable $@"elif [ "$sdkversion" -eq "27" ]; then
fullpath="$processname -Xrunjdwp:transport=dt_android_adb,suspend=n,server=y -Xcompiler-option --debuggable -Xcompiler-option --generate-mini-debug-info $@"elselog -p e -t "WRAPPER""Wrapper script only works starting API level 27!"exit 1
fi$fullpath
For using with ASAN, just add your required ASAN configs(e.g. LD_PRELOAD
) at start of wrapper script. So it will become somethign like this:
#!/system/bin/sh
HERE="$(cd "$(dirname "$0")" && pwd)"export ASAN_OPTIONS=log_to_syslog=false,allow_user_segv_handler=1
export LD_PRELOAD=$HERE/libclang_rt.asan-${arch}-android.so
processname=$1shift
sdkversion=$(getprop ro.build.version.sdk)
if [ "$sdkversion" -gt "28" ]; then
fullpath="$processname -XjdwpProvider:adbconnection $@"elif [ "$sdkversion" -eq "28" ]; then
fullpath="$processname -XjdwpProvider:adbconnection -XjdwpOptions:suspend=n,server=y -Xcompiler-option --debuggable $@"elif [ "$sdkversion" -eq "27" ]; then
fullpath="$processname -Xrunjdwp:transport=dt_android_adb,suspend=n,server=y -Xcompiler-option --debuggable -Xcompiler-option --generate-mini-debug-info $@"elselog -p e -t "WRAPPER""Wrapper script only works starting API level 27!"exit 1
fi$fullpath
I wish this script will be useful for everyone.
Update: Google updated wrap.sh page in NDK based on this thread. You can see final wrapper script there too.
Best Regards
Post a Comment for "Cannot Debug App When Using Wrapper Script"