perf annotate: Fix segfault with source toggle
authorRavi Bangoria <ravi.bangoria@linux.ibm.com>
Tue, 4 Feb 2020 04:52:31 +0000 (10:22 +0530)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 27 Feb 2020 14:47:23 +0000 (11:47 -0300)
commite0560ba6d92f06dbe13e9d11c921a60c07ea6fcc
treed3c1ef8704af24adc907f22e8d57c14c251ecb09
parentd3c03147bf8019bda821334428e0ba31ce4fb425
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: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Acked-by: Jiri 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.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/annotate.c