diff options
author | Masami Hiramatsu (Google) <mhiramat@kernel.org> | 2024-11-07 17:52:31 +0300 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2024-11-14 22:56:32 +0300 |
commit | b9e577225c16fae9f5e4d3d642153c64b538c44e (patch) | |
tree | 81f3c126b1061b8116ff78316933f33d64578bcf /tools/perf | |
parent | 47fa0f99a9aa962bac8e6da09cb104e8da94e4df (diff) | |
download | linux-b9e577225c16fae9f5e4d3d642153c64b538c44e.tar.xz |
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 <mhiramat@kernel.org>
Cc: Alexander Lobakin <aleksander.lobakin@intel.com>
Cc: Dima Kogan <dima@secretsauce.net>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Link: https://lore.kernel.org/r/173099115149.2431889.13682110856853358354.stgit@mhiramat.roam.corp.google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/util/probe-event.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c index b9119391d373..c287e89dabcb 100644 --- a/tools/perf/util/probe-event.c +++ b/tools/perf/util/probe-event.c @@ -1360,6 +1360,8 @@ static bool is_c_func_name(const char *name) * * SRC[:SLN[+NUM|-ELN]] * FNC[@SRC][:SLN[+NUM|-ELN]] + * + * FNC@SRC accepts `FNC@*` which forcibly specify FNC as function name. */ int parse_line_range_desc(const char *arg, struct line_range *lr) { @@ -1415,13 +1417,21 @@ int parse_line_range_desc(const char *arg, struct line_range *lr) file = strpbrk_esc(name, "@"); if (file) { - *file = '\0'; - lr->file = strdup(++file); - if (lr->file == NULL) { - err = -ENOMEM; + *file++ = '\0'; + if (strcmp(file, "*")) { + lr->file = strdup_esc(file); + if (lr->file == NULL) { + err = -ENOMEM; + goto err; + } + } + if (*name != '\0') + lr->function = name; + if (!lr->function && !lr->file) { + semantic_error("Only '@*' is not allowed.\n"); + err = -EINVAL; goto err; } - lr->function = name; } else if (strpbrk_esc(name, "/.")) lr->file = name; 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) semantic_error("SRC@SRC is not allowed.\n"); return -EINVAL; } + if (!strcmp(arg, "*")) + break; pp->file = strdup_esc(arg); if (pp->file == NULL) return -ENOMEM; |