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.
Unified · Split
| @@ -1586,19 +1586,6 @@ static int perf_sample__fprintf_callindent(struct perf_sample *sample, · 1585 unmodified lines | ||
| 1586 | 1586 | return len + dlen; |
| 1587 | 1587 | } |
| 1588 | 1588 | |
| 1589 | −__weak void arch_fetch_insn(struct perf_sample *sample __maybe_unused, | |
| 1590 | − struct thread *thread __maybe_unused, | |
| 1591 | − struct machine *machine __maybe_unused) | |
| 1592 | −{ | |
| 1593 | −} | |
| 1594 | − | |
| 1595 | −void script_fetch_insn(struct perf_sample *sample, struct thread *thread, | |
| 1596 | − struct machine *machine) | |
| 1597 | −{ | |
| 1598 | − if (sample->insn_len == 0 && native_arch) | |
| 1599 | − arch_fetch_insn(sample, thread, machine); | |
| 1600 | −} | |
| 1601 | − | |
| 1602 | 1589 | static int perf_sample__fprintf_insn(struct perf_sample *sample, |
| 1603 | 1590 | struct evsel *evsel, |
| 1604 | 1591 | struct perf_event_attr *attr, |
| @@ -1608,7 +1595,7 @@ static int perf_sample__fprintf_insn(struct perf_sample *sample, · 3 unmodified lines | ||
| 1608 | 1595 | { |
| 1609 | 1596 | int printed = 0; |
| 1610 | 1597 | |
| 1611 | − script_fetch_insn(sample, thread, machine); | |
| 1598 | + script_fetch_insn(sample, thread, machine, native_arch); | |
| 1612 | 1599 | |
| 1613 | 1600 | if (PRINT_FIELD(INSNLEN)) |
| 1614 | 1601 | printed += fprintf(fp, " ilen: %d", sample->insn_len); |
| @@ -93,7 +93,7 @@ static PyObject *perf_sample_insn(PyObject *obj, PyObject *args) · 92 unmodified lines | ||
| 93 | 93 | if (c->sample->ip && !c->sample->insn_len && thread__maps(c->al->thread)) { |
| 94 | 94 | struct machine *machine = maps__machine(thread__maps(c->al->thread)); |
| 95 | 95 | |
| 96 | − script_fetch_insn(c->sample, c->al->thread, machine); | |
| 96 | + script_fetch_insn(c->sample, c->al->thread, machine, /*native_arch=*/true); | |
| 97 | 97 | } |
| 98 | 98 | if (!c->sample->insn_len) |
| 99 | 99 | Py_RETURN_NONE; /* N.B. This is a return statement */ |
| @@ -234,7 +234,8 @@ static const __u8 *dlfilter__insn(void *ctx, __u32 *len) · 233 unmodified lines | ||
| 234 | 234 | struct machine *machine = maps__machine(thread__maps(al->thread)); |
| 235 | 235 | |
| 236 | 236 | if (machine) |
| 237 | − script_fetch_insn(d->sample, al->thread, machine); | |
| 237 | + script_fetch_insn(d->sample, al->thread, machine, | |
| 238 | + /*native_arch=*/true); | |
| 238 | 239 | } |
| 239 | 240 | } |
| 240 | 241 | |
| @@ -1317,12 +1317,6 @@ struct kwork_work *perf_kwork_add_work(struct perf_kwork *kwork __maybe_unused, · 1316 unmodified lines | ||
| 1317 | 1317 | return NULL; |
| 1318 | 1318 | } |
| 1319 | 1319 | |
| 1320 | −void script_fetch_insn(struct perf_sample *sample __maybe_unused, | |
| 1321 | − struct thread *thread __maybe_unused, | |
| 1322 | − struct machine *machine __maybe_unused) | |
| 1323 | −{ | |
| 1324 | −} | |
| 1325 | − | |
| 1326 | 1320 | int perf_sample__sprintf_flags(u32 flags __maybe_unused, char *str __maybe_unused, |
| 1327 | 1321 | size_t sz __maybe_unused) |
| 1328 | 1322 | { |
| @@ -13,6 +13,7 @@ · 12 unmodified lines | ||
| 13 | 13 | #include <event-parse.h> |
| 14 | 14 | #endif |
| 15 | 15 | |
| 16 | +#include "archinsn.h" | |
| 16 | 17 | #include "debug.h" |
| 17 | 18 | #include "trace-event.h" |
| 18 | 19 | #include "evsel.h" |
| @@ -271,3 +272,16 @@ void setup_perl_scripting(void) · 252 unmodified lines | ||
| 271 | 272 | } |
| 272 | 273 | #endif |
| 273 | 274 | #endif |
| 275 | + | |
| 276 | +__weak void arch_fetch_insn(struct perf_sample *sample __maybe_unused, | |
| 277 | + struct thread *thread __maybe_unused, | |
| 278 | + struct machine *machine __maybe_unused) | |
| 279 | +{ | |
| 280 | +} | |
| 281 | + | |
| 282 | +void script_fetch_insn(struct perf_sample *sample, struct thread *thread, | |
| 283 | + struct machine *machine, bool native_arch) | |
| 284 | +{ | |
| 285 | + if (sample->insn_len == 0 && native_arch) | |
| 286 | + arch_fetch_insn(sample, thread, machine); | |
| 287 | +} | |
| @@ -117,7 +117,7 @@ struct scripting_ops *script_spec__lookup(const char *spec); · 116 unmodified lines | ||
| 117 | 117 | int script_spec__for_each(int (*cb)(struct scripting_ops *ops, const char *spec)); |
| 118 | 118 | |
| 119 | 119 | void script_fetch_insn(struct perf_sample *sample, struct thread *thread, |
| 120 | − struct machine *machine); | |
| 120 | + struct machine *machine, bool native_arch); | |
| 121 | 121 | |
| 122 | 122 | void setup_perl_scripting(void); |
| 123 | 123 | void setup_python_scripting(void); |