The minus operator has higher precedence than ?:
Add parentheses around ?: fix this.
---
tools/perf/util/probe-event.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 919937e..bed8d0f 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -150,7 +150,7 @@ static u64 kernel_get_symbol_address_by_name(const char *name, bool reloc)
sym = __find_kernel_function_by_name(name, &map);
if (sym)
return map->unmap_ip(map, sym->start) -
- (reloc) ? 0 : map->reloc;
+ ((reloc) ? 0 : map->reloc);
}
return 0;
}
--
2.2.0.33.gc18b867
Signed-off-by: He Kuang <[email protected]>
?? 2015/2/27 17:35, He Kuang д??:
> The minus operator has higher precedence than ?:
> Add parentheses around ?: fix this.
> ---
> tools/perf/util/probe-event.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
> index 919937e..bed8d0f 100644
> --- a/tools/perf/util/probe-event.c
> +++ b/tools/perf/util/probe-event.c
> @@ -150,7 +150,7 @@ static u64 kernel_get_symbol_address_by_name(const char *name, bool reloc)
> sym = __find_kernel_function_by_name(name, &map);
> if (sym)
> return map->unmap_ip(map, sym->start) -
> - (reloc) ? 0 : map->reloc;
> + ((reloc) ? 0 : map->reloc);
> }
> return 0;
> }
Hi,
(2015/02/27 18:35), He Kuang wrote:
> The minus operator has higher precedence than ?:
> Add parentheses around ?: fix this.
Thank you for fixing that,
Could you give us an actual example of the result?
e.g. What happened? and how to reproduce it?
Thank you,
> ---
> tools/perf/util/probe-event.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
> index 919937e..bed8d0f 100644
> --- a/tools/perf/util/probe-event.c
> +++ b/tools/perf/util/probe-event.c
> @@ -150,7 +150,7 @@ static u64 kernel_get_symbol_address_by_name(const char *name, bool reloc)
> sym = __find_kernel_function_by_name(name, &map);
> if (sym)
> return map->unmap_ip(map, sym->start) -
> - (reloc) ? 0 : map->reloc;
> + ((reloc) ? 0 : map->reloc);
> }
> return 0;
> }
>
--
Masami HIRAMATSU
Software Platform Research Dept. Linux Technology Research Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: [email protected]
The minus operator has higher precedence than ?:
Add parentheses around ?: fix this.
Before this patch:
$ echo 'p:myprobe do_sys_open' > /sys/kernel/debug/tracing/kprobe_events
$ perf probe -l -k ../vmlinux
kprobes:myprobe (on do_sys_open)
After this patch:
$ echo 'p:myprobe do_sys_open' > /sys/kernel/debug/tracing/kprobe_events
$ perf probe -l -k ../vmlinux
kprobes:myprobe (on [email protected]/fs/open.c)
Signed-off-by: He Kuang <[email protected]>
---
tools/perf/util/probe-event.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 919937e..bed8d0f 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -150,7 +150,7 @@ static u64 kernel_get_symbol_address_by_name(const char *name, bool reloc)
sym = __find_kernel_function_by_name(name, &map);
if (sym)
return map->unmap_ip(map, sym->start) -
- (reloc) ? 0 : map->reloc;
+ ((reloc) ? 0 : map->reloc);
}
return 0;
}
--
2.2.0.33.gc18b867
(2015/02/27 19:52), He Kuang wrote:
> The minus operator has higher precedence than ?:
> Add parentheses around ?: fix this.
>
> Before this patch:
> $ echo 'p:myprobe do_sys_open' > /sys/kernel/debug/tracing/kprobe_events
> $ perf probe -l -k ../vmlinux
> kprobes:myprobe (on do_sys_open)
>
> After this patch:
> $ echo 'p:myprobe do_sys_open' > /sys/kernel/debug/tracing/kprobe_events
> $ perf probe -l -k ../vmlinux
> kprobes:myprobe (on [email protected]/fs/open.c)
Thanks for finding this bug!
Acked-by: Masami Hiramatsu <[email protected]>
>
> Signed-off-by: He Kuang <[email protected]>
> ---
> tools/perf/util/probe-event.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
> index 919937e..bed8d0f 100644
> --- a/tools/perf/util/probe-event.c
> +++ b/tools/perf/util/probe-event.c
> @@ -150,7 +150,7 @@ static u64 kernel_get_symbol_address_by_name(const char *name, bool reloc)
> sym = __find_kernel_function_by_name(name, &map);
> if (sym)
> return map->unmap_ip(map, sym->start) -
> - (reloc) ? 0 : map->reloc;
> + ((reloc) ? 0 : map->reloc);
> }
> return 0;
> }
>
--
Masami HIRAMATSU
Software Platform Research Dept. Linux Technology Research Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: [email protected]
(2015/02/27 19:52), He Kuang wrote:
> The minus operator has higher precedence than ?:
> Add parentheses around ?: fix this.
>
> Before this patch:
> $ echo 'p:myprobe do_sys_open' > /sys/kernel/debug/tracing/kprobe_events
> $ perf probe -l -k ../vmlinux
> kprobes:myprobe (on do_sys_open)
>
> After this patch:
> $ echo 'p:myprobe do_sys_open' > /sys/kernel/debug/tracing/kprobe_events
> $ perf probe -l -k ../vmlinux
> kprobes:myprobe (on [email protected]/fs/open.c)
BTW, on my environment (CentOS7)
# ./perf probe -a do_fork
Added new event:
probe:do_fork (on do_fork)
You can now use it in all perf tools, such as:
perf record -e probe:do_fork -aR sleep 1
# ./perf probe -l
probe:do_fork (on do_fork@kernel/fork.c)
# ./perf probe -l -k /usr/lib/debug/lib/modules/3.10.0-123.13.2.el7.x86_64/vmlinux
probe:do_fork (on do_fork@kernel/fork.c)
Hm, the current perf (without this patch) seems work...
But anyway, it looks safer to brace it.
Thank you,
>
> Signed-off-by: He Kuang <[email protected]>
> ---
> tools/perf/util/probe-event.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
> index 919937e..bed8d0f 100644
> --- a/tools/perf/util/probe-event.c
> +++ b/tools/perf/util/probe-event.c
> @@ -150,7 +150,7 @@ static u64 kernel_get_symbol_address_by_name(const char *name, bool reloc)
> sym = __find_kernel_function_by_name(name, &map);
> if (sym)
> return map->unmap_ip(map, sym->start) -
> - (reloc) ? 0 : map->reloc;
> + ((reloc) ? 0 : map->reloc);
> }
> return 0;
> }
>
--
Masami HIRAMATSU
Software Platform Research Dept. Linux Technology Research Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: [email protected]
Commit-ID: f56847c2e99810781f6941d01baff9ae223eeac3
Gitweb: http://git.kernel.org/tip/f56847c2e99810781f6941d01baff9ae223eeac3
Author: He Kuang <[email protected]>
AuthorDate: Fri, 27 Feb 2015 18:52:53 +0800
Committer: Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Fri, 27 Feb 2015 10:31:09 -0300
perf probe: Fix a precedence bug
The minus operator has higher precedence than ?: Add parentheses around
?: fix this.
Before this patch:
$ echo 'p:myprobe do_sys_open' > /sys/kernel/debug/tracing/kprobe_events
$ perf probe -l -k ../vmlinux
kprobes:myprobe (on do_sys_open)
After this patch:
$ echo 'p:myprobe do_sys_open' > /sys/kernel/debug/tracing/kprobe_events
$ perf probe -l -k ../vmlinux
kprobes:myprobe (on [email protected]/fs/open.c)
Signed-off-by: He Kuang <[email protected]>
Acked-by: Masami Hiramatsu <[email protected]>
Cc: Wang Nan <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/util/probe-event.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 9526cf3..7c0e765 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -151,7 +151,7 @@ static u64 kernel_get_symbol_address_by_name(const char *name, bool reloc)
sym = __find_kernel_function_by_name(name, &map);
if (sym)
return map->unmap_ip(map, sym->start) -
- (reloc) ? 0 : map->reloc;
+ ((reloc) ? 0 : map->reloc);
}
return 0;
}