4

I am trying to analyse a simple HelloJni project (built in Android Studio) using Valgrind and I am facing some troubles in the final steps when executing the application with Valgrind. I am developing on a Nexus 4 device with Android 5.1.

Installation info:

I have used the "build_valgrind.sh" script to cross-compile valgrind (for api android-21) and to copy it to /data/local/Inst. I have also copied "start_valgrind.sh" to /data/local/ folder, giving all permissions ("chmod 777) to the script. Then I set properties to the HelloJni app.

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

The actual problem comes when I try to execute the app:

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

The logcat output I get is posted at the end.

When I execute the HelloJni app without setting logwrapper properties, it executes as expected. I am not sure what I am doing wrong, but it looks as if I have problems with "CheckJNI is OFF". Has someone been able to execute any application with this approach? Any help will be appreciated.

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
Community
  • 1
  • 1
ortisenderos
  • 370
  • 4
  • 15

0 Answers0