ndk-gdbでERROR: Could not extract package's data directory.
ndk-gdbを実行しようとしたら以下のエラーになり実行できなかった。
$ ndk-gdb --verbose Android NDK installation path: /home/user01/android-ndk-r7 Using default adb command: /cygdrive/d/android-sdk-windows_r16/platform-tools/adb ADB version found: Android Debug Bridge version 1.0.29 Using final ADB command: '/cygdrive/d/android-sdk-windows_r16/platform-tools/adb' Using auto-detected project path: . Found package name: com.my.android.app ABIs targetted by application: armeabi armeabi-v7a Device API Level: 10 Device CPU ABIs: armeabi-v7a armeabi Compatible device ABI: armeabi-v7a Found debuggable flag: true Found device gdbserver: /data/data/com.hoge.app/lib/gdbserver Using gdb setup init: ./libs/armeabi-v7a/gdb.setup Using toolchain prefix: /home/user01/android-ndk-r7/toolchains /arm-linux-androideabi-4.4.3/prebuilt /windows/bin/arm-linux-androideabi- Using app out directory: ./obj/local/armeabi-v7a ERROR: Could not extract package's data directory. Are you sure that your installed application is debuggable?
オプションを追加してみたが、ダメだ。
--LOCAL_CFLAGS := -Wall
--LOCAL_LDLIBS := -llog
++LOCAL_CFLAGS := -Wall -g
++LOCAL_LDLIBS := -llog -Wl,-Map,my.map
ndk-gdbの529行目付近
# Get information from the build system GDBSETUP_INIT=`get_build_var_for_abi NDK_APP_GDBSETUP $COMPAT_ABI` log "Using gdb setup init: $GDBSETUP_INIT" TOOLCHAIN_PREFIX=`get_build_var_for_abi TOOLCHAIN_PREFIX $COMPAT_ABI` log "Using toolchain prefix: $TOOLCHAIN_PREFIX" APP_OUT=`get_build_var_for_abi TARGET_OUT $COMPAT_ABI` log "Using app out directory: $APP_OUT" # Find the <dataDir> of the package on the device adb_var_shell2 DATA_DIR run-as $PACKAGE_NAME /system/bin/sh -c pwd if [ $? != 0 -o -z "$DATA_DIR" ] ; then echo "ERROR: Could not extract package's data directory. Are you sure that" echo " your installed application is debuggable?" exit 1 fi log "Found data directory: '$DATA_DIR'"
$ANDROID_NDK_ROOT = /home/user01/android-ndk-r7
$ADB_CMD = /cygdrive/d/android-sdk-windows_r16/platform-tools/adb
$ADB_VERSION = Android Debug Bridge version 1.0.29
adb_var_shell2の中身、1と2の違いは、エラーのリダイレクトが違うだけだな。
# Run a command through 'adb shell' and captures its standard output # into a variable. The function's exit code is the same than the command's. # # This is required because there is a bug where "adb shell" always returns # 0 on the host, even if the command fails on the device. # # $1: Variable name (e.g. FOO) # On exit, $FOO is set to the command's standard output # # The return status will be 0 (success) if the command succeeded # or 1 (failure) otherwise. adb_var_shell () { _adb_var_shell 0 $@ } # A variant of adb_var_shell that stores both stdout and stderr in the output # $1: Variable name adb_var_shell2 () { _adb_var_shell 1 $@ }
adb_var_shellの中身
# Used internally by adb_var_shell and adb_var_shell2. # $1: 1 to redirect stderr to $1, 0 otherwise. # $2: Variable name that will contain the result # $3+: Command options _adb_var_shell () { # We need a temporary file to store the output of our command local CMD_OUT RET OUTPUT VARNAME REDIRECT_STDERR REDIRECT_STDERR=$1 VARNAME=$2 shift; shift; CMD_OUT=`mktemp /tmp/ndk-gdb-cmdout-XXXXXX` # Run the command, while storing the standard output to CMD_OUT # and appending the exit code as the last line. if [ "$REDIRECT_STDERR" != 0 ]; then $ADB_CMD shell $@ ";" echo \$? | sed -e 's![[:cntrl:]]!!g' > $CMD_OUT 2>&1 else $ADB_CMD shell $@ ";" echo \$? | sed -e 's![[:cntrl:]]!!g' > $CMD_OUT fi # Get last line in log, which contains the exit code from the command RET=`sed -e '$!d' $CMD_OUT` # Get output, which corresponds to everything except the last line OUT=`sed -e '$d' $CMD_OUT` rm -f $CMD_OUT eval $VARNAME=\"\$OUT\" return $RET }
ndk-gdbをndk-gdb_debugとしてコピーし、
#!/bin/sh -xにして実行してみた。
$ ndk-gdb_debug --verbose ++ dirname /home/user01/android-ndk-r7/ndk-gdb_debug + . /home/user01/android-ndk-r7/build/core/ndk-common.sh +++ basename /home/user01/android-ndk-r7/ndk-gdb_debug ++ PROGNAME=ndk-gdb_debug ++ '[' -z '' ']' ++ find_ndk_root ANDROID_NDK_ROOT /home/user01/android-ndk-r7/ndk-gdb_debug +++ dirname /home/user01/android-ndk-r7/ndk-gdb_debug ++ local PROGDIR=/home/user01/android-ndk-r7 ++ '[' -n 1 ']' ++ '[' -d /home/user01/android-ndk-r7/build/core ']' ++ break ++ eval ANDROID_NDK_ROOT=/home/user01/android-ndk-r7 +++ ANDROID_NDK_ROOT=/home/user01/android-ndk-r7 ++ '[' 0 '!=' 0 ']' ++ echo /home/user01/android-ndk-r7 ++ grep -q -e ' ' ++ '[' 1 = 0 ']' ++ '[' '!' -d /home/user01/android-ndk-r7 ']' ++ '[' '!' -f /home/user01/android-ndk-r7/build/core/ndk-common.sh ']' ++ VERBOSE=yes ++ VERBOSE2=no ++ TMPLOG= ++ '[' -n '' ']' +++ uname -m ++ HOST_ARCH=i686 ++ case "$HOST_ARCH" in ++ HOST_ARCH=x86 ++ log2 HOST_ARCH=x86 ++ '[' no = yes ']' ++ '[' -n '' ']' ++ HOST_EXE= +++ uname -s ++ HOST_OS=CYGWIN_NT-6.1-WOW64 ++ case "$HOST_OS" in ++ HOST_OS=windows ++ HOST_EXE=.exe ++ '[' xcygwin = xcygwin ']' ++ HOST_OS=cygwin ++ log2 HOST_OS=cygwin ++ '[' no = yes ']' ++ '[' -n '' ']' ++ log2 HOST_EXE=.exe ++ '[' no = yes ']' ++ '[' -n '' ']' ++ compute_host_tag ++ case "$HOST_OS" in ++ HOST_TAG=windows ++ log2 HOST_TAG=windows ++ '[' no = yes ']' ++ '[' -n '' ']' ++ case "$HOST_OS" in ++ HOST_NUM_CPUS=8 ++ log2 HOST_NUM_CPUS=8 ++ '[' no = yes ']' ++ '[' -n '' ']' ++ '[' -z '' ']' +++ expr 8 '*' 2 ++ BUILD_NUM_CPUS=16 ++ log2 BUILD_NUM_CPUS=16 ++ '[' no = yes ']' ++ '[' -n '' ']' ++ FORCE_32BIT=no ++ mkdir -p /tmp/ndk-user01/tmp/tests ++ TMPC=/tmp/ndk-user01/tmp/tests/test-10108.c ++ TMPO=/tmp/ndk-user01/tmp/tests/test-10108.o ++ TMPE=/tmp/ndk-user01/tmp/tests/test-10108 ++ TMPL=/tmp/ndk-user01/tmp/tests/test-10108.log + force_32bit_binaries + '[' x86 = x86_64 ']' + find_program ADB_CMD adb + local PROG ++ which adb + PROG=/cygdrive/d/android-sdk-windows_r16/platform-tools/adb + '[' -n /cygdrive/d/android-sdk-windows_r16/platform-tools/adb ']' + pattern_match '^no ' /cygdrive/d/android-sdk-windows_r16/platform-tools/adb + echo /cygdrive/d/android-sdk-windows_r16/platform-tools/adb + grep -q -E -e '^no ' + eval ADB_CMD=/cygdrive/d/android-sdk-windows_r16/platform-tools/adb ++ ADB_CMD=/cygdrive/d/android-sdk-windows_r16/platform-tools/adb + ADB_FLAGS= + AWK_CMD=awk + DEBUG_PORT=5039 + DELAY=2 + PARAMETERS= + OPTION_HELP=no + OPTION_PROJECT= + OPTION_FORCE=no + OPTION_ADB= + OPTION_EXEC= + OPTION_START=no + OPTION_LAUNCH= + OPTION_LAUNCH_LIST=no + OPTION_DELAY= + '[' cygwin = cygwin ']' + path_is_absolute /home/user01/android-ndk-r7 + local P P2 + P=/home/user01/android-ndk-r7 + P2=home/user01/android-ndk-r7 + '[' /home/user01/android-ndk-r7 '!=' home/user01/android-ndk-r7 ']' + VERBOSE=no + '[' -n --verbose ']' + opt=--verbose ++ expr x--verbose : 'x[^=]*=\(.*\)' + optarg= + case "$opt" in + VERBOSE=yes + shift + '[' -n '' ']' + '[' no = yes ']' + log 'Android NDK installation path: /home/user01/android-ndk-r7' + '[' yes = yes ']' + echo 'Android NDK installation path: /home/user01/android-ndk-r7' Android NDK installation path: /home/user01/android-ndk-r7 + '[' -n '' ']' + '[' -n '' ']' + '[' -n '' ']' + '[' -z /cygdrive/d/android-sdk-windows_r16/platform-tools/adb ']' + log 'Using default adb command: /cygdrive/d/android-sdk-windows_r16/platform-tools/adb' + '[' yes = yes ']' + echo 'Using default adb command: /cygdrive/d/android-sdk-windows_r16/platform-tools/adb' Using default adb command: /cygdrive/d/android-sdk-windows_r16/platform-tools/adb ++ /cygdrive/d/android-sdk-windows_r16/platform-tools/adb version ' ADB_VERSION='Android Debug Bridge version 1.0.29 + '[' 0 '!=' 0 ']' ' log 'ADB version found: Android Debug Bridge version 1.0.29 + '[' yes = yes ']' ' echo 'ADB version found: Android Debug Bridge version 1.0.29 ADB version found: Android Debug Bridge version 1.0.29 + ADB_CMD=/cygdrive/d/android-sdk-windows_r16/platform-tools/adb + log 'Using final ADB command: '\''/cygdrive/d/android-sdk-windows_r16/platform-tools/adb'\''' + '[' yes = yes ']' + echo 'Using final ADB command: '\''/cygdrive/d/android-sdk-windows_r16/platform-tools/adb'\''' Using final ADB command: '/cygdrive/d/android-sdk-windows_r16/platform-tools/adb' + AWK_SCRIPTS=/home/user01/android-ndk-r7/build/awk ++ awk -f /home/user01/android-ndk-r7/build/awk/check-awk.awk + AWK_TEST=Pass + '[' 0 '!=' 0 ']' + '[' Pass '!=' Pass ']' + MANIFEST=AndroidManifest.xml + '[' -n '' ']' + '[' -f AndroidManifest.xml ']' + PROJECT=. + log 'Using auto-detected project path: .' + '[' yes = yes ']' + echo 'Using auto-detected project path: .' Using auto-detected project path: . ++ run_awk_manifest_script extract-package-name.awk ++ awk -f /home/user01/android-ndk-r7/build/awk/extract-package-name.awk ./AndroidManifest.xml + PACKAGE_NAME=com.my.android.app + log 'Found package name: com.my.android.app' + '[' yes = yes ']' + echo 'Found package name: com.my.android.app' Found package name: com.my.android.app + '[' 0 '!=' 0 -o com.my.android.app = '<none>' ']' + '[' no = yes ']' ++ get_build_var APP_ABI ++ '[' -z '' ']' ++ GNUMAKE=make ++ make --no-print-dir -f /home/user01/android-ndk-r7/build/core/build-local.mk -C . DUMP_APP_ABI + APP_ABIS='armeabi armeabi-v7a' + log 'ABIs targetted by application: armeabi armeabi-v7a' + '[' yes = yes ']' + echo 'ABIs targetted by application: armeabi armeabi-v7a' ABIs targetted by application: armeabi armeabi-v7a ++ /cygdrive/d/android-sdk-windows_r16/platform-tools/adb shell ls + ADB_TEST='config cache sdcard acct mnt vendor d etc ueventd.rc ueventd.goldfish.rc ueventd.es209ra.rc system sys sbin proc logo.rle init.rc init.goldfish.rc init.es209ra.sh init.es209ra.rc init.es209ra.post_boot.sh init hw_config.sh default.prop data root 'ev + '[' 0 '!=' 0 ']' + adb_var_shell API_LEVEL getprop ro.build.version.sdk + _adb_var_shell 0 API_LEVEL getprop ro.build.version.sdk + local CMD_OUT RET OUTPUT VARNAME REDIRECT_STDERR + REDIRECT_STDERR=0 + VARNAME=API_LEVEL + shift + shift ++ mktemp /tmp/ndk-gdb-cmdout-XXXXXX + CMD_OUT=/tmp/ndk-gdb-cmdout-LiugM3 + '[' 0 '!=' 0 ']' + /cygdrive/d/android-sdk-windows_r16/platform-tools/adb shell getprop ro.build.version.sdk ';' echo '$?' + sed -e 's![[:cntrl:]]!!g' ++ sed -e '$!d' /tmp/ndk-gdb-cmdout-LiugM3 + RET=0 ++ sed -e '$d' /tmp/ndk-gdb-cmdout-LiugM3 + OUT=10 + rm -f /tmp/ndk-gdb-cmdout-LiugM3 + eval 'API_LEVEL="$OUT"' ++ API_LEVEL=10 + return 0 + '[' 0 '!=' 0 -o -z 10 ']' + log 'Device API Level: 10' + '[' yes = yes ']' + echo 'Device API Level: 10' Device API Level: 10 + '[' 10 -lt 8 ']' + COMPAT_ABI=none + adb_var_shell CPU_ABI getprop ro.product.cpu.abi + _adb_var_shell 0 CPU_ABI getprop ro.product.cpu.abi + local CMD_OUT RET OUTPUT VARNAME REDIRECT_STDERR + REDIRECT_STDERR=0 + VARNAME=CPU_ABI + shift + shift ++ mktemp /tmp/ndk-gdb-cmdout-XXXXXX + CMD_OUT=/tmp/ndk-gdb-cmdout-oaiPc6 + '[' 0 '!=' 0 ']' + /cygdrive/d/android-sdk-windows_r16/platform-tools/adb shell getprop ro.product.cpu.abi ';' echo '$?' + sed -e 's![[:cntrl:]]!!g' ++ sed -e '$!d' /tmp/ndk-gdb-cmdout-oaiPc6 + RET=0 ++ sed -e '$d' /tmp/ndk-gdb-cmdout-oaiPc6 + OUT=armeabi-v7a + rm -f /tmp/ndk-gdb-cmdout-oaiPc6 + eval 'CPU_ABI="$OUT"' ++ CPU_ABI=armeabi-v7a + return 0 + for ABI in '$APP_ABIS' + '[' armeabi = armeabi-v7a ']' + for ABI in '$APP_ABIS' + '[' armeabi-v7a = armeabi-v7a ']' + COMPAT_ABI=armeabi-v7a + break + adb_var_shell CPU_ABI2 getprop ro.product.cpu.abi2 + _adb_var_shell 0 CPU_ABI2 getprop ro.product.cpu.abi2 + local CMD_OUT RET OUTPUT VARNAME REDIRECT_STDERR + REDIRECT_STDERR=0 + VARNAME=CPU_ABI2 + shift + shift ++ mktemp /tmp/ndk-gdb-cmdout-XXXXXX + CMD_OUT=/tmp/ndk-gdb-cmdout-SsupX1 + '[' 0 '!=' 0 ']' + /cygdrive/d/android-sdk-windows_r16/platform-tools/adb shell getprop ro.product.cpu.abi2 ';' echo '$?' + sed -e 's![[:cntrl:]]!!g' ++ sed -e '$!d' /tmp/ndk-gdb-cmdout-SsupX1 + RET=0 ++ sed -e '$d' /tmp/ndk-gdb-cmdout-SsupX1 + OUT=armeabi + rm -f /tmp/ndk-gdb-cmdout-SsupX1 + eval 'CPU_ABI2="$OUT"' ++ CPU_ABI2=armeabi + return 0 + '[' 0 '!=' 0 -o -z armeabi ']' + log 'Device CPU ABIs: armeabi-v7a armeabi' + '[' yes = yes ']' + echo 'Device CPU ABIs: armeabi-v7a armeabi' Device CPU ABIs: armeabi-v7a armeabi + '[' armeabi-v7a = none ']' + '[' armeabi-v7a = none ']' + log 'Compatible device ABI: armeabi-v7a' + '[' yes = yes ']' + echo 'Compatible device ABI: armeabi-v7a' Compatible device ABI: armeabi-v7a ++ run_awk_manifest_script extract-debuggable.awk ++ awk -f /home/user01/android-ndk-r7/build/awk/extract-debuggable.awk ./AndroidManifest.xml + DEBUGGABLE=true + log 'Found debuggable flag: true' + '[' yes = yes ']' + echo 'Found debuggable flag: true' Found debuggable flag: true + '[' 0 '!=' 0 -o true '!=' true ']' + '[' '!' -f ./libs/armeabi-v7a/gdbserver ']' + adb_var_shell2 DEVICE_GDBSERVER ls /data/data/com.my.android.app/lib/gdbserver + _adb_var_shell 1 DEVICE_GDBSERVER ls /data/data/com.my.android.app/lib/gdbserver + local CMD_OUT RET OUTPUT VARNAME REDIRECT_STDERR + REDIRECT_STDERR=1 + VARNAME=DEVICE_GDBSERVER + shift + shift ++ mktemp /tmp/ndk-gdb-cmdout-XXXXXX + CMD_OUT=/tmp/ndk-gdb-cmdout-Xqze8I + '[' 1 '!=' 0 ']' + /cygdrive/d/android-sdk-windows_r16/platform-tools/adb shell ls /data/data/com.my.android.app/lib/gdbserver ';' echo '$?' + sed -e 's![[:cntrl:]]!!g' ++ sed -e '$!d' /tmp/ndk-gdb-cmdout-Xqze8I + RET=0 ++ sed -e '$d' /tmp/ndk-gdb-cmdout-Xqze8I + OUT=/data/data/com.my.android.app/lib/gdbserver + rm -f /tmp/ndk-gdb-cmdout-Xqze8I + eval 'DEVICE_GDBSERVER="$OUT"' ++ DEVICE_GDBSERVER=/data/data/com.my.android.app/lib/gdbserver + return 0 + '[' 0 '!=' 0 ']' + log 'Found device gdbserver: /data/data/com.my.android.app/lib/gdbserver' + '[' yes = yes ']' + echo 'Found device gdbserver: /data/data/com.my.android.app/lib/gdbserver' Found device gdbserver: /data/data/com.my.android.app/lib/gdbserver ++ get_build_var_for_abi NDK_APP_GDBSETUP armeabi-v7a ++ '[' -z '' ']' ++ GNUMAKE=make ++ make --no-print-dir -f /home/user01/android-ndk-r7/build/core/build-local.mk -C . DUMP_NDK_APP_GDBSETUP APP_ABI=armeabi-v7a + GDBSETUP_INIT=./libs/armeabi-v7a/gdb.setup + log 'Using gdb setup init: ./libs/armeabi-v7a/gdb.setup' + '[' yes = yes ']' + echo 'Using gdb setup init: ./libs/armeabi-v7a/gdb.setup' Using gdb setup init: ./libs/armeabi-v7a/gdb.setup ++ get_build_var_for_abi TOOLCHAIN_PREFIX armeabi-v7a ++ '[' -z '' ']' ++ GNUMAKE=make ++ make --no-print-dir -f /home/user01/android-ndk-r7/build/core/build-local.mk -C . DUMP_TOOLCHAIN_PREFIX APP_ABI=armeabi-v7a + TOOLCHAIN_PREFIX=/home/user01/android-ndk-r7/toolchains /arm-linux-androideabi-4.4.3/prebuilt /windows/bin/arm-linux-androideabi- + log 'Using toolchain prefix: /home/user01/android-ndk-r7/toolchains /arm-linux-androideabi-4.4.3/prebuilt /windows/bin/arm-linux-androideabi-' + '[' yes = yes ']' + echo 'Using toolchain prefix: /home/user01/android-ndk-r7/toolchains /arm-linux-androideabi-4.4.3/prebuilt /windows/bin/arm-linux-androideabi-' Using toolchain prefix: /home/user01/android-ndk-r7/toolchains /arm-linux-androideabi-4.4.3/prebuilt /windows/bin/arm-linux-androideabi- ++ get_build_var_for_abi TARGET_OUT armeabi-v7a ++ '[' -z '' ']' ++ GNUMAKE=make ++ make --no-print-dir -f /home/user01/android-ndk-r7/build/core/build-local.mk -C . DUMP_TARGET_OUT APP_ABI=armeabi-v7a + APP_OUT=./obj/local/armeabi-v7a + log 'Using app out directory: ./obj/local/armeabi-v7a' + '[' yes = yes ']' + echo 'Using app out directory: ./obj/local/armeabi-v7a' Using app out directory: ./obj/local/armeabi-v7a + adb_var_shell2 DATA_DIR run-as com.my.android.app /system/bin/sh -c pwd + _adb_var_shell 1 DATA_DIR run-as com.my.android.app /system/bin/sh -c pwd + local CMD_OUT RET OUTPUT VARNAME REDIRECT_STDERR + REDIRECT_STDERR=1 + VARNAME=DATA_DIR + shift + shift ++ mktemp /tmp/ndk-gdb-cmdout-XXXXXX + CMD_OUT=/tmp/ndk-gdb-cmdout-2ydDHv + '[' 1 '!=' 0 ']' + /cygdrive/d/android-sdk-windows_r16/platform-tools/adb shell run-as com.my.android.app /system/bin/sh -c pwd ';' echo '$?' + sed -e 's![[:cntrl:]]!!g' ++ sed -e '$!d' /tmp/ndk-gdb-cmdout-2ydDHv + RET=1 ++ sed -e '$d' /tmp/ndk-gdb-cmdout-2ydDHv + OUT='run-as: Package '\''com.my.android.app'\'' has corrupt installation' + rm -f /tmp/ndk-gdb-cmdout-2ydDHv + eval 'DATA_DIR="$OUT"' ++ DATA_DIR='run-as: Package '\''com.my.android.app'\'' has corrupt installation' + return 1 + '[' 1 '!=' 0 -o -z 'run-as: Package '\''com.my.android.app'\'' has corrupt installation' ']' + echo 'ERROR: Could not extract package'\''s data directory. Are you sure that' ERROR: Could not extract package's data directory. Are you sure that + echo ' your installed application is debuggable?' your installed application is debuggable? + exit 1
adb_var_shellのrmをコメントアウトする
# Used internally by adb_var_shell and adb_var_shell2. # $1: 1 to redirect stderr to $1, 0 otherwise. # $2: Variable name that will contain the result # $3+: Command options _adb_var_shell () { # We need a temporary file to store the output of our command local CMD_OUT RET OUTPUT VARNAME REDIRECT_STDERR REDIRECT_STDERR=$1 VARNAME=$2 shift; shift; CMD_OUT=`mktemp /tmp/ndk-gdb-cmdout-XXXXXX` # Run the command, while storing the standard output to CMD_OUT # and appending the exit code as the last line. if [ "$REDIRECT_STDERR" != 0 ]; then $ADB_CMD shell $@ ";" echo \$? | sed -e 's![[:cntrl:]]!!g' > $CMD_OUT 2>&1 else $ADB_CMD shell $@ ";" echo \$? | sed -e 's![[:cntrl:]]!!g' > $CMD_OUT fi # Get last line in log, which contains the exit code from the command RET=`sed -e '$!d' $CMD_OUT` # Get output, which corresponds to everything except the last line OUT=`sed -e '$d' $CMD_OUT` #####rm -f $CMD_OUT <=======ここ eval $VARNAME=\"\$OUT\" return $RET }
tmpのファイルを確認する。
$ ls -l /tmp
合計 9.0K
- rwsrwsrwt+ 1 user01 None 1.0K 2月 16 16:20 adb.log*
drwxr-xr-x+ 1 user01 None 0 2月 21 15:47 hsperfdata_user01/
- rw-------+ 1 user01 None 10 3月 2 14:04 ndk-gdb-cmdout-EUBkCY
- rw-------+ 1 user01 None 14 3月 2 14:04 ndk-gdb-cmdout-H7pE8d
- rw-------+ 1 user01 None 5 3月 2 14:04 ndk-gdb-cmdout-kQOkQP
- rw-------+ 1 user01 None 49 3月 2 14:04 ndk-gdb-cmdout-nQZn39
- rw-------+ 1 user01 None 67 3月 2 14:04 ndk-gdb-cmdout-sD4ie2
drwxr-x---+ 1 user01 None 0 2月 29 16:18 ndk-user01/
catしてみる。
2行づつ1ファイルの内容、2行目が返り値
$ cat /tmp/ndk*
armeabi
0armeabi-v7a
010
0/data/data/jp.co.lim.android.app/lib/gdbserver
0run-as: Package 'com.my.android.app' has corrupt installation
1
cat: /tmp/ndk-m_fujii: Is a directory
corrupt installationなので、うまくインストールできていないらしい。
sed -e '$d'で最終行を表示しないようにしている。
$ sed -e '$d' ndk-gdb-cmdout-sD4ie2
run-as: Package 'com.my.android.app' has corrupt installation$ sed -e '' ndk-gdb-cmdout-sD4ie2
run-as: Package 'jp.co.lim.android.app' has corrupt installation
1
adb shell上でのコマンドがエラーになっている。
$ run-as com.my.android.app /system/bin/sh -c pwd
run-as com.my.android..app /system/bin/sh -c pwd
run-as: Package 'com.my.android.app' has corrupt installation
$ which run-as
which run-as
/system/bin/run-as
$ ls -l /system/bin | grep run*
- rwxrwxrwx root shell 59848 2011-08-01 19:11
$ run-as
run-as
Usage: run-as[ ]
run-asコマンドのソースを見ると、/data/system/packages.list というファイルをopenしてreadしています。このファイルはテキストファイルで、各アプリケーションのパッケージ名、UID、デバッグ可否、ディレクトリが書かれています。run-asコマンドはこのファイルからそのアプリケーションがデバッグを許可しているかを調べ、許可している場合のみそのアプリケーションと同じUIDで指定のコマンドを実行するわけです。
ちゃんと登録されてるみたい。13KB弱ある。
$ cat /data/system/packages.list | grep com.my
com.my.lim.android.app 10133 1 /data/data/com.my.android.app$ ls -l /data/system | grep pack*
ls -l /data/system | grep pack*
- rw-rw-r-- system system 12287 2012-03-02 14:52 packages.list
- rw-rw-r-- system system 197710 2012-03-02 14:52 packages.xml
$
2.3.7だと#define PACKAGES_LIST_BUFFER_SIZE 65536になってる。
2.3は、#define PACKAGES_LIST_BUFFER_SIZE 8192だ。http://tools.oesf.biz/android-2.3.7_r1.0/xref/system/core/run-as/run-as.c:run-as.c
package.c
Gerritの方は特に書いてないな。
Gerrit Code Review:message:"run-as"
GitHubの方にあった。
run-as: Bump the size of the internal packages list buffer.
This patch increases the size of the internal buffer used by run-as
to store the content of /data/system/packages.list from 8KB to 64KB.
Apr 27, 2011なんだ。
run-as can't read packages after the 8192nd byte of /data/system/packages.list
2.3.3だと、修正まえなのかな?
2011年2月9日(SDK 2.3.3)
2011年4月28日(2.3.4)
2011年7月25日(2.3.5)
2011年9月2日(2.3.6)
2011年9月20日(2.3.7)
アプリをほとんど削除したけど、これ以上削れない。だめっぽいな。
$ ls -l /data/system | grep pack
- rw-rw-r-- system system 9581 2012-03-02 15:43 packages.list
- rw-rw-r-- system system 129700 2012-03-02 15:43 packages.xml