Skip to content

Commit

Permalink
perf script: Assume native_arch for pipe mode
Browse files Browse the repository at this point in the history
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: David Carrillo Cisneros <[email protected]>
Signed-off-by: Song Liu <[email protected]>
Tested-by: Arnaldo Carvalho de Melo <[email protected]>
Cc: Andi Kleen <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: [email protected]
Cc: [email protected] #v5.1+
Fixes: 3ab481a ("perf script: Support insn output for normal samples")
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
  • Loading branch information
liu-song-6 authored and acmel committed Jul 9, 2019
1 parent 1334bb9 commit 9d49169
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tools/perf/builtin-script.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 9d49169

Please sign in to comment.