[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <173099115149.2431889.13682110856853358354.stgit@mhiramat.roam.corp.google.com>
Date: Thu, 7 Nov 2024 23:52:31 +0900
From: "Masami Hiramatsu (Google)" <mhiramat@...nel.org>
To: Arnaldo Carvalho de Melo <acme@...nel.org>,
Namhyung Kim <namhyung@...nel.org>
Cc: Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>,
Masami Hiramatsu <mhiramat@...nel.org>,
Ian Rogers <irogers@...gle.com>,
Dima Kogan <dima@...retsauce.net>,
Alexander Lobakin <aleksander.lobakin@...el.com>,
Przemek Kitszel <przemyslaw.kitszel@...el.com>,
linux-perf-users@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH v2 3/6] perf-probe: Accept FUNC@* to specify function name explicitly
From: Masami Hiramatsu (Google) <mhiramat@...nel.org>
In Golang, the function name will have the '.', and perf probe
misinterpret it is a file name. To mitigate this situation, introduce
`function@*` so that user can explicitly specify that is a function
name.
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@...nel.org>
---
Changes in v2:
- Added new patch.
---
tools/perf/util/probe-event.c | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index edc205e4b0ee..777ef00f0d3f 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -1357,6 +1357,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)
{
@@ -1412,13 +1414,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 */
@@ -1619,6 +1629,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;
Powered by blists - more mailing lists