From 349e8d2611316cce11c0b9d0830ebb585c9b82b8 Mon Sep 17 00:00:00 2001 From: He Kuang Date: Mon, 11 May 2015 09:25:03 +0000 Subject: perf probe: Add --range option to show a variable's location range It is not easy for users to get the accurate byte offset or the line number where a local variable can be probed. With '--range' option, local variables in the scope of the probe point are showed with a byte offset range, and can be added according to this range information. For example, there are some variables in the function generic_perform_write(): 0 ssize_t generic_perform_write(struct file *file, 1 struct iov_iter *i, loff_t pos) 2 { 3 struct address_space *mapping = file->f_mapping; 4 const struct address_space_operations *a_ops = mapping->a_ops; ... 42 status = a_ops->write_begin(file, mapping, pos, bytes, flags, &page, &fsdata); 44 if (unlikely(status < 0)) But we fail when we try to probe the variable 'a_ops' at line 42 or 44. $ perf probe --add 'generic_perform_write:42 a_ops' Failed to find the location of a_ops at this address. Perhaps, it has been optimized out. This is because the source code do not match the assembly, so a variable may not be available in the source code line where it appears. After this patch, we can lookup the accurate byte offset range of a variable, 'INV' indicates that this variable is not valid at the given point, but available in the scope: $ perf probe --vars 'generic_perform_write:42' --range Available variables at generic_perform_write:42 @ [INV] ssize_t written @ [INV] struct address_space_operations* a_ops @ [VAL] (unknown_type) fsdata @ [VAL] loff_t pos @ [VAL] long int status @ [VAL] long unsigned int bytes @ [VAL] struct address_space* mapping @ [VAL] struct iov_iter* i @ [VAL] struct page* page @ Then it is more clear for us to add a probe with this variable: $ perf probe --add 'generic_perform_write+170 a_ops' Added new event: probe:generic_perform_write (on generic_perform_write+170 with a_ops) Signed-off-by: He Kuang Acked-by: Masami Hiramatsu Cc: Jiri Olsa Cc: Peter Zijlstra Cc: Wang Nan Link: http://lkml.kernel.org/r/1431336304-16863-2-git-send-email-hekuang@huawei.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/probe-event.h | 1 + 1 file changed, 1 insertion(+) (limited to 'tools/perf/util/probe-event.h') diff --git a/tools/perf/util/probe-event.h b/tools/perf/util/probe-event.h index 1e2faa3559d2..537eb329c2cf 100644 --- a/tools/perf/util/probe-event.h +++ b/tools/perf/util/probe-event.h @@ -9,6 +9,7 @@ /* Probe related configurations */ struct probe_conf { bool show_ext_vars; + bool show_location_range; bool force_add; bool no_inlines; int max_probes; -- cgit v1.2.3-55-g7522