diff options
Diffstat (limited to 'tools/lib/traceevent/event-parse.c')
-rw-r--r-- | tools/lib/traceevent/event-parse.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c index a46cae701db7..1373e4cf109e 100644 --- a/tools/lib/traceevent/event-parse.c +++ b/tools/lib/traceevent/event-parse.c | |||
@@ -4795,6 +4795,49 @@ enum pevent_errno pevent_parse_event(struct pevent *pevent, const char *buf, | |||
4795 | return ret; | 4795 | return ret; |
4796 | } | 4796 | } |
4797 | 4797 | ||
4798 | #undef _PE | ||
4799 | #define _PE(code, str) str | ||
4800 | static const char * const pevent_error_str[] = { | ||
4801 | PEVENT_ERRORS | ||
4802 | }; | ||
4803 | #undef _PE | ||
4804 | |||
4805 | int pevent_strerror(struct pevent *pevent, enum pevent_errno errnum, | ||
4806 | char *buf, size_t buflen) | ||
4807 | { | ||
4808 | int idx; | ||
4809 | const char *msg; | ||
4810 | |||
4811 | if (errnum >= 0) { | ||
4812 | strerror_r(errnum, buf, buflen); | ||
4813 | return 0; | ||
4814 | } | ||
4815 | |||
4816 | if (errnum <= __PEVENT_ERRNO__START || | ||
4817 | errnum >= __PEVENT_ERRNO__END) | ||
4818 | return -1; | ||
4819 | |||
4820 | idx = errnum - __PEVENT_ERRNO__START; | ||
4821 | msg = pevent_error_str[idx]; | ||
4822 | |||
4823 | switch (errnum) { | ||
4824 | case PEVENT_ERRNO__MEM_ALLOC_FAILED: | ||
4825 | case PEVENT_ERRNO__PARSE_EVENT_FAILED: | ||
4826 | case PEVENT_ERRNO__READ_ID_FAILED: | ||
4827 | case PEVENT_ERRNO__READ_FORMAT_FAILED: | ||
4828 | case PEVENT_ERRNO__READ_PRINT_FAILED: | ||
4829 | case PEVENT_ERRNO__OLD_FTRACE_ARG_FAILED: | ||
4830 | snprintf(buf, buflen, "%s", msg); | ||
4831 | break; | ||
4832 | |||
4833 | default: | ||
4834 | /* cannot reach here */ | ||
4835 | break; | ||
4836 | } | ||
4837 | |||
4838 | return 0; | ||
4839 | } | ||
4840 | |||
4798 | int get_field_val(struct trace_seq *s, struct format_field *field, | 4841 | int get_field_val(struct trace_seq *s, struct format_field *field, |
4799 | const char *name, struct pevent_record *record, | 4842 | const char *name, struct pevent_record *record, |
4800 | unsigned long long *val, int err) | 4843 | unsigned long long *val, int err) |