]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/blobdiff - tools/perf/builtin-script.c
perf script: Add scripting operation process_switch()
[mirror_ubuntu-eoan-kernel.git] / tools / perf / builtin-script.c
index 2f6232f1bfdc4649a242a8ad597ca736641abcd4..8f24865596af2fd5a6334f9c5fa10b726bc22956 100644 (file)
@@ -14,7 +14,6 @@
 #include "util/symbol.h"
 #include "util/thread.h"
 #include "util/trace-event.h"
-#include "util/util.h"
 #include "util/evlist.h"
 #include "util/evsel.h"
 #include "util/sort.h"
@@ -34,6 +33,7 @@
 #include <linux/kernel.h>
 #include <linux/stringify.h>
 #include <linux/time64.h>
+#include <linux/zalloc.h>
 #include <sys/utsname.h>
 #include "asm/bug.h"
 #include "util/mem-events.h"
@@ -2289,6 +2289,12 @@ static int process_switch_event(struct perf_tool *tool,
        if (perf_event__process_switch(tool, event, sample, machine) < 0)
                return -1;
 
+       if (scripting_ops && scripting_ops->process_switch)
+               scripting_ops->process_switch(event, sample, machine);
+
+       if (!script->show_switch_events)
+               return 0;
+
        thread = machine__findnew_thread(machine, sample->pid,
                                         sample->tid);
        if (thread == NULL) {
@@ -2467,7 +2473,7 @@ static int __cmd_script(struct perf_script *script)
                script->tool.mmap = process_mmap_event;
                script->tool.mmap2 = process_mmap2_event;
        }
-       if (script->show_switch_events)
+       if (script->show_switch_events || (scripting_ops && scripting_ops->process_switch))
                script->tool.context_switch = process_switch_event;
        if (script->show_namespace_events)
                script->tool.namespaces = process_namespaces_event;
@@ -3752,7 +3758,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;