add oprofile_command
authorwoojin <woojin2.jung@samsung.com>
Fri, 29 Mar 2013 14:02:17 +0000 (23:02 +0900)
committerwoojin <woojin2.jung@samsung.com>
Fri, 29 Mar 2013 14:02:17 +0000 (23:02 +0900)
Change-Id: I0a1716282249bd2a6bb1f46454986dc5442c869c

packaging/oprofile.spec
utils/Makefile.am
utils/Makefile.in
utils/oprofile_command [new file with mode: 0755]

index 67744f9..c7c8a39 100644 (file)
@@ -25,6 +25,7 @@ rm -rf %{buildroot}
 
 %files  
 %{_bindir}/opcontrol  
+%{_bindir}/oprofile_command
 %{_bindir}/oprofiled  
 %{_bindir}/ophelp  
 %{_bindir}/op-check-perfevents
@@ -38,8 +39,8 @@ rm -rf %{buildroot}
 %{_datadir}/oprofile/arm/armv7-common
 %{_datadir}/oprofile/arm/armv7-scorpion
 %{_datadir}/oprofile/arm/armv7-scorpionmp
+%{_datadir}/oprofile/arm/mpcore
 %exclude %{_datadir}/oprofile/arm/armv6
-%exclude %{_datadir}/oprofile/arm/mpcore
 %exclude %{_datadir}/oprofile/arm/xscale1
 %exclude %{_datadir}/oprofile/arm/xscale2
 %else  
@@ -47,7 +48,22 @@ rm -rf %{buildroot}
 %endif  
 
 %ifarch %{ix86}  
-%{_datadir}/oprofile/i386  
+%{_datadir}/oprofile/i386/arch_perfmon  
+%{_datadir}/oprofile/i386/atom  
+%{_datadir}/oprofile/i386/core  
+%{_datadir}/oprofile/i386/core_2  
+%{_datadir}/oprofile/i386/core_i7  
+%{_datadir}/oprofile/i386/ivybridge
+%{_datadir}/oprofile/i386/nehalem
+%{_datadir}/oprofile/i386/p6_mobile  
+%{_datadir}/oprofile/i386/sandybridge  
+%{_datadir}/oprofile/i386/westmere  
+%exclude %{_datadir}/oprofile/i386/athlon
+%exclude %{_datadir}/oprofile/i386/p4
+%exclude %{_datadir}/oprofile/i386/p4-ht
+%exclude %{_datadir}/oprofile/i386/pii
+%exclude %{_datadir}/oprofile/i386/piii
+%exclude %{_datadir}/oprofile/i386/ppro
 %else  
 %exclude %{_datadir}/oprofile/i386  
 %endif  
index d34b060..cfd6481 100644 (file)
@@ -8,7 +8,7 @@ AM_LDFLAGS = @OP_LDFLAGS@
 LIBS=@POPT_LIBS@ @LIBERTY_LIBS@
 
 bin_PROGRAMS = ophelp op-check-perfevents
-dist_bin_SCRIPTS = opcontrol
+dist_bin_SCRIPTS = opcontrol oprofile_command
 
 op_check_perfevents_SOURCES = op_perf_events_checker.c
 op_check_perfevents_CPPFLAGS = ${AM_CFLAGS} @PERF_EVENT_FLAGS@
index 1b83cf7..9d5d2c6 100644 (file)
@@ -267,7 +267,7 @@ AM_CPPFLAGS = -I ${top_srcdir}/libop \
 
 AM_CFLAGS = @OP_CFLAGS@
 AM_LDFLAGS = @OP_LDFLAGS@
-dist_bin_SCRIPTS = opcontrol
+dist_bin_SCRIPTS = opcontrol oprofile_command
 op_check_perfevents_SOURCES = op_perf_events_checker.c
 op_check_perfevents_CPPFLAGS = ${AM_CFLAGS} @PERF_EVENT_FLAGS@
 ophelp_SOURCES = ophelp.c
diff --git a/utils/oprofile_command b/utils/oprofile_command
new file mode 100755 (executable)
index 0000000..74587d3
--- /dev/null
@@ -0,0 +1,207 @@
+#!/bin/bash
+
+OPCONTROL=/usr/bin/opcontrol
+OPHELP=/usr/bin/ophelp
+
+op_init()
+{
+       $OPCONTROL --init
+}
+
+op_startdaemon()
+{
+       $OPCONTROL --start-daemon
+}
+
+op_start()
+{
+       $OPCONTROL --start && echo start_ok
+}
+
+op_dump()
+{
+       $OPCONTROL --dump
+}
+
+op_stop()
+{
+       $OPCONTROL --stop
+}
+
+op_shutdown()
+{
+       $OPCONTROL --shutdown
+}
+
+op_reset()
+{
+       $OPCONTROL --reset
+}
+
+op_deinit()
+{
+       $OPCONTROL --deinit
+}
+
+op_list()
+{
+       $OPCONTROL --list-events 2> /dev/null
+}
+
+op_status()
+{
+       $OPCONTROL --status 2> /dev/null | grep ^Event
+}
+
+op_save()
+{
+       $OPCONTROL --save=$SAVENAME
+}
+
+op_help()
+{
+       $OPHELP -e $EVENTQUERY
+}
+
+op_setup()
+{
+#      validate $SETUPOPTION
+       while [[ "$#" -ne 0 ]]
+               do
+                       arg=`printf %s $1 | awk -F= '{printf $1}'`
+                       val=`printf %s $1 | awk -F= '{printf $2}'`
+                       shift
+
+                       if [[ -z "$val" ]] ; then
+                               echo "Invalid setup option!"
+                               exit 1
+                       fi
+
+                       case "$arg" in
+                               separate)
+                                       SEPARATE=$val
+                                       ;;
+                               vmlinux)
+                                       VMLINUX=$val
+                                       ;;
+                               image)
+                                       IMAGEPATH=$val
+                                       ;;
+                               callgraph)
+                                       CALLGRAPH=$val
+                                       ;;
+                               event)
+                                       EVENT=$val
+                                       ;;
+                               *)
+                                       echo "Unknown setup option!"
+                                       exit 1
+                                       ;;
+                       esac
+               done
+       
+       if [[ -n "$SEPARATE" ]] ; then
+               SETUPARGS="$SETUPARGS --separate=$SEPARATE"
+       fi
+
+       if [[ -n "$VMLINUX" ]] ; then
+               if [[ "$VMLINUX" == "no" ]] ; then
+                       SETUPARGS="$SETUPARGS --no-vmlinux"
+               else
+                       SETUPARGS="$SETUPARGS --vmlinux=$VMLINUX"
+               fi
+       fi
+
+       if [[ -n "$IMAGEPATH" ]] ; then
+               SETUPARGS="$SETUPARGS --image=$IMAGEPATH"
+       fi
+
+       if [[ -n "$CALLGRAPH" ]] ; then
+               SETUPARGS="$SETUPARGS --callgraph=$CALLGRAPH"
+       fi
+
+       if [[ -n "$EVENT" ]] ; then
+               SETUPARGS="$SETUPARGS --event=$EVENT"
+       fi
+
+       $OPCONTROL --setup $SETUPARGS   
+}
+
+disable_watchdog()
+{
+       echo 0 > /proc/sys/kernel/nmi_watchdog
+}
+
+
+
+echo $@
+#echo $@ >> /home/developer/oprofile_history
+
+if [[ -n $1 ]]; then
+       case "$1" in
+               init)
+                       op_init
+                       ;;
+               startdaemon)
+                       op_startdaemon
+                       ;;
+               start)
+                       op_start
+                       ;;
+               dump)
+                       op_dump
+                       ;;
+               stop)
+                       op_stop
+                       ;;
+               shutdown)
+                       op_shutdown
+                       ;;
+               reset)
+                       op_reset
+                       ;;
+               deinit)
+                       op_deinit
+                       ;;
+               list)
+                       op_list
+                       ;;
+               save)
+                       if [[ -n $2 ]]; then
+                               SAVENAME=$2
+                       else
+                               echo "Save name is not given!"
+                               exit 1
+                       fi
+                       op_save
+                       ;;
+               ophelp)
+                       if [[ -n $2 ]]; then
+                               EVENTQUERY=$2
+                       else
+                               echo "Event query is not given!"
+                               exit 1
+                       fi
+                       op_help
+                       ;;
+               setup)
+                       if [[ $# -ge 2 ]]; then
+                               shift
+                               SETUPOPTION=$@
+                       else
+                               echo "Setup option is not given!"
+                               exit 1
+                       fi
+                       op_setup $@
+                       ;;
+               watchdogoff)
+                       disable_watchdog
+                       ;;
+               *)
+                       echo "Unknown option!" >&2
+                       exit 1
+                       ;;
+       esac
+fi
+
+