Skip to content

Commit b9e5772

Browse files
mhiramatacmel
authored andcommitted
perf probe: Accept FUNC@* to specify function name explicitly
In Golang, the function name will have the '.', and 'perf probe' misinterprets it as a file name. To mitigate this situation, introduce `function@*` so that user can explicitly specify that it is a function name. Signed-off-by: Masami Hiramatsu <[email protected]> Cc: Alexander Lobakin <[email protected]> Cc: Dima Kogan <[email protected]> Cc: Ian Rogers <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Przemek Kitszel <[email protected]> Link: https://lore.kernel.org/r/173099115149.2431889.13682110856853358354.stgit@mhiramat.roam.corp.google.com Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 47fa0f9 commit b9e5772

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

tools/perf/util/probe-event.c

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,6 +1360,8 @@ static bool is_c_func_name(const char *name)
13601360
*
13611361
* SRC[:SLN[+NUM|-ELN]]
13621362
* FNC[@SRC][:SLN[+NUM|-ELN]]
1363+
*
1364+
* FNC@SRC accepts `FNC@*` which forcibly specify FNC as function name.
13631365
*/
13641366
int parse_line_range_desc(const char *arg, struct line_range *lr)
13651367
{
@@ -1415,13 +1417,21 @@ int parse_line_range_desc(const char *arg, struct line_range *lr)
14151417

14161418
file = strpbrk_esc(name, "@");
14171419
if (file) {
1418-
*file = '\0';
1419-
lr->file = strdup(++file);
1420-
if (lr->file == NULL) {
1421-
err = -ENOMEM;
1420+
*file++ = '\0';
1421+
if (strcmp(file, "*")) {
1422+
lr->file = strdup_esc(file);
1423+
if (lr->file == NULL) {
1424+
err = -ENOMEM;
1425+
goto err;
1426+
}
1427+
}
1428+
if (*name != '\0')
1429+
lr->function = name;
1430+
if (!lr->function && !lr->file) {
1431+
semantic_error("Only '@*' is not allowed.\n");
1432+
err = -EINVAL;
14221433
goto err;
14231434
}
1424-
lr->function = name;
14251435
} else if (strpbrk_esc(name, "/."))
14261436
lr->file = name;
14271437
else if (is_c_func_name(name))/* We reuse it for checking funcname */
@@ -1622,6 +1632,8 @@ static int parse_perf_probe_point(char *arg, struct perf_probe_event *pev)
16221632
semantic_error("SRC@SRC is not allowed.\n");
16231633
return -EINVAL;
16241634
}
1635+
if (!strcmp(arg, "*"))
1636+
break;
16251637
pp->file = strdup_esc(arg);
16261638
if (pp->file == NULL)
16271639
return -ENOMEM;

0 commit comments

Comments
 (0)