Commit e0560ba6 authored by Ravi Bangoria's avatar Ravi Bangoria Committed by Arnaldo Carvalho de Melo

perf annotate: Fix segfault with source toggle

While rendering annotate browser from perf report tui, we keep track
of total number of lines(asm + source) in annotation->nr_entries and
total number of asm lines in annotation->nr_asm_entries. But we don't
reset them before starting. Thus if user annotates same function
multiple times, we restart incrementing these fields with old values.

This causes a segfault when user tries to toggle source code after
annotating same function multiple times. Fix it.
Signed-off-by: default avatarRavi Bangoria <ravi.bangoria@linux.ibm.com>
Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jin Yao <yao.jin@linux.intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Song Liu <songliubraving@fb.com>
Link: http://lore.kernel.org/lkml/20200204045233.474937-5-ravi.bangoria@linux.ibm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent d3c03147
...@@ -2621,6 +2621,8 @@ void annotation__set_offsets(struct annotation *notes, s64 size) ...@@ -2621,6 +2621,8 @@ void annotation__set_offsets(struct annotation *notes, s64 size)
struct annotation_line *al; struct annotation_line *al;
notes->max_line_len = 0; notes->max_line_len = 0;
notes->nr_entries = 0;
notes->nr_asm_entries = 0;
list_for_each_entry(al, &notes->src->source, node) { list_for_each_entry(al, &notes->src->source, node) {
size_t line_len = strlen(al->line); size_t line_len = strlen(al->line);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment