Skip to content

Commit

Permalink
perf probe: Support function@filename syntax for --line
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Masami Hiramatsu authored and Arnaldo Carvalho de Melo committed Feb 16, 2011
1 parent 4187e26 commit e116dfa
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
7 changes: 4 additions & 3 deletions tools/perf/Documentation/perf-probe.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ or
or
'perf probe' --list
or
'perf probe' [options] --line='FUNC[:RLN[+NUM|:RLN2]]|SRC:ALN[+NUM|:ALN2]'
'perf probe' [options] --line='LINE'
or
'perf probe' [options] --vars='PROBEPOINT'

Expand Down Expand Up @@ -128,13 +128,14 @@ LINE SYNTAX
-----------
Line range is described by following syntax.

"FUNC[:RLN[+NUM|-RLN2]]|SRC[:ALN[+NUM|-ALN2]]"
"FUNC[@SRC][:RLN[+NUM|-RLN2]]|SRC[:ALN[+NUM|-ALN2]]"

FUNC specifies the function name of showing lines. 'RLN' is the start line
number from function entry line, and 'RLN2' is the end line number. As same as
probe syntax, 'SRC' means the source file path, 'ALN' is start line number,
and 'ALN2' is end line number in the file. It is also possible to specify how
many lines to show by using 'NUM'.
many lines to show by using 'NUM'. Moreover, 'FUNC@SRC' combination is good
for searching a specific function when several functions share same name.
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.

LAZY MATCHING
Expand Down
15 changes: 12 additions & 3 deletions tools/perf/util/probe-event.c
Original file line number Diff line number Diff line change
Expand Up @@ -595,11 +595,11 @@ static int parse_line_num(char **ptr, int *val, const char *what)
* The line range syntax is described by:
*
* SRC[:SLN[+NUM|-ELN]]
* FNC[:SLN[+NUM|-ELN]]
* FNC[@SRC][:SLN[+NUM|-ELN]]
*/
int parse_line_range_desc(const char *arg, struct line_range *lr)
{
char *range, *name = strdup(arg);
char *range, *file, *name = strdup(arg);
int err;

if (!name)
Expand Down Expand Up @@ -649,7 +649,16 @@ int parse_line_range_desc(const char *arg, struct line_range *lr)
}
}

if (strchr(name, '.'))
file = strchr(name, '@');
if (file) {
*file = '\0';
lr->file = strdup(++file);
if (lr->file == NULL) {
err = -ENOMEM;
goto err;
}
lr->function = name;
} else if (strchr(name, '.'))
lr->file = name;
else
lr->function = name;
Expand Down

0 comments on commit e116dfa

Please sign in to comment.