Re: [tip:perf/core] perf script/python: Print array argument as string

Sebastian Andrzej Siewior
2014-06-26T15:37:33Z

On 06/12/2014 02:01 PM, tip-bot for Namhyung Kim wrote:

> Commit-ID: e646fe730a324098a718f1c9b2f349efb99d5457
> Gitweb: http://git.kernel.org/tip/e646fe730a324098a718f1c9b2f349efb99d5457
> Author: Namhyung Kim <namhyung@kernel.org>
> AuthorDate: Thu, 29 May 2014 13:44:55 +0900
> Committer: Jiri Olsa <jolsa@kernel.org>
> CommitDate: Mon, 9 Jun 2014 12:21:03 +0200
>
> perf script/python: Print array argument as string
>
> With the Sebastian's change of handling num array argument (of raw
> syscall enter), the script still failed to work like this:

This patch got merged. It fixes something that was introduced by
"perf script: move the number processing into its own function" [0]
"perf script: handle the num array type in python properly" [1]

which was not yet merged.

[0] lkml.kernel.org/r/1401207274-8170-1-git-send-email-bigeasy@linutronix.de
[1] lkml.kernel.org/r/1401207274-8170-2-git-send-email-bigeasy@linutronix.de

> $ perf record -e raw_syscalls:* sleep 1
> $ perf script -g python
> $ perf script -s perf-script.py
> ...
> Traceback (most recent call last):
> File "perf-script.py", line 42, in raw_syscalls__sys_enter
> (id, args),
> TypeError: %u format: a number is required, not list
> Fatal Python error: problem in Python trace event handler
> Aborted (core dumped)
>
> This is because the generated script tries to print the array arg as
> unsigned integer (%u). Since the python seems to convert arguments to
> strings by default, just using %s solved the problem for me.

Sebastian