Commit 64e23790 authored by Tzvetomir Stoyanov (VMware)'s avatar Tzvetomir Stoyanov (VMware) Committed by Arnaldo Carvalho de Melo

tools lib traceevent: Rename pevent_filter* APIs

In order to make libtraceevent into a proper library, variables, data
structures and functions require a unique prefix to prevent name space
conflicts. That prefix will be "tep_" and not "pevent_". This changes
APIs: PEVENT_FILTER_ERROR_BUFSZ, pevent_filter_alloc,
pevent_filter_add_filter_str, pevent_filter_match, pevent_filter_strerror,
pevent_event_filtered, pevent_filter_reset, pevent_filter_clear_trivial,
pevent_filter_free, pevent_filter_make_string, pevent_filter_remove_event,
pevent_filter_event_has_trivial, pevent_filter_copy, pevent_update_trivial,
pevent_filter_compare
Signed-off-by: default avatarTzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
Cc: linux-trace-devel@vger.kernel.org
Link: http://lkml.kernel.org/r/20180808180702.370659353@goodmis.orgSigned-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent ca2921dd
...@@ -930,16 +930,16 @@ struct filter_type { ...@@ -930,16 +930,16 @@ struct filter_type {
struct filter_arg *filter; struct filter_arg *filter;
}; };
#define PEVENT_FILTER_ERROR_BUFSZ 1024 #define TEP_FILTER_ERROR_BUFSZ 1024
struct event_filter { struct event_filter {
struct tep_handle *pevent; struct tep_handle *pevent;
int filters; int filters;
struct filter_type *event_filters; struct filter_type *event_filters;
char error_buffer[PEVENT_FILTER_ERROR_BUFSZ]; char error_buffer[TEP_FILTER_ERROR_BUFSZ];
}; };
struct event_filter *pevent_filter_alloc(struct tep_handle *pevent); struct event_filter *tep_filter_alloc(struct tep_handle *pevent);
/* for backward compatibility */ /* for backward compatibility */
#define FILTER_NONE TEP_ERRNO__NO_FILTER #define FILTER_NONE TEP_ERRNO__NO_FILTER
...@@ -953,39 +953,39 @@ enum filter_trivial_type { ...@@ -953,39 +953,39 @@ enum filter_trivial_type {
FILTER_TRIVIAL_BOTH, FILTER_TRIVIAL_BOTH,
}; };
enum tep_errno pevent_filter_add_filter_str(struct event_filter *filter, enum tep_errno tep_filter_add_filter_str(struct event_filter *filter,
const char *filter_str); const char *filter_str);
enum tep_errno pevent_filter_match(struct event_filter *filter, enum tep_errno tep_filter_match(struct event_filter *filter,
struct tep_record *record); struct tep_record *record);
int pevent_filter_strerror(struct event_filter *filter, enum tep_errno err, int tep_filter_strerror(struct event_filter *filter, enum tep_errno err,
char *buf, size_t buflen); char *buf, size_t buflen);
int pevent_event_filtered(struct event_filter *filter, int tep_event_filtered(struct event_filter *filter,
int event_id); int event_id);
void pevent_filter_reset(struct event_filter *filter); void tep_filter_reset(struct event_filter *filter);
int pevent_filter_clear_trivial(struct event_filter *filter, int tep_filter_clear_trivial(struct event_filter *filter,
enum filter_trivial_type type); enum filter_trivial_type type);
void pevent_filter_free(struct event_filter *filter); void tep_filter_free(struct event_filter *filter);
char *pevent_filter_make_string(struct event_filter *filter, int event_id); char *tep_filter_make_string(struct event_filter *filter, int event_id);
int pevent_filter_remove_event(struct event_filter *filter, int tep_filter_remove_event(struct event_filter *filter,
int event_id); int event_id);
int pevent_filter_event_has_trivial(struct event_filter *filter, int tep_filter_event_has_trivial(struct event_filter *filter,
int event_id, int event_id,
enum filter_trivial_type type); enum filter_trivial_type type);
int pevent_filter_copy(struct event_filter *dest, struct event_filter *source); int tep_filter_copy(struct event_filter *dest, struct event_filter *source);
int pevent_update_trivial(struct event_filter *dest, struct event_filter *source, int tep_update_trivial(struct event_filter *dest, struct event_filter *source,
enum filter_trivial_type type); enum filter_trivial_type type);
int pevent_filter_compare(struct event_filter *filter1, struct event_filter *filter2); int tep_filter_compare(struct event_filter *filter1, struct event_filter *filter2);
#endif /* _PARSE_EVENTS_H */ #endif /* _PARSE_EVENTS_H */
...@@ -66,7 +66,7 @@ static void show_error(char *error_buf, const char *fmt, ...) ...@@ -66,7 +66,7 @@ static void show_error(char *error_buf, const char *fmt, ...)
} }
va_start(ap, fmt); va_start(ap, fmt);
vsnprintf(error_buf + len, PEVENT_FILTER_ERROR_BUFSZ - len, fmt, ap); vsnprintf(error_buf + len, TEP_FILTER_ERROR_BUFSZ - len, fmt, ap);
va_end(ap); va_end(ap);
} }
...@@ -176,10 +176,10 @@ add_filter_type(struct event_filter *filter, int id) ...@@ -176,10 +176,10 @@ add_filter_type(struct event_filter *filter, int id)
} }
/** /**
* pevent_filter_alloc - create a new event filter * tep_filter_alloc - create a new event filter
* @pevent: The pevent that this filter is associated with * @pevent: The pevent that this filter is associated with
*/ */
struct event_filter *pevent_filter_alloc(struct tep_handle *pevent) struct event_filter *tep_filter_alloc(struct tep_handle *pevent)
{ {
struct event_filter *filter; struct event_filter *filter;
...@@ -1259,16 +1259,16 @@ static void filter_init_error_buf(struct event_filter *filter) ...@@ -1259,16 +1259,16 @@ static void filter_init_error_buf(struct event_filter *filter)
} }
/** /**
* pevent_filter_add_filter_str - add a new filter * tep_filter_add_filter_str - add a new filter
* @filter: the event filter to add to * @filter: the event filter to add to
* @filter_str: the filter string that contains the filter * @filter_str: the filter string that contains the filter
* *
* Returns 0 if the filter was successfully added or a * Returns 0 if the filter was successfully added or a
* negative error code. Use pevent_filter_strerror() to see * negative error code. Use tep_filter_strerror() to see
* actual error message in case of error. * actual error message in case of error.
*/ */
enum tep_errno pevent_filter_add_filter_str(struct event_filter *filter, enum tep_errno tep_filter_add_filter_str(struct event_filter *filter,
const char *filter_str) const char *filter_str)
{ {
struct tep_handle *pevent = filter->pevent; struct tep_handle *pevent = filter->pevent;
struct event_list *event; struct event_list *event;
...@@ -1349,7 +1349,7 @@ enum tep_errno pevent_filter_add_filter_str(struct event_filter *filter, ...@@ -1349,7 +1349,7 @@ enum tep_errno pevent_filter_add_filter_str(struct event_filter *filter,
if (ret >= 0 && pevent->test_filters) { if (ret >= 0 && pevent->test_filters) {
char *test; char *test;
test = pevent_filter_make_string(filter, event->event->id); test = tep_filter_make_string(filter, event->event->id);
if (test) { if (test) {
printf(" '%s: %s'\n", event->event->name, test); printf(" '%s: %s'\n", event->event->name, test);
free(test); free(test);
...@@ -1371,7 +1371,7 @@ static void free_filter_type(struct filter_type *filter_type) ...@@ -1371,7 +1371,7 @@ static void free_filter_type(struct filter_type *filter_type)
} }
/** /**
* pevent_filter_strerror - fill error message in a buffer * tep_filter_strerror - fill error message in a buffer
* @filter: the event filter contains error * @filter: the event filter contains error
* @err: the error code * @err: the error code
* @buf: the buffer to be filled in * @buf: the buffer to be filled in
...@@ -1379,8 +1379,8 @@ static void free_filter_type(struct filter_type *filter_type) ...@@ -1379,8 +1379,8 @@ static void free_filter_type(struct filter_type *filter_type)
* *
* Returns 0 if message was filled successfully, -1 if error * Returns 0 if message was filled successfully, -1 if error
*/ */
int pevent_filter_strerror(struct event_filter *filter, enum tep_errno err, int tep_filter_strerror(struct event_filter *filter, enum tep_errno err,
char *buf, size_t buflen) char *buf, size_t buflen)
{ {
if (err <= __TEP_ERRNO__START || err >= __TEP_ERRNO__END) if (err <= __TEP_ERRNO__START || err >= __TEP_ERRNO__END)
return -1; return -1;
...@@ -1397,7 +1397,7 @@ int pevent_filter_strerror(struct event_filter *filter, enum tep_errno err, ...@@ -1397,7 +1397,7 @@ int pevent_filter_strerror(struct event_filter *filter, enum tep_errno err,
} }
/** /**
* pevent_filter_remove_event - remove a filter for an event * tep_filter_remove_event - remove a filter for an event
* @filter: the event filter to remove from * @filter: the event filter to remove from
* @event_id: the event to remove a filter for * @event_id: the event to remove a filter for
* *
...@@ -1407,8 +1407,8 @@ int pevent_filter_strerror(struct event_filter *filter, enum tep_errno err, ...@@ -1407,8 +1407,8 @@ int pevent_filter_strerror(struct event_filter *filter, enum tep_errno err,
* Returns 1: if an event was removed * Returns 1: if an event was removed
* 0: if the event was not found * 0: if the event was not found
*/ */
int pevent_filter_remove_event(struct event_filter *filter, int tep_filter_remove_event(struct event_filter *filter,
int event_id) int event_id)
{ {
struct filter_type *filter_type; struct filter_type *filter_type;
unsigned long len; unsigned long len;
...@@ -1437,12 +1437,12 @@ int pevent_filter_remove_event(struct event_filter *filter, ...@@ -1437,12 +1437,12 @@ int pevent_filter_remove_event(struct event_filter *filter,
} }
/** /**
* pevent_filter_reset - clear all filters in a filter * tep_filter_reset - clear all filters in a filter
* @filter: the event filter to reset * @filter: the event filter to reset
* *
* Removes all filters from a filter and resets it. * Removes all filters from a filter and resets it.
*/ */
void pevent_filter_reset(struct event_filter *filter) void tep_filter_reset(struct event_filter *filter)
{ {
int i; int i;
...@@ -1454,11 +1454,11 @@ void pevent_filter_reset(struct event_filter *filter) ...@@ -1454,11 +1454,11 @@ void pevent_filter_reset(struct event_filter *filter)
filter->event_filters = NULL; filter->event_filters = NULL;
} }
void pevent_filter_free(struct event_filter *filter) void tep_filter_free(struct event_filter *filter)
{ {
pevent_unref(filter->pevent); pevent_unref(filter->pevent);
pevent_filter_reset(filter); tep_filter_reset(filter);
free(filter); free(filter);
} }
...@@ -1515,18 +1515,18 @@ static int copy_filter_type(struct event_filter *filter, ...@@ -1515,18 +1515,18 @@ static int copy_filter_type(struct event_filter *filter,
} }
/** /**
* pevent_filter_copy - copy a filter using another filter * tep_filter_copy - copy a filter using another filter
* @dest - the filter to copy to * @dest - the filter to copy to
* @source - the filter to copy from * @source - the filter to copy from
* *
* Returns 0 on success and -1 if not all filters were copied * Returns 0 on success and -1 if not all filters were copied
*/ */
int pevent_filter_copy(struct event_filter *dest, struct event_filter *source) int tep_filter_copy(struct event_filter *dest, struct event_filter *source)
{ {
int ret = 0; int ret = 0;
int i; int i;
pevent_filter_reset(dest); tep_filter_reset(dest);
for (i = 0; i < source->filters; i++) { for (i = 0; i < source->filters; i++) {
if (copy_filter_type(dest, source, &source->event_filters[i])) if (copy_filter_type(dest, source, &source->event_filters[i]))
...@@ -1537,7 +1537,7 @@ int pevent_filter_copy(struct event_filter *dest, struct event_filter *source) ...@@ -1537,7 +1537,7 @@ int pevent_filter_copy(struct event_filter *dest, struct event_filter *source)
/** /**
* pevent_update_trivial - update the trivial filters with the given filter * tep_update_trivial - update the trivial filters with the given filter
* @dest - the filter to update * @dest - the filter to update
* @source - the filter as the source of the update * @source - the filter as the source of the update
* @type - the type of trivial filter to update. * @type - the type of trivial filter to update.
...@@ -1547,8 +1547,8 @@ int pevent_filter_copy(struct event_filter *dest, struct event_filter *source) ...@@ -1547,8 +1547,8 @@ int pevent_filter_copy(struct event_filter *dest, struct event_filter *source)
* Returns 0 on success and -1 if there was a problem updating, but * Returns 0 on success and -1 if there was a problem updating, but
* events may have still been updated on error. * events may have still been updated on error.
*/ */
int pevent_update_trivial(struct event_filter *dest, struct event_filter *source, int tep_update_trivial(struct event_filter *dest, struct event_filter *source,
enum filter_trivial_type type) enum filter_trivial_type type)
{ {
struct tep_handle *src_pevent; struct tep_handle *src_pevent;
struct tep_handle *dest_pevent; struct tep_handle *dest_pevent;
...@@ -1585,7 +1585,7 @@ int pevent_update_trivial(struct event_filter *dest, struct event_filter *source ...@@ -1585,7 +1585,7 @@ int pevent_update_trivial(struct event_filter *dest, struct event_filter *source
return -1; return -1;
} }
str = pevent_filter_make_string(source, event->id); str = tep_filter_make_string(source, event->id);
if (!str) if (!str)
continue; continue;
...@@ -1598,7 +1598,7 @@ int pevent_update_trivial(struct event_filter *dest, struct event_filter *source ...@@ -1598,7 +1598,7 @@ int pevent_update_trivial(struct event_filter *dest, struct event_filter *source
} }
/** /**
* pevent_filter_clear_trivial - clear TRUE and FALSE filters * tep_filter_clear_trivial - clear TRUE and FALSE filters
* @filter: the filter to remove trivial filters from * @filter: the filter to remove trivial filters from
* @type: remove only true, false, or both * @type: remove only true, false, or both
* *
...@@ -1606,8 +1606,8 @@ int pevent_update_trivial(struct event_filter *dest, struct event_filter *source ...@@ -1606,8 +1606,8 @@ int pevent_update_trivial(struct event_filter *dest, struct event_filter *source
* *
* Returns 0 on success and -1 if there was a problem. * Returns 0 on success and -1 if there was a problem.
*/ */
int pevent_filter_clear_trivial(struct event_filter *filter, int tep_filter_clear_trivial(struct event_filter *filter,
enum filter_trivial_type type) enum filter_trivial_type type)
{ {
struct filter_type *filter_type; struct filter_type *filter_type;
int count = 0; int count = 0;
...@@ -1653,14 +1653,14 @@ int pevent_filter_clear_trivial(struct event_filter *filter, ...@@ -1653,14 +1653,14 @@ int pevent_filter_clear_trivial(struct event_filter *filter,
return 0; return 0;
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
pevent_filter_remove_event(filter, ids[i]); tep_filter_remove_event(filter, ids[i]);
free(ids); free(ids);
return 0; return 0;
} }
/** /**
* pevent_filter_event_has_trivial - return true event contains trivial filter * tep_filter_event_has_trivial - return true event contains trivial filter
* @filter: the filter with the information * @filter: the filter with the information
* @event_id: the id of the event to test * @event_id: the id of the event to test
* @type: trivial type to test for (TRUE, FALSE, EITHER) * @type: trivial type to test for (TRUE, FALSE, EITHER)
...@@ -1668,9 +1668,9 @@ int pevent_filter_clear_trivial(struct event_filter *filter, ...@@ -1668,9 +1668,9 @@ int pevent_filter_clear_trivial(struct event_filter *filter,
* Returns 1 if the event contains a matching trivial type * Returns 1 if the event contains a matching trivial type
* otherwise 0. * otherwise 0.
*/ */
int pevent_filter_event_has_trivial(struct event_filter *filter, int tep_filter_event_has_trivial(struct event_filter *filter,
int event_id, int event_id,
enum filter_trivial_type type) enum filter_trivial_type type)
{ {
struct filter_type *filter_type; struct filter_type *filter_type;
...@@ -2015,14 +2015,14 @@ static int test_filter(struct event_format *event, struct filter_arg *arg, ...@@ -2015,14 +2015,14 @@ static int test_filter(struct event_format *event, struct filter_arg *arg,
} }
/** /**
* pevent_event_filtered - return true if event has filter * tep_event_filtered - return true if event has filter
* @filter: filter struct with filter information * @filter: filter struct with filter information
* @event_id: event id to test if filter exists * @event_id: event id to test if filter exists
* *
* Returns 1 if filter found for @event_id * Returns 1 if filter found for @event_id
* otherwise 0; * otherwise 0;
*/ */
int pevent_event_filtered(struct event_filter *filter, int event_id) int tep_event_filtered(struct event_filter *filter, int event_id)
{ {
struct filter_type *filter_type; struct filter_type *filter_type;
...@@ -2035,7 +2035,7 @@ int pevent_event_filtered(struct event_filter *filter, int event_id) ...@@ -2035,7 +2035,7 @@ int pevent_event_filtered(struct event_filter *filter, int event_id)
} }
/** /**
* pevent_filter_match - test if a record matches a filter * tep_filter_match - test if a record matches a filter
* @filter: filter struct with filter information * @filter: filter struct with filter information
* @record: the record to test against the filter * @record: the record to test against the filter
* *
...@@ -2046,8 +2046,8 @@ int pevent_event_filtered(struct event_filter *filter, int event_id) ...@@ -2046,8 +2046,8 @@ int pevent_event_filtered(struct event_filter *filter, int event_id)
* NO_FILTER - if no filters exist * NO_FILTER - if no filters exist
* otherwise - error occurred during test * otherwise - error occurred during test
*/ */
enum tep_errno pevent_filter_match(struct event_filter *filter, enum tep_errno tep_filter_match(struct event_filter *filter,
struct tep_record *record) struct tep_record *record)
{ {
struct tep_handle *pevent = filter->pevent; struct tep_handle *pevent = filter->pevent;
struct filter_type *filter_type; struct filter_type *filter_type;
...@@ -2364,7 +2364,7 @@ static char *arg_to_str(struct event_filter *filter, struct filter_arg *arg) ...@@ -2364,7 +2364,7 @@ static char *arg_to_str(struct event_filter *filter, struct filter_arg *arg)
} }
/** /**
* pevent_filter_make_string - return a string showing the filter * tep_filter_make_string - return a string showing the filter
* @filter: filter struct with filter information * @filter: filter struct with filter information
* @event_id: the event id to return the filter string with * @event_id: the event id to return the filter string with
* *
...@@ -2373,7 +2373,7 @@ static char *arg_to_str(struct event_filter *filter, struct filter_arg *arg) ...@@ -2373,7 +2373,7 @@ static char *arg_to_str(struct event_filter *filter, struct filter_arg *arg)
* NULL is returned if no filter is found or allocation failed. * NULL is returned if no filter is found or allocation failed.
*/ */
char * char *
pevent_filter_make_string(struct event_filter *filter, int event_id) tep_filter_make_string(struct event_filter *filter, int event_id)
{ {
struct filter_type *filter_type; struct filter_type *filter_type;
...@@ -2389,7 +2389,7 @@ pevent_filter_make_string(struct event_filter *filter, int event_id) ...@@ -2389,7 +2389,7 @@ pevent_filter_make_string(struct event_filter *filter, int event_id)
} }
/** /**
* pevent_filter_compare - compare two filters and return if they are the same * tep_filter_compare - compare two filters and return if they are the same
* @filter1: Filter to compare with @filter2 * @filter1: Filter to compare with @filter2
* @filter2: Filter to compare with @filter1 * @filter2: Filter to compare with @filter1
* *
...@@ -2397,7 +2397,7 @@ pevent_filter_make_string(struct event_filter *filter, int event_id) ...@@ -2397,7 +2397,7 @@ pevent_filter_make_string(struct event_filter *filter, int event_id)
* 1 if the two filters hold the same content. * 1 if the two filters hold the same content.
* 0 if they do not. * 0 if they do not.
*/ */
int pevent_filter_compare(struct event_filter *filter1, struct event_filter *filter2) int tep_filter_compare(struct event_filter *filter1, struct event_filter *filter2)
{ {
struct filter_type *filter_type1; struct filter_type *filter_type1;
struct filter_type *filter_type2; struct filter_type *filter_type2;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment