diff options
Diffstat (limited to 'tools/perf/builtin-script.c')
-rw-r--r-- | tools/perf/builtin-script.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c index 53f78cf3113f..a5080afd361d 100644 --- a/tools/perf/builtin-script.c +++ b/tools/perf/builtin-script.c | |||
@@ -29,10 +29,12 @@ | |||
29 | #include "util/time-utils.h" | 29 | #include "util/time-utils.h" |
30 | #include "util/path.h" | 30 | #include "util/path.h" |
31 | #include "print_binary.h" | 31 | #include "print_binary.h" |
32 | #include "archinsn.h" | ||
32 | #include <linux/bitmap.h> | 33 | #include <linux/bitmap.h> |
33 | #include <linux/kernel.h> | 34 | #include <linux/kernel.h> |
34 | #include <linux/stringify.h> | 35 | #include <linux/stringify.h> |
35 | #include <linux/time64.h> | 36 | #include <linux/time64.h> |
37 | #include <sys/utsname.h> | ||
36 | #include "asm/bug.h" | 38 | #include "asm/bug.h" |
37 | #include "util/mem-events.h" | 39 | #include "util/mem-events.h" |
38 | #include "util/dump-insn.h" | 40 | #include "util/dump-insn.h" |
@@ -63,6 +65,7 @@ static const char *cpu_list; | |||
63 | static DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS); | 65 | static DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS); |
64 | static struct perf_stat_config stat_config; | 66 | static struct perf_stat_config stat_config; |
65 | static int max_blocks; | 67 | static int max_blocks; |
68 | static bool native_arch; | ||
66 | 69 | ||
67 | unsigned int scripting_max_stack = PERF_MAX_STACK_DEPTH; | 70 | unsigned int scripting_max_stack = PERF_MAX_STACK_DEPTH; |
68 | 71 | ||
@@ -1227,6 +1230,12 @@ static int perf_sample__fprintf_callindent(struct perf_sample *sample, | |||
1227 | return len + dlen; | 1230 | return len + dlen; |
1228 | } | 1231 | } |
1229 | 1232 | ||
1233 | __weak void arch_fetch_insn(struct perf_sample *sample __maybe_unused, | ||
1234 | struct thread *thread __maybe_unused, | ||
1235 | struct machine *machine __maybe_unused) | ||
1236 | { | ||
1237 | } | ||
1238 | |||
1230 | static int perf_sample__fprintf_insn(struct perf_sample *sample, | 1239 | static int perf_sample__fprintf_insn(struct perf_sample *sample, |
1231 | struct perf_event_attr *attr, | 1240 | struct perf_event_attr *attr, |
1232 | struct thread *thread, | 1241 | struct thread *thread, |
@@ -1234,9 +1243,12 @@ static int perf_sample__fprintf_insn(struct perf_sample *sample, | |||
1234 | { | 1243 | { |
1235 | int printed = 0; | 1244 | int printed = 0; |
1236 | 1245 | ||
1246 | if (sample->insn_len == 0 && native_arch) | ||
1247 | arch_fetch_insn(sample, thread, machine); | ||
1248 | |||
1237 | if (PRINT_FIELD(INSNLEN)) | 1249 | if (PRINT_FIELD(INSNLEN)) |
1238 | printed += fprintf(fp, " ilen: %d", sample->insn_len); | 1250 | printed += fprintf(fp, " ilen: %d", sample->insn_len); |
1239 | if (PRINT_FIELD(INSN)) { | 1251 | if (PRINT_FIELD(INSN) && sample->insn_len) { |
1240 | int i; | 1252 | int i; |
1241 | 1253 | ||
1242 | printed += fprintf(fp, " insn:"); | 1254 | printed += fprintf(fp, " insn:"); |
@@ -3277,6 +3289,7 @@ int cmd_script(int argc, const char **argv) | |||
3277 | .set = false, | 3289 | .set = false, |
3278 | .default_no_sample = true, | 3290 | .default_no_sample = true, |
3279 | }; | 3291 | }; |
3292 | struct utsname uts; | ||
3280 | char *script_path = NULL; | 3293 | char *script_path = NULL; |
3281 | const char **__argv; | 3294 | const char **__argv; |
3282 | int i, j, err = 0; | 3295 | int i, j, err = 0; |
@@ -3615,6 +3628,12 @@ int cmd_script(int argc, const char **argv) | |||
3615 | if (symbol__init(&session->header.env) < 0) | 3628 | if (symbol__init(&session->header.env) < 0) |
3616 | goto out_delete; | 3629 | goto out_delete; |
3617 | 3630 | ||
3631 | uname(&uts); | ||
3632 | if (!strcmp(uts.machine, session->header.env.arch) || | ||
3633 | (!strcmp(uts.machine, "x86_64") && | ||
3634 | !strcmp(session->header.env.arch, "i386"))) | ||
3635 | native_arch = true; | ||
3636 | |||
3618 | script.session = session; | 3637 | script.session = session; |
3619 | script__setup_sample_type(&script); | 3638 | script__setup_sample_type(&script); |
3620 | 3639 | ||