From: Masami Hiramatsu <mhiramat@kernel.org>
To: Arnaldo Carvalho de Melo <acme@kernel.org>,
Steven Rostedt <rostedt@goodmis.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>,
linux-kernel@vger.kernel.org,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Naohiro Aota <naohiro.aota@hgst.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Wang Nan <wangnan0@huawei.com>,
Hemant Kumar <hemant@linux.vnet.ibm.com>
Subject: [PATCH 4/6] perf probe: Support hexadecimal casting
Date: Thu, 18 Aug 2016 17:58:47 +0900 [thread overview]
Message-ID: <147151072679.12957.4458656416765710753.stgit@devbox> (raw)
In-Reply-To: <147151064700.12957.1184322470361742842.stgit@devbox>
Support hexadecimal unsigned integer casting by 'x'.
This allows user to explicitly specify the output
format of the probe arguments as hexadecimal.
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
---
tools/perf/Documentation/perf-probe.txt | 4 ++--
tools/perf/util/probe-finder.c | 17 ++++++++++-------
2 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/tools/perf/Documentation/perf-probe.txt b/tools/perf/Documentation/perf-probe.txt
index aa33325..d217617 100644
--- a/tools/perf/Documentation/perf-probe.txt
+++ b/tools/perf/Documentation/perf-probe.txt
@@ -176,13 +176,13 @@ Each probe argument follows below syntax.
'NAME' specifies the name of this argument (optional). You can use the name of local variable, local data structure member (e.g. var->field, var.field2), local array with fixed index (e.g. array[1], var->array[0], var->pointer[2]), or kprobe-tracer argument format (e.g. $retval, %ax, etc). Note that the name of this argument will be set as the last member name if you specify a local data structure member (e.g. field2 for 'var->field1.field2'.)
'$vars' and '$params' special arguments are also available for NAME, '$vars' is expanded to the local variables (including function parameters) which can access at given probe point. '$params' is expanded to only the function parameters.
-'TYPE' casts the type of this argument (optional). If omitted, perf probe automatically set the type based on debuginfo. Currently, basic types (u8/u16/u32/u64/s8/s16/s32/s64), hexadecimal integers (x8/x16/x32/x64), signedness casting (u/s), "string" and bitfield are supported. (see TYPES for detail)
+'TYPE' casts the type of this argument (optional). If omitted, perf probe automatically set the type based on debuginfo. Currently, basic types (u8/u16/u32/u64/s8/s16/s32/s64), hexadecimal integers (x/x8/x16/x32/x64), signedness casting (u/s), "string" and bitfield are supported. (see TYPES for detail)
On x86 systems %REG is always the short form of the register: for example %AX. %RAX or %EAX is not valid.
TYPES
-----
-Basic types (u8/u16/u32/u64/s8/s16/s32/s64) and hexadecimal integers (x8/x16/x32/x64) are integer types. Prefix 's' and 'u' means those types are signed and unsigned respectively, and 'x' means that is shown in hexadecimal format. Traced arguments are shown in decimal (signed) or hex (unsigned). You can also use 's' or 'u' to specify only signedness and leave its size auto-detected by perf probe.
+Basic types (u8/u16/u32/u64/s8/s16/s32/s64) and hexadecimal integers (x8/x16/x32/x64) are integer types. Prefix 's' and 'u' means those types are signed and unsigned respectively, and 'x' means that is shown in hexadecimal format. Traced arguments are shown in decimal (signed) or hex (unsigned). You can also use 's' or 'u' to specify only signedness and leave its size auto-detected by perf probe. Moreover, you can use 'x' to explicitly specify to be shown in hexadecimal (the size is also auto-detected).
String type is a special type, which fetches a "null-terminated" string from kernel space. This means it will fail and store NULL if the string container has been paged out. You can specify 'string' type only for the local variable or structure member which is an array of or a pointer to 'char' or 'unsigned char' type.
Bitfield is another special type, which takes 3 parameters, bit-width, bit-offset, and container-size (usually 32). The syntax is;
diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
index 24dbe23..f18cd6b 100644
--- a/tools/perf/util/probe-finder.c
+++ b/tools/perf/util/probe-finder.c
@@ -298,13 +298,13 @@ static int convert_variable_type(Dwarf_Die *vr_die,
char sbuf[STRERR_BUFSIZE];
int bsize, boffs, total;
int ret;
- char sign;
+ char prefix;
/* TODO: check all types */
- if (cast && strcmp(cast, "string") != 0 &&
+ if (cast && strcmp(cast, "string") != 0 && strcmp(cast, "x") != 0 &&
strcmp(cast, "s") != 0 && strcmp(cast, "u") != 0) {
/* Non string type is OK */
- /* and respect signedness cast */
+ /* and respect signedness/hexadecimal cast */
tvar->type = strdup(cast);
return (tvar->type == NULL) ? -ENOMEM : 0;
}
@@ -366,11 +366,14 @@ static int convert_variable_type(Dwarf_Die *vr_die,
}
if (cast && (strcmp(cast, "u") == 0))
- sign = 'u';
+ prefix = 'u';
else if (cast && (strcmp(cast, "s") == 0))
- sign = 's';
+ prefix = 's';
+ else if (cast && (strcmp(cast, "x") == 0) &&
+ probe_type_is_available(PROBE_TYPE_X))
+ prefix = 'x';
else
- sign = die_is_signed_type(&type) ? 's' : 'u';
+ prefix = die_is_signed_type(&type) ? 's' : 'u';
ret = dwarf_bytesize(&type);
if (ret <= 0)
@@ -384,7 +387,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", sign, ret);
+ ret = snprintf(buf, 16, "%c%d", prefix, ret);
formatted:
if (ret < 0 || ret >= 16) {
next prev parent reply other threads:[~2016-08-18 9:01 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-18 8:57 [PATCH 0/6] perf/ftrace: Introduce hexadecimal type casting Masami Hiramatsu
2016-08-18 8:57 ` [PATCH 1/6] ftrace: kprobe: uprobe: Add x8/x16/x32/x64 for hexadecimal types Masami Hiramatsu
2016-08-18 15:38 ` Steven Rostedt
2016-08-24 9:25 ` [tip:perf/core] " tip-bot for Masami Hiramatsu
2016-08-18 8:58 ` [PATCH 2/6] ftrace: probe: Add README entries for k/uprobe-events Masami Hiramatsu
2016-08-18 15:40 ` Steven Rostedt
2016-08-24 9:25 ` [tip:perf/core] " tip-bot for Masami Hiramatsu
2016-08-18 8:58 ` [PATCH 3/6] perf probe: Add supported type casting of running kernel Masami Hiramatsu
2016-08-23 19:45 ` Arnaldo Carvalho de Melo
2016-08-24 9:26 ` [tip:perf/core] perf probe: Add supported for type casting by the " tip-bot for Masami Hiramatsu
2016-08-18 8:58 ` Masami Hiramatsu [this message]
2016-08-24 9:26 ` [tip:perf/core] perf probe: Support hexadecimal casting tip-bot for Masami Hiramatsu
2016-08-18 8:59 ` [PATCH 5/6] perf-probe: Use hexadecimal type by default if possible Masami Hiramatsu
2016-08-24 9:27 ` [tip:perf/core] perf probe: " tip-bot for Masami Hiramatsu
2016-08-18 8:59 ` [PATCH 6/6] ftrace: kprobe: uprobe: Show u8/u16/u32/u64 types in decimal Masami Hiramatsu
2016-08-18 15:41 ` Steven Rostedt
2016-08-24 9:27 ` [tip:perf/core] " tip-bot for Masami Hiramatsu
2016-08-18 14:14 ` [PATCH 0/6] perf/ftrace: Introduce hexadecimal type casting Arnaldo Carvalho de Melo
2016-08-18 16:01 ` Masami Hiramatsu
2016-08-18 16:13 ` Arnaldo Carvalho de Melo
2016-08-20 3:40 ` Masami Hiramatsu
2016-08-18 16:03 ` Steven Rostedt
2016-08-18 16:08 ` 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=147151072679.12957.4458656416765710753.stgit@devbox \
--to=mhiramat@kernel.org \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=hemant@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=naohiro.aota@hgst.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.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