perf-script: assume native_arch for pipe mode
Subsystems (2)
PATCH 1/1 perf-script: assume native_arch for pipe mode
In pipe mode, session->header.env.arch is not populated until the events are processed. Therefore, the following command crashes:
perf record -o - | perf script
(gdb) bt
It fails when we try to compare env.arch against uts.machine:
if (!strcmp(uts.machine, session->header.env.arch) ||
(!strcmp(uts.machine, "x86_64") &&
!strcmp(session->header.env.arch, "i386")))
native_arch = true;In pipe mode, it is tricky to find env.arch at this stage. To keep it simple, let's just assume native_arch is always true for pipe mode.
--- tools/perf/builtin-script.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/perf/builtin-script.c +2 -1
@@ -3733,7 +3733,8 @@ int cmd_script(int argc, const char **argv) goto out_delete;uname (&uts); -if (!strcmp (uts.machine, session->header.env.arch) || +if (data.is_pipe ||/* assume pipe_mode indicates native_arch */ + !strcmp (uts.machine, session->header.env.arch) || (!strcmp (uts.machine,"x86_64" ) && !strcmp (session->header.env.arch,"i386" ))) native_arch = true;
Signature · 1 line
2.17.1
tip-bot for Song Liu
merge bot[tip:perf/urgent] perf script: Assume native_arch for pipe mode
perf script: Assume native_arch for pipe mode
Commit-ID: 9d49169c5958e429ffa6874fbef734ae7502ad65 Gitweb: https://git.kernel.org/tip/9d49169c5958e429ffa6874fbef734ae7502ad65 Author: Song Liu <[email protected]> AuthorDate: Thu, 20 Jun 2019 18:44:38 -0700 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 9 Jul 2019 10:13:28 -0300
perf script: Assume native_arch for pipe mode
In pipe mode, session->header.env.arch is not populated until the events are processed. Therefore, the following command crashes:
perf record -o - | perf script
(gdb) bt
It fails when we try to compare env.arch against uts.machine:
if (!strcmp(uts.machine, session->header.env.arch) ||
(!strcmp(uts.machine, "x86_64") &&
!strcmp(session->header.env.arch, "i386")))
native_arch = true;In pipe mode, it is tricky to find env.arch at this stage. To keep it simple, let's just assume native_arch is always true for pipe mode.
--- tools/perf/builtin-script.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/perf/builtin-script.c +2 -1
@@ -3752,7 +3752,8 @@ int cmd_script(int argc, const char **argv) goto out_delete;uname (&uts); -if (!strcmp (uts.machine, session->header.env.arch) || +if (data.is_pipe ||/* assume pipe_mode indicates native_arch */ + !strcmp (uts.machine, session->header.env.arch) || (!strcmp (uts.machine,"x86_64" ) && !strcmp (session->header.env.arch,"i386" ))) native_arch = true;