Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Adrian 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.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Adrian Hunter and committed by
Arnaldo Carvalho de Melo
8bd1b2d2 f70cfa07

+14 -14
+14 -14
tools/perf/perf-with-kcore.sh
··· 50 50 fi 51 51 52 52 rm -f perf.data.junk 53 - ("$PERF" record -o perf.data.junk $PERF_OPTIONS -- sleep 60) >/dev/null 2>/dev/null & 53 + ("$PERF" record -o perf.data.junk "${PERF_OPTIONS[@]}" -- sleep 60) >/dev/null 2>/dev/null & 54 54 PERF_PID=$! 55 55 56 56 # Need to make sure that perf has started ··· 160 160 echo "*** WARNING *** /proc/sys/kernel/kptr_restrict prevents access to kernel addresses" >&2 161 161 fi 162 162 163 - if echo "$PERF_OPTIONS" | grep -q ' -a \|^-a \| -a$\|^-a$\| --all-cpus \|^--all-cpus \| --all-cpus$\|^--all-cpus$' ; then 163 + if echo "${PERF_OPTIONS[@]}" | grep -q ' -a \|^-a \| -a$\|^-a$\| --all-cpus \|^--all-cpus \| --all-cpus$\|^--all-cpus$' ; then 164 164 echo "*** WARNING *** system-wide tracing without root access will not be able to read all necessary information from /proc" >&2 165 165 fi 166 166 167 - if echo "$PERF_OPTIONS" | grep -q 'intel_pt\|intel_bts\| -I\|^-I' ; then 167 + if echo "${PERF_OPTIONS[@]}" | grep -q 'intel_pt\|intel_bts\| -I\|^-I' ; then 168 168 if [ "$(cat /proc/sys/kernel/perf_event_paranoid)" -gt -1 ] ; then 169 169 echo "*** WARNING *** /proc/sys/kernel/perf_event_paranoid restricts buffer size and tracepoint (sched_switch) use" >&2 170 170 fi 171 171 172 - if echo "$PERF_OPTIONS" | grep -q ' --per-thread \|^--per-thread \| --per-thread$\|^--per-thread$' ; then 172 + if echo "${PERF_OPTIONS[@]}" | grep -q ' --per-thread \|^--per-thread \| --per-thread$\|^--per-thread$' ; then 173 173 true 174 - elif echo "$PERF_OPTIONS" | grep -q ' -t \|^-t \| -t$\|^-t$' ; then 174 + elif echo "${PERF_OPTIONS[@]}" | grep -q ' -t \|^-t \| -t$\|^-t$' ; then 175 175 true 176 176 elif [ ! -r /sys/kernel/debug -o ! -x /sys/kernel/debug ] ; then 177 177 echo "*** WARNING *** /sys/kernel/debug permissions prevent tracepoint (sched_switch) use" >&2 ··· 193 193 194 194 mkdir "$PERF_DATA_DIR" 195 195 196 - echo "$PERF record -o $PERF_DATA_DIR/perf.data $PERF_OPTIONS -- $*" 197 - "$PERF" record -o "$PERF_DATA_DIR/perf.data" $PERF_OPTIONS -- $* || true 196 + echo "$PERF record -o $PERF_DATA_DIR/perf.data ${PERF_OPTIONS[@]} -- $@" 197 + "$PERF" record -o "$PERF_DATA_DIR/perf.data" "${PERF_OPTIONS[@]}" -- "$@" || true 198 198 199 199 if rmdir "$PERF_DATA_DIR" > /dev/null 2>/dev/null ; then 200 200 exit 1 ··· 209 209 { 210 210 find_perf 211 211 check_buildid_cache_permissions 212 - echo "$PERF $PERF_SUB_COMMAND -i $PERF_DATA_DIR/perf.data --kallsyms=$PERF_DATA_DIR/kcore_dir/kallsyms $*" 213 - "$PERF" $PERF_SUB_COMMAND -i "$PERF_DATA_DIR/perf.data" "--kallsyms=$PERF_DATA_DIR/kcore_dir/kallsyms" $* 212 + echo "$PERF $PERF_SUB_COMMAND -i $PERF_DATA_DIR/perf.data --kallsyms=$PERF_DATA_DIR/kcore_dir/kallsyms $@" 213 + "$PERF" $PERF_SUB_COMMAND -i "$PERF_DATA_DIR/perf.data" "--kallsyms=$PERF_DATA_DIR/kcore_dir/kallsyms" "$@" 214 214 } 215 215 216 216 if [ "$1" = "fix_buildid_cache_permissions" ] ; then ··· 234 234 case "$PERF_SUB_COMMAND" in 235 235 "record") 236 236 while [ "$1" != "--" ] ; do 237 - PERF_OPTIONS+="$1 " 237 + PERF_OPTIONS+=("$1") 238 238 shift || break 239 239 done 240 240 if [ "$1" != "--" ] ; then ··· 242 242 usage 243 243 fi 244 244 shift 245 - record $* 245 + record "$@" 246 246 ;; 247 247 "script") 248 - subcommand $* 248 + subcommand "$@" 249 249 ;; 250 250 "report") 251 - subcommand $* 251 + subcommand "$@" 252 252 ;; 253 253 "inject") 254 - subcommand $* 254 + subcommand "$@" 255 255 ;; 256 256 *) 257 257 usage