不能运行一个Java Android程序与Valgrind的 [英] Can't run a Java Android program with Valgrind
问题描述
我试图启动Valgring这样下一个Java程序(ADB壳):
的valgrind上午开始-a -n android.intent.action.MAIN com.me.myapp / .MainActivity
我收到:
== 2362 ==的Memcheck,内存错误检测
== 2362 ==版权所有(C)2002-2012,和GNU GPL的,由朱利安·苏厄德等。
== 2362 ==使用Valgrind的-3.8.1和LibVEX;重新运行与-h版权信息
== 2362 ==命令:上午
== 2362 ==
/系统/ bin / sh的:上午:没有这样的文件或目录
您必须创建一个脚本,让我们把它叫做start_valgrind.sh
#!/系统/ bin / sh的
PACKAGE =com.example.hellojni
#Callgrind工具
#VGPARAMS =' - V --error限制=无--trace儿= YES --log文件= / SD卡/ valgrind.log%P --tool = callgrind --callgrind出文件= / SD卡/callgrind.out.%p
#工具的Memcheck
VGPARAMS =' - V --error限制=无--trace儿= YES --log文件= / SD卡/ valgrind.log%P --tool =的Memcheck --leak检查=满--show-到达= YES'
出口TMPDIR = /数据/数据/ $ PACKAGE
EXEC /数据/本地/安装/斌/的valgrind $ VGPARAMS $ *
这应该被复制到设备。
在你在 start_valgrind.sh 文件上面的脚本地方在您的本地文件系统中你可以使用下面的脚本(可以调用它的 bootstrap_valgrind.sh ),以做所有的工作(复制start_valgrind.sh脚本到手机,运行它,开始通过Valgrind的你的应用程序)。
#!的/ usr / bin中/ env的庆典
PACKAGE =com.example.hellojni
亚行推start_valgrind.sh /数据/本地/
亚行外壳搭配chmod 777 /data/local/start_valgrind.sh
亚行根
亚行外壳setprop包裹。$ PACKAGElogwrapper /data/local/start_valgrind.sh
回声包$ PACKAGE:(ADB壳getprop包$ PACKAGE)$
亚行外壳时强制停止$ PACKAGE
亚行外壳上午开始-a -n android.intent.action.MAIN $ PACKAGE / .HelloJni
亚行logcat -c
亚行logcat
退出0
警告:确保属性名称设置setprop即(wrap.com.yourcompany.yourapp)小于31个字符的长度
否则,你会得到无法设置属性,因为你不能设置一个属性名的长度大于31,这是在属性名的数量最大允许的字符错误。
另外,属性值应为&LT; = 91个字符:<一href="http://stackoverflow.com/a/5068818/313113">http://stackoverflow.com/a/5068818/313113
对于如何建立Valgrind的Android版(ARM)看我的剧本从这里:的http:// stackoverflow.com/a/19255251/313113
I'm trying to start a Java program under Valgring like this (in adb shell):
valgrind am start -a android.intent.action.MAIN -n com.me.myapp/.MainActivity
I'm getting:
==2362== Memcheck, a memory error detector
==2362== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==2362== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==2362== Command: am
==2362==
/system/bin/sh: am: No such file or directory
You have to create a script, lets call it start_valgrind.sh
#!/system/bin/sh
PACKAGE="com.example.hellojni"
# Callgrind tool
#VGPARAMS='-v --error-limit=no --trace-children=yes --log-file=/sdcard/valgrind.log.%p --tool=callgrind --callgrind-out-file=/sdcard/callgrind.out.%p'
# Memcheck tool
VGPARAMS='-v --error-limit=no --trace-children=yes --log-file=/sdcard/valgrind.log.%p --tool=memcheck --leak-check=full --show-reachable=yes'
export TMPDIR=/data/data/$PACKAGE
exec /data/local/Inst/bin/valgrind $VGPARAMS $*
that should be copied to the device.
Once you have the above script in the start_valgrind.sh file somewhere on your local filesystem you can just use the below script (lets call it bootstrap_valgrind.sh) to do the all the work (copies the start_valgrind.sh script to the phone, runs it, starts your app through Valgrind).
#!/usr/bin/env bash
PACKAGE="com.example.hellojni"
adb push start_valgrind.sh /data/local/
adb shell chmod 777 /data/local/start_valgrind.sh
adb root
adb shell setprop wrap.$PACKAGE "logwrapper /data/local/start_valgrind.sh"
echo "wrap.$PACKAGE: $(adb shell getprop wrap.$PACKAGE)"
adb shell am force-stop $PACKAGE
adb shell am start -a android.intent.action.MAIN -n $PACKAGE/.HelloJni
adb logcat -c
adb logcat
exit 0
WARNING: Make sure the property name set with setprop i.e. (wrap.com.yourcompany.yourapp) has a length of less than 31 characters.
Otherwise, you'll get the error "could not set property" because you CANNOT set a property name with a length greater than 31, which is the number maximum allowed characters in the property name.
Also the property value should be <= 91 characters: http://stackoverflow.com/a/5068818/313113
For how to build Valgrind for Android (ARM) see my script from here: http://stackoverflow.com/a/19255251/313113
这篇关于不能运行一个Java Android程序与Valgrind的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!