@@ -371,3 +371,30 @@ void tep_set_test_filters(struct tep_handle *tep, int test_filters)
if (tep)
tep->test_filters = test_filters;
}
+
+/**
+ * tep_get_parsing_failures - get the count of parsing failures
+ * @tep: a handle to a tep_handle
+ *
+ * Every time when tep_parse_event() fails to parse an event format file,
+ * a parsing failure is registered. This returns the parsing failures count.
+ */
+int tep_get_parsing_failures(struct tep_handle *tep)
+{
+ if (tep)
+ return tep->parsing_failures;
+ return 0;
+}
+
+/**
+ * tep_clear_parsing_failures - clear parsing failures count
+ * @tep: a handle to a tep_handle
+ *
+ * Every time when tep_parse_event() fails to parse an event format file,
+ * a parsing failure is registered. This clears the parsing failures counter.
+ */
+void tep_clear_parsing_failures(struct tep_handle *tep)
+{
+ if (tep)
+ tep->parsing_failures = 0;
+}
@@ -83,6 +83,8 @@ struct tep_handle {
struct event_handler *handlers;
struct tep_function_handler *func_handlers;
+ int parsing_failures;
+
/* cache */
struct tep_event *last_event;
@@ -6230,7 +6230,13 @@ enum tep_errno tep_parse_event(struct tep_handle *pevent, const char *buf,
unsigned long size, const char *sys)
{
struct tep_event *event = NULL;
- return __parse_event(pevent, &event, buf, size, sys);
+ enum tep_errno ret;
+
+ ret = __parse_event(pevent, &event, buf, size, sys);
+ if (ret != TEP_ERRNO__SUCCESS)
+ pevent->parsing_failures++;
+
+ return ret;
}
int get_field_val(struct trace_seq *s, struct tep_format_field *field,
@@ -464,6 +464,8 @@ enum tep_errno tep_parse_format(struct tep_handle *pevent,
struct tep_event **eventp,
const char *buf,
unsigned long size, const char *sys);
+int tep_get_parsing_failures(struct tep_handle *tep);
+void tep_clear_parsing_failures(struct tep_handle *tep);
void *tep_get_field_raw(struct trace_seq *s, struct tep_event *event,
const char *name, struct tep_record *record,
This patch adds a parsing failures counter to struct tep_handle. The counter can be used to track failures on parsing event format files. It is updated automatically by tep_parse_event(), when failure is detected. The patch also adds two new APIs for accessing the counter: tep_get_parsing_failures() - returns the current value of the counter. tep_clear_parsing_failures() - clears the counter. Signed-off-by: Tzvetomir Stoyanov <tstoyanov@vmware.com> --- tools/lib/traceevent/event-parse-api.c | 27 ++++++++++++++++++++++++ tools/lib/traceevent/event-parse-local.h | 2 ++ tools/lib/traceevent/event-parse.c | 8 ++++++- tools/lib/traceevent/event-parse.h | 2 ++ 4 files changed, 38 insertions(+), 1 deletion(-)