aboutsummaryrefslogtreecommitdiffstats
path: root/tools/lib
diff options
context:
space:
mode:
authorTzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>2018-09-19 14:56:55 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2018-09-19 16:28:28 -0400
commit9334c9616b71202c751a12edf5f83f51ec5a1663 (patch)
treefffcf69d6fdf7e0805aa06c25c7d52402b5a4f20 /tools/lib
parent88e6c21a11c5464ebdaefeb18822ab55f37a6473 (diff)
tools lib traceevent: Add prefix tep_ to structs filter_type and event_filter
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_". This adds prefix tep_ to structs filter_type and event_filter Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com> Cc: linux-trace-devel@vger.kernel.org Link: http://lkml.kernel.org/r/20180919185724.309837130@goodmis.org Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/lib')
-rw-r--r--tools/lib/traceevent/event-parse.h34
-rw-r--r--tools/lib/traceevent/parse-filter.c96
2 files changed, 65 insertions, 65 deletions
diff --git a/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h
index 1330fca2da1e..1abf15882460 100644
--- a/tools/lib/traceevent/event-parse.h
+++ b/tools/lib/traceevent/event-parse.h
@@ -882,7 +882,7 @@ struct tep_filter_arg {
882 }; 882 };
883}; 883};
884 884
885struct filter_type { 885struct tep_filter_type {
886 int event_id; 886 int event_id;
887 struct tep_event_format *event; 887 struct tep_event_format *event;
888 struct tep_filter_arg *filter; 888 struct tep_filter_arg *filter;
@@ -890,14 +890,14 @@ struct filter_type {
890 890
891#define TEP_FILTER_ERROR_BUFSZ 1024 891#define TEP_FILTER_ERROR_BUFSZ 1024
892 892
893struct event_filter { 893struct tep_event_filter {
894 struct tep_handle *pevent; 894 struct tep_handle *pevent;
895 int filters; 895 int filters;
896 struct filter_type *event_filters; 896 struct tep_filter_type *event_filters;
897 char error_buffer[TEP_FILTER_ERROR_BUFSZ]; 897 char error_buffer[TEP_FILTER_ERROR_BUFSZ];
898}; 898};
899 899
900struct event_filter *tep_filter_alloc(struct tep_handle *pevent); 900struct tep_event_filter *tep_filter_alloc(struct tep_handle *pevent);
901 901
902/* for backward compatibility */ 902/* for backward compatibility */
903#define FILTER_NONE TEP_ERRNO__NO_FILTER 903#define FILTER_NONE TEP_ERRNO__NO_FILTER
@@ -911,39 +911,39 @@ enum filter_trivial_type {
911 FILTER_TRIVIAL_BOTH, 911 FILTER_TRIVIAL_BOTH,
912}; 912};
913 913
914enum tep_errno tep_filter_add_filter_str(struct event_filter *filter, 914enum tep_errno tep_filter_add_filter_str(struct tep_event_filter *filter,
915 const char *filter_str); 915 const char *filter_str);
916 916
917enum tep_errno tep_filter_match(struct event_filter *filter, 917enum tep_errno tep_filter_match(struct tep_event_filter *filter,
918 struct tep_record *record); 918 struct tep_record *record);
919 919
920int tep_filter_strerror(struct event_filter *filter, enum tep_errno err, 920int tep_filter_strerror(struct tep_event_filter *filter, enum tep_errno err,
921 char *buf, size_t buflen); 921 char *buf, size_t buflen);
922 922
923int tep_event_filtered(struct event_filter *filter, 923int tep_event_filtered(struct tep_event_filter *filter,
924 int event_id); 924 int event_id);
925 925
926void tep_filter_reset(struct event_filter *filter); 926void tep_filter_reset(struct tep_event_filter *filter);
927 927
928int tep_filter_clear_trivial(struct event_filter *filter, 928int tep_filter_clear_trivial(struct tep_event_filter *filter,
929 enum filter_trivial_type type); 929 enum filter_trivial_type type);
930 930
931void tep_filter_free(struct event_filter *filter); 931void tep_filter_free(struct tep_event_filter *filter);
932 932
933char *tep_filter_make_string(struct event_filter *filter, int event_id); 933char *tep_filter_make_string(struct tep_event_filter *filter, int event_id);
934 934
935int tep_filter_remove_event(struct event_filter *filter, 935int tep_filter_remove_event(struct tep_event_filter *filter,
936 int event_id); 936 int event_id);
937 937
938int tep_filter_event_has_trivial(struct event_filter *filter, 938int tep_filter_event_has_trivial(struct tep_event_filter *filter,
939 int event_id, 939 int event_id,
940 enum filter_trivial_type type); 940 enum filter_trivial_type type);
941 941
942int tep_filter_copy(struct event_filter *dest, struct event_filter *source); 942int tep_filter_copy(struct tep_event_filter *dest, struct tep_event_filter *source);
943 943
944int tep_update_trivial(struct event_filter *dest, struct event_filter *source, 944int tep_update_trivial(struct tep_event_filter *dest, struct tep_event_filter *source,
945 enum filter_trivial_type type); 945 enum filter_trivial_type type);
946 946
947int tep_filter_compare(struct event_filter *filter1, struct event_filter *filter2); 947int tep_filter_compare(struct tep_event_filter *filter1, struct tep_event_filter *filter2);
948 948
949#endif /* _PARSE_EVENTS_H */ 949#endif /* _PARSE_EVENTS_H */
diff --git a/tools/lib/traceevent/parse-filter.c b/tools/lib/traceevent/parse-filter.c
index b9ca1b9e14e4..875bfaf79771 100644
--- a/tools/lib/traceevent/parse-filter.c
+++ b/tools/lib/traceevent/parse-filter.c
@@ -94,8 +94,8 @@ static enum tep_event_type read_token(char **tok)
94 94
95static int filter_cmp(const void *a, const void *b) 95static int filter_cmp(const void *a, const void *b)
96{ 96{
97 const struct filter_type *ea = a; 97 const struct tep_filter_type *ea = a;
98 const struct filter_type *eb = b; 98 const struct tep_filter_type *eb = b;
99 99
100 if (ea->event_id < eb->event_id) 100 if (ea->event_id < eb->event_id)
101 return -1; 101 return -1;
@@ -106,11 +106,11 @@ static int filter_cmp(const void *a, const void *b)
106 return 0; 106 return 0;
107} 107}
108 108
109static struct filter_type * 109static struct tep_filter_type *
110find_filter_type(struct event_filter *filter, int id) 110find_filter_type(struct tep_event_filter *filter, int id)
111{ 111{
112 struct filter_type *filter_type; 112 struct tep_filter_type *filter_type;
113 struct filter_type key; 113 struct tep_filter_type key;
114 114
115 key.event_id = id; 115 key.event_id = id;
116 116
@@ -122,10 +122,10 @@ find_filter_type(struct event_filter *filter, int id)
122 return filter_type; 122 return filter_type;
123} 123}
124 124
125static struct filter_type * 125static struct tep_filter_type *
126add_filter_type(struct event_filter *filter, int id) 126add_filter_type(struct tep_event_filter *filter, int id)
127{ 127{
128 struct filter_type *filter_type; 128 struct tep_filter_type *filter_type;
129 int i; 129 int i;
130 130
131 filter_type = find_filter_type(filter, id); 131 filter_type = find_filter_type(filter, id);
@@ -165,9 +165,9 @@ add_filter_type(struct event_filter *filter, int id)
165 * tep_filter_alloc - create a new event filter 165 * tep_filter_alloc - create a new event filter
166 * @pevent: The pevent that this filter is associated with 166 * @pevent: The pevent that this filter is associated with
167 */ 167 */
168struct event_filter *tep_filter_alloc(struct tep_handle *pevent) 168struct tep_event_filter *tep_filter_alloc(struct tep_handle *pevent)
169{ 169{
170 struct event_filter *filter; 170 struct tep_event_filter *filter;
171 171
172 filter = malloc(sizeof(*filter)); 172 filter = malloc(sizeof(*filter));
173 if (filter == NULL) 173 if (filter == NULL)
@@ -1204,10 +1204,10 @@ process_event(struct tep_event_format *event, const char *filter_str,
1204} 1204}
1205 1205
1206static enum tep_errno 1206static enum tep_errno
1207filter_event(struct event_filter *filter, struct tep_event_format *event, 1207filter_event(struct tep_event_filter *filter, struct tep_event_format *event,
1208 const char *filter_str, char *error_str) 1208 const char *filter_str, char *error_str)
1209{ 1209{
1210 struct filter_type *filter_type; 1210 struct tep_filter_type *filter_type;
1211 struct tep_filter_arg *arg; 1211 struct tep_filter_arg *arg;
1212 enum tep_errno ret; 1212 enum tep_errno ret;
1213 1213
@@ -1237,7 +1237,7 @@ filter_event(struct event_filter *filter, struct tep_event_format *event,
1237 return 0; 1237 return 0;
1238} 1238}
1239 1239
1240static void filter_init_error_buf(struct event_filter *filter) 1240static void filter_init_error_buf(struct tep_event_filter *filter)
1241{ 1241{
1242 /* clear buffer to reset show error */ 1242 /* clear buffer to reset show error */
1243 tep_buffer_init("", 0); 1243 tep_buffer_init("", 0);
@@ -1253,7 +1253,7 @@ static void filter_init_error_buf(struct event_filter *filter)
1253 * negative error code. Use tep_filter_strerror() to see 1253 * negative error code. Use tep_filter_strerror() to see
1254 * actual error message in case of error. 1254 * actual error message in case of error.
1255 */ 1255 */
1256enum tep_errno tep_filter_add_filter_str(struct event_filter *filter, 1256enum tep_errno tep_filter_add_filter_str(struct tep_event_filter *filter,
1257 const char *filter_str) 1257 const char *filter_str)
1258{ 1258{
1259 struct tep_handle *pevent = filter->pevent; 1259 struct tep_handle *pevent = filter->pevent;
@@ -1351,7 +1351,7 @@ enum tep_errno tep_filter_add_filter_str(struct event_filter *filter,
1351 return rtn; 1351 return rtn;
1352} 1352}
1353 1353
1354static void free_filter_type(struct filter_type *filter_type) 1354static void free_filter_type(struct tep_filter_type *filter_type)
1355{ 1355{
1356 free_arg(filter_type->filter); 1356 free_arg(filter_type->filter);
1357} 1357}
@@ -1365,7 +1365,7 @@ static void free_filter_type(struct filter_type *filter_type)
1365 * 1365 *
1366 * Returns 0 if message was filled successfully, -1 if error 1366 * Returns 0 if message was filled successfully, -1 if error
1367 */ 1367 */
1368int tep_filter_strerror(struct event_filter *filter, enum tep_errno err, 1368int tep_filter_strerror(struct tep_event_filter *filter, enum tep_errno err,
1369 char *buf, size_t buflen) 1369 char *buf, size_t buflen)
1370{ 1370{
1371 if (err <= __TEP_ERRNO__START || err >= __TEP_ERRNO__END) 1371 if (err <= __TEP_ERRNO__START || err >= __TEP_ERRNO__END)
@@ -1393,10 +1393,10 @@ int tep_filter_strerror(struct event_filter *filter, enum tep_errno err,
1393 * Returns 1: if an event was removed 1393 * Returns 1: if an event was removed
1394 * 0: if the event was not found 1394 * 0: if the event was not found
1395 */ 1395 */
1396int tep_filter_remove_event(struct event_filter *filter, 1396int tep_filter_remove_event(struct tep_event_filter *filter,
1397 int event_id) 1397 int event_id)
1398{ 1398{
1399 struct filter_type *filter_type; 1399 struct tep_filter_type *filter_type;
1400 unsigned long len; 1400 unsigned long len;
1401 1401
1402 if (!filter->filters) 1402 if (!filter->filters)
@@ -1428,7 +1428,7 @@ int tep_filter_remove_event(struct event_filter *filter,
1428 * 1428 *
1429 * Removes all filters from a filter and resets it. 1429 * Removes all filters from a filter and resets it.
1430 */ 1430 */
1431void tep_filter_reset(struct event_filter *filter) 1431void tep_filter_reset(struct tep_event_filter *filter)
1432{ 1432{
1433 int i; 1433 int i;
1434 1434
@@ -1440,7 +1440,7 @@ void tep_filter_reset(struct event_filter *filter)
1440 filter->event_filters = NULL; 1440 filter->event_filters = NULL;
1441} 1441}
1442 1442
1443void tep_filter_free(struct event_filter *filter) 1443void tep_filter_free(struct tep_event_filter *filter)
1444{ 1444{
1445 tep_unref(filter->pevent); 1445 tep_unref(filter->pevent);
1446 1446
@@ -1449,11 +1449,11 @@ void tep_filter_free(struct event_filter *filter)
1449 free(filter); 1449 free(filter);
1450} 1450}
1451 1451
1452static char *arg_to_str(struct event_filter *filter, struct tep_filter_arg *arg); 1452static char *arg_to_str(struct tep_event_filter *filter, struct tep_filter_arg *arg);
1453 1453
1454static int copy_filter_type(struct event_filter *filter, 1454static int copy_filter_type(struct tep_event_filter *filter,
1455 struct event_filter *source, 1455 struct tep_event_filter *source,
1456 struct filter_type *filter_type) 1456 struct tep_filter_type *filter_type)
1457{ 1457{
1458 struct tep_filter_arg *arg; 1458 struct tep_filter_arg *arg;
1459 struct tep_event_format *event; 1459 struct tep_event_format *event;
@@ -1507,7 +1507,7 @@ static int copy_filter_type(struct event_filter *filter,
1507 * 1507 *
1508 * Returns 0 on success and -1 if not all filters were copied 1508 * Returns 0 on success and -1 if not all filters were copied
1509 */ 1509 */
1510int tep_filter_copy(struct event_filter *dest, struct event_filter *source) 1510int tep_filter_copy(struct tep_event_filter *dest, struct tep_event_filter *source)
1511{ 1511{
1512 int ret = 0; 1512 int ret = 0;
1513 int i; 1513 int i;
@@ -1533,13 +1533,13 @@ int tep_filter_copy(struct event_filter *dest, struct event_filter *source)
1533 * Returns 0 on success and -1 if there was a problem updating, but 1533 * Returns 0 on success and -1 if there was a problem updating, but
1534 * events may have still been updated on error. 1534 * events may have still been updated on error.
1535 */ 1535 */
1536int tep_update_trivial(struct event_filter *dest, struct event_filter *source, 1536int tep_update_trivial(struct tep_event_filter *dest, struct tep_event_filter *source,
1537 enum filter_trivial_type type) 1537 enum filter_trivial_type type)
1538{ 1538{
1539 struct tep_handle *src_pevent; 1539 struct tep_handle *src_pevent;
1540 struct tep_handle *dest_pevent; 1540 struct tep_handle *dest_pevent;
1541 struct tep_event_format *event; 1541 struct tep_event_format *event;
1542 struct filter_type *filter_type; 1542 struct tep_filter_type *filter_type;
1543 struct tep_filter_arg *arg; 1543 struct tep_filter_arg *arg;
1544 char *str; 1544 char *str;
1545 int i; 1545 int i;
@@ -1592,10 +1592,10 @@ int tep_update_trivial(struct event_filter *dest, struct event_filter *source,
1592 * 1592 *
1593 * Returns 0 on success and -1 if there was a problem. 1593 * Returns 0 on success and -1 if there was a problem.
1594 */ 1594 */
1595int tep_filter_clear_trivial(struct event_filter *filter, 1595int tep_filter_clear_trivial(struct tep_event_filter *filter,
1596 enum filter_trivial_type type) 1596 enum filter_trivial_type type)
1597{ 1597{
1598 struct filter_type *filter_type; 1598 struct tep_filter_type *filter_type;
1599 int count = 0; 1599 int count = 0;
1600 int *ids = NULL; 1600 int *ids = NULL;
1601 int i; 1601 int i;
@@ -1654,11 +1654,11 @@ int tep_filter_clear_trivial(struct event_filter *filter,
1654 * Returns 1 if the event contains a matching trivial type 1654 * Returns 1 if the event contains a matching trivial type
1655 * otherwise 0. 1655 * otherwise 0.
1656 */ 1656 */
1657int tep_filter_event_has_trivial(struct event_filter *filter, 1657int tep_filter_event_has_trivial(struct tep_event_filter *filter,
1658 int event_id, 1658 int event_id,
1659 enum filter_trivial_type type) 1659 enum filter_trivial_type type)
1660{ 1660{
1661 struct filter_type *filter_type; 1661 struct tep_filter_type *filter_type;
1662 1662
1663 if (!filter->filters) 1663 if (!filter->filters)
1664 return 0; 1664 return 0;
@@ -2008,9 +2008,9 @@ static int test_filter(struct tep_event_format *event, struct tep_filter_arg *ar
2008 * Returns 1 if filter found for @event_id 2008 * Returns 1 if filter found for @event_id
2009 * otherwise 0; 2009 * otherwise 0;
2010 */ 2010 */
2011int tep_event_filtered(struct event_filter *filter, int event_id) 2011int tep_event_filtered(struct tep_event_filter *filter, int event_id)
2012{ 2012{
2013 struct filter_type *filter_type; 2013 struct tep_filter_type *filter_type;
2014 2014
2015 if (!filter->filters) 2015 if (!filter->filters)
2016 return 0; 2016 return 0;
@@ -2032,11 +2032,11 @@ int tep_event_filtered(struct event_filter *filter, int event_id)
2032 * NO_FILTER - if no filters exist 2032 * NO_FILTER - if no filters exist
2033 * otherwise - error occurred during test 2033 * otherwise - error occurred during test
2034 */ 2034 */
2035enum tep_errno tep_filter_match(struct event_filter *filter, 2035enum tep_errno tep_filter_match(struct tep_event_filter *filter,
2036 struct tep_record *record) 2036 struct tep_record *record)
2037{ 2037{
2038 struct tep_handle *pevent = filter->pevent; 2038 struct tep_handle *pevent = filter->pevent;
2039 struct filter_type *filter_type; 2039 struct tep_filter_type *filter_type;
2040 int event_id; 2040 int event_id;
2041 int ret; 2041 int ret;
2042 enum tep_errno err = 0; 2042 enum tep_errno err = 0;
@@ -2059,7 +2059,7 @@ enum tep_errno tep_filter_match(struct event_filter *filter,
2059 return ret ? TEP_ERRNO__FILTER_MATCH : TEP_ERRNO__FILTER_MISS; 2059 return ret ? TEP_ERRNO__FILTER_MATCH : TEP_ERRNO__FILTER_MISS;
2060} 2060}
2061 2061
2062static char *op_to_str(struct event_filter *filter, struct tep_filter_arg *arg) 2062static char *op_to_str(struct tep_event_filter *filter, struct tep_filter_arg *arg)
2063{ 2063{
2064 char *str = NULL; 2064 char *str = NULL;
2065 char *left = NULL; 2065 char *left = NULL;
@@ -2163,7 +2163,7 @@ static char *op_to_str(struct event_filter *filter, struct tep_filter_arg *arg)
2163 return str; 2163 return str;
2164} 2164}
2165 2165
2166static char *val_to_str(struct event_filter *filter, struct tep_filter_arg *arg) 2166static char *val_to_str(struct tep_event_filter *filter, struct tep_filter_arg *arg)
2167{ 2167{
2168 char *str = NULL; 2168 char *str = NULL;
2169 2169
@@ -2172,12 +2172,12 @@ static char *val_to_str(struct event_filter *filter, struct tep_filter_arg *arg)
2172 return str; 2172 return str;
2173} 2173}
2174 2174
2175static char *field_to_str(struct event_filter *filter, struct tep_filter_arg *arg) 2175static char *field_to_str(struct tep_event_filter *filter, struct tep_filter_arg *arg)
2176{ 2176{
2177 return strdup(arg->field.field->name); 2177 return strdup(arg->field.field->name);
2178} 2178}
2179 2179
2180static char *exp_to_str(struct event_filter *filter, struct tep_filter_arg *arg) 2180static char *exp_to_str(struct tep_event_filter *filter, struct tep_filter_arg *arg)
2181{ 2181{
2182 char *lstr; 2182 char *lstr;
2183 char *rstr; 2183 char *rstr;
@@ -2233,7 +2233,7 @@ out:
2233 return str; 2233 return str;
2234} 2234}
2235 2235
2236static char *num_to_str(struct event_filter *filter, struct tep_filter_arg *arg) 2236static char *num_to_str(struct tep_event_filter *filter, struct tep_filter_arg *arg)
2237{ 2237{
2238 char *lstr; 2238 char *lstr;
2239 char *rstr; 2239 char *rstr;
@@ -2283,7 +2283,7 @@ out:
2283 return str; 2283 return str;
2284} 2284}
2285 2285
2286static char *str_to_str(struct event_filter *filter, struct tep_filter_arg *arg) 2286static char *str_to_str(struct tep_event_filter *filter, struct tep_filter_arg *arg)
2287{ 2287{
2288 char *str = NULL; 2288 char *str = NULL;
2289 char *op = NULL; 2289 char *op = NULL;
@@ -2315,7 +2315,7 @@ static char *str_to_str(struct event_filter *filter, struct tep_filter_arg *arg)
2315 return str; 2315 return str;
2316} 2316}
2317 2317
2318static char *arg_to_str(struct event_filter *filter, struct tep_filter_arg *arg) 2318static char *arg_to_str(struct tep_event_filter *filter, struct tep_filter_arg *arg)
2319{ 2319{
2320 char *str = NULL; 2320 char *str = NULL;
2321 2321
@@ -2359,9 +2359,9 @@ static char *arg_to_str(struct event_filter *filter, struct tep_filter_arg *arg)
2359 * NULL is returned if no filter is found or allocation failed. 2359 * NULL is returned if no filter is found or allocation failed.
2360 */ 2360 */
2361char * 2361char *
2362tep_filter_make_string(struct event_filter *filter, int event_id) 2362tep_filter_make_string(struct tep_event_filter *filter, int event_id)
2363{ 2363{
2364 struct filter_type *filter_type; 2364 struct tep_filter_type *filter_type;
2365 2365
2366 if (!filter->filters) 2366 if (!filter->filters)
2367 return NULL; 2367 return NULL;
@@ -2383,10 +2383,10 @@ tep_filter_make_string(struct event_filter *filter, int event_id)
2383 * 1 if the two filters hold the same content. 2383 * 1 if the two filters hold the same content.
2384 * 0 if they do not. 2384 * 0 if they do not.
2385 */ 2385 */
2386int tep_filter_compare(struct event_filter *filter1, struct event_filter *filter2) 2386int tep_filter_compare(struct tep_event_filter *filter1, struct tep_event_filter *filter2)
2387{ 2387{
2388 struct filter_type *filter_type1; 2388 struct tep_filter_type *filter_type1;
2389 struct filter_type *filter_type2; 2389 struct tep_filter_type *filter_type2;
2390 char *str1, *str2; 2390 char *str1, *str2;
2391 int result; 2391 int result;
2392 int i; 2392 int i;