mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-27 14:14:24 +08:00
7e66ef0046
Add a bconf2ftrace.sh under tools/bootconfig/scripts which generates a shell script to setup boot-time trace from bootconfig file for testing the bootconfig. bconf2ftrace.sh will take a bootconfig file (includes boot-time tracing) and convert it into a shell-script which is almost same as the boot-time tracer does. If --apply option is given, it also tries to apply those command to the running kernel, which requires the root privilege (or sudo). For example, if you just want to confirm the shell commands, save the output as below. # bconf2ftrace.sh ftrace.bconf > ftrace.sh Or, you can apply it directly. # bconf2ftrace.sh --apply ftrace.bconf Note that some boot-time tracing parameters under kernel.* are not able to set via tracefs nor procfs (e.g. tp_printk, traceoff_on_warning.), so those are ignored. Link: https://lkml.kernel.org/r/159704851101.175360.15119132351139842345.stgit@devnote2 Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
57 lines
1.1 KiB
Bash
57 lines
1.1 KiB
Bash
#!/bin/sh
|
|
# SPDX-License-Identifier: GPL-2.0-only
|
|
|
|
# bootconfig utility functions
|
|
|
|
XBC_TMPFILE=
|
|
XBC_BASEDIR=`dirname $0`
|
|
BOOTCONFIG=${BOOTCONFIG:=$XBC_BASEDIR/../bootconfig}
|
|
if [ ! -x "$BOOTCONFIG" ]; then
|
|
BOOTCONFIG=`which bootconfig`
|
|
if [ -z "$BOOTCONFIG" ]; then
|
|
echo "Erorr: bootconfig command is not found" 1>&2
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
xbc_cleanup() {
|
|
if [ "$XBC_TMPFILE" ]; then
|
|
rm -f "$XBC_TMPFILE"
|
|
fi
|
|
}
|
|
|
|
xbc_init() { # bootconfig-file
|
|
xbc_cleanup
|
|
XBC_TMPFILE=`mktemp bconf-XXXX`
|
|
trap xbc_cleanup EXIT TERM
|
|
|
|
$BOOTCONFIG -l $1 > $XBC_TMPFILE || exit 1
|
|
}
|
|
|
|
nr_args() { # args
|
|
echo $#
|
|
}
|
|
|
|
xbc_get_val() { # key [maxnum]
|
|
if [ "$2" ]; then
|
|
MAXOPT="-L $2"
|
|
fi
|
|
grep "^$1 =" $XBC_TMPFILE | cut -d= -f2- | \
|
|
sed -e 's/", /" /g' -e "s/',/' /g" | \
|
|
xargs $MAXOPT -n 1 echo
|
|
}
|
|
|
|
xbc_has_key() { # key
|
|
grep -q "^$1 =" $XBC_TMPFILE
|
|
}
|
|
|
|
xbc_has_branch() { # prefix-key
|
|
grep -q "^$1" $XBC_TMPFILE
|
|
}
|
|
|
|
xbc_subkeys() { # prefix-key depth
|
|
__keys=`echo $1 | sed "s/\./ /g"`
|
|
__s=`nr_args $__keys`
|
|
grep "^$1" $XBC_TMPFILE | cut -d= -f1| cut -d. -f$((__s + 1))-$((__s + $2)) | uniq
|
|
}
|