]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
perf annotate: Make sure to call symbol__annotate2() in TUI
authorNamhyung Kim <namhyung@kernel.org>
Fri, 5 Apr 2024 21:17:57 +0000 (14:17 -0700)
committerNamhyung Kim <namhyung@kernel.org>
Thu, 11 Apr 2024 17:14:58 +0000 (10:14 -0700)
The symbol__annotate2() initializes some data structures needed by TUI.
It has a logic to prevent calling it multiple times by checking if it
has the annotated source.  But data type profiling uses a different
code (symbol__annotate) to allocate the annotated lines in advance.
So TUI missed to call symbol__annotate2() when it shows the annotation
browser.

Make symbol__annotate() reentrant and handle that situation properly.
This fixes a crash in the annotation browser started by perf report in
TUI like below.

  $ perf report -s type,sym --tui
  # and press 'a' key and then move down

Fixes: 81e57deec325 ("perf report: Support data type profiling")
Reviewed-by: Ian Rogers <irogers@google.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20240405211800.1412920-2-namhyung@kernel.org
tools/perf/ui/browsers/annotate.c
tools/perf/util/annotate.c

index ec5e21932876038b99afbfa30560d856efd8afd5..4790c735599bdd97b62a39edd861230464abc5d8 100644 (file)
@@ -970,7 +970,7 @@ int symbol__tui_annotate(struct map_symbol *ms, struct evsel *evsel,
        if (dso->annotate_warned)
                return -1;
 
-       if (not_annotated) {
+       if (not_annotated || !sym->annotate2) {
                err = symbol__annotate2(ms, evsel, &browser.arch);
                if (err) {
                        char msg[BUFSIZ];
index ac002d907d81801c941876731e29acfc8dcf97b3..50ca92255ff62a61e2923179c1e7f4fb7e98ded5 100644 (file)
@@ -2461,6 +2461,9 @@ int symbol__annotate(struct map_symbol *ms, struct evsel *evsel,
        if (parch)
                *parch = arch;
 
+       if (!list_empty(&notes->src->source))
+               return 0;
+
        args.arch = arch;
        args.ms = *ms;
        if (annotate_opts.full_addr)