From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Tom Zanussi <zanussi@kernel.org>
Subject: [for-next][PATCH 09/12] tracing: Update synth command errors
Date: Wed, 10 Feb 2021 21:09:36 -0500 [thread overview]
Message-ID: <20210211020949.780243101@goodmis.org> (raw)
In-Reply-To: 20210211020927.829775774@goodmis.org
From: Tom Zanussi <zanussi@kernel.org>
Since array types are handled differently, errors referencing them
also need to be handled differently. Add and use a new
INVALID_ARRAY_SPEC error. Also add INVALID_CMD and INVALID_DYN_CMD to
catch and display the correct form for badly-formed commands, which
can also be used in place of CMD_INCOMPLETE, which is removed, and
remove CMD_TOO_LONG, since it's no longer used.
Link: https://lkml.kernel.org/r/b9dd434dc6458dcff11adc6ed616fe93a8794770.1612208610.git.zanussi@kernel.org
Signed-off-by: Tom Zanussi <zanussi@kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
kernel/trace/trace_events_synth.c | 30 +++++++++++++++++++-----------
1 file changed, 19 insertions(+), 11 deletions(-)
diff --git a/kernel/trace/trace_events_synth.c b/kernel/trace/trace_events_synth.c
index 4f6c5a104ee2..aace72426e99 100644
--- a/kernel/trace/trace_events_synth.c
+++ b/kernel/trace/trace_events_synth.c
@@ -23,13 +23,14 @@
#undef ERRORS
#define ERRORS \
C(BAD_NAME, "Illegal name"), \
- C(CMD_INCOMPLETE, "Incomplete command"), \
+ C(INVALID_CMD, "Command must be of the form: <name> field[;field] ..."),\
+ C(INVALID_DYN_CMD, "Command must be of the form: s or -:[synthetic/]<name> field[;field] ..."),\
C(EVENT_EXISTS, "Event already exists"), \
C(TOO_MANY_FIELDS, "Too many fields"), \
C(INCOMPLETE_TYPE, "Incomplete type"), \
C(INVALID_TYPE, "Invalid type"), \
- C(INVALID_FIELD, "Invalid field"), \
- C(CMD_TOO_LONG, "Command too long"),
+ C(INVALID_FIELD, "Invalid field"), \
+ C(INVALID_ARRAY_SPEC, "Invalid array specification"),
#undef C
#define C(a, b) SYNTH_ERR_##a
@@ -655,7 +656,10 @@ static struct synth_field *parse_synth_field(int argc, char **argv)
size = synth_field_size(field->type);
if (size < 0) {
- synth_err(SYNTH_ERR_INVALID_TYPE, errpos(field_type));
+ if (array)
+ synth_err(SYNTH_ERR_INVALID_ARRAY_SPEC, errpos(field_name));
+ else
+ synth_err(SYNTH_ERR_INVALID_TYPE, errpos(field_type));
ret = -EINVAL;
goto free;
} else if (size == 0) {
@@ -1174,7 +1178,7 @@ static int __create_synth_event(const char *name, const char *raw_fields)
*/
if (name[0] == '\0') {
- synth_err(SYNTH_ERR_CMD_INCOMPLETE, 0);
+ synth_err(SYNTH_ERR_INVALID_CMD, 0);
return -EINVAL;
}
@@ -1226,7 +1230,7 @@ static int __create_synth_event(const char *name, const char *raw_fields)
}
if (n_fields == 0) {
- synth_err(SYNTH_ERR_CMD_INCOMPLETE, 0);
+ synth_err(SYNTH_ERR_INVALID_CMD, 0);
ret = -EINVAL;
goto err;
}
@@ -1410,13 +1414,13 @@ static int create_or_delete_synth_event(const char *raw_command)
ret = check_command(raw_command);
if (ret) {
- synth_err(SYNTH_ERR_CMD_INCOMPLETE, 0);
+ synth_err(SYNTH_ERR_INVALID_CMD, 0);
return ret;
}
p = strpbrk(raw_command, " \t");
if (!p && raw_command[0] != '!') {
- synth_err(SYNTH_ERR_CMD_INCOMPLETE, 0);
+ synth_err(SYNTH_ERR_INVALID_CMD, 0);
ret = -EINVAL;
goto free;
}
@@ -1993,8 +1997,10 @@ static int create_synth_event(const char *raw_command)
last_cmd_set(raw_command);
p = strpbrk(raw_command, " \t");
- if (!p)
+ if (!p) {
+ synth_err(SYNTH_ERR_INVALID_CMD, 0);
return -EINVAL;
+ }
fields = skip_spaces(p);
@@ -2007,8 +2013,10 @@ static int create_synth_event(const char *raw_command)
/* This interface accepts group name prefix */
if (strchr(name, '/')) {
len = str_has_prefix(name, SYNTH_SYSTEM "/");
- if (len == 0)
+ if (len == 0) {
+ synth_err(SYNTH_ERR_INVALID_DYN_CMD, 0);
return -EINVAL;
+ }
name += len;
}
@@ -2016,7 +2024,7 @@ static int create_synth_event(const char *raw_command)
ret = check_command(raw_command + len);
if (ret) {
- synth_err(SYNTH_ERR_CMD_INCOMPLETE, 0);
+ synth_err(SYNTH_ERR_INVALID_CMD, 0);
return ret;
}
--
2.29.2
next prev parent reply other threads:[~2021-02-11 2:13 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-11 2:09 [for-next][PATCH 00/12] tracing: Updates for 5.12 Steven Rostedt
2021-02-11 2:09 ` [for-next][PATCH 01/12] tracing: Do not create "enable" or "filter" files for ftrace event subsystem Steven Rostedt
2021-02-11 2:09 ` [for-next][PATCH 02/12] tracepoints: Remove unnecessary "data_args" macro parameter Steven Rostedt
2021-02-11 2:09 ` [for-next][PATCH 03/12] tracepoints: Do not punish non static call users Steven Rostedt
2021-02-11 2:09 ` [for-next][PATCH 04/12] tracepoints: Code clean up Steven Rostedt
2021-02-11 2:09 ` [for-next][PATCH 05/12] ftrace: Remove unused ftrace_force_update() Steven Rostedt
2021-02-11 2:09 ` [for-next][PATCH 06/12] kprobes: Warn if the kprobe is reregistered Steven Rostedt
2021-02-11 2:09 ` [for-next][PATCH 07/12] tracing/dynevent: Delegate parsing to create function Steven Rostedt
2021-02-11 2:09 ` [for-next][PATCH 08/12] tracing: Rework synthetic event command parsing Steven Rostedt
2021-02-11 2:09 ` Steven Rostedt [this message]
2021-02-11 2:09 ` [for-next][PATCH 10/12] tracing: Add a backward-compatibility check for synthetic event creation Steven Rostedt
2021-02-11 2:09 ` [for-next][PATCH 11/12] selftests/ftrace: Update synthetic event syntax errors Steven Rostedt
2021-02-11 2:09 ` [for-next][PATCH 12/12] selftests/ftrace: Add !event synthetic event syntax check Steven Rostedt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210211020949.780243101@goodmis.org \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=zanussi@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.