tracing/uprobes: Fix documentation of uprobe registration syntax
Subsystems (2)
PATCH 1/2 tracing/uprobes: Fix documentation of uprobe registration syntax
From: Namhyung Kim <[email protected]>
The uprobe syntax requires an offset after a file path not a symbol.
--- Documentation/trace/uprobetracer.txt | 10 +++++----- kernel/trace/trace_uprobe.c | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-)
Documentation/trace/uprobetracer.txt +5 -5
@@ -19,15 +19,15 @@ user to calculate the offset of the probepoint in the object. Synopsis of uprobe_tracer ------------------------- - p[:[GRP/]EVENT] PATH:SYMBOL[+offs] [FETCHARGS] : Set a uprobe - r[:[GRP/]EVENT] PATH:SYMBOL[+offs] [FETCHARGS] : Set a return uprobe (uretprobe) - -:[GRP/]EVENT : Clear uprobe or uretprobe event + p[:[GRP/]EVENT] PATH:OFFSET [FETCHARGS] : Set a uprobe + r[:[GRP/]EVENT] PATH:OFFSET [FETCHARGS] : Set a return uprobe (uretprobe) + -:[GRP/]EVENT : Clear uprobe or uretprobe event GRP : Group name. If omitted, "uprobes" is the default value. EVENT : Event name. If omitted, the event name is generated based - on SYMBOL+offs. + on PATH+OFFSET. PATH : Path to an executable or a library. - SYMBOL[+offs] : Symbol+offset where the probe is inserted. + OFFSET : Offset where the probe is inserted. FETCHARGS : Arguments. Each probe can have up to 128 args. %REG : Fetch register REG
kernel/trace/trace_uprobe.c +1 -1
@@ -210,7 +210,7 @@ end:/* * Argument syntax: -* - Add uprobe: p|r[:[GRP/]EVENT] PATH:SYMBOL [FETCHARGS] +* - Add uprobe: p|r[:[GRP/]EVENT] PATH:OFFSET [FETCHARGS] * * - Remove uprobe: -:[GRP/]EVENT */
Signature · 1 line
1.7.11.7
PATCH 2/2 tracing/probes: Fix basic print type functions
From: Namhyung Kim <[email protected]>
The print format of s32 type was "ld" and it's casted to "long". So it turned out to print 4294967295 for "-1" on 64-bit systems. Not sure whether it worked well on 32-bit systems.
Anyway, it'd be better if we have exact format and type cast for each types on both of 32- and 64-bit systems. In fact, the only difference is on s64/u64 types.
--- kernel/trace/trace_probe.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
kernel/trace/trace_probe.c +11 -6
@@ -49,14 +49,19 @@ static __kprobes int PRINT_TYPE_FUNC_NAME(type)(struct trace_seq *s, \ } \static const char PRINT_TYPE_FMT_NAME (type )[] = fmt; -DEFINE_BASIC_PRINT_TYPE_FUNC(u8, "%x", unsigned int) -DEFINE_BASIC_PRINT_TYPE_FUNC(u16, "%x", unsigned int) -DEFINE_BASIC_PRINT_TYPE_FUNC(u32, "%lx", unsigned long) +DEFINE_BASIC_PRINT_TYPE_FUNC(u8 , "%x", unsigned char) +DEFINE_BASIC_PRINT_TYPE_FUNC(u16, "%x", unsigned short) +DEFINE_BASIC_PRINT_TYPE_FUNC(u32, "%x", unsigned int) +DEFINE_BASIC_PRINT_TYPE_FUNC(s8, "%d", signed char) +DEFINE_BASIC_PRINT_TYPE_FUNC(s16, "%d", short) +DEFINE_BASIC_PRINT_TYPE_FUNC(s32, "%d", int) +#if BITS_PER_LONG ==32 DEFINE_BASIC_PRINT_TYPE_FUNC(u64, "%llx", unsigned long long) -DEFINE_BASIC_PRINT_TYPE_FUNC(s8, "%d", int) -DEFINE_BASIC_PRINT_TYPE_FUNC(s16, "%d", int) -DEFINE_BASIC_PRINT_TYPE_FUNC(s32, "%ld", long) DEFINE_BASIC_PRINT_TYPE_FUNC(s64, "%lld", long long) +#else /* BITS_PER_LONG == 64 */ +DEFINE_BASIC_PRINT_TYPE_FUNC(u64, "%lx", unsigned long) +DEFINE_BASIC_PRINT_TYPE_FUNC(s64, "%ld", long) +#endif static inline void *get_rloc_data (u32 *dl) {
Signature · 1 line
1.7.11.7
Re: [PATCH 2/2] tracing/probes: Fix basic print type functions
Quoted 10 lines · Namhyung Kim
(quoted diff) +6
-3-DEFINE_BASIC_PRINT_TYPE_FUNC(u8, "%x", unsigned int) -DEFINE_BASIC_PRINT_TYPE_FUNC(u16, "%x", unsigned int) -DEFINE_BASIC_PRINT_TYPE_FUNC(u32, "%lx", unsigned long) +DEFINE_BASIC_PRINT_TYPE_FUNC(u8 , "%x", unsigned char) +DEFINE_BASIC_PRINT_TYPE_FUNC(u16, "%x", unsigned short) +DEFINE_BASIC_PRINT_TYPE_FUNC(u32, "%x", unsigned int) +DEFINE_BASIC_PRINT_TYPE_FUNC(s8, "%d", signed char) +DEFINE_BASIC_PRINT_TYPE_FUNC(s16, "%d", short) +DEFINE_BASIC_PRINT_TYPE_FUNC(s32, "%d", int)
Review
Quoted 10 lines
(quoted diff) +5
-3+#if BITS_PER_LONG == 32 DEFINE_BASIC_PRINT_TYPE_FUNC(u64, "%llx", unsigned long long) -DEFINE_BASIC_PRINT_TYPE_FUNC(s8, "%d", int) -DEFINE_BASIC_PRINT_TYPE_FUNC(s16, "%d", int) -DEFINE_BASIC_PRINT_TYPE_FUNC(s32, "%ld", long) DEFINE_BASIC_PRINT_TYPE_FUNC(s64, "%lld", long long) +#else /* BITS_PER_LONG == 64 */ +DEFINE_BASIC_PRINT_TYPE_FUNC(u64, "%lx", unsigned long) +DEFINE_BASIC_PRINT_TYPE_FUNC(s64, "%ld", long) +#endif
I must have missed something... Not only I do not understand why do we need "#if BITS_PER_LONG", I can't understand why DEFINE_BASIC_PRINT_TYPE_FUNC() needs "cast" argument.
IOW, how about the patch below instead?
Oleg.
kernel/trace/trace_probe.c +11 -11
@@ -40,23 +40,23 @@ const char *reserved_field_names[] = {#define PRINT_TYPE_FMT_NAME (type) print_type_format_##type/* Printing in basic type function template */ -#define DEFINE_BASIC_PRINT_TYPE_FUNC (type, fmt, cast) \ +#define DEFINE_BASIC_PRINT_TYPE_FUNC (type, fmt) \ static __kprobes int PRINT_TYPE_FUNC_NAME(type)(struct trace_seq *s, \ const char *name, \ - void *data, void *ent)\ + void *data, void *ent) \ { \ - return trace_seq_printf(s, " %s=" fmt, name, (cast)*(type *)data);\ + return trace_seq_printf(s, " %s=" fmt, name, *(type *)data); \ } \ static const char PRINT_TYPE_FMT_NAME(type)[] = fmt; -DEFINE_BASIC_PRINT_TYPE_FUNC(u8, "%x", unsigned int) -DEFINE_BASIC_PRINT_TYPE_FUNC(u16, "%x", unsigned int) -DEFINE_BASIC_PRINT_TYPE_FUNC(u32, "%lx", unsigned long) -DEFINE_BASIC_PRINT_TYPE_FUNC(u64, "%llx", unsigned long long) -DEFINE_BASIC_PRINT_TYPE_FUNC(s8, "%d", int) -DEFINE_BASIC_PRINT_TYPE_FUNC(s16, "%d", int) -DEFINE_BASIC_PRINT_TYPE_FUNC(s32, "%ld", long) -DEFINE_BASIC_PRINT_TYPE_FUNC(s64, "%lld", long long) +DEFINE_BASIC_PRINT_TYPE_FUNC(u8, "%x") +DEFINE_BASIC_PRINT_TYPE_FUNC(u16, "%x") +DEFINE_BASIC_PRINT_TYPE_FUNC(u32, "%x") +DEFINE_BASIC_PRINT_TYPE_FUNC(u64, "%Lx") +DEFINE_BASIC_PRINT_TYPE_FUNC(s8, "%d") +DEFINE_BASIC_PRINT_TYPE_FUNC(s16, "%d") +DEFINE_BASIC_PRINT_TYPE_FUNC(s32, "%d") +DEFINE_BASIC_PRINT_TYPE_FUNC(s64, "%Ld")static inline void *get_rloc_data (u32 *dl) {
Re: [PATCH 2/2] tracing/probes: Fix basic print type functions
Hi Oleg,
Quoted 26 lines · Oleg Nesterov
Quoted 10 lines · Namhyung Kim
(quoted diff) +6
-3-DEFINE_BASIC_PRINT_TYPE_FUNC(u8, "%x", unsigned int) -DEFINE_BASIC_PRINT_TYPE_FUNC(u16, "%x", unsigned int) -DEFINE_BASIC_PRINT_TYPE_FUNC(u32, "%lx", unsigned long) +DEFINE_BASIC_PRINT_TYPE_FUNC(u8 , "%x", unsigned char) +DEFINE_BASIC_PRINT_TYPE_FUNC(u16, "%x", unsigned short) +DEFINE_BASIC_PRINT_TYPE_FUNC(u32, "%x", unsigned int) +DEFINE_BASIC_PRINT_TYPE_FUNC(s8, "%d", signed char) +DEFINE_BASIC_PRINT_TYPE_FUNC(s16, "%d", short) +DEFINE_BASIC_PRINT_TYPE_FUNC(s32, "%d", int)Review
Quoted 10 lines
(quoted diff) +5
-3+#if BITS_PER_LONG == 32 DEFINE_BASIC_PRINT_TYPE_FUNC(u64, "%llx", unsigned long long) -DEFINE_BASIC_PRINT_TYPE_FUNC(s8, "%d", int) -DEFINE_BASIC_PRINT_TYPE_FUNC(s16, "%d", int) -DEFINE_BASIC_PRINT_TYPE_FUNC(s32, "%ld", long) DEFINE_BASIC_PRINT_TYPE_FUNC(s64, "%lld", long long) +#else /* BITS_PER_LONG == 64 */ +DEFINE_BASIC_PRINT_TYPE_FUNC(u64, "%lx", unsigned long) +DEFINE_BASIC_PRINT_TYPE_FUNC(s64, "%ld", long) +#endifI must have missed something... Not only I do not understand why do we need "#if
BITS_PER_LONG", I can't understand whyDEFINE_BASIC_PRINT_TYPE_FUNC()needs "cast" argument.
Quoted 1 line
IOW, how about the patch below instead?
Looks good to me.
Masami, did you have any issue regarding the casts?
Thanks,
Namhyung
Quoted 38 lines
kernel/trace/trace_probe.c +11
-11@@ -40,23 +40,23 @@ const char *reserved_field_names[] = {#define PRINT_TYPE_FMT_NAME (type) print_type_format_##type/* Printing in basic type function template */ -#define DEFINE_BASIC_PRINT_TYPE_FUNC (type, fmt, cast) \ +#define DEFINE_BASIC_PRINT_TYPE_FUNC (type, fmt) \ static __kprobes int PRINT_TYPE_FUNC_NAME(type)(struct trace_seq *s, \ const char *name, \ - void *data, void *ent)\ + void *data, void *ent) \ { \ - return trace_seq_printf(s, " %s=" fmt, name, (cast)*(type *)data);\ + return trace_seq_printf(s, " %s=" fmt, name, *(type *)data); \ } \ static const char PRINT_TYPE_FMT_NAME(type)[] = fmt; -DEFINE_BASIC_PRINT_TYPE_FUNC(u8, "%x", unsigned int) -DEFINE_BASIC_PRINT_TYPE_FUNC(u16, "%x", unsigned int) -DEFINE_BASIC_PRINT_TYPE_FUNC(u32, "%lx", unsigned long) -DEFINE_BASIC_PRINT_TYPE_FUNC(u64, "%llx", unsigned long long) -DEFINE_BASIC_PRINT_TYPE_FUNC(s8, "%d", int) -DEFINE_BASIC_PRINT_TYPE_FUNC(s16, "%d", int) -DEFINE_BASIC_PRINT_TYPE_FUNC(s32, "%ld", long) -DEFINE_BASIC_PRINT_TYPE_FUNC(s64, "%lld", long long) +DEFINE_BASIC_PRINT_TYPE_FUNC(u8, "%x") +DEFINE_BASIC_PRINT_TYPE_FUNC(u16, "%x") +DEFINE_BASIC_PRINT_TYPE_FUNC(u32, "%x") +DEFINE_BASIC_PRINT_TYPE_FUNC(u64, "%Lx") +DEFINE_BASIC_PRINT_TYPE_FUNC(s8, "%d") +DEFINE_BASIC_PRINT_TYPE_FUNC(s16, "%d") +DEFINE_BASIC_PRINT_TYPE_FUNC(s32, "%d") +DEFINE_BASIC_PRINT_TYPE_FUNC(s64, "%Ld")static inline void *get_rloc_data (u32 *dl) {
Masami Hiramatsu
Acked-byRe: Re: [PATCH 2/2] tracing/probes: Fix basic print type functions
Quoted 29 lines · Namhyung Kim
Hi Oleg,
Quoted 26 lines · Oleg Nesterov
Quoted 10 lines · Namhyung Kim
(quoted diff) +6
-3-DEFINE_BASIC_PRINT_TYPE_FUNC(u8, "%x", unsigned int) -DEFINE_BASIC_PRINT_TYPE_FUNC(u16, "%x", unsigned int) -DEFINE_BASIC_PRINT_TYPE_FUNC(u32, "%lx", unsigned long) +DEFINE_BASIC_PRINT_TYPE_FUNC(u8 , "%x", unsigned char) +DEFINE_BASIC_PRINT_TYPE_FUNC(u16, "%x", unsigned short) +DEFINE_BASIC_PRINT_TYPE_FUNC(u32, "%x", unsigned int) +DEFINE_BASIC_PRINT_TYPE_FUNC(s8, "%d", signed char) +DEFINE_BASIC_PRINT_TYPE_FUNC(s16, "%d", short) +DEFINE_BASIC_PRINT_TYPE_FUNC(s32, "%d", int)Review
Quoted 10 lines
(quoted diff) +5
-3+#if BITS_PER_LONG == 32 DEFINE_BASIC_PRINT_TYPE_FUNC(u64, "%llx", unsigned long long) -DEFINE_BASIC_PRINT_TYPE_FUNC(s8, "%d", int) -DEFINE_BASIC_PRINT_TYPE_FUNC(s16, "%d", int) -DEFINE_BASIC_PRINT_TYPE_FUNC(s32, "%ld", long) DEFINE_BASIC_PRINT_TYPE_FUNC(s64, "%lld", long long) +#else /* BITS_PER_LONG == 64 */ +DEFINE_BASIC_PRINT_TYPE_FUNC(u64, "%lx", unsigned long) +DEFINE_BASIC_PRINT_TYPE_FUNC(s64, "%ld", long) +#endifI must have missed something... Not only I do not understand why do we need "#if
BITS_PER_LONG", I can't understand whyDEFINE_BASIC_PRINT_TYPE_FUNC()needs "cast" argument.
Quoted 5 lines
Quoted 1 line
IOW, how about the patch below instead?
Looks good to me.
Masami, did you have any issue regarding the casts?
Hm, unless compiler doesn't complain about it,I'm OK for that. And as far as I tested on x86/x86-64/arm(32), this has no problem. :)
Thank you!
Signature · 4 lines
Masami HIRAMATSU IT Management Research Dept. Linux Technology Center Hitachi, Ltd., Yokohama Research Laboratory E-mail: [email protected]
Quoted 11 lines · Namhyung Kim
From: Namhyung Kim <[email protected]>
The uprobe syntax requires an offset after a file path not a symbol.
Reviewed-by Masami Hiramatsu <[email protected]>Cc Srikar Dronamraju <[email protected]>Cc Oleg Nesterov <[email protected]>Cc zhangwei(Jovi) <[email protected]>Cc Arnaldo Carvalho de Melo <[email protected]>Signed-off-by Namhyung Kim <[email protected]>