]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
perf script: Move script_fetch_insn to trace-event-scripting.c
authorIan Rogers <irogers@google.com>
Tue, 19 Nov 2024 01:16:32 +0000 (17:16 -0800)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 18 Dec 2024 19:24:32 +0000 (16:24 -0300)
Add native_arch as a parameter to script_fetch_insn rather than
relying on the builtin-script value that won't be initialized for the
dlfilter and python Context use cases. Assume both of those cases are
running natively.

Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Acked-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Colin Ian King <colin.i.king@gmail.com>
Cc: Dapeng Mi <dapeng1.mi@linux.intel.com>
Cc: Howard Chu <howardchu95@gmail.com>
Cc: Ilya Leoshkevich <iii@linux.ibm.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Richter <tmricht@linux.ibm.com>
Cc: Veronika Molnarova <vmolnaro@redhat.com>
Cc: Weilin Wang <weilin.wang@intel.com>
Link: https://lore.kernel.org/r/20241119011644.971342-11-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-script.c
tools/perf/scripts/python/Perf-Trace-Util/Context.c
tools/perf/util/dlfilter.c
tools/perf/util/python.c
tools/perf/util/trace-event-scripting.c
tools/perf/util/trace-event.h

index 7158669239da68c24f16d2996e7d00469eca3598..098c5ac6a6f5482e4373cdefeb6f35f07a4dbe4a 100644 (file)
@@ -1586,19 +1586,6 @@ static int perf_sample__fprintf_callindent(struct perf_sample *sample,
        return len + dlen;
 }
 
-__weak void arch_fetch_insn(struct perf_sample *sample __maybe_unused,
-                           struct thread *thread __maybe_unused,
-                           struct machine *machine __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 evsel *evsel,
                                     struct perf_event_attr *attr,
@@ -1608,7 +1595,7 @@ static int perf_sample__fprintf_insn(struct perf_sample *sample,
 {
        int printed = 0;
 
-       script_fetch_insn(sample, thread, machine);
+       script_fetch_insn(sample, thread, machine, native_arch);
 
        if (PRINT_FIELD(INSNLEN))
                printed += fprintf(fp, " ilen: %d", sample->insn_len);
index d742daaa5d5a223ff8ca7bb775f7e060543d1810..60dcfe56d4d9b4946f20e38ea50ca01cdf987d69 100644 (file)
@@ -93,7 +93,7 @@ static PyObject *perf_sample_insn(PyObject *obj, PyObject *args)
        if (c->sample->ip && !c->sample->insn_len && thread__maps(c->al->thread)) {
                struct machine *machine =  maps__machine(thread__maps(c->al->thread));
 
-               script_fetch_insn(c->sample, c->al->thread, machine);
+               script_fetch_insn(c->sample, c->al->thread, machine, /*native_arch=*/true);
        }
        if (!c->sample->insn_len)
                Py_RETURN_NONE; /* N.B. This is a return statement */
index 7d180bdaedbc9ec374e251e5a69229b03033c8d6..ddacef881af2fd7447d6ded76e21154e93d533a1 100644 (file)
@@ -234,7 +234,8 @@ static const __u8 *dlfilter__insn(void *ctx, __u32 *len)
                        struct machine *machine = maps__machine(thread__maps(al->thread));
 
                        if (machine)
-                               script_fetch_insn(d->sample, al->thread, machine);
+                               script_fetch_insn(d->sample, al->thread, machine,
+                                                 /*native_arch=*/true);
                }
        }
 
index d157aaa4bb53c0ce825e28de1966b5987d6c97bc..3ade7b05def2a4a1234d27af6f3b5d48cecb524c 100644 (file)
@@ -1317,12 +1317,6 @@ struct kwork_work *perf_kwork_add_work(struct perf_kwork *kwork __maybe_unused,
        return NULL;
 }
 
-void script_fetch_insn(struct perf_sample *sample __maybe_unused,
-               struct thread *thread __maybe_unused,
-               struct machine *machine __maybe_unused)
-{
-}
-
 int perf_sample__sprintf_flags(u32 flags __maybe_unused, char *str __maybe_unused,
                        size_t sz __maybe_unused)
 {
index d8f4b5bce4ad5daa8e70a2d572715feef0d55327..62ba1af799368c59ce99d4485021706d2910bf21 100644 (file)
@@ -13,6 +13,7 @@
 #include <event-parse.h>
 #endif
 
+#include "archinsn.h"
 #include "debug.h"
 #include "trace-event.h"
 #include "evsel.h"
@@ -271,3 +272,16 @@ void setup_perl_scripting(void)
 }
 #endif
 #endif
+
+__weak void arch_fetch_insn(struct perf_sample *sample __maybe_unused,
+                    struct thread *thread __maybe_unused,
+                    struct machine *machine __maybe_unused)
+{
+}
+
+void script_fetch_insn(struct perf_sample *sample, struct thread *thread,
+                      struct machine *machine, bool native_arch)
+{
+       if (sample->insn_len == 0 && native_arch)
+               arch_fetch_insn(sample, thread, machine);
+}
index 4eacf802c65588ad58b99d4e4352f81b78d707c2..ac9fde2f980cc31bcadbe92e2b4ac0003fa23184 100644 (file)
@@ -117,7 +117,7 @@ struct scripting_ops *script_spec__lookup(const char *spec);
 int script_spec__for_each(int (*cb)(struct scripting_ops *ops, const char *spec));
 
 void script_fetch_insn(struct perf_sample *sample, struct thread *thread,
-                      struct machine *machine);
+                      struct machine *machine, bool native_arch);
 
 void setup_perl_scripting(void);
 void setup_python_scripting(void);