perf script: Factor out script_fetch_insn()
authorAdrian Hunter <adrian.hunter@intel.com>
Sun, 30 May 2021 19:23:01 +0000 (22:23 +0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 1 Jun 2021 13:03:46 +0000 (10:03 -0300)
Factor out script_fetch_insn() so it can be reused.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: https://lore.kernel.org/r/20210530192308.7382-7-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-script.c
tools/perf/util/trace-event.h

index fd5c257..57488d6 100644 (file)
@@ -1417,6 +1417,13 @@ __weak void arch_fetch_insn(struct perf_sample *sample __maybe_unused,
 {
 }
 
+void script_fetch_insn(struct perf_sample *sample, struct thread *thread,
+                      struct machine *machine)
+{
+       if (sample->insn_len == 0 && native_arch)
+               arch_fetch_insn(sample, thread, machine);
+}
+
 static int perf_sample__fprintf_insn(struct perf_sample *sample,
                                     struct perf_event_attr *attr,
                                     struct thread *thread,
@@ -1424,8 +1431,7 @@ static int perf_sample__fprintf_insn(struct perf_sample *sample,
 {
        int printed = 0;
 
-       if (sample->insn_len == 0 && native_arch)
-               arch_fetch_insn(sample, thread, machine);
+       script_fetch_insn(sample, thread, machine);
 
        if (PRINT_FIELD(INSNLEN))
                printed += fprintf(fp, " ilen: %d", sample->insn_len);
index 73f5b29..54aadee 100644 (file)
@@ -97,6 +97,9 @@ extern unsigned int scripting_max_stack;
 
 int script_spec_register(const char *spec, struct scripting_ops *ops);
 
+void script_fetch_insn(struct perf_sample *sample, struct thread *thread,
+                      struct machine *machine);
+
 void setup_perl_scripting(void);
 void setup_python_scripting(void);