diff options
| author | Ian Rogers <[email protected]> | 2025-01-17 18:18:48 +0000 |
|---|---|---|
| committer | Namhyung Kim <[email protected]> | 2025-01-18 18:02:10 +0000 |
| commit | 035f0c279bcfc07314240de273d90f4061aef04d (patch) | |
| tree | 28ff6090c9d777f129609c70ab4c9b3ca018f6fc /tools/perf/ui/gtk/annotate.c | |
| parent | perf lock: Rename fields in lock_type_table (diff) | |
| download | kernel-035f0c279bcfc07314240de273d90f4061aef04d.tar.gz kernel-035f0c279bcfc07314240de273d90f4061aef04d.zip | |
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 <[email protected]>
Cc: Chen Ni <[email protected]>
Cc: Athira Rajeev <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Namhyung Kim <[email protected]>
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) |
