From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161244AbcHELlJ (ORCPT ); Fri, 5 Aug 2016 07:41:09 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:9423 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161197AbcHELlF (ORCPT ); Fri, 5 Aug 2016 07:41:05 -0400 X-IronPort-AV: E=Sophos;i="5.28,473,1464624000"; d="scan'208";a="9536636" From: Naohiro Aota To: "mhiramat@kernel.org" CC: "hemant@linux.vnet.ibm.com" , "linux-kernel@vger.kernel.org" , "peterz@infradead.org" , "alexander.shishkin@linux.intel.com" , "mingo@redhat.com" , "wangnan0@huawei.com" , "acme@kernel.org" Subject: Re: [PATCH] perf probe: support signedness casting Thread-Topic: [PATCH] perf probe: support signedness casting Thread-Index: AQHR7tynjuOW26HQnEqL37DJlK9iraA6FJ+AgAAqIQA= Date: Fri, 5 Aug 2016 11:41:01 +0000 Message-ID: <1470397260.26381.0.camel@hgst.com> References: <1470375233-28396-1-git-send-email-naohiro.aota@hgst.com> <20160805181013.053409b3261aa52909226b64@kernel.org> In-Reply-To: <20160805181013.053409b3261aa52909226b64@kernel.org> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Naohiro.Aota@hgst.com; x-originating-ip: [199.255.47.6] x-ms-office365-filtering-correlation-id: a8c981ec-4661-48f3-2b2d-08d3bd25601f x-microsoft-exchange-diagnostics: 1;BLUPR04MB691;20:sDOVCN067TlUajkZIBV3Evwv3sfMTzuksscLb1b7IISqiZtQhkzbT6Rmxv+qu0gJ24xZnKnMyo4tv9+kYb3qR+wMubzD56PAaKvjgFg6Ltvr71cvjRCsFdFVazgVY1XfDlMMmkDFnomV4QFgkKQbOFqcpnuMbMCmJzZSESz9Bgl9i6g8X388RQ2ZIUEupNvynMh0OwW/tfl3JTOYZzrtAi+3pTBPzk0yh8YCelpLLuomvTjdEHVQivHmcZS92ifp x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR04MB691; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(79135771888625); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6055026);SRVR:BLUPR04MB691;BCL:0;PCL:0;RULEID:;SRVR:BLUPR04MB691; x-forefront-prvs: 0025434D2D x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(979002)(6009001)(7916002)(199003)(24454002)(51914003)(189002)(76176999)(8676002)(3280700002)(36756003)(99286002)(81156014)(1730700003)(81166006)(97736004)(50986999)(54356999)(11100500001)(110136002)(92566002)(2906002)(8936002)(3846002)(102836003)(86362001)(105586002)(586003)(6116002)(87936001)(4326007)(33646002)(66066001)(19580395003)(5640700001)(103116003)(2950100001)(2900100001)(19580405001)(106116001)(7736002)(7846002)(2501003)(68736007)(106356001)(189998001)(122556002)(3660700001)(101416001)(5002640100001)(10400500002)(305945005)(2351001)(77096005)(969003)(989001)(999001)(1009001)(1019001);DIR:OUT;SFP:1102;SCL:1;SRVR:BLUPR04MB691;H:BLUPR04MB691.namprd04.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="utf-8" Content-ID: <1326F70908C5D247BF21321D6DA0BF91@namprd04.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: hgst.com X-MS-Exchange-CrossTenant-originalarrivaltime: 05 Aug 2016 11:41:01.0774 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR04MB691 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 u75BfIO3011335 2016-08-05 (金) の 18:10 +0900 に Masami Hiramatsu さんは書きました: > On Fri, 5 Aug 2016 14:33:53 +0900 > Naohiro Aota wrote: > > > > > Perf-probe detects a variable's type and use the detected type to > > add new > > probe. Then, kprobes prints its variable in hexadecimal format if > > the > > variable is unsigned and prints in decimal if it is signed. > > > > We sometimes want to see unsigned variable in decimal format (e.g. > > sector_t or size_t). In that case, we need to investigate > > variable's > > size manually to specify just signedness. > > > > This patch add signedness casting support. By specifying "s" or "u" > > as a > > type, perf-probe will investigate variable size as usual and use > > the specified signedness. > OK, I could understand what the patch does from code. Please add an > example, and update tools/perf/Documentation/perf-probe.txt too. Thanks for the review. I'm posting updated patch with type descriptions. > Thank you, > > > > > > > Signed-off-by: Naohiro Aota > > --- > >  tools/perf/util/probe-finder.c | 15 ++++++++++++--- > >  1 file changed, 12 insertions(+), 3 deletions(-) > > > > diff --git a/tools/perf/util/probe-finder.c > > b/tools/perf/util/probe-finder.c > > index f2d9ff0..5c290c6 100644 > > --- a/tools/perf/util/probe-finder.c > > +++ b/tools/perf/util/probe-finder.c > > @@ -297,10 +297,13 @@ static int convert_variable_type(Dwarf_Die > > *vr_die, > >   char sbuf[STRERR_BUFSIZE]; > >   int bsize, boffs, total; > >   int ret; > > + char sign; > >   > >   /* TODO: check all types */ > > - if (cast && strcmp(cast, "string") != 0) { > > + if (cast && strcmp(cast, "string") != 0 && > > +     strcmp(cast, "s") != 0 && strcmp(cast, "u") != 0) { > >   /* Non string type is OK */ > > + /* and respect signedness cast */ > >   tvar->type = strdup(cast); > >   return (tvar->type == NULL) ? -ENOMEM : 0; > >   } > > @@ -361,6 +364,13 @@ static int convert_variable_type(Dwarf_Die > > *vr_die, > >   return (tvar->type == NULL) ? -ENOMEM : 0; > >   } > >   > > + if (cast && (strcmp(cast, "u") == 0)) > > + sign = 'u'; > > + else if (cast && (strcmp(cast, "s") == 0)) > > + sign = 's'; > > + else > > + sign = die_is_signed_type(&type) ? 's' : 'u'; > > + > >   ret = dwarf_bytesize(&type); > >   if (ret <= 0) > >   /* No size ... try to use default type */ > > @@ -373,8 +383,7 @@ static int convert_variable_type(Dwarf_Die > > *vr_die, > >   dwarf_diename(&type), > > MAX_BASIC_TYPE_BITS); > >   ret = MAX_BASIC_TYPE_BITS; > >   } > > - ret = snprintf(buf, 16, "%c%d", > > -        die_is_signed_type(&type) ? 's' : 'u', > > ret); > > + ret = snprintf(buf, 16, "%c%d", sign, ret); > >   > >  formatted: > >   if (ret < 0 || ret >= 16) { > > --  > > 2.7.3 > > > Western Digital Corporation (and its subsidiaries) E-mail Confidentiality Notice & Disclaimer: This e-mail and any files transmitted with it may contain confidential or legally privileged information of WDC and/or its affiliates, and are intended solely for the use of the individual or entity to which they are addressed. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited. If you have received this e-mail in error, please notify the sender immediately and delete the e-mail in its entirety from your system.