Cannot run HelloJni application using Valgrind

I'm trying to parse a simple HelloJni project (built into Android Studio) using Valgrind, and I ran into some problems in the last steps when running the application with Valgrind. I am developing on a Nexus 4 device with Android 5.1.

Installation Information:

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

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

The actual problem occurs when I try to execute the application:

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

The logcat output that I get is sent at the end.

When I launch the HelloJni application without setting the logwrapper properties, it runs as expected. I'm not sure what I'm doing wrong, but it looks like I'm having problems with "CheckJNI is OFF". Has anyone been able to run any application with this approach? Any help would 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
+4
source share

Source: https://habr.com/ru/post/1660974/


All Articles