perf map: Add accessor for dso
Later changes will add reference count checking for struct map, with dso being the most frequently accessed variable. Add an accessor so that the reference count check is only necessary in one place. Additional changes: - add a dso variable to avoid repeated map__dso calls. - in builtin-mem.c dump_raw_samples, code only partially tested for dso == NULL. Make the possibility of NULL consistent. - in thread.c thread__memcpy fix use of spaces and use tabs. Committer notes: Did missing conversions on these files: tools/perf/arch/powerpc/util/skip-callchain-idx.c tools/perf/arch/powerpc/util/sym-handling.c tools/perf/ui/browsers/hists.c tools/perf/ui/gtk/annotate.c tools/perf/util/cs-etm.c tools/perf/util/thread.c tools/perf/util/unwind-libunwind-local.c tools/perf/util/unwind-libunwind.c Signed-off-by: Ian Rogers <irogers@google.com> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Alexey Bayduraev <alexey.v.bayduraev@linux.intel.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Cc: Darren Hart <dvhart@infradead.org> Cc: Davidlohr Bueso <dave@stgolabs.net> Cc: Dmitriy Vyukov <dvyukov@google.com> Cc: Eric Dumazet <edumazet@google.com> Cc: German Gomez <german.gomez@arm.com> Cc: Hao Luo <haoluo@google.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: James Clark <james.clark@arm.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: John Garry <john.g.garry@oracle.com> Cc: Kajol Jain <kjain@linux.ibm.com> Cc: Kan Liang <kan.liang@linux.intel.com> Cc: Leo Yan <leo.yan@linaro.org> Cc: Madhavan Srinivasan <maddy@linux.ibm.com> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: Miaoqian Lin <linmq006@gmail.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Riccardo Mancini <rickyman7@gmail.com> Cc: Shunsuke Nakamura <nakamura.shun@fujitsu.com> Cc: Song Liu <song@kernel.org> Cc: Stephane Eranian <eranian@google.com> Cc: Stephen Brennan <stephen.s.brennan@oracle.com> Cc: Steven Rostedt (VMware) <rostedt@goodmis.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Thomas Richter <tmricht@linux.ibm.com> Cc: Yury Norov <yury.norov@gmail.com> Link: https://lore.kernel.org/r/20230320212248.1175731-2-irogers@google.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
committed by
Arnaldo Carvalho de Melo
parent
5ab6d715c3
commit
63df0e4bc3
@@ -441,7 +441,8 @@ static void ui_browser__init_asm_mode(struct ui_browser *browser)
|
||||
static int sym_title(struct symbol *sym, struct map *map, char *title,
|
||||
size_t sz, int percent_type)
|
||||
{
|
||||
return snprintf(title, sz, "%s %s [Percent: %s]", sym->name, map->dso->long_name,
|
||||
return snprintf(title, sz, "%s %s [Percent: %s]", sym->name,
|
||||
map__dso(map)->long_name,
|
||||
percent_type_str(percent_type));
|
||||
}
|
||||
|
||||
@@ -964,20 +965,22 @@ int symbol__tui_annotate(struct map_symbol *ms, struct evsel *evsel,
|
||||
},
|
||||
.opts = opts,
|
||||
};
|
||||
struct dso *dso;
|
||||
int ret = -1, err;
|
||||
int not_annotated = list_empty(¬es->src->source);
|
||||
|
||||
if (sym == NULL)
|
||||
return -1;
|
||||
|
||||
if (ms->map->dso->annotate_warned)
|
||||
dso = map__dso(ms->map);
|
||||
if (dso->annotate_warned)
|
||||
return -1;
|
||||
|
||||
if (not_annotated) {
|
||||
err = symbol__annotate2(ms, evsel, opts, &browser.arch);
|
||||
if (err) {
|
||||
char msg[BUFSIZ];
|
||||
ms->map->dso->annotate_warned = true;
|
||||
dso->annotate_warned = true;
|
||||
symbol__strerror_disassemble(ms, err, msg, sizeof(msg));
|
||||
ui__error("Couldn't annotate %s:\n%s", sym->name, msg);
|
||||
goto out_free_offsets;
|
||||
|
||||
@@ -2487,7 +2487,7 @@ static struct symbol *symbol__new_unresolved(u64 addr, struct map *map)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
dso__insert_symbol(map->dso, sym);
|
||||
dso__insert_symbol(map__dso(map), sym);
|
||||
}
|
||||
|
||||
return sym;
|
||||
@@ -2499,7 +2499,9 @@ add_annotate_opt(struct hist_browser *browser __maybe_unused,
|
||||
struct map_symbol *ms,
|
||||
u64 addr)
|
||||
{
|
||||
if (!ms->map || !ms->map->dso || ms->map->dso->annotate_warned)
|
||||
struct dso *dso = map__dso(ms->map);
|
||||
|
||||
if (!ms->map || !dso || dso->annotate_warned)
|
||||
return 0;
|
||||
|
||||
if (!ms->sym)
|
||||
@@ -2589,9 +2591,10 @@ static int hists_browser__zoom_map(struct hist_browser *browser, struct map *map
|
||||
browser->hists->dso_filter = NULL;
|
||||
ui_helpline__pop();
|
||||
} else {
|
||||
struct dso *dso = map__dso(map);
|
||||
ui_helpline__fpush("To zoom out press ESC or ENTER + \"Zoom out of %s DSO\"",
|
||||
__map__is_kernel(map) ? "the Kernel" : map->dso->short_name);
|
||||
browser->hists->dso_filter = map->dso;
|
||||
__map__is_kernel(map) ? "the Kernel" : dso->short_name);
|
||||
browser->hists->dso_filter = dso;
|
||||
perf_hpp__set_elide(HISTC_DSO, true);
|
||||
pstack__push(browser->pstack, &browser->hists->dso_filter);
|
||||
}
|
||||
@@ -2616,7 +2619,7 @@ add_dso_opt(struct hist_browser *browser, struct popup_action *act,
|
||||
|
||||
if (asprintf(optstr, "Zoom %s %s DSO (use the 'k' hotkey to zoom directly into the kernel)",
|
||||
browser->hists->dso_filter ? "out of" : "into",
|
||||
__map__is_kernel(map) ? "the Kernel" : map->dso->short_name) < 0)
|
||||
__map__is_kernel(map) ? "the Kernel" : map__dso(map)->short_name) < 0)
|
||||
return 0;
|
||||
|
||||
act->ms.map = map;
|
||||
@@ -3091,8 +3094,8 @@ do_hotkey: // key came straight from options ui__popup_menu()
|
||||
|
||||
if (!browser->selection ||
|
||||
!browser->selection->map ||
|
||||
!browser->selection->map->dso ||
|
||||
browser->selection->map->dso->annotate_warned) {
|
||||
!map__dso(browser->selection->map) ||
|
||||
map__dso(browser->selection->map)->annotate_warned) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ static int map_browser__run(struct map_browser *browser)
|
||||
{
|
||||
int key;
|
||||
|
||||
if (ui_browser__show(&browser->b, browser->map->dso->long_name,
|
||||
if (ui_browser__show(&browser->b, map__dso(browser->map)->long_name,
|
||||
"Press ESC to exit, %s / to search",
|
||||
verbose > 0 ? "" : "restart with -v to use") < 0)
|
||||
return -1;
|
||||
@@ -106,7 +106,7 @@ int map__browse(struct map *map)
|
||||
{
|
||||
struct map_browser mb = {
|
||||
.b = {
|
||||
.entries = &map->dso->symbols,
|
||||
.entries = &map__dso(map)->symbols,
|
||||
.refresh = ui_browser__rb_tree_refresh,
|
||||
.seek = ui_browser__rb_tree_seek,
|
||||
.write = map_browser__write,
|
||||
|
||||
Reference in New Issue
Block a user