Skip to content

Commit 8bd1b2d

Browse files
ahunter6acmel
authored andcommitted
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>
1 parent f70cfa0 commit 8bd1b2d

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

tools/perf/perf-with-kcore.sh

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ copy_kcore()
5050
fi
5151

5252
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 &
5454
PERF_PID=$!
5555

5656
# Need to make sure that perf has started
@@ -160,18 +160,18 @@ record()
160160
echo "*** WARNING *** /proc/sys/kernel/kptr_restrict prevents access to kernel addresses" >&2
161161
fi
162162
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
164164
echo "*** WARNING *** system-wide tracing without root access will not be able to read all necessary information from /proc" >&2
165165
fi
166166
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
168168
if [ "$(cat /proc/sys/kernel/perf_event_paranoid)" -gt -1 ] ; then
169169
echo "*** WARNING *** /proc/sys/kernel/perf_event_paranoid restricts buffer size and tracepoint (sched_switch) use" >&2
170170
fi
171171
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
173173
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
175175
true
176176
elif [ ! -r /sys/kernel/debug -o ! -x /sys/kernel/debug ] ; then
177177
echo "*** WARNING *** /sys/kernel/debug permissions prevent tracepoint (sched_switch) use" >&2
@@ -193,8 +193,8 @@ record()
193193
194194
mkdir "$PERF_DATA_DIR"
195195
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
198198
199199
if rmdir "$PERF_DATA_DIR" > /dev/null 2>/dev/null ; then
200200
exit 1
@@ -209,8 +209,8 @@ subcommand()
209209
{
210210
find_perf
211211
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" "$@"
214214
}
215215
216216
if [ "$1" = "fix_buildid_cache_permissions" ] ; then
@@ -234,24 +234,24 @@ fi
234234
case "$PERF_SUB_COMMAND" in
235235
"record")
236236
while [ "$1" != "--" ] ; do
237-
PERF_OPTIONS+="$1 "
237+
PERF_OPTIONS+=("$1")
238238
shift || break
239239
done
240240
if [ "$1" != "--" ] ; then
241241
echo "Options and workload are required for recording" >&2
242242
usage
243243
fi
244244
shift
245-
record $*
245+
record "$@"
246246
;;
247247
"script")
248-
subcommand $*
248+
subcommand "$@"
249249
;;
250250
"report")
251-
subcommand $*
251+
subcommand "$@"
252252
;;
253253
"inject")
254-
subcommand $*
254+
subcommand "$@"
255255
;;
256256
*)
257257
usage

0 commit comments

Comments
 (0)