[Title] add valgrind command
authorgreatim <jaewon81.lim@samsung.com>
Tue, 16 Apr 2013 07:47:25 +0000 (16:47 +0900)
committergreatim <jaewon81.lim@samsung.com>
Tue, 16 Apr 2013 07:48:31 +0000 (16:48 +0900)
[Desc.]
[Issue]

Change-Id: Ic0176559eb0150c33cbfe95b45784d30364e8408

utils/oprofile_command

index b67e020..f6220fc 100755 (executable)
@@ -3,6 +3,9 @@
 KILL=/usr/bin/killall
 OPCONTROL=/usr/bin/opcontrol
 OPHELP=/usr/bin/ophelp
+VALGRIND=/home/developer/sdk_tools/valgrind/usr/bin/valgrind
+GETMACHINEINFO="/bin/uname -m"
+CHMOD=/bin/chmod
 
 is_app_executable()
 {
@@ -13,6 +16,16 @@ is_app_executable()
        fi
 }
 
+is_emulator()
+{
+       MACHINE=`$GETMACHINEINFO`
+       if [[ $MACHINE =~ .*emulated.* ]] ; then
+               return 1
+       else
+               return 0
+       fi
+}
+
 op_init()
 {
        $OPCONTROL --init
@@ -162,6 +175,24 @@ kill_app()
        $KILL $APPPATH
 }
 
+valgrind_run()
+{
+#      validate $VALGRINDOPTION
+       VALGRINDAPPPATH=`printf %s "$*" | awk '{printf $NF}'`
+       is_app_executable $VALGRINDAPPPATH
+       if [[ "$?" -ne 1 ]] ; then
+               echo "Invalid application executable path!"
+               exit 1
+       fi
+       $VALGRIND $@
+}
+
+valgrind_chmod_result()
+{
+       RESULTDIRECTORY=/tmp/valgrind_result
+       $CHMOD 777 $RESULTDIRECTORY/*
+}
+
 echo $@
 #echo $@ >> /home/developer/oprofile_history
 
@@ -252,6 +283,29 @@ if [[ -n $1 ]]; then
                        fi
                        kill_app
                        ;;
+               valgrind)
+                       is_emulator
+                       if [[ "$?" -ne 1 ]] ; then
+                               echo "Valgrind option is available only on the emulator!"
+                               exit 1
+                       fi
+                       if [[ $# -ge 2 ]]; then
+                               shift
+                               VALGRINDOPTION=$@
+                       else
+                               echo "Valgrind option is not given!"
+                               exit 1
+                       fi
+                       valgrind_run $@
+                       ;;
+               valgrind_chmod)
+                       is_emulator
+                       if [[ "$?" -ne 1 ]] ; then
+                               echo "Valgrind option is available only on the emulator!"
+                               exit 1
+                       fi
+                       valgrind_chmod_result
+                       ;;
                *)
                        echo "Unknown option!" >&2
                        exit 1