#!/bin/bash # # opreport_module is a script to generate profiling information # for a module. It should automate the process. # # NOTE that his needs to be run as root to create and remove the required # symlinks # # Copyright 2005 # Read the file COPYING # # Authors: Will Cohen # print help message do_help() { echo -en "Usage:\t`basename $0`" echo -e " module_name [arguments for opreport]" exit 1 } # Figure out which version of oprofile is being used. OP_VERSION=`opcontrol -v|awk '{print $3}'` # need to warn that make sure that data taken for the kernel running # check arguments # there should be one MODULE_NAME=`basename $1` # find module path MODULE_DIRECTORY="/lib/modules/`uname -r`/" MODULE_PATH=`find $MODULE_DIRECTORY -name "$MODULE_NAME.ko"` if test ! -f $MODULE_PATH; then #try .o files before giving up MODULE_PATH=`find $MODULE_DIRECTORY -name "$MODULE_NAME.o"` if test ! -f $MODULE_PATH; then echo "Unable to find a module for $MODULE_NAME" >&2 exit 1 fi fi # check where oprofile saved data # /module # /lib/module/uname/... # see if the module file exists OPROF_MOD_LOCATION="/$MODULE_NAME" # if not make the link if test ! -f $OPROF_MOD_LOCATION; then #make the link ln -s $MODULE_PATH $OPROF_MOD_LOCATION fi # do the analsysis shift 1 case "$OP_VERSION" in 0.5*) oprofpp $OPROF_MOD_LOCATION $@ ;; 0.6*) opreport image:$OPROF_MOD_LOCATION $@ ;; 0.7*) opreport image:$OPROF_MOD_LOCATION $@ ;; 0.8*) opreport image:$OPROF_MOD_LOCATION $@ ;; 0.9*) opreport image:$OPROF_MOD_LOCATION $@ ;; esac # undo any symlink if test -L $OPROF_MOD_LOCATION; then #make the link rm $OPROF_MOD_LOCATION fi