]> git.baikalelectronics.ru Git - kernel.git/commit
perf annotate: Fix printing of unaugmented disassembled instructions from BPF
authorArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 6 Aug 2019 14:24:09 +0000 (11:24 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 8 Aug 2019 18:40:56 +0000 (15:40 -0300)
commitf725f4cafc858f0e4d70b9897945094f5a95dfd2
treeff5f25a51577a5ea2a321ec800819606854a9e1e
parentc163a25a419f8ff34dfdda6e206746edc3034946
perf annotate: Fix printing of unaugmented disassembled instructions from BPF

The code to disassemble BPF programs uses binutil's disassembling
routines, and those use in turn fprintf to print to a memstream FILE,
adding a newline at the end of each line, which ends up confusing the
TUI routines called from:

  annotate_browser__write()
    annotate_line__write()
      annotate_browser__printf()
        ui_browser__vprintf()
          SLsmg_vprintf()

The SLsmg_vprintf() function in the slang library gets confused with the
terminating newline, so make the disasm_line__parse() function that
parses the lines produced by the BPF specific disassembler (that uses
binutil's libopcodes) and the lines produced by the objdump based
disassembler used for everything else (and that doesn't adds this
terminating newline) trim the end of the line in addition of the
beginning.

This way when disasm_line->ops.raw, i.e. for instructions without a
special scnprintf() method, we'll not have that \n getting in the way of
filling the screen right after the instruction with spaces to avoid
leaving what was on the screen before and thus garbling the annotation
screen, breaking scrolling, etc.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Song Liu <songliubraving@fb.com>
Fixes: 9c620d82b367 ("perf annotate: Enable annotation of BPF programs")
Link: https://lkml.kernel.org/n/tip-unbr5a5efakobfr6rhxq99ta@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/annotate.c