From: Naohiro Aota <Naohiro.Aota@hgst.com>
To: "mhiramat@kernel.org" <mhiramat@kernel.org>
Cc: "hemant@linux.vnet.ibm.com" <hemant@linux.vnet.ibm.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"peterz@infradead.org" <peterz@infradead.org>,
"alexander.shishkin@linux.intel.com"
<alexander.shishkin@linux.intel.com>,
"mingo@redhat.com" <mingo@redhat.com>,
"wangnan0@huawei.com" <wangnan0@huawei.com>,
"acme@kernel.org" <acme@kernel.org>
Subject: Re: [PATCH] perf probe: support signedness casting
Date: Fri, 5 Aug 2016 11:41:01 +0000 [thread overview]
Message-ID: <1470397260.26381.0.camel@hgst.com> (raw)
In-Reply-To: <20160805181013.053409b3261aa52909226b64@kernel.org>
2016-08-05 (金) の 18:10 +0900 に Masami Hiramatsu さんは書きました:
> On Fri, 5 Aug 2016 14:33:53 +0900
> Naohiro Aota <naohiro.aota@hgst.com> 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 <naohiro.aota@hgst.com>
> > ---
> > 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.
next prev parent reply other threads:[~2016-08-05 11:41 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-05 5:33 Naohiro Aota
2016-08-05 9:10 ` Masami Hiramatsu
2016-08-05 11:41 ` Naohiro Aota [this message]
2016-08-05 11:53 ` [PATCH v2] perf probe: Support " Naohiro Aota
2016-08-06 10:35 ` Masami Hiramatsu
2016-08-09 2:40 ` [PATCH v3] " Naohiro Aota
2016-08-09 10:02 ` Masami Hiramatsu
2016-08-09 14:05 ` Arnaldo Carvalho de Melo
2016-08-09 22:38 ` Masami Hiramatsu
2016-08-10 13:04 ` Arnaldo Carvalho de Melo
2016-08-10 19:37 ` Masami Hiramatsu
2016-08-09 19:19 ` [tip:perf/urgent] " tip-bot for Naohiro Aota
2016-08-09 22:28 ` Masami Hiramatsu
2016-08-10 13:48 ` Arnaldo Carvalho de Melo
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=1470397260.26381.0.camel@hgst.com \
--to=naohiro.aota@hgst.com \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=hemant@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=wangnan0@huawei.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome