无法使用Valgrind

时间:2016-11-16 17:02:14

标签: android android-ndk profiling valgrind

我正在尝试使用Valgrind分析一个简单的HelloJni项目(在Android Studio中构建),在使用Valgrind执行应用程序时,我在最后的步骤中遇到了一些麻烦。 我正在开发使用Android 5.1的Nexus 4设备。

安装信息:

我使用"build_valgrind.sh"脚本交叉编译valgrind(用于api android-21)并将其复制到/ data / local / Inst。 我还将"start_valgrind.sh"复制到/ data / local /文件夹,为脚本提供了所有权限(“chmod 777”)。 然后我将属性设置为HelloJni应用程序。

adb shell "su -c 'setprop wrap.com.example.hellojni \"logwrapper /data/local/start_valgrind.sh \"'"

当我尝试执行应用程序时出现了实际问题:

adb shell "su -c 'am start -a android.intent.action.MAIN -n com.example.hellojni/.HelloJni'"

我得到的logcat输出在最后发布。

当我在不设置logwrapper属性的情况下执行HelloJni应用程序时,它会按预期执行。我不确定我做错了什么,但看起来好像我有“CheckJNI关闭”的问题。有人能用这种方法执行任何应用程序吗?任何帮助将不胜感激。

logcat_output
--------- beginning of main
    I/Finsky  (19498): [1] com.google.android.finsky.services.j.a(148): Installation state replication succeeded.
    E/kickstart(  627): Wrote to /sys/power/wake_lock
    E/kickstart(  627): Received file "/dev/block/platform/msm_sdcc.1/by-name/m9kefs1"
    E/kickstart(  627): 786432 bytes transferred in 0.185s (4.06 MBps)
    E/kickstart(  627): Successfully downloaded files from target 
    E/kickstart(  627): Wrote to /sys/power/wake_unlock
    E/kickstart(  627): Sahara protocol completed
    D/AndroidRuntime(22076): >>>>>> START com.android.internal.os.RuntimeInit uid 0 <<<<<<
    D/AndroidRuntime(22076): CheckJNI is OFF
    D/AndroidRuntime(22077): >>>>>> START com.android.internal.os.RuntimeInit uid 0 <<<<<<
    D/AndroidRuntime(22077): CheckJNI is OFF
    W/app_process32_o(22077): type=1400 audit(0.0:317): avc: denied { write } for name="system@framework@boot.art" dev="mmcblk0p23" ino=185108 scontext=u:r:shell:s0 tcontext=u:object_r:dalvikcache_data_file:s0 tclass=file
    D/AndroidRuntime(22076): Calling main entry com.android.commands.am.Am
    --------- beginning of system
    I/ActivityManager(18563): START u0 {act=android.intent.action.MAIN flg=0x10000000 cmp=com.example.hellojni/.HelloJni} from uid 0 on display 0
    V/WindowManager(18563): addAppToken: AppWindowToken{385169a4 token=Token{13e037 ActivityRecord{2ce09936 u0 com.example.hellojni/.HelloJni t3}}} to stack=1 task=3 at 0
    D/AndroidRuntime(22077): Calling main entry com.android.commands.am.Am
    I/art     (22110): Late-enabling -Xcheck:jni
    I/start_valgrind.sh(22127): valgrind: cannot create log file '/sdcard/valgrind.log.22128': Permission denied
    I/start_valgrind.sh(22127): start_valgrind.sh terminated by exit(1)
    W/Zygote  (18317): Error reading pid from wrapped process, child may have died
    W/Zygote  (18317): java.io.EOFException
    W/Zygote  (18317):  at libcore.io.Streams.readFully(Streams.java:83)
    W/Zygote  (18317):  at java.io.DataInputStream.readInt(DataInputStream.java:103)
    W/Zygote  (18317):  at com.android.internal.os.ZygoteConnection.handleParentProc(ZygoteConnection.java:979)
    W/Zygote  (18317):  at com.android.internal.os.ZygoteConnection.runOnce(ZygoteConnection.java:276)
    W/Zygote  (18317):  at com.android.internal.os.ZygoteInit.runSelectLoop(ZygoteInit.java:788)
    W/Zygote  (18317):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
    I/ActivityManager(18563): Start proc 22110:com.example.hellojni/u0a125 for activity com.example.hellojni/.HelloJni
    D/AndroidRuntime(22076): Shutting down VM
    I/art     (22076): Debugger is no longer active
    D/AndroidRuntime(22077): Shutting down VM
    I/art     (22077): Debugger is no longer active
    I/Zygote  (18317): Process 22110 exited cleanly (1)
    W/ActivityManager(18563): Process ProcessRecord{173c48d3 22110:com.example.hellojni/u0a125} failed to attach
    I/ActivityManager(18563): Killing 22110:com.example.hellojni/u0a125 (adj -100): start timeout

0 个答案:

没有答案