diff options
author | Steven Rostedt (Google) <rostedt@goodmis.org> | 2022-02-21 15:44:18 -0500 |
---|---|---|
committer | Steven Rostedt (Google) <rostedt@goodmis.org> | 2022-02-21 16:13:06 -0500 |
commit | 69d59c8bf4c732afb537acfc4c324f10d2484704 (patch) | |
tree | 56ebfa9bc2e8a750e02ee3728d67107a4003c01e | |
parent | e4391d720f086bc9ea95770f37c6b02eefaad489 (diff) | |
download | libtraceevent-69d59c8bf4c732afb537acfc4c324f10d2484704.tar.gz |
libtraceevent: Show what the failed expected tokens are
Instead of just showing a very cryptic message of what enum type was
expected and failed during parsing, at least include the name of said
type.
Link: https://lore.kernel.org/linux-trace-devel/20220221154418.2449fa19@rorschach.local.home
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
-rw-r--r-- | src/event-parse.c | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/src/event-parse.c b/src/event-parse.c index 2b346a5..11557b1 100644 --- a/src/event-parse.c +++ b/src/event-parse.c @@ -114,6 +114,22 @@ void breakpoint(void) x++; } +static const char *get_event_type(enum tep_event_type type) +{ + switch (type) { + case TEP_EVENT_ERROR: return "ERROR"; + case TEP_EVENT_NONE: return "NONE"; + case TEP_EVENT_SPACE: return "SPACE"; + case TEP_EVENT_NEWLINE: return "NEWLINE"; + case TEP_EVENT_OP: return "OP"; + case TEP_EVENT_DELIM: return "DELIM"; + case TEP_EVENT_ITEM: return "ITEM"; + case TEP_EVENT_DQUOTE: return "DQUOTE"; + case TEP_EVENT_SQUOTE: return "SQUOTE"; + } + return "(UNKNOWN)"; +} + static struct tep_print_arg *alloc_arg(void) { return calloc(1, sizeof(struct tep_print_arg)); @@ -1401,8 +1417,9 @@ static enum tep_event_type read_token_item(char **tok) static int test_type(enum tep_event_type type, enum tep_event_type expect) { if (type != expect) { - do_warning("Error: expected type %d but read %d", - expect, type); + do_warning("Error: expected type %d (%s) but read %d (%s)", + expect, get_event_type(expect), + type, get_event_type(type)); return -1; } return 0; @@ -1412,8 +1429,9 @@ static int test_type_token(enum tep_event_type type, const char *token, enum tep_event_type expect, const char *expect_tok) { if (type != expect) { - do_warning("Error: expected type %d but read %d", - expect, type); + do_warning("Error: expected type %d (%s) but read %d (%s)", + expect, get_event_type(expect), + type, get_event_type(type)); return -1; } |