Thanks for the reply.
Luckily, I've managed to run drmemory on my Android device. And I successfully used it to find bugs from my test program, which was a native C application.
So I hope to move a step forward, using drmemory to instrument Android Apps, not only native applications. Now I had some progress.
Android App's launch process is sophisticated. Generally, a App is started by forking from Zygote process and passing several important parameters to it to get the thread entry to run.
In order to use drmemory to start a Android app, we could use the wrap function.
First, make a shell script as follows, androidWrapper.sh
#!/system/bin/sh
exec /system/xbin/DrMemory/bin/drmemory -show_reachable -v -logdir /data/local/tmp/drlog -- $*
Then, activate the wrap function for the test App
setprop wrap.com.ryu.asandemo "logwrapper /system/xbin/DrMemory/bin/androidWrapper.sh"
Here logwrapper is used to redirect the print log to JNI log.
So, while we start the asandemo App from the Launcher, Android will follow the execution process as app_process -> logwrapper -> drmemory -> app_process -> activityThread
Theoretically, this way shall works. But now I am stuck at below error(bold texts) which made the app fail to start.
I/ActivityManager( 694): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.ryu.asandemo/.MainActivity (has extras)} from uid 10034 on display 0
I/androidWrapper.sh(32376): INFO: targeting application: "/system/bin/app_process32"
I/androidWrapper.sh(32376): INFO: app cmdline: "/system/bin/app_process" "/system/bin" "--application" "--nice-name=com.ryu.asandemo" "com.android.internal.os.WrapperInit" "14" "21" "android.app.ActivityThread"
I/androidWrapper.sh(32376): INFO: logdir is "/data/local/tmp/drlog"
I/androidWrapper.sh(32376): INFO: symcache_dir is "/data/local/tmp/drlog/symcache"
I/androidWrapper.sh(32376): INFO: DynamoRIO configuration directory is /system/xbin/DrMemory/bin/../dynamorio/lib32/release/libdynamorio.so
I/androidWrapper.sh(32376): INFO: configuring app_process32 pid=32378 dr_ops="-disable_traces -bb_single_restore_prefix -max_bb_instrs 256 -vm_size 256M -no_enable_reset -logdir `/data/local/tmp/drlog/dynamorio` "
I/androidWrapper.sh(32376): ERROR: failed to register DynamoRIO configuration for "app_process32"(32378) dr_ops="-disable_traces -bb_single_restore_prefix -max_bb_instrs 256 -vm_size 256M -no_enable_reset -logdir `/data/local/tmp/drlog/dynamorio` ".
I/androidWrapper.sh(32376): Error code 13 (failed to locate a valid config directory)
I/androidWrapper.sh(32376): androidWrapper.sh terminated by exit(1)
W/Zygote ( 201): Error reading pid from wrapped process, child may have died
W/Zygote ( 201): java.io.EOFException
W/Zygote ( 201): at libcore.io.Streams.readFully(Streams.java:83)
W/Zygote ( 201): at java.io.DataInputStream.readInt(DataInputStream.java:103)
W/Zygote ( 201): at com.android.internal.os.ZygoteConnection.handleParentProc(ZygoteConnection.java:979)
W/Zygote ( 201): at com.android.internal.os.ZygoteConnection.runOnce(ZygoteConnection.java:276)
W/Zygote ( 201): at com.android.internal.os.ZygoteInit.runSelectLoop(ZygoteInit.java:788)
W/Zygote ( 201): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
I/ActivityManager( 694): Start proc 32360:com.ryu.asandemo/u0a55 for activity com.ryu.asandemo/.MainActivity
I tried to use below command to reg app_process32.
drconfig -reg app_process32
But I got the error:
process app_process32 registration failed: check config dir /system/xbin/DrMemory/dynamorio/bin32/.dynamorio permissions
Actually I'm sure the permission configuration is correct.
So what shall I do? I think if I could fix this error, I would have much more chance the start the App.
在 2016年2月23日星期二 UTC+8上午12:15:29,Derek Bruening写道: