perf probe: Support hexadecimal casting
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> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Hemant Kumar <hemant@linux.vnet.ibm.com> Cc: Naohiro Aota <naohiro.aota@hgst.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/r/147151072679.12957.4458656416765710753.stgit@devbox Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:

committed by
Arnaldo Carvalho de Melo

parent
180b20616c
commit
9254378725
@@ -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) {
|
||||
|
Reference in New Issue
Block a user