diff options
author | Namhyung Kim <namhyung.kim@lge.com> | 2012-08-22 03:00:30 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-08-22 15:03:39 -0400 |
commit | 2f197b9d7eeaa723a80243610956fe4a17e7b5a4 (patch) | |
tree | b5f8181066874ece8cff95a5a0e8b18857cb5de7 /tools/lib/traceevent/event-parse.h | |
parent | bffddffde7f9bd093909235a25dbb806fe639dde (diff) |
tools lib traceevent: Introduce pevent_strerror
The pevent_strerror() sets @buf to a string that describes the
(libtraceevent-specific) error condition that is passed via @errnum.
This is similar to strerror_r() and does same thing if @errnum has a
standard errno value.
To sync error string with its code, define PEVENT_ERRORS with _PE()
macro and use it as suggested by Steven.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Steven Rostedt <rostedt@goodmis.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/1345618831-9148-4-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/lib/traceevent/event-parse.h')
-rw-r--r-- | tools/lib/traceevent/event-parse.h | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h index 3c48229a7bce..527df038a25f 100644 --- a/tools/lib/traceevent/event-parse.h +++ b/tools/lib/traceevent/event-parse.h | |||
@@ -345,6 +345,16 @@ enum pevent_flag { | |||
345 | PEVENT_NSEC_OUTPUT = 1, /* output in NSECS */ | 345 | PEVENT_NSEC_OUTPUT = 1, /* output in NSECS */ |
346 | }; | 346 | }; |
347 | 347 | ||
348 | #define PEVENT_ERRORS \ | ||
349 | _PE(MEM_ALLOC_FAILED, "failed to allocate memory"), \ | ||
350 | _PE(PARSE_EVENT_FAILED, "failed to parse event"), \ | ||
351 | _PE(READ_ID_FAILED, "failed to read event id"), \ | ||
352 | _PE(READ_FORMAT_FAILED, "failed to read event format"), \ | ||
353 | _PE(READ_PRINT_FAILED, "failed to read event print fmt"), \ | ||
354 | _PE(OLD_FTRACE_ARG_FAILED,"failed to allocate field name for ftrace") | ||
355 | |||
356 | #undef _PE | ||
357 | #define _PE(__code, __str) PEVENT_ERRNO__ ## __code | ||
348 | enum pevent_errno { | 358 | enum pevent_errno { |
349 | PEVENT_ERRNO__SUCCESS = 0, | 359 | PEVENT_ERRNO__SUCCESS = 0, |
350 | 360 | ||
@@ -357,15 +367,11 @@ enum pevent_errno { | |||
357 | */ | 367 | */ |
358 | __PEVENT_ERRNO__START = -100000, | 368 | __PEVENT_ERRNO__START = -100000, |
359 | 369 | ||
360 | PEVENT_ERRNO__MEM_ALLOC_FAILED = __PEVENT_ERRNO__START, | 370 | PEVENT_ERRORS, |
361 | PEVENT_ERRNO__PARSE_EVENT_FAILED, | ||
362 | PEVENT_ERRNO__READ_ID_FAILED, | ||
363 | PEVENT_ERRNO__READ_FORMAT_FAILED, | ||
364 | PEVENT_ERRNO__READ_PRINT_FAILED, | ||
365 | PEVENT_ERRNO__OLD_FTRACE_ARG_FAILED, | ||
366 | 371 | ||
367 | __PEVENT_ERRNO__END, | 372 | __PEVENT_ERRNO__END, |
368 | }; | 373 | }; |
374 | #undef _PE | ||
369 | 375 | ||
370 | struct cmdline; | 376 | struct cmdline; |
371 | struct cmdline_list; | 377 | struct cmdline_list; |
@@ -583,6 +589,8 @@ int pevent_data_pid(struct pevent *pevent, struct pevent_record *rec); | |||
583 | const char *pevent_data_comm_from_pid(struct pevent *pevent, int pid); | 589 | const char *pevent_data_comm_from_pid(struct pevent *pevent, int pid); |
584 | void pevent_event_info(struct trace_seq *s, struct event_format *event, | 590 | void pevent_event_info(struct trace_seq *s, struct event_format *event, |
585 | struct pevent_record *record); | 591 | struct pevent_record *record); |
592 | int pevent_strerror(struct pevent *pevent, enum pevent_errno errnum, | ||
593 | char *buf, size_t buflen); | ||
586 | 594 | ||
587 | struct event_format **pevent_list_events(struct pevent *pevent, enum event_sort_type); | 595 | struct event_format **pevent_list_events(struct pevent *pevent, enum event_sort_type); |
588 | struct format_field **pevent_event_common_fields(struct event_format *event); | 596 | struct format_field **pevent_event_common_fields(struct event_format *event); |