Skip to content

Commit 2b8dbf6

Browse files
committed
perf annotate: Make sure to call symbol__annotate2() in TUI
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 <[email protected]> Signed-off-by: Namhyung Kim <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent fec50db commit 2b8dbf6

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

tools/perf/ui/browsers/annotate.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -970,7 +970,7 @@ int symbol__tui_annotate(struct map_symbol *ms, struct evsel *evsel,
970970
if (dso->annotate_warned)
971971
return -1;
972972

973-
if (not_annotated) {
973+
if (not_annotated || !sym->annotate2) {
974974
err = symbol__annotate2(ms, evsel, &browser.arch);
975975
if (err) {
976976
char msg[BUFSIZ];

tools/perf/util/annotate.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2461,6 +2461,9 @@ int symbol__annotate(struct map_symbol *ms, struct evsel *evsel,
24612461
if (parch)
24622462
*parch = arch;
24632463

2464+
if (!list_empty(&notes->src->source))
2465+
return 0;
2466+
24642467
args.arch = arch;
24652468
args.ms = *ms;
24662469
if (annotate_opts.full_addr)

0 commit comments

Comments
 (0)