Skip to content

Commit

Permalink
perf annotate: Make sure to call symbol__annotate2() in TUI
Browse files Browse the repository at this point in the history
[ Upstream commit 2b8dbf6 ]

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: 81e57de ("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
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
namhyung authored and gregkh committed Apr 27, 2024
1 parent 85235e2 commit 6450c4f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tools/perf/ui/browsers/annotate.c
Expand Up @@ -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];
Expand Down
3 changes: 3 additions & 0 deletions tools/perf/util/annotate.c
Expand Up @@ -2435,6 +2435,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)
Expand Down

0 comments on commit 6450c4f

Please sign in to comment.