[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210621230047.211430-1-rickyman7@gmail.com>
Date: Tue, 22 Jun 2021 01:00:47 +0200
From: Riccardo Mancini <rickyman7@...il.com>
To: Arnaldo Carvalho de Melo <acme@...nel.org>
Cc: Namhyung Kim <namhyung@...nel.org>,
Ian Rogers <irogers@...gle.com>,
Riccardo Mancini <rickyman7@...il.com>,
Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Jiri Olsa <jolsa@...hat.com>, Martin Liska <mliska@...e.cz>,
Jason Yan <yanaijie@...wei.com>,
linux-perf-users@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH] perf annotate: allow 's' on source code lines
In perf annotate, when 's' is pressed on a line containing
source code, it shows the message "Only available for assembly
lines".
This patch gets rid of the error, moving the cursr to the next
available asm line (or the closest previous one if no asm line
is found moving forwards), before hiding source code lines.
Signed-off-by: Riccardo Mancini <rickyman7@...il.com>
---
tools/perf/ui/browsers/annotate.c | 28 +++++++++++++++++++++++++---
1 file changed, 25 insertions(+), 3 deletions(-)
diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c
index ad0a70f0edaf..eb94d20d0d13 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -343,6 +343,29 @@ static void annotate_browser__calc_percent(struct annotate_browser *browser,
browser->curr_hot = rb_last(&browser->entries);
}
+static struct annotation_line *annotate_browser__find_next_asm_line(
+ struct annotate_browser *browser,
+ struct annotation_line *al)
+{
+ struct annotation_line *it = al;
+
+ /* find next asm line */
+ list_for_each_entry_continue(it, browser->b.top, node) {
+ if (it->idx_asm >= 0)
+ return it;
+ }
+
+ /* no asm line found forwards, try backwards */
+ it = al;
+ list_for_each_entry_continue_reverse(it, browser->b.top, node) {
+ if (it->idx_asm >= 0)
+ return it;
+ }
+
+ /* There are no asm lines */
+ return al;
+}
+
static bool annotate_browser__toggle_source(struct annotate_browser *browser)
{
struct annotation *notes = browser__annotation(&browser->b);
@@ -363,9 +386,8 @@ static bool annotate_browser__toggle_source(struct annotate_browser *browser)
browser->b.index = al->idx;
} else {
if (al->idx_asm < 0) {
- ui_helpline__puts("Only available for assembly lines.");
- browser->b.seek(&browser->b, -offset, SEEK_CUR);
- return false;
+ /* move cursor to next asm line */
+ al = annotate_browser__find_next_asm_line(browser, al);
}
if (al->idx_asm < offset)
--
2.31.1
Powered by blists - more mailing lists