]> www.infradead.org Git - users/hch/misc.git/commitdiff
perf annotate: Pass annotation_print_data to annotation_line__write()
authorNamhyung Kim <namhyung@kernel.org>
Sat, 16 Aug 2025 03:16:27 +0000 (20:16 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 28 Aug 2025 15:32:32 +0000 (12:32 -0300)
It will be used for data type display later.

Reviewed-by: Ian Rogers <irogers@google.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20250816031635.25318-5-namhyung@kernel.org
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: LKML <linux-kernel@vger.kernel.org>
Cc: linux-perf-users@vger.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/ui/browsers/annotate.c
tools/perf/util/annotate.c
tools/perf/util/annotate.h

index 4d5cbb86cbb6d50657b186b64a6188135225661f..3e8b111e3f12b030107edf287adb0a2bad181382 100644 (file)
@@ -33,6 +33,8 @@ struct annotate_browser {
         * its lifetime.
         */
        struct hist_entry          *he;
+       struct debuginfo           *dbg;
+       struct evsel               *evsel;
        bool                        searching_backwards;
        char                        search_bf[128];
 };
@@ -116,12 +118,18 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int
                .printf                  = annotate_browser__printf,
                .write_graph             = annotate_browser__write_graph,
        };
+       struct annotation_print_data apd = {
+               .he = ab->he,
+               .arch = ab->arch,
+               .evsel = ab->evsel,
+               .dbg = ab->dbg,
+       };
 
        /* The scroll bar isn't being used */
        if (!browser->navkeypressed)
                ops.width += 1;
 
-       annotation_line__write(al, notes, &ops);
+       annotation_line__write(al, notes, &ops, &apd);
 
        if (ops.current_entry)
                ab->selection = al;
@@ -984,7 +992,7 @@ show_sup_ins:
                        continue;
                }
                case 'P':
-                       map_symbol__annotation_dump(ms, evsel);
+                       map_symbol__annotation_dump(ms, evsel, browser->he);
                        continue;
                case 't':
                        if (symbol_conf.show_total_period) {
@@ -1069,6 +1077,7 @@ int __hist_entry__tui_annotate(struct hist_entry *he, struct map_symbol *ms,
                        .use_navkeypressed = true,
                },
                .he = he,
+               .evsel = evsel,
        };
        struct dso *dso;
        int ret = -1, err;
index 7929f108e35b4e65edbea53ba04500207360790d..2544d83a52a0a596d3a5911257aea1ff3cf50bbf 100644 (file)
@@ -765,14 +765,6 @@ __hist_entry__get_data_type(struct hist_entry *he, struct arch *arch,
                            struct debuginfo *dbg, struct disasm_line *dl,
                            int *type_offset);
 
-struct annotation_print_data {
-       struct hist_entry *he;
-       struct evsel *evsel;
-       struct arch *arch;
-       struct debuginfo *dbg;
-       int addr_fmt_width;
-};
-
 static int
 annotation_line__print(struct annotation_line *al, struct annotation_print_data *apd,
                       struct annotation_options *opts, int printed,
@@ -1355,7 +1347,8 @@ static void FILE__write_graph(void *fp, int graph)
        fputs(s, fp);
 }
 
-static int symbol__annotate_fprintf2(struct symbol *sym, FILE *fp)
+static int symbol__annotate_fprintf2(struct symbol *sym, FILE *fp,
+                                    struct annotation_print_data *apd)
 {
        struct annotation *notes = symbol__annotation(sym);
        struct annotation_write_ops wops = {
@@ -1372,7 +1365,7 @@ static int symbol__annotate_fprintf2(struct symbol *sym, FILE *fp)
        list_for_each_entry(al, &notes->src->source, node) {
                if (annotation_line__filter(al))
                        continue;
-               annotation_line__write(al, notes, &wops);
+               annotation_line__write(al, notes, &wops, apd);
                fputc('\n', fp);
                wops.first_line = false;
        }
@@ -1380,13 +1373,18 @@ static int symbol__annotate_fprintf2(struct symbol *sym, FILE *fp)
        return 0;
 }
 
-int map_symbol__annotation_dump(struct map_symbol *ms, struct evsel *evsel)
+int map_symbol__annotation_dump(struct map_symbol *ms, struct evsel *evsel,
+                               struct hist_entry *he)
 {
        const char *ev_name = evsel__name(evsel);
        char buf[1024];
        char *filename;
        int err = -1;
        FILE *fp;
+       struct annotation_print_data apd = {
+               .he = he,
+               .evsel = evsel,
+       };
 
        if (asprintf(&filename, "%s.annotation", ms->sym->name) < 0)
                return -1;
@@ -1402,7 +1400,7 @@ int map_symbol__annotation_dump(struct map_symbol *ms, struct evsel *evsel)
 
        fprintf(fp, "%s() %s\nEvent: %s\n\n",
                ms->sym->name, dso__long_name(map__dso(ms->map)), ev_name);
-       symbol__annotate_fprintf2(ms->sym, fp);
+       symbol__annotate_fprintf2(ms->sym, fp, &apd);
 
        fclose(fp);
        err = 0;
@@ -1654,6 +1652,10 @@ int hist_entry__tty_annotate2(struct hist_entry *he, struct evsel *evsel)
        struct symbol *sym = ms->sym;
        struct rb_root source_line = RB_ROOT;
        struct hists *hists = evsel__hists(evsel);
+       struct annotation_print_data apd = {
+               .he = he,
+               .evsel = evsel,
+       };
        char buf[1024];
        int err;
 
@@ -1676,7 +1678,7 @@ int hist_entry__tty_annotate2(struct hist_entry *he, struct evsel *evsel)
        hists__scnprintf_title(hists, buf, sizeof(buf));
        fprintf(stdout, "%s, [percent: %s]\n%s() %s\n",
                buf, percent_type_str(annotate_opts.percent_type), sym->name, dso__long_name(dso));
-       symbol__annotate_fprintf2(sym, stdout);
+       symbol__annotate_fprintf2(sym, stdout, &apd);
 
        annotated_source__purge(symbol__annotation(sym)->src);
 
@@ -1934,7 +1936,8 @@ err:
 }
 
 void annotation_line__write(struct annotation_line *al, struct annotation *notes,
-                           const struct annotation_write_ops *wops)
+                           const struct annotation_write_ops *wops,
+                           struct annotation_print_data *apd)
 {
        bool current_entry = wops->current_entry;
        bool change_color = wops->change_color;
@@ -2112,6 +2115,8 @@ print_addr:
                disasm_line__write(disasm_line(al), notes, obj, bf, sizeof(bf), obj__printf, obj__write_graph);
 
                obj__printf(obj, "%-*s", width - pcnt_width - cycles_width - 3 - printed, bf);
+
+               (void)apd;
        }
 
 }
index 2e28a24fa13a736af0bed494d63235a43f96cf14..86e858f5bf17315244be080fc5af0c8a41b88cb0 100644 (file)
@@ -199,8 +199,18 @@ struct annotation_write_ops {
        void (*write_graph)(void *obj, int graph);
 };
 
+struct annotation_print_data {
+       struct hist_entry *he;
+       struct evsel *evsel;
+       struct arch *arch;
+       struct debuginfo *dbg;
+       /* It'll be set in hist_entry__annotate_printf() */
+       int addr_fmt_width;
+};
+
 void annotation_line__write(struct annotation_line *al, struct annotation *notes,
-                           const struct annotation_write_ops *ops);
+                           const struct annotation_write_ops *ops,
+                           struct annotation_print_data *apd);
 
 int __annotation__scnprintf_samples_period(struct annotation *notes,
                                           char *bf, size_t size,
@@ -463,7 +473,8 @@ void symbol__annotate_zero_histogram(struct symbol *sym, struct evsel *evsel);
 void symbol__annotate_decay_histogram(struct symbol *sym, struct evsel *evsel);
 void annotated_source__purge(struct annotated_source *as);
 
-int map_symbol__annotation_dump(struct map_symbol *ms, struct evsel *evsel);
+int map_symbol__annotation_dump(struct map_symbol *ms, struct evsel *evsel,
+                               struct hist_entry *he);
 
 bool ui__has_annotation(void);