Commit 5c008c97 authored by Song Liu's avatar Song Liu Committed by Greg Kroah-Hartman

perf script: Assume native_arch for pipe mode

commit 9d49169c upstream.

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.
Reported-by: default avatarDavid Carrillo Cisneros <davidca@fb.com>
Signed-off-by: default avatarSong Liu <songliubraving@fb.com>
Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: kernel-team@fb.com
Cc: stable@vger.kernel.org #v5.1+
Fixes: 3ab481a1 ("perf script: Support insn output for normal samples")
Link: http://lkml.kernel.org/r/20190621014438.810342-1-songliubraving@fb.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 8206c6c1
...@@ -3669,7 +3669,8 @@ int cmd_script(int argc, const char **argv) ...@@ -3669,7 +3669,8 @@ int cmd_script(int argc, const char **argv)
goto out_delete; goto out_delete;
uname(&uts); 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(uts.machine, "x86_64") &&
!strcmp(session->header.env.arch, "i386"))) !strcmp(session->header.env.arch, "i386")))
native_arch = true; native_arch = true;
......
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