tools lib traceevent: Refactor process_filter()
[firefly-linux-kernel-4.4.55.git] / tools / lib / traceevent / event-parse.h
index 8d73d2594f65de39c4a0c9d35c976847e30ab0fe..da942d59cc3ae5bf486a97426632ef4acf4bb3ac 100644 (file)
@@ -23,6 +23,7 @@
 #include <stdbool.h>
 #include <stdarg.h>
 #include <regex.h>
+#include <string.h>
 
 #ifndef __maybe_unused
 #define __maybe_unused __attribute__((unused))
@@ -355,7 +356,23 @@ enum pevent_flag {
        _PE(READ_FORMAT_FAILED, "failed to read event format"),               \
        _PE(READ_PRINT_FAILED,  "failed to read event print fmt"),            \
        _PE(OLD_FTRACE_ARG_FAILED,"failed to allocate field name for ftrace"),\
-       _PE(INVALID_ARG_TYPE,   "invalid argument type")
+       _PE(INVALID_ARG_TYPE,   "invalid argument type"),                     \
+       _PE(INVALID_EVENT_NAME, "invalid event name"),                        \
+       _PE(EVENT_NOT_FOUND,    "no event found"),                            \
+       _PE(SYNTAX_ERROR,       "syntax error"),                              \
+       _PE(ILLEGAL_RVALUE,     "illegal rvalue"),                            \
+       _PE(ILLEGAL_LVALUE,     "illegal lvalue for string comparison"),      \
+       _PE(INVALID_REGEX,      "regex did not compute"),                     \
+       _PE(ILLEGAL_STRING_CMP, "illegal comparison for string"),             \
+       _PE(ILLEGAL_INTEGER_CMP,"illegal comparison for integer"),            \
+       _PE(REPARENT_NOT_OP,    "cannot reparent other than OP"),             \
+       _PE(REPARENT_FAILED,    "failed to reparent filter OP"),              \
+       _PE(BAD_FILTER_ARG,     "bad arg in filter tree"),                    \
+       _PE(UNEXPECTED_TYPE,    "unexpected type (not a value)"),             \
+       _PE(ILLEGAL_TOKEN,      "illegal token"),                             \
+       _PE(INVALID_PAREN,      "open parenthesis cannot come here"),         \
+       _PE(UNBALANCED_PAREN,   "unbalanced number of parenthesis"),          \
+       _PE(UNKNOWN_TOKEN,      "unknown token")
 
 #undef _PE
 #define _PE(__code, __str) PEVENT_ERRNO__ ## __code
@@ -377,6 +394,11 @@ enum pevent_errno {
 };
 #undef _PE
 
+struct plugin_list;
+
+struct plugin_list *traceevent_load_plugins(struct pevent *pevent);
+void traceevent_unload_plugins(struct plugin_list *plugin_list);
+
 struct cmdline;
 struct cmdline_list;
 struct func_map;
@@ -522,6 +544,15 @@ __data2host8(struct pevent *pevent, unsigned long long data)
        __data2host8(pevent, __val);                            \
 })
 
+static inline int traceevent_host_bigendian(void)
+{
+       unsigned char str[] = { 0x1, 0x2, 0x3, 0x4 };
+       unsigned int val;
+
+       memcpy(&val, str, 4);
+       return val == 0x01020304;
+}
+
 /* taken from kernel/trace/trace.h */
 enum trace_flag_type {
        TRACE_FLAG_IRQS_OFF             = 0x01,
@@ -547,7 +578,9 @@ int pevent_parse_header_page(struct pevent *pevent, char *buf, unsigned long siz
 
 enum pevent_errno pevent_parse_event(struct pevent *pevent, const char *buf,
                                     unsigned long size, const char *sys);
-enum pevent_errno pevent_parse_format(struct event_format **eventp, const char *buf,
+enum pevent_errno pevent_parse_format(struct pevent *pevent,
+                                     struct event_format **eventp,
+                                     const char *buf,
                                      unsigned long size, const char *sys);
 void pevent_free_format(struct event_format *event);
 
@@ -843,7 +876,7 @@ int pevent_event_filtered(struct event_filter *filter,
 
 void pevent_filter_reset(struct event_filter *filter);
 
-void pevent_filter_clear_trivial(struct event_filter *filter,
+int pevent_filter_clear_trivial(struct event_filter *filter,
                                 enum filter_trivial_type type);
 
 void pevent_filter_free(struct event_filter *filter);