All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@redhat.com>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>, lkml <linux-kernel@vger.kernel.org>,
	Ingo Molnar <mingo@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	David Ahern <dsahern@gmail.com>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Andi Kleen <andi@firstfloor.org>
Subject: [PATCHv2 29/35] perf annotate browser: Change selection to struct annotation_line
Date: Mon, 6 Nov 2017 11:56:17 +0100	[thread overview]
Message-ID: <20171106105617.GC20858@krava> (raw)
In-Reply-To: <20171011150158.11895-30-jolsa@kernel.org>

On Wed, Oct 11, 2017 at 05:01:52PM +0200, Jiri Olsa wrote:
> Use struct annotation_line as a browser::selection.
> 

v2 with updated changelog attached

jirka


---
Use struct annotation_line as a browser::selection.

We want to be able to use the annotate_browser for all sorts
of source data, so it needs to be able to work over the generic
struct annotation_line.

Link: http://lkml.kernel.org/n/tip-hq5alvt759wne4pd1doj2ix7@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 tools/perf/ui/browsers/annotate.c | 63 +++++++++++++++++++++------------------
 1 file changed, 34 insertions(+), 29 deletions(-)

diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c
index f6259d06ee61..17e8759e0ce2 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -46,26 +46,26 @@ static struct annotate_browser_opt {
 struct arch;
 
 struct annotate_browser {
-	struct ui_browser b;
-	struct rb_root	  entries;
-	struct rb_node	  *curr_hot;
-	struct disasm_line  *selection;
-	struct disasm_line  **offsets;
-	struct arch	    *arch;
-	int		    nr_events;
-	u64		    start;
-	int		    nr_asm_entries;
-	int		    nr_entries;
-	int		    max_jump_sources;
-	int		    nr_jumps;
-	bool		    searching_backwards;
-	bool		    have_cycles;
-	u8		    addr_width;
-	u8		    jumps_width;
-	u8		    target_width;
-	u8		    min_addr_width;
-	u8		    max_addr_width;
-	char		    search_bf[128];
+	struct ui_browser	    b;
+	struct rb_root		    entries;
+	struct rb_node		   *curr_hot;
+	struct annotation_line	   *selection;
+	struct disasm_line	  **offsets;
+	struct arch		   *arch;
+	int			    nr_events;
+	u64			    start;
+	int			    nr_asm_entries;
+	int			    nr_entries;
+	int			    max_jump_sources;
+	int			    nr_jumps;
+	bool			    searching_backwards;
+	bool			    have_cycles;
+	u8			    addr_width;
+	u8			    jumps_width;
+	u8			    target_width;
+	u8			    min_addr_width;
+	u8			    max_addr_width;
+	char			    search_bf[128];
 };
 
 static inline struct browser_line *browser_line(struct disasm_line *dl)
@@ -264,7 +264,7 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int
 	}
 
 	if (current_entry)
-		ab->selection = dl;
+		ab->selection = &dl->al;
 }
 
 static bool disasm_line__is_valid_jump(struct disasm_line *dl, struct symbol *sym)
@@ -300,7 +300,8 @@ static bool is_fused(struct annotate_browser *ab, struct disasm_line *cursor)
 static void annotate_browser__draw_current_jump(struct ui_browser *browser)
 {
 	struct annotate_browser *ab = container_of(browser, struct annotate_browser, b);
-	struct disasm_line *cursor = ab->selection, *target;
+	struct disasm_line *cursor = disasm_line(ab->selection);
+	struct disasm_line *target;
 	struct browser_line *btarget, *bcursor;
 	unsigned int from, to;
 	struct map_symbol *ms = ab->b.priv;
@@ -522,7 +523,7 @@ static bool annotate_browser__callq(struct annotate_browser *browser,
 				    struct hist_browser_timer *hbt)
 {
 	struct map_symbol *ms = browser->b.priv;
-	struct disasm_line *dl = browser->selection;
+	struct disasm_line *dl = disasm_line(browser->selection);
 	struct annotation *notes;
 	struct addr_map_symbol target = {
 		.map = ms->map,
@@ -580,7 +581,7 @@ struct disasm_line *annotate_browser__find_offset(struct annotate_browser *brows
 
 static bool annotate_browser__jump(struct annotate_browser *browser)
 {
-	struct disasm_line *dl = browser->selection;
+	struct disasm_line *dl = disasm_line(browser->selection);
 	u64 offset;
 	s64 idx;
 
@@ -606,7 +607,7 @@ struct disasm_line *annotate_browser__find_string(struct annotate_browser *brows
 	struct map_symbol *ms = browser->b.priv;
 	struct symbol *sym = ms->sym;
 	struct annotation *notes = symbol__annotation(sym);
-	struct disasm_line *pos = browser->selection;
+	struct disasm_line *pos = disasm_line(browser->selection);
 
 	*idx = browser->b.index;
 	list_for_each_entry_continue(pos, &notes->src->source, al.node) {
@@ -645,7 +646,7 @@ struct disasm_line *annotate_browser__find_string_reverse(struct annotate_browse
 	struct map_symbol *ms = browser->b.priv;
 	struct symbol *sym = ms->sym;
 	struct annotation *notes = symbol__annotation(sym);
-	struct disasm_line *pos = browser->selection;
+	struct disasm_line *pos = disasm_line(browser->selection);
 
 	*idx = browser->b.index;
 	list_for_each_entry_continue_reverse(pos, &notes->src->source, al.node) {
@@ -878,13 +879,16 @@ static int annotate_browser__run(struct annotate_browser *browser,
 			continue;
 		case K_ENTER:
 		case K_RIGHT:
+		{
+			struct disasm_line *dl = disasm_line(browser->selection);
+
 			if (browser->selection == NULL)
 				ui_helpline__puts("Huh? No selection. Report to linux-kernel@vger.kernel.org");
-			else if (browser->selection->al.offset == -1)
+			else if (browser->selection->offset == -1)
 				ui_helpline__puts("Actions are only available for assembly lines.");
-			else if (!browser->selection->ins.ops)
+			else if (!dl->ins.ops)
 				goto show_sup_ins;
-			else if (ins__is_ret(&browser->selection->ins))
+			else if (ins__is_ret(&dl->ins))
 				goto out;
 			else if (!(annotate_browser__jump(browser) ||
 				     annotate_browser__callq(browser, evsel, hbt))) {
@@ -892,6 +896,7 @@ static int annotate_browser__run(struct annotate_browser *browser,
 				ui_helpline__puts("Actions are only available for function call/return & jump/branch instructions.");
 			}
 			continue;
+		}
 		case 't':
 			if (annotate_browser__opts.show_total_period) {
 				annotate_browser__opts.show_total_period = false;
-- 
2.13.6

  reply	other threads:[~2017-11-06 10:56 UTC|newest]

Thread overview: 94+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-11 15:01 [PATCH 00/35] perf annotate: Use generic annotation line Jiri Olsa
2017-10-11 15:01 ` [PATCH 01/35] perf annotate: Remove arch::cpuid_parse callback Jiri Olsa
2017-10-24 10:14   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 02/35] perf annotate: Add annotation_line struct Jiri Olsa
2017-10-11 15:29   ` Arnaldo Carvalho de Melo
2017-10-11 19:12     ` Jiri Olsa
2017-11-18  8:10   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 03/35] perf annotate: Move line/offset into " Jiri Olsa
2017-11-18  8:11   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 04/35] perf annotate: Move ipc/cycles " Jiri Olsa
2017-11-18  8:11   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 05/35] perf annotate: Add symbol__annotate function Jiri Olsa
2017-11-18  8:12   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 06/35] perf annotate: Add struct annotate_args Jiri Olsa
2017-11-18  8:12   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 07/35] perf annotate: Add arch into " Jiri Olsa
2017-11-18  8:13   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 08/35] perf annotate: Add map " Jiri Olsa
2017-11-18  8:13   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 09/35] perf annotate: Add offset/line/line_nr " Jiri Olsa
2017-11-18  8:13   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 10/35] perf annotate: Add evsel into struct annotation_line_args Jiri Olsa
2017-11-18  8:14   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 11/35] perf annotate: Add annotation_line__next function Jiri Olsa
2017-11-18  8:14   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 12/35] perf annotate: Add annotation_line__add function Jiri Olsa
2017-11-18  8:15   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 13/35] perf annotate: Move rb_node into struct annotation_line Jiri Olsa
2017-11-18  8:15   ` [tip:perf/core] perf annotate: Move rb_node to " tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 14/35] perf annotate: Add annotation_line__(new|free) functions Jiri Olsa
2017-11-18  8:15   ` [tip:perf/core] perf annotate: Add annotation_line__(new|delete) functions tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 15/35] perf annotate: Add annotated_source__purge function Jiri Olsa
2017-11-18  8:16   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 16/35] perf annotate: Add samples into struct annotation_line Jiri Olsa
2017-11-13 15:46   ` Ravi Bangoria
2017-11-13 20:14     ` Jiri Olsa
2017-11-14  9:31       ` Jiri Olsa
2017-11-14 10:15         ` Ravi Bangoria
2017-11-14 10:29           ` Jiri Olsa
2017-11-15 14:04             ` Jiri Olsa
2017-11-16  4:27               ` Ravi Bangoria
2017-11-18  8:16   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 17/35] perf annotate: Add symbol__calc_percent function Jiri Olsa
2017-11-18  8:17   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 18/35] perf annotate: Add symbol__calc_lines function Jiri Olsa
2017-11-18  8:17   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 19/35] perf annotate: Remove disasm__calc_percent from disasm_line__print Jiri Olsa
2017-11-18  8:17   ` [tip:perf/core] perf annotate: Remove disasm__calc_percent() from disasm_line__print() tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 20/35] perf annotate: Remove disasm__calc_percent from annotate_browser__calc_percent Jiri Olsa
2017-11-18  8:18   ` [tip:perf/core] perf annotate: Remove disasm__calc_percent() from annotate_browser__calc_percent() tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 21/35] perf annotate: Remove disasm__calc_percent function Jiri Olsa
2017-11-18  8:18   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 22/35] perf annotate: Remove struct source_line Jiri Olsa
2017-11-18  8:19   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 23/35] perf annotate: Add annotation_line__print function Jiri Olsa
2017-11-18  8:19   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 24/35] perf annotate: Factor annotation_line__print from disasm_line__print Jiri Olsa
2017-11-18  8:19   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 25/35] perf annotate browser: Use samples data from struct annotation_line Jiri Olsa
2017-11-18  8:20   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 26/35] perf annotate browser: Do not pass nr_events in disasm_rb_tree__insert Jiri Olsa
2017-11-18  8:20   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 27/35] perf annotate browser: Rename struct browser_disasm_line to browser_line Jiri Olsa
2017-11-06 10:55   ` [PATCHv2 " Jiri Olsa
2017-11-18  8:21     ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 28/35] perf annotate browser: Rename disasm_line__browser " Jiri Olsa
2017-11-06 10:55   ` [PATCHv2 " Jiri Olsa
2017-11-18  8:21     ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 29/35] perf annotate browser: Change selection to struct annotation_line Jiri Olsa
2017-11-06 10:56   ` Jiri Olsa [this message]
2017-11-18  8:21     ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 30/35] perf annotate browser: Change offsets " Jiri Olsa
2017-11-18  8:22   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 31/35] perf annotate browser: Use struct annotation_line in browser_line Jiri Olsa
2017-11-18  8:22   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 32/35] perf annotate browser: Use struct annotation_line in find functions Jiri Olsa
2017-11-18  8:23   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 33/35] perf annotate browser: Use struct annotation_line in browser top Jiri Olsa
2017-11-18  8:23   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 34/35] perf annotate browser: Add disasm_line__write function Jiri Olsa
2017-11-18  8:23   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-10-11 15:01 ` [PATCH 35/35] perf annotate: Align source and offset lines Jiri Olsa
2017-11-07 14:10   ` Arnaldo Carvalho de Melo
2017-11-07 14:50     ` Jiri Olsa
2017-11-18  8:24   ` [tip:perf/core] " tip-bot for Jiri Olsa
2017-10-11 15:27 ` [PATCH 00/35] perf annotate: Use generic annotation line Arnaldo Carvalho de Melo
2017-10-11 19:10   ` Jiri Olsa
2017-10-11 19:18     ` Arnaldo Carvalho de Melo
2017-10-11 19:30       ` Jiri Olsa
2017-10-11 19:43         ` Arnaldo Carvalho de Melo
2017-11-02 12:16 ` Jiri Olsa
2017-11-03 16:59   ` Arnaldo Carvalho de Melo
2017-11-04 10:29     ` Jiri Olsa
2017-11-06 10:56       ` Jiri Olsa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171106105617.GC20858@krava \
    --to=jolsa@redhat.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@kernel.org \
    --cc=andi@firstfloor.org \
    --cc=dsahern@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.