Commit dcaa3948 authored by Jin Yao's avatar Jin Yao Committed by Arnaldo Carvalho de Melo

perf annotate: Return arch from symbol__disassemble() and save it in browser

In annotate browser, we will add support to check fused instructions.
While this is x86-specific feature so we need the annotate browser to
know what the arch it runs on.

symbol__disassemble() has figured out the arch. This patch just lets the
arch return from symbol__disassemble and save the arch in annotate
browser.
Signed-off-by: default avatarYao Jin <yao.jin@linux.intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1497840958-4759-2-git-send-email-yao.jin@linux.intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent d3cef7fe
...@@ -134,7 +134,7 @@ static int perf_top__parse_source(struct perf_top *top, struct hist_entry *he) ...@@ -134,7 +134,7 @@ static int perf_top__parse_source(struct perf_top *top, struct hist_entry *he)
return err; return err;
} }
err = symbol__disassemble(sym, map, NULL, 0); err = symbol__disassemble(sym, map, NULL, 0, NULL);
if (err == 0) { if (err == 0) {
out_assign: out_assign:
top->sym_filter_entry = he; top->sym_filter_entry = he;
......
...@@ -46,12 +46,15 @@ static struct annotate_browser_opt { ...@@ -46,12 +46,15 @@ static struct annotate_browser_opt {
.jump_arrows = true, .jump_arrows = true,
}; };
struct arch;
struct annotate_browser { struct annotate_browser {
struct ui_browser b; struct ui_browser b;
struct rb_root entries; struct rb_root entries;
struct rb_node *curr_hot; struct rb_node *curr_hot;
struct disasm_line *selection; struct disasm_line *selection;
struct disasm_line **offsets; struct disasm_line **offsets;
struct arch *arch;
int nr_events; int nr_events;
u64 start; u64 start;
int nr_asm_entries; int nr_asm_entries;
...@@ -1070,7 +1073,8 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, ...@@ -1070,7 +1073,8 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map,
(nr_pcnt - 1); (nr_pcnt - 1);
} }
err = symbol__disassemble(sym, map, perf_evsel__env_arch(evsel), sizeof_bdl); err = symbol__disassemble(sym, map, perf_evsel__env_arch(evsel),
sizeof_bdl, &browser.arch);
if (err) { if (err) {
char msg[BUFSIZ]; char msg[BUFSIZ];
symbol__strerror_disassemble(sym, map, err, msg, sizeof(msg)); symbol__strerror_disassemble(sym, map, err, msg, sizeof(msg));
......
...@@ -168,7 +168,8 @@ static int symbol__gtk_annotate(struct symbol *sym, struct map *map, ...@@ -168,7 +168,8 @@ static int symbol__gtk_annotate(struct symbol *sym, struct map *map,
if (map->dso->annotate_warned) if (map->dso->annotate_warned)
return -1; return -1;
err = symbol__disassemble(sym, map, perf_evsel__env_arch(evsel), 0); err = symbol__disassemble(sym, map, perf_evsel__env_arch(evsel),
0, NULL);
if (err) { if (err) {
char msg[BUFSIZ]; char msg[BUFSIZ];
symbol__strerror_disassemble(sym, map, err, msg, sizeof(msg)); symbol__strerror_disassemble(sym, map, err, msg, sizeof(msg));
......
...@@ -1379,7 +1379,9 @@ static const char *annotate__norm_arch(const char *arch_name) ...@@ -1379,7 +1379,9 @@ static const char *annotate__norm_arch(const char *arch_name)
return normalize_arch((char *)arch_name); return normalize_arch((char *)arch_name);
} }
int symbol__disassemble(struct symbol *sym, struct map *map, const char *arch_name, size_t privsize) int symbol__disassemble(struct symbol *sym, struct map *map,
const char *arch_name, size_t privsize,
struct arch **parch)
{ {
struct dso *dso = map->dso; struct dso *dso = map->dso;
char command[PATH_MAX * 2]; char command[PATH_MAX * 2];
...@@ -1405,6 +1407,9 @@ int symbol__disassemble(struct symbol *sym, struct map *map, const char *arch_na ...@@ -1405,6 +1407,9 @@ int symbol__disassemble(struct symbol *sym, struct map *map, const char *arch_na
if (arch == NULL) if (arch == NULL)
return -ENOTSUP; return -ENOTSUP;
if (parch)
*parch = arch;
if (arch->init) { if (arch->init) {
err = arch->init(arch); err = arch->init(arch);
if (err) { if (err) {
...@@ -1901,7 +1906,8 @@ int symbol__tty_annotate(struct symbol *sym, struct map *map, ...@@ -1901,7 +1906,8 @@ int symbol__tty_annotate(struct symbol *sym, struct map *map,
struct rb_root source_line = RB_ROOT; struct rb_root source_line = RB_ROOT;
u64 len; u64 len;
if (symbol__disassemble(sym, map, perf_evsel__env_arch(evsel), 0) < 0) if (symbol__disassemble(sym, map, perf_evsel__env_arch(evsel),
0, NULL) < 0)
return -1; return -1;
len = symbol__size(sym); len = symbol__size(sym);
......
...@@ -158,7 +158,9 @@ int hist_entry__inc_addr_samples(struct hist_entry *he, int evidx, u64 addr); ...@@ -158,7 +158,9 @@ int hist_entry__inc_addr_samples(struct hist_entry *he, int evidx, u64 addr);
int symbol__alloc_hist(struct symbol *sym); int symbol__alloc_hist(struct symbol *sym);
void symbol__annotate_zero_histograms(struct symbol *sym); void symbol__annotate_zero_histograms(struct symbol *sym);
int symbol__disassemble(struct symbol *sym, struct map *map, const char *arch_name, size_t privsize); int symbol__disassemble(struct symbol *sym, struct map *map,
const char *arch_name, size_t privsize,
struct arch **parch);
enum symbol_disassemble_errno { enum symbol_disassemble_errno {
SYMBOL_ANNOTATE_ERRNO__SUCCESS = 0, SYMBOL_ANNOTATE_ERRNO__SUCCESS = 0,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment