Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1432191

Re: [RFC 4/6] perf annotate: generalize handling of ret instructions

From Arnaldo Carvalho de Melo <acme@kernel.org>
Newsgroups linux.kernel
Subject Re: [RFC 4/6] perf annotate: generalize handling of ret instructions
Date 2016-06-27 19:40 +0200
Message-ID <rOIFP-3km-17@gated-at.bofh.it> (permalink)
References <rNxWa-7AL-11@gated-at.bofh.it> <rNxWa-7AL-9@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Em Fri, Jun 24, 2016 at 05:23:58PM +0530, Ravi Bangoria escreveu:
> From: "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com>
> 
> Introduce helper to detect ret instructions and use the same in the tui.
> A helper is needed since some architectures such as powerpc have more
> than one return instruction.

Thanks, applied.
 
> Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
> ---
>  tools/perf/ui/browsers/annotate.c | 20 +++++++++-----------
>  tools/perf/util/annotate.c        | 10 ++++++++++
>  tools/perf/util/annotate.h        |  1 +
>  3 files changed, 20 insertions(+), 11 deletions(-)
> 
> diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c
> index b65a979..288200f 100644
> --- a/tools/perf/ui/browsers/annotate.c
> +++ b/tools/perf/ui/browsers/annotate.c
> @@ -223,16 +223,14 @@ static void annotate_browser__write(struct ui_browser *browser, void *entry, int
>  			} else if (ins__is_call(dl->ins)) {
>  				ui_browser__write_graph(browser, SLSMG_RARROW_CHAR);
>  				SLsmg_write_char(' ');
> +			} else if (ins__is_ret(dl->ins)) {
> +				ui_browser__write_graph(browser, SLSMG_LARROW_CHAR);
> +				SLsmg_write_char(' ');
>  			} else {
>  				ui_browser__write_nstring(browser, " ", 2);
>  			}
>  		} else {
> -			if (strcmp(dl->name, "retq")) {
> -				ui_browser__write_nstring(browser, " ", 2);
> -			} else {
> -				ui_browser__write_graph(browser, SLSMG_LARROW_CHAR);
> -				SLsmg_write_char(' ');
> -			}
> +			ui_browser__write_nstring(browser, " ", 2);
>  		}
>  
>  		disasm_line__scnprintf(dl, bf, sizeof(bf), !annotate_browser__opts.use_offset);
> @@ -843,14 +841,14 @@ show_help:
>  				ui_helpline__puts("Huh? No selection. Report to linux-kernel@vger.kernel.org");
>  			else if (browser->selection->offset == -1)
>  				ui_helpline__puts("Actions are only available for assembly lines.");
> -			else if (!browser->selection->ins) {
> -				if (strcmp(browser->selection->name, "retq"))
> -					goto show_sup_ins;
> +			else if (!browser->selection->ins)
> +				goto show_sup_ins;
> +			else if (ins__is_ret(browser->selection->ins))
>  				goto out;
> -			} else if (!(annotate_browser__jump(browser) ||
> +			else if (!(annotate_browser__jump(browser) ||
>  				     annotate_browser__callq(browser, evsel, hbt))) {
>  show_sup_ins:
> -				ui_helpline__puts("Actions are only available for 'callq', 'retq' & jump instructions.");
> +				ui_helpline__puts("Actions are only available for function call/return & jump/branch instructions.");
>  			}
>  			continue;
>  		case 't':
> diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
> index e0dc7b2..634daf5 100644
> --- a/tools/perf/util/annotate.c
> +++ b/tools/perf/util/annotate.c
> @@ -363,6 +363,15 @@ static struct ins_ops nop_ops = {
>  	.scnprintf = nop__scnprintf,
>  };
>  
> +static struct ins_ops ret_ops = {
> +	.scnprintf = ins__raw_scnprintf,
> +};
> +
> +bool ins__is_ret(const struct ins *ins)
> +{
> +	return ins->ops == &ret_ops;
> +}
> +
>  static struct ins instructions_x86[] = {
>  	{ .name = "add",   .ops  = &mov_ops, },
>  	{ .name = "addl",  .ops  = &mov_ops, },
> @@ -439,6 +448,7 @@ static struct ins instructions_x86[] = {
>  	{ .name = "xadd",  .ops  = &mov_ops, },
>  	{ .name = "xbeginl", .ops  = &jump_ops, },
>  	{ .name = "xbeginq", .ops  = &jump_ops, },
> +	{ .name = "retq",  .ops  = &ret_ops, },
>  };
>  
>  static struct ins instructions_arm[] = {
> diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h
> index f7b669e..488c427 100644
> --- a/tools/perf/util/annotate.h
> +++ b/tools/perf/util/annotate.h
> @@ -48,6 +48,7 @@ struct ins {
>  
>  bool ins__is_jump(const struct ins *ins);
>  bool ins__is_call(const struct ins *ins);
> +bool ins__is_ret(const struct ins *ins);
>  int ins__scnprintf(struct ins *ins, char *bf, size_t size, struct ins_operands *ops);
>  
>  struct annotation;
> -- 
> 2.5.5

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[RFC 0/6] perf annotate: Enable cross arch annotate Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com> - 2016-06-24 14:00 +0200
  [RFC 4/6] perf annotate: generalize handling of ret instructions Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com> - 2016-06-24 14:00 +0200
    Re: [RFC 4/6] perf annotate: generalize handling of ret instructions Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-06-27 19:40 +0200
    [tip:perf/core] perf annotate: Generalize handling of 'ret'  instructions "tip-bot for Naveen N. Rao" <tipbot@zytor.com> - 2016-06-29 11:50 +0200
  [RFC 5/6] perf annotate: add powerpc support Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com> - 2016-06-24 14:00 +0200
  [RFC 2/6] perf annotate: Define macro for arch names Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com> - 2016-06-24 14:00 +0200
  [RFC 1/6] perf: Remove unused hist_entry__annotate function Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com> - 2016-06-24 14:00 +0200
    Re: [RFC 1/6] perf: Remove unused hist_entry__annotate function Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-06-27 19:40 +0200
    [tip:perf/core] perf annotate: Remove unused hist_entry__annotate  function tip-bot for Ravi Bangoria <tipbot@zytor.com> - 2016-06-29 11:50 +0200
  [RFC 3/6] perf annotate: Enable cross arch annotate Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com> - 2016-06-24 14:00 +0200
    Re: [RFC 3/6] perf annotate: Enable cross arch annotate Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-06-27 19:20 +0200
      Re: [RFC 3/6] perf annotate: Enable cross arch annotate Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com> - 2016-06-28 13:50 +0200

csiph-web