usage() { echo"Ftrace boottime trace test tool" echo"Usage: $0 [--apply|--init] [--debug] BOOTCONFIG-FILE" echo" --apply: Test actual apply to tracefs (need sudo)" echo" --init: Initialize ftrace before applying (imply --apply)"
exit 1
}
[ $# -eq 0 ] && usage
BCONF=
DEBUG=
APPLY=
INIT= while [ x"$1" != x ]; do
case "$1" in "--debug")
DEBUG=$1;; "--apply")
APPLY=$1;; "--init")
APPLY=$1
INIT=$1;;
*)
[ ! -f $1 ] && usage
BCONF=$1;;
esac
shift 1 done
if [ x"$APPLY" != x ]; then if [ `id -u` -ne 0 ]; then echo"This must be run by root user. Try sudo." 1>&2
exec sudo $0 $DEBUG $APPLY $BCONF fi fi
run_cmd() { # command echo"$*" if [ x"$APPLY" != x ]; then# apply command eval $* fi
}
if [ x"$DEBUG" != x ]; then
set -x fi
TRACEFS=`grep -m 1 -w tracefs /proc/mounts | cut -f 2 -d " "` if [ -z "$TRACEFS" ]; then if ! grep -wq debugfs /proc/mounts; then echo"Error: No tracefs/debugfs was mounted." 1>&2
exit 1 fi
TRACEFS=`grep -m 1 -w debugfs /proc/mounts | cut -f 2 -d " "`/tracing if [ ! -d $TRACEFS ]; then echo"Error: ftrace is not enabled on this kernel." 1>&2
exit 1 fi fi
if [ x"$INIT" != x ]; then
. `dirname $0`/ftrace.sh
(cd $TRACEFS; initialize_ftrace) fi
. `dirname $0`/xbc.sh
######## main #########
set -e
xbc_init $BCONF
set_value_of() { # key file if xbc_has_key $1; then
val=`xbc_get_val $1 1`
run_cmd "echo '$val' >> $2" fi
}
set_array_of() { # key file if xbc_has_key $1; then
xbc_get_val $1 | while read line; do
run_cmd "echo '$line' >> $2" done fi
}
print_hist_one_action() { # prefix handler param echo -n ":${2}("`xbc_get_val ${1}.${3}`")" if xbc_has_key "${1}.trace"; then
print_hist_action_array ${1} "trace" elif xbc_has_key "${1}.save"; then
print_hist_action_array ${1} "save" elif xbc_has_key "${1}.snapshot"; then echo -n ".snapshot()" fi
}
print_hist_actions() { # prefix handler param for __hdr in `xbc_subkeys ${1}.${2} 1 ".[0-9]"`; do
print_hist_one_action ${1}.${2}.$__hdr ${2} ${3} done if xbc_has_key ${1}.${2}.${3} ; then
print_hist_one_action ${1}.${2} ${2} ${3} fi
}
setup_histograms() { # prefix trigger-file for __hist in `xbc_subkeys ${1} 1 ".[0-9]"`; do
setup_one_histogram ${1}.$__hist ${2} done if xbc_has_key ${1}.keys; then
setup_one_histogram ${1} ${2} fi
}
setup_event() { # prefix group event [instance]
branch=$1.$2.$3 if [ "$4" ]; then
eventdir="$TRACEFS/instances/$4/events/$2/$3" else
eventdir="$TRACEFS/events/$2/$3" fi # group enable if [ "$3" = "enable" ]; then
run_cmd "echo 1 > ${eventdir}"
return fi
case $2 in
kprobes)
xbc_get_val ${branch}.probes | while read line; do
run_cmd "echo 'p:kprobes/$3 $line' >> $TRACEFS/kprobe_events" done
;;
synthetic)
run_cmd "echo '`compose_synth $3 ${branch}.fields`' >> $TRACEFS/synthetic_events"
;;
esac
if xbc_has_key ${branch}.enable; then
run_cmd "echo 1 > ${eventdir}/enable" fi
}
setup_events() { # prefix("ftrace" or "ftrace.instance.INSTANCE") [instance]
prefix="${1}.event" if xbc_has_branch ${1}.event; then for grpev in `xbc_subkeys ${1}.event 2`; do
setup_event $prefix ${grpev%.*} ${grpev#*.} $2 done fi if xbc_has_branch ${1}.event.enable; then if [ "$2" ]; then
run_cmd "echo 1 > $TRACEFS/instances/$2/events/enable" else
run_cmd "echo 1 > $TRACEFS/events/enable" fi fi
}
setup_instance() { # [instance] if [ "$1" ]; then
instance="ftrace.instance.${1}"
instancedir=$TRACEFS/instances/$1 else
instance="ftrace"
instancedir=$TRACEFS fi
# Per-instance/per-event configs if ! xbc_has_branch "ftrace" ; then
exit 0 fi
setup_instance # root instance
if xbc_has_branch "ftrace.instance"; then for i in `xbc_subkeys "ftrace.instance" 1`; do
run_cmd "mkdir -p $TRACEFS/instances/$i"
setup_instance $i done fi
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.