Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1433087
| From | David Laight <David.Laight@ACULAB.COM> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | RE: [PATCH 3/4] perf annotate: add powerpc support |
| Date | 2016-06-28 18:10 +0200 |
| Message-ID | <rP3Kh-Rj-11@gated-at.bofh.it> (permalink) |
| References | <rOZwZ-6qc-3@gated-at.bofh.it> <rOZwZ-6qc-15@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
From: Ravi Bangoria
> Sent: 28 June 2016 12:37
>
> Powerpc has long list of branch instructions and hardcoding them in table
> appears to be error-prone. So, add new function to find instruction
> instead of creating table.
>
> Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
> Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
> ---
> tools/perf/util/annotate.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 64 insertions(+)
>
> diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
> index 36a5825..96c6610 100644
> --- a/tools/perf/util/annotate.c
> +++ b/tools/perf/util/annotate.c
> @@ -476,6 +476,68 @@ static int ins__cmp(const void *a, const void *b)
> return strcmp(ia->name, ib->name);
> }
>
> +static struct ins *ins__find_powerpc(const char *name)
It would be better if the function name include 'branch'.
> +{
> + int i;
> + struct ins *ins;
> +
> + ins = zalloc(sizeof(struct ins));
> + if (!ins)
> + return NULL;
> +
> + ins->name = strdup(name);
> + if (!ins->name)
> + return NULL;
You leak 'ins' here.
> +
> + if (name[0] == 'b') {
> + /* branch instructions */
> + ins->ops = &jump_ops;
> +
> + /*
> + * - Few start with 'b', but aren't branch instructions.
> + * - Let's also ignore instructions involving 'ctr' and
> + * 'tar' since target branch addresses for those can't
> + * be determined statically.
> + */
> + if (!strncmp(name, "bcd", 3) ||
> + !strncmp(name, "brinc", 5) ||
> + !strncmp(name, "bper", 4) ||
> + strstr(name, "ctr") ||
> + strstr(name, "tar"))
> + return NULL;
More importantly you leak 'ins' and 'ins->name' here.
And on other paths below.
...
David
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 3/4] perf annotate: add powerpc support Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com> - 2016-06-28 13:40 +0200
RE: [PATCH 3/4] perf annotate: add powerpc support David Laight <David.Laight@ACULAB.COM> - 2016-06-28 18:10 +0200
Re: [PATCH 3/4] perf annotate: add powerpc support Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com> - 2016-06-29 08:50 +0200
csiph-web