Skip to content

Commit bdca79c

Browse files
mhiramatacmel
authored andcommitted
ftrace: kprobe: uprobe: Show u8/u16/u32/u64 types in decimal
Change kprobe/uprobe-tracer to show the arguments type-casted with u8/u16/u32/u64 in decimal digits instead of hexadecimal. To minimize compatibility issue, the arguments without type casting are typed by x64 (or x32 for 32bit arch) by default. Note: all arguments set by old perf probe without types are shown in decimal by default. Signed-off-by: Masami Hiramatsu <[email protected]> Acked-by: Steven Rostedt <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Hemant Kumar <[email protected]> Cc: Naohiro Aota <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Wang Nan <[email protected]> Link: http://lkml.kernel.org/r/147151076135.12957.14684546093034343894.stgit@devbox Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 9880ce4 commit bdca79c

File tree

5 files changed

+15
-10
lines changed

5 files changed

+15
-10
lines changed

Documentation/trace/kprobetrace.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ Types
5454
-----
5555
Several types are supported for fetch-args. Kprobe tracer will access memory
5656
by given type. Prefix 's' and 'u' means those types are signed and unsigned
57-
respectively. Traced arguments are shown in decimal (signed) or hex (unsigned).
57+
respectively. 'x' prefix implies it is unsigned. Traced arguments are shown
58+
in decimal ('s' and 'u') or hexadecimal ('x'). Without type casting, 'x32'
59+
or 'x64' is used depends on the architecture (e.g. x86-32 uses x32, and
60+
x86-64 uses x64).
5861
String type is a special type, which fetches a "null-terminated" string from
5962
kernel space. This means it will fail and store NULL if the string container
6063
has been paged out.

Documentation/trace/uprobetracer.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ Types
5050
-----
5151
Several types are supported for fetch-args. Uprobe tracer will access memory
5252
by given type. Prefix 's' and 'u' means those types are signed and unsigned
53-
respectively. Traced arguments are shown in decimal (signed) or hex (unsigned).
53+
respectively. 'x' prefix implies it is unsigned. Traced arguments are shown
54+
in decimal ('s' and 'u') or hexadecimal ('x'). Without type casting, 'x32'
55+
or 'x64' is used depends on the architecture (e.g. x86-32 uses x32, and
56+
x86-64 uses x64).
5457
String type is a special type, which fetches a "null-terminated" string from
5558
user space.
5659
Bitfield is another special type, which takes 3 parameters, bit-width, bit-

kernel/trace/trace_probe.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ int PRINT_TYPE_FUNC_NAME(tname)(struct trace_seq *s, const char *name, \
4646
const char PRINT_TYPE_FMT_NAME(tname)[] = fmt; \
4747
NOKPROBE_SYMBOL(PRINT_TYPE_FUNC_NAME(tname));
4848

49-
DEFINE_BASIC_PRINT_TYPE_FUNC(u8, u8, "0x%x")
50-
DEFINE_BASIC_PRINT_TYPE_FUNC(u16, u16, "0x%x")
51-
DEFINE_BASIC_PRINT_TYPE_FUNC(u32, u32, "0x%x")
52-
DEFINE_BASIC_PRINT_TYPE_FUNC(u64, u64, "0x%Lx")
49+
DEFINE_BASIC_PRINT_TYPE_FUNC(u8, u8, "%u")
50+
DEFINE_BASIC_PRINT_TYPE_FUNC(u16, u16, "%u")
51+
DEFINE_BASIC_PRINT_TYPE_FUNC(u32, u32, "%u")
52+
DEFINE_BASIC_PRINT_TYPE_FUNC(u64, u64, "%Lu")
5353
DEFINE_BASIC_PRINT_TYPE_FUNC(s8, s8, "%d")
5454
DEFINE_BASIC_PRINT_TYPE_FUNC(s16, s16, "%d")
5555
DEFINE_BASIC_PRINT_TYPE_FUNC(s32, s32, "%d")

kernel/trace/trace_probe.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ DEFINE_FETCH_##method(u32) \
208208
DEFINE_FETCH_##method(u64)
209209

210210
/* Default (unsigned long) fetch type */
211-
#define __DEFAULT_FETCH_TYPE(t) u##t
211+
#define __DEFAULT_FETCH_TYPE(t) x##t
212212
#define _DEFAULT_FETCH_TYPE(t) __DEFAULT_FETCH_TYPE(t)
213213
#define DEFAULT_FETCH_TYPE _DEFAULT_FETCH_TYPE(BITS_PER_LONG)
214214
#define DEFAULT_FETCH_TYPE_STR __stringify(DEFAULT_FETCH_TYPE)

tools/perf/Documentation/perf-probe.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,12 @@ Each probe argument follows below syntax.
176176

177177
'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'.)
178178
'$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.
179-
'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)
180-
179+
'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)
181180
On x86 systems %REG is always the short form of the register: for example %AX. %RAX or %EAX is not valid.
182181

183182
TYPES
184183
-----
185-
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).
184+
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 (sNN/uNN) or hex (xNN). 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).
186185
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.
187186
Bitfield is another special type, which takes 3 parameters, bit-width, bit-offset, and container-size (usually 32). The syntax is;
188187

0 commit comments

Comments
 (0)