Commit 8bd1b2d2 authored by Adrian Hunter's avatar Adrian Hunter Committed by Arnaldo Carvalho de Melo

perf tools: Fix perf-with-kcore handling of arguments containing spaces

Fix the perf-with-kcore script so that it doesn't split arguments that
contain spaces.
Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/1437150840-31811-13-git-send-email-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent f70cfa07
...@@ -50,7 +50,7 @@ copy_kcore() ...@@ -50,7 +50,7 @@ copy_kcore()
fi fi
rm -f perf.data.junk rm -f perf.data.junk
("$PERF" record -o perf.data.junk $PERF_OPTIONS -- sleep 60) >/dev/null 2>/dev/null & ("$PERF" record -o perf.data.junk "${PERF_OPTIONS[@]}" -- sleep 60) >/dev/null 2>/dev/null &
PERF_PID=$! PERF_PID=$!
# Need to make sure that perf has started # Need to make sure that perf has started
...@@ -160,18 +160,18 @@ record() ...@@ -160,18 +160,18 @@ record()
echo "*** WARNING *** /proc/sys/kernel/kptr_restrict prevents access to kernel addresses" >&2 echo "*** WARNING *** /proc/sys/kernel/kptr_restrict prevents access to kernel addresses" >&2
fi fi
if echo "$PERF_OPTIONS" | grep -q ' -a \|^-a \| -a$\|^-a$\| --all-cpus \|^--all-cpus \| --all-cpus$\|^--all-cpus$' ; then if echo "${PERF_OPTIONS[@]}" | grep -q ' -a \|^-a \| -a$\|^-a$\| --all-cpus \|^--all-cpus \| --all-cpus$\|^--all-cpus$' ; then
echo "*** WARNING *** system-wide tracing without root access will not be able to read all necessary information from /proc" >&2 echo "*** WARNING *** system-wide tracing without root access will not be able to read all necessary information from /proc" >&2
fi fi
if echo "$PERF_OPTIONS" | grep -q 'intel_pt\|intel_bts\| -I\|^-I' ; then if echo "${PERF_OPTIONS[@]}" | grep -q 'intel_pt\|intel_bts\| -I\|^-I' ; then
if [ "$(cat /proc/sys/kernel/perf_event_paranoid)" -gt -1 ] ; then if [ "$(cat /proc/sys/kernel/perf_event_paranoid)" -gt -1 ] ; then
echo "*** WARNING *** /proc/sys/kernel/perf_event_paranoid restricts buffer size and tracepoint (sched_switch) use" >&2 echo "*** WARNING *** /proc/sys/kernel/perf_event_paranoid restricts buffer size and tracepoint (sched_switch) use" >&2
fi fi
if echo "$PERF_OPTIONS" | grep -q ' --per-thread \|^--per-thread \| --per-thread$\|^--per-thread$' ; then if echo "${PERF_OPTIONS[@]}" | grep -q ' --per-thread \|^--per-thread \| --per-thread$\|^--per-thread$' ; then
true true
elif echo "$PERF_OPTIONS" | grep -q ' -t \|^-t \| -t$\|^-t$' ; then elif echo "${PERF_OPTIONS[@]}" | grep -q ' -t \|^-t \| -t$\|^-t$' ; then
true true
elif [ ! -r /sys/kernel/debug -o ! -x /sys/kernel/debug ] ; then elif [ ! -r /sys/kernel/debug -o ! -x /sys/kernel/debug ] ; then
echo "*** WARNING *** /sys/kernel/debug permissions prevent tracepoint (sched_switch) use" >&2 echo "*** WARNING *** /sys/kernel/debug permissions prevent tracepoint (sched_switch) use" >&2
...@@ -193,8 +193,8 @@ record() ...@@ -193,8 +193,8 @@ record()
mkdir "$PERF_DATA_DIR" mkdir "$PERF_DATA_DIR"
echo "$PERF record -o $PERF_DATA_DIR/perf.data $PERF_OPTIONS -- $*" echo "$PERF record -o $PERF_DATA_DIR/perf.data ${PERF_OPTIONS[@]} -- $@"
"$PERF" record -o "$PERF_DATA_DIR/perf.data" $PERF_OPTIONS -- $* || true "$PERF" record -o "$PERF_DATA_DIR/perf.data" "${PERF_OPTIONS[@]}" -- "$@" || true
if rmdir "$PERF_DATA_DIR" > /dev/null 2>/dev/null ; then if rmdir "$PERF_DATA_DIR" > /dev/null 2>/dev/null ; then
exit 1 exit 1
...@@ -209,8 +209,8 @@ subcommand() ...@@ -209,8 +209,8 @@ subcommand()
{ {
find_perf find_perf
check_buildid_cache_permissions check_buildid_cache_permissions
echo "$PERF $PERF_SUB_COMMAND -i $PERF_DATA_DIR/perf.data --kallsyms=$PERF_DATA_DIR/kcore_dir/kallsyms $*" echo "$PERF $PERF_SUB_COMMAND -i $PERF_DATA_DIR/perf.data --kallsyms=$PERF_DATA_DIR/kcore_dir/kallsyms $@"
"$PERF" $PERF_SUB_COMMAND -i "$PERF_DATA_DIR/perf.data" "--kallsyms=$PERF_DATA_DIR/kcore_dir/kallsyms" $* "$PERF" $PERF_SUB_COMMAND -i "$PERF_DATA_DIR/perf.data" "--kallsyms=$PERF_DATA_DIR/kcore_dir/kallsyms" "$@"
} }
if [ "$1" = "fix_buildid_cache_permissions" ] ; then if [ "$1" = "fix_buildid_cache_permissions" ] ; then
...@@ -234,7 +234,7 @@ fi ...@@ -234,7 +234,7 @@ fi
case "$PERF_SUB_COMMAND" in case "$PERF_SUB_COMMAND" in
"record") "record")
while [ "$1" != "--" ] ; do while [ "$1" != "--" ] ; do
PERF_OPTIONS+="$1 " PERF_OPTIONS+=("$1")
shift || break shift || break
done done
if [ "$1" != "--" ] ; then if [ "$1" != "--" ] ; then
...@@ -242,16 +242,16 @@ case "$PERF_SUB_COMMAND" in ...@@ -242,16 +242,16 @@ case "$PERF_SUB_COMMAND" in
usage usage
fi fi
shift shift
record $* record "$@"
;; ;;
"script") "script")
subcommand $* subcommand "$@"
;; ;;
"report") "report")
subcommand $* subcommand "$@"
;; ;;
"inject") "inject")
subcommand $* subcommand "$@"
;; ;;
*) *)
usage usage
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment