From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752672AbcF1QJl (ORCPT ); Tue, 28 Jun 2016 12:09:41 -0400 Received: from smtp-out6.electric.net ([192.162.217.187]:62609 "EHLO smtp-out6.electric.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752265AbcF1QJj (ORCPT ); Tue, 28 Jun 2016 12:09:39 -0400 From: David Laight To: "'Ravi Bangoria'" , "linux-kernel@vger.kernel.org" , "acme@kernel.org" , "linuxppc-dev@lists.ozlabs.org" CC: "ananth@in.ibm.com" , "naveen.n.rao@linux.vnet.ibm.com" , "dja@axtens.net" Subject: RE: [PATCH 3/4] perf annotate: add powerpc support Thread-Topic: [PATCH 3/4] perf annotate: add powerpc support Thread-Index: AQHR0TIof2F/S+f99UGabCidkds7+5//Cy4g Date: Tue, 28 Jun 2016 16:07:10 +0000 Message-ID: <063D6719AE5E284EB5DD2968C1650D6D5F4E67FA@AcuExch.aculab.com> References: <1467113807-29571-1-git-send-email-ravi.bangoria@linux.vnet.ibm.com> <1467113807-29571-4-git-send-email-ravi.bangoria@linux.vnet.ibm.com> In-Reply-To: <1467113807-29571-4-git-send-email-ravi.bangoria@linux.vnet.ibm.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.202.99.200] Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 X-Outbound-IP: 213.249.233.130 X-Env-From: David.Laight@ACULAB.COM X-PolicySMART: 3396946, 3397078 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id u5SG9qCw013982 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 > Signed-off-by: Ravi Bangoria > --- > 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