Commit e116dfa1c357da49f55e1555767ec991225a8321
Committed by
Arnaldo Carvalho de Melo
1 parent
4187e262bc
perf probe: Support function@filename syntax for --line
Since "perf probe --add" supports function@filename syntax, --line option should also support it. Cc: 2nddept-manager@sdl.hitachi.co.jp Cc: Franck Bui-Huu <fbuihuu@gmail.com> Cc: Ingo Molnar <mingo@elte.hu> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: linux-kernel@vger.kernel.org LKML-Reference: <20110210090810.1809.26913.stgit@ltc236.sdl.hitachi.co.jp> Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Showing 2 changed files with 16 additions and 6 deletions Side-by-side Diff
tools/perf/Documentation/perf-probe.txt
... | ... | @@ -16,7 +16,7 @@ |
16 | 16 | or |
17 | 17 | 'perf probe' --list |
18 | 18 | or |
19 | -'perf probe' [options] --line='FUNC[:RLN[+NUM|:RLN2]]|SRC:ALN[+NUM|:ALN2]' | |
19 | +'perf probe' [options] --line='LINE' | |
20 | 20 | or |
21 | 21 | 'perf probe' [options] --vars='PROBEPOINT' |
22 | 22 | |
23 | 23 | |
... | ... | @@ -128,13 +128,14 @@ |
128 | 128 | ----------- |
129 | 129 | Line range is described by following syntax. |
130 | 130 | |
131 | - "FUNC[:RLN[+NUM|-RLN2]]|SRC[:ALN[+NUM|-ALN2]]" | |
131 | + "FUNC[@SRC][:RLN[+NUM|-RLN2]]|SRC[:ALN[+NUM|-ALN2]]" | |
132 | 132 | |
133 | 133 | FUNC specifies the function name of showing lines. 'RLN' is the start line |
134 | 134 | number from function entry line, and 'RLN2' is the end line number. As same as |
135 | 135 | probe syntax, 'SRC' means the source file path, 'ALN' is start line number, |
136 | 136 | and 'ALN2' is end line number in the file. It is also possible to specify how |
137 | -many lines to show by using 'NUM'. | |
137 | +many lines to show by using 'NUM'. Moreover, 'FUNC@SRC' combination is good | |
138 | +for searching a specific function when several functions share same name. | |
138 | 139 | So, "source.c:100-120" shows lines between 100th to l20th in source.c file. And "func:10+20" shows 20 lines from 10th line of func function. |
139 | 140 | |
140 | 141 | LAZY MATCHING |
tools/perf/util/probe-event.c
... | ... | @@ -595,11 +595,11 @@ |
595 | 595 | * The line range syntax is described by: |
596 | 596 | * |
597 | 597 | * SRC[:SLN[+NUM|-ELN]] |
598 | - * FNC[:SLN[+NUM|-ELN]] | |
598 | + * FNC[@SRC][:SLN[+NUM|-ELN]] | |
599 | 599 | */ |
600 | 600 | int parse_line_range_desc(const char *arg, struct line_range *lr) |
601 | 601 | { |
602 | - char *range, *name = strdup(arg); | |
602 | + char *range, *file, *name = strdup(arg); | |
603 | 603 | int err; |
604 | 604 | |
605 | 605 | if (!name) |
... | ... | @@ -649,7 +649,16 @@ |
649 | 649 | } |
650 | 650 | } |
651 | 651 | |
652 | - if (strchr(name, '.')) | |
652 | + file = strchr(name, '@'); | |
653 | + if (file) { | |
654 | + *file = '\0'; | |
655 | + lr->file = strdup(++file); | |
656 | + if (lr->file == NULL) { | |
657 | + err = -ENOMEM; | |
658 | + goto err; | |
659 | + } | |
660 | + lr->function = name; | |
661 | + } else if (strchr(name, '.')) | |
653 | 662 | lr->file = name; |
654 | 663 | else |
655 | 664 | lr->function = name; |