Merge tag 'arm64-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64...
[cascardo/linux.git] / tools / lib / traceevent / event-parse.h
index abdfd3c..791c539 100644 (file)
@@ -58,6 +58,12 @@ struct pevent_record {
 #endif
 };
 
+enum trace_seq_fail {
+       TRACE_SEQ__GOOD,
+       TRACE_SEQ__BUFFER_POISONED,
+       TRACE_SEQ__MEM_ALLOC_FAILED,
+};
+
 /*
  * Trace sequences are used to allow a function to call several other functions
  * to create a string of data to use (up to a max of PAGE_SIZE).
@@ -68,6 +74,7 @@ struct trace_seq {
        unsigned int            buffer_size;
        unsigned int            len;
        unsigned int            readpos;
+       enum trace_seq_fail     state;
 };
 
 void trace_seq_init(struct trace_seq *s);
@@ -98,7 +105,7 @@ typedef int (*pevent_event_handler_func)(struct trace_seq *s,
                                         void *context);
 
 typedef int (*pevent_plugin_load_func)(struct pevent *pevent);
-typedef int (*pevent_plugin_unload_func)(void);
+typedef int (*pevent_plugin_unload_func)(struct pevent *pevent);
 
 struct plugin_option {
        struct plugin_option            *next;
@@ -123,7 +130,7 @@ struct plugin_option {
  * PEVENT_PLUGIN_UNLOADER:  (optional)
  *   The function called just before unloading
  *
- *   int PEVENT_PLUGIN_UNLOADER(void)
+ *   int PEVENT_PLUGIN_UNLOADER(struct pevent *pevent)
  *
  * PEVENT_PLUGIN_OPTIONS:  (optional)
  *   Plugin options that can be set before loading
@@ -357,13 +364,34 @@ enum pevent_flag {
        _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_EXP_TYPE,   "invalid expression type"),                   \
+       _PE(INVALID_OP_TYPE,    "invalid operator type"),                     \
        _PE(INVALID_EVENT_NAME, "invalid event name"),                        \
-       _PE(EVENT_NOT_FOUND,    "No event found")
+       _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"),                             \
+       _PE(FILTER_NOT_FOUND,   "no filter found"),                           \
+       _PE(NOT_A_NUMBER,       "must have number field"),                    \
+       _PE(NO_FILTER,          "no filters exists"),                         \
+       _PE(FILTER_MISS,        "record does not match to filter")
 
 #undef _PE
 #define _PE(__code, __str) PEVENT_ERRNO__ ## __code
 enum pevent_errno {
        PEVENT_ERRNO__SUCCESS                   = 0,
+       PEVENT_ERRNO__FILTER_MATCH              = PEVENT_ERRNO__SUCCESS,
 
        /*
         * Choose an arbitrary negative big number not to clash with standard
@@ -383,7 +411,8 @@ enum pevent_errno {
 struct plugin_list;
 
 struct plugin_list *traceevent_load_plugins(struct pevent *pevent);
-void traceevent_unload_plugins(struct plugin_list *plugin_list);
+void traceevent_unload_plugins(struct plugin_list *plugin_list,
+                              struct pevent *pevent);
 
 struct cmdline;
 struct cmdline_list;
@@ -595,10 +624,15 @@ int pevent_print_func_field(struct trace_seq *s, const char *fmt,
 int pevent_register_event_handler(struct pevent *pevent, int id,
                                  const char *sys_name, const char *event_name,
                                  pevent_event_handler_func func, void *context);
+int pevent_unregister_event_handler(struct pevent *pevent, int id,
+                                   const char *sys_name, const char *event_name,
+                                   pevent_event_handler_func func, void *context);
 int pevent_register_print_function(struct pevent *pevent,
                                   pevent_func_handler func,
                                   enum pevent_func_arg_type ret_type,
                                   char *name, ...);
+int pevent_unregister_print_function(struct pevent *pevent,
+                                    pevent_func_handler func, char *name);
 
 struct format_field *pevent_find_common_field(struct event_format *event, const char *name);
 struct format_field *pevent_find_field(struct event_format *event, const char *name);
@@ -830,18 +864,22 @@ struct filter_type {
        struct filter_arg       *filter;
 };
 
+#define PEVENT_FILTER_ERROR_BUFSZ  1024
+
 struct event_filter {
        struct pevent           *pevent;
        int                     filters;
        struct filter_type      *event_filters;
+       char                    error_buffer[PEVENT_FILTER_ERROR_BUFSZ];
 };
 
 struct event_filter *pevent_filter_alloc(struct pevent *pevent);
 
-#define FILTER_NONE            -2
-#define FILTER_NOEXIST         -1
-#define FILTER_MISS            0
-#define FILTER_MATCH           1
+/* for backward compatibility */
+#define FILTER_NONE            PEVENT_ERRNO__FILTER_NOT_FOUND
+#define FILTER_NOEXIST         PEVENT_ERRNO__NO_FILTER
+#define FILTER_MISS            PEVENT_ERRNO__FILTER_MISS
+#define FILTER_MATCH           PEVENT_ERRNO__FILTER_MATCH
 
 enum filter_trivial_type {
        FILTER_TRIVIAL_FALSE,
@@ -849,13 +887,14 @@ enum filter_trivial_type {
        FILTER_TRIVIAL_BOTH,
 };
 
-int pevent_filter_add_filter_str(struct event_filter *filter,
-                                const char *filter_str,
-                                char **error_str);
+enum pevent_errno pevent_filter_add_filter_str(struct event_filter *filter,
+                                              const char *filter_str);
 
+enum pevent_errno pevent_filter_match(struct event_filter *filter,
+                                     struct pevent_record *record);
 
-int pevent_filter_match(struct event_filter *filter,
-                       struct pevent_record *record);
+int pevent_filter_strerror(struct event_filter *filter, enum pevent_errno err,
+                          char *buf, size_t buflen);
 
 int pevent_event_filtered(struct event_filter *filter,
                          int event_id);