From 2975489458c59ce2e348b1b3aef5d8d2acb5cc8d Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Mon, 4 Nov 2019 11:10:00 -0300 Subject: perf annotate: Pass a 'map_symbol' in places receiving a pair of 'map' and 'symbol' pointers We are already passing things like: symbol__annotate(ms->sym, ms->map, ...) So shorten the signature of such functions to receive the 'map_symbol' pointer. This also paves the way to having the 'struct map_groups' pointer in the 'struct map_symbol' so that we can get rid of 'struct map'->groups. Cc: Adrian Hunter Cc: Andi Kleen Cc: Jiri Olsa Cc: Namhyung Kim Link: https://lkml.kernel.org/n/tip-23yx8v1t41nzpkpi7rdrozww@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/ui/browsers/annotate.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'tools/perf/ui/browsers/annotate.c') diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c index 82207db8f97c..ad1fe5b6d0cd 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c @@ -410,7 +410,7 @@ static bool annotate_browser__callq(struct annotate_browser *browser, struct evsel *evsel, struct hist_browser_timer *hbt) { - struct map_symbol *ms = browser->b.priv; + struct map_symbol *ms = browser->b.priv, target_ms; struct disasm_line *dl = disasm_line(browser->selection); struct annotation *notes; char title[SYM_TITLE_MAX_SIZE]; @@ -430,8 +430,10 @@ static bool annotate_browser__callq(struct annotate_browser *browser, return true; } + target_ms.map = ms->map; + target_ms.sym = dl->ops.target.sym; pthread_mutex_unlock(¬es->lock); - symbol__tui_annotate(dl->ops.target.sym, ms->map, evsel, hbt, browser->opts); + symbol__tui_annotate(&target_ms, evsel, hbt, browser->opts); sym_title(ms->sym, ms->map, title, sizeof(title), browser->opts->percent_type); ui_browser__show_title(&browser->b, title); return true; @@ -874,7 +876,7 @@ int map_symbol__tui_annotate(struct map_symbol *ms, struct evsel *evsel, struct hist_browser_timer *hbt, struct annotation_options *opts) { - return symbol__tui_annotate(ms->sym, ms->map, evsel, hbt, opts); + return symbol__tui_annotate(ms, evsel, hbt, opts); } int hist_entry__tui_annotate(struct hist_entry *he, struct evsel *evsel, @@ -888,16 +890,12 @@ int hist_entry__tui_annotate(struct hist_entry *he, struct evsel *evsel, return map_symbol__tui_annotate(&he->ms, evsel, hbt, opts); } -int symbol__tui_annotate(struct symbol *sym, struct map *map, - struct evsel *evsel, +int symbol__tui_annotate(struct map_symbol *ms, struct evsel *evsel, struct hist_browser_timer *hbt, struct annotation_options *opts) { + struct symbol *sym = ms->sym; struct annotation *notes = symbol__annotation(sym); - struct map_symbol ms = { - .map = map, - .sym = sym, - }; struct annotate_browser browser = { .b = { .refresh = annotate_browser__refresh, @@ -905,7 +903,7 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, .write = annotate_browser__write, .filter = disasm_line__filter, .extra_title_lines = 1, /* for hists__scnprintf_title() */ - .priv = &ms, + .priv = ms, .use_navkeypressed = true, }, .opts = opts, @@ -915,13 +913,13 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, if (sym == NULL) return -1; - if (map->dso->annotate_warned) + if (ms->map->dso->annotate_warned) return -1; - err = symbol__annotate2(sym, map, evsel, opts, &browser.arch); + err = symbol__annotate2(ms, evsel, opts, &browser.arch); if (err) { char msg[BUFSIZ]; - symbol__strerror_disassemble(sym, map, err, msg, sizeof(msg)); + symbol__strerror_disassemble(ms, err, msg, sizeof(msg)); ui__error("Couldn't annotate %s:\n%s", sym->name, msg); goto out_free_offsets; } -- cgit v1.2.3 From 94e44b9ca52a72cddd07111a8beb12a2f217c6a2 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Mon, 4 Nov 2019 16:52:19 -0300 Subject: perf annotate: Stop using map->groups, use map_symbol->mg instead These were the last uses of map->groups, next cset will nuke it. Cc: Adrian Hunter Cc: Andi Kleen Cc: Jiri Olsa Cc: Namhyung Kim Link: https://lkml.kernel.org/n/tip-n3g0foos7l7uxq9nar0zo0vj@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/arch/s390/annotate/instructions.c | 2 +- tools/perf/ui/browsers/annotate.c | 1 + tools/perf/util/annotate.c | 6 +++--- 3 files changed, 5 insertions(+), 4 deletions(-) (limited to 'tools/perf/ui/browsers/annotate.c') diff --git a/tools/perf/arch/s390/annotate/instructions.c b/tools/perf/arch/s390/annotate/instructions.c index bdd7ab34ce4f..2a6662e42f89 100644 --- a/tools/perf/arch/s390/annotate/instructions.c +++ b/tools/perf/arch/s390/annotate/instructions.c @@ -38,7 +38,7 @@ static int s390_call__parse(struct arch *arch, struct ins_operands *ops, return -1; target.addr = map__objdump_2mem(map, ops->target.addr); - if (map_groups__find_ams(map->groups, &target) == 0 && + if (map_groups__find_ams(ms->mg, &target) == 0 && map__rip_2objdump(target.ms.map, map->map_ip(target.ms.map, target.addr)) == ops->target.addr) ops->target.sym = target.ms.sym; diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c index ad1fe5b6d0cd..992705c78bd0 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c @@ -430,6 +430,7 @@ static bool annotate_browser__callq(struct annotate_browser *browser, return true; } + target_ms.mg = ms->mg; target_ms.map = ms->map; target_ms.sym = dl->ops.target.sym; pthread_mutex_unlock(¬es->lock); diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index e0a9e9e49bb1..5ea9a4534848 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -271,7 +271,7 @@ static int call__parse(struct arch *arch, struct ins_operands *ops, struct map_s find_target: target.addr = map__objdump_2mem(map, ops->target.addr); - if (map_groups__find_ams(map->groups, &target) == 0 && + if (map_groups__find_ams(ms->mg, &target) == 0 && map__rip_2objdump(target.ms.map, map->map_ip(target.ms.map, target.addr)) == ops->target.addr) ops->target.sym = target.ms.sym; @@ -391,7 +391,7 @@ static int jump__parse(struct arch *arch, struct ins_operands *ops, struct map_s * Actual navigation will come next, with further understanding of how * the symbol searching and disassembly should be done. */ - if (map_groups__find_ams(map->groups, &target) == 0 && + if (map_groups__find_ams(ms->mg, &target) == 0 && map__rip_2objdump(target.ms.map, map->map_ip(target.ms.map, target.addr)) == ops->target.addr) ops->target.sym = target.ms.sym; @@ -1545,7 +1545,7 @@ static int symbol__parse_objdump_line(struct symbol *sym, .ms = { .map = map, }, }; - if (!map_groups__find_ams(map->groups, &target) && + if (!map_groups__find_ams(args->ms.mg, &target) && target.ms.sym->start == target.al_addr) dl->ops.target.sym = target.ms.sym; } -- cgit v1.2.3 From f2eaea09d684177f57db55a9ce2b67d048083fd5 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Mon, 25 Nov 2019 22:15:35 -0300 Subject: perf map_symbol: Rename ms->mg to ms->maps One more step on the merge of 'struct maps' with 'struct map_groups'. Cc: Adrian Hunter Cc: Andi Kleen Cc: Jiri Olsa Cc: Namhyung Kim Link: https://lkml.kernel.org/n/tip-61rra2wg392rhvdgw421wzpt@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/arch/s390/annotate/instructions.c | 2 +- tools/perf/ui/browsers/annotate.c | 2 +- tools/perf/util/annotate.c | 6 +++--- tools/perf/util/callchain.c | 2 +- tools/perf/util/hist.c | 8 ++++---- tools/perf/util/machine.c | 6 +++--- tools/perf/util/map_symbol.h | 2 +- tools/perf/util/unwind-libdw.c | 2 +- tools/perf/util/unwind-libunwind-local.c | 2 +- 9 files changed, 16 insertions(+), 16 deletions(-) (limited to 'tools/perf/ui/browsers/annotate.c') diff --git a/tools/perf/arch/s390/annotate/instructions.c b/tools/perf/arch/s390/annotate/instructions.c index 57be973aea74..0e136630659e 100644 --- a/tools/perf/arch/s390/annotate/instructions.c +++ b/tools/perf/arch/s390/annotate/instructions.c @@ -38,7 +38,7 @@ static int s390_call__parse(struct arch *arch, struct ins_operands *ops, return -1; target.addr = map__objdump_2mem(map, ops->target.addr); - if (maps__find_ams(ms->mg, &target) == 0 && + if (maps__find_ams(ms->maps, &target) == 0 && map__rip_2objdump(target.ms.map, map->map_ip(target.ms.map, target.addr)) == ops->target.addr) ops->target.sym = target.ms.sym; diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c index 992705c78bd0..badbddbb30f8 100644 --- a/tools/perf/ui/browsers/annotate.c +++ b/tools/perf/ui/browsers/annotate.c @@ -430,7 +430,7 @@ static bool annotate_browser__callq(struct annotate_browser *browser, return true; } - target_ms.mg = ms->mg; + target_ms.maps = ms->maps; target_ms.map = ms->map; target_ms.sym = dl->ops.target.sym; pthread_mutex_unlock(¬es->lock); diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 1b0980afdc3c..14f3edc3c261 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -271,7 +271,7 @@ static int call__parse(struct arch *arch, struct ins_operands *ops, struct map_s find_target: target.addr = map__objdump_2mem(map, ops->target.addr); - if (maps__find_ams(ms->mg, &target) == 0 && + if (maps__find_ams(ms->maps, &target) == 0 && map__rip_2objdump(target.ms.map, map->map_ip(target.ms.map, target.addr)) == ops->target.addr) ops->target.sym = target.ms.sym; @@ -391,7 +391,7 @@ static int jump__parse(struct arch *arch, struct ins_operands *ops, struct map_s * Actual navigation will come next, with further understanding of how * the symbol searching and disassembly should be done. */ - if (maps__find_ams(ms->mg, &target) == 0 && + if (maps__find_ams(ms->maps, &target) == 0 && map__rip_2objdump(target.ms.map, map->map_ip(target.ms.map, target.addr)) == ops->target.addr) ops->target.sym = target.ms.sym; @@ -1545,7 +1545,7 @@ static int symbol__parse_objdump_line(struct symbol *sym, .ms = { .map = map, }, }; - if (!maps__find_ams(args->ms.mg, &target) && + if (!maps__find_ams(args->ms.maps, &target) && target.ms.sym->start == target.al_addr) dl->ops.target.sym = target.ms.sym; } diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c index c7270c057b6b..818aa4efd386 100644 --- a/tools/perf/util/callchain.c +++ b/tools/perf/util/callchain.c @@ -1106,7 +1106,7 @@ int hist_entry__append_callchain(struct hist_entry *he, struct perf_sample *samp int fill_callchain_info(struct addr_location *al, struct callchain_cursor_node *node, bool hide_unresolved) { - al->maps = node->ms.mg; + al->maps = node->ms.maps; al->map = node->ms.map; al->sym = node->ms.sym; al->srcline = node->srcline; diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index 5ebfbe373442..ca5a8f4d007e 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c @@ -692,7 +692,7 @@ __hists__add_entry(struct hists *hists, .ino = ns ? ns->link_info[CGROUP_NS_INDEX].ino : 0, }, .ms = { - .mg = al->maps, + .maps = al->maps, .map = al->map, .sym = al->sym, }, @@ -760,7 +760,7 @@ struct hist_entry *hists__add_entry_block(struct hists *hists, .block_info = block_info, .hists = hists, .ms = { - .mg = al->maps, + .maps = al->maps, .map = al->map, .sym = al->sym, }, @@ -895,7 +895,7 @@ iter_next_branch_entry(struct hist_entry_iter *iter, struct addr_location *al) if (iter->curr >= iter->total) return 0; - al->maps = bi[i].to.ms.mg; + al->maps = bi[i].to.ms.maps; al->map = bi[i].to.ms.map; al->sym = bi[i].to.ms.sym; al->addr = bi[i].to.addr; @@ -1072,7 +1072,7 @@ iter_add_next_cumulative_entry(struct hist_entry_iter *iter, .comm = thread__comm(al->thread), .ip = al->addr, .ms = { - .mg = al->maps, + .maps = al->maps, .map = al->map, .sym = al->sym, }, diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index de5d6b4727e3..c1ae5e6f84e2 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c @@ -1934,7 +1934,7 @@ static void ip__resolve_ams(struct thread *thread, ams->addr = ip; ams->al_addr = al.addr; - ams->ms.mg = al.maps; + ams->ms.maps = al.maps; ams->ms.sym = al.sym; ams->ms.map = al.map; ams->phys_addr = 0; @@ -1952,7 +1952,7 @@ static void ip__resolve_data(struct thread *thread, ams->addr = addr; ams->al_addr = al.addr; - ams->ms.mg = al.maps; + ams->ms.maps = al.maps; ams->ms.sym = al.sym; ams->ms.map = al.map; ams->phys_addr = phys_addr; @@ -2069,7 +2069,7 @@ static int add_callchain_ip(struct thread *thread, iter_cycles = iter->cycles; } - ms.mg = al.maps; + ms.maps = al.maps; ms.map = al.map; ms.sym = al.sym; srcline = callchain_srcline(&ms, al.addr); diff --git a/tools/perf/util/map_symbol.h b/tools/perf/util/map_symbol.h index bd985c1c6831..5b8ca93798e9 100644 --- a/tools/perf/util/map_symbol.h +++ b/tools/perf/util/map_symbol.h @@ -9,7 +9,7 @@ struct map; struct symbol; struct map_symbol { - struct maps *mg; + struct maps *maps; struct map *map; struct symbol *sym; }; diff --git a/tools/perf/util/unwind-libdw.c b/tools/perf/util/unwind-libdw.c index bb4f515bdff9..7a3dbc259cec 100644 --- a/tools/perf/util/unwind-libdw.c +++ b/tools/perf/util/unwind-libdw.c @@ -81,7 +81,7 @@ static int entry(u64 ip, struct unwind_info *ui) return -1; e->ip = ip; - e->ms.mg = al.maps; + e->ms.maps = al.maps; e->ms.map = al.map; e->ms.sym = al.sym; diff --git a/tools/perf/util/unwind-libunwind-local.c b/tools/perf/util/unwind-libunwind-local.c index a744dfaefef5..515131e85e9c 100644 --- a/tools/perf/util/unwind-libunwind-local.c +++ b/tools/perf/util/unwind-libunwind-local.c @@ -578,7 +578,7 @@ static int entry(u64 ip, struct thread *thread, e.ms.sym = thread__find_symbol(thread, PERF_RECORD_MISC_USER, ip, &al); e.ip = ip; e.ms.map = al.map; - e.ms.mg = al.maps; + e.ms.maps = al.maps; pr_debug("unwind: %s:ip = 0x%" PRIx64 " (0x%" PRIx64 ")\n", al.sym ? al.sym->name : "''", -- cgit v1.2.3