diff options
author | Ian Rogers <irogers@google.com> | 2025-01-17 10:18:48 -0800 |
---|---|---|
committer | Namhyung Kim <namhyung@kernel.org> | 2025-01-18 10:02:10 -0800 |
commit | 035f0c279bcfc07314240de273d90f4061aef04d (patch) | |
tree | 28ff6090c9d777f129609c70ab4c9b3ca018f6fc /tools/perf/ui/gtk/annotate.c | |
parent | ac22d75377a04ceca53a8d438440e82bf4c722fc (diff) |
perf annotate: Prefer passing evsel to evsel->core.idx
An evsel idx may not be stable due to sorting, evlist removal,
etc. Try to reduce it being part of APIs by explicitly passing the
evsel in annotate code. Internally the code just reads evsel->core.idx
so behavior is unchanged.
Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Chen Ni <nichen@iscas.ac.cn>
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Link: https://lore.kernel.org/r/20250117181848.690474-1-irogers@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Diffstat (limited to 'tools/perf/ui/gtk/annotate.c')
-rw-r--r-- | tools/perf/ui/gtk/annotate.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/tools/perf/ui/gtk/annotate.c b/tools/perf/ui/gtk/annotate.c index 6da24aa039eb..8920e298420a 100644 --- a/tools/perf/ui/gtk/annotate.c +++ b/tools/perf/ui/gtk/annotate.c @@ -3,6 +3,7 @@ #include "util/sort.h" #include "util/debug.h" #include "util/annotate.h" +#include "util/evlist.h" #include "util/evsel.h" #include "util/map.h" #include "util/dso.h" @@ -26,7 +27,7 @@ static const char *const col_names[] = { }; static int perf_gtk__get_percent(char *buf, size_t size, struct symbol *sym, - struct disasm_line *dl, int evidx) + struct disasm_line *dl, const struct evsel *evsel) { struct annotation *notes; struct sym_hist *symhist; @@ -42,8 +43,8 @@ static int perf_gtk__get_percent(char *buf, size_t size, struct symbol *sym, return 0; notes = symbol__annotation(sym); - symhist = annotation__histogram(notes, evidx); - entry = annotated_source__hist_entry(notes->src, evidx, dl->al.offset); + symhist = annotation__histogram(notes, evsel); + entry = annotated_source__hist_entry(notes->src, evsel, dl->al.offset); if (entry) nr_samples = entry->nr_samples; @@ -139,16 +140,17 @@ static int perf_gtk__annotate_symbol(GtkWidget *window, struct map_symbol *ms, gtk_list_store_append(store, &iter); if (evsel__is_group_event(evsel)) { - for (i = 0; i < evsel->core.nr_members; i++) { + struct evsel *cur_evsel; + + for_each_group_evsel(cur_evsel, evsel__leader(evsel)) { ret += perf_gtk__get_percent(s + ret, sizeof(s) - ret, sym, pos, - evsel->core.idx + i); + cur_evsel); ret += scnprintf(s + ret, sizeof(s) - ret, " "); } } else { - ret = perf_gtk__get_percent(s, sizeof(s), sym, pos, - evsel->core.idx); + ret = perf_gtk__get_percent(s, sizeof(s), sym, pos, evsel); } if (ret) |