aboutsummaryrefslogtreecommitdiffstats
path: root/tools/lib/traceevent
diff options
context:
space:
mode:
authorTzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>2018-08-08 14:03:01 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2018-08-13 14:26:31 -0400
commit64e237906963d0c26d3b25e7751b4d6aaa01f720 (patch)
tree17024797a7b5ac43b1a5a6fa4dc2a28253bb4843 /tools/lib/traceevent
parentca2921dd90268dc37cd5096eb985da4288aa7041 (diff)
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: Tzvetomir 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.org Signed-off-by: Steven Rostedt <rostedt@goodmis.org> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/lib/traceevent')
-rw-r--r--tools/lib/traceevent/event-parse.h50
-rw-r--r--tools/lib/traceevent/parse-filter.c84
2 files changed, 67 insertions, 67 deletions
diff --git a/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h
index ec327849a7dc..c60329cd9463 100644
--- a/tools/lib/traceevent/event-parse.h
+++ b/tools/lib/traceevent/event-parse.h
@@ -930,16 +930,16 @@ struct filter_type {
930 struct filter_arg *filter; 930 struct filter_arg *filter;
931}; 931};
932 932
933#define PEVENT_FILTER_ERROR_BUFSZ 1024 933#define TEP_FILTER_ERROR_BUFSZ 1024
934 934
935struct event_filter { 935struct event_filter {
936 struct tep_handle *pevent; 936 struct tep_handle *pevent;
937 int filters; 937 int filters;
938 struct filter_type *event_filters; 938 struct filter_type *event_filters;
939 char error_buffer[PEVENT_FILTER_ERROR_BUFSZ]; 939 char error_buffer[TEP_FILTER_ERROR_BUFSZ];
940}; 940};
941 941
942struct event_filter *pevent_filter_alloc(struct tep_handle *pevent); 942struct event_filter *tep_filter_alloc(struct tep_handle *pevent);
943 943
944/* for backward compatibility */ 944/* for backward compatibility */
945#define FILTER_NONE TEP_ERRNO__NO_FILTER 945#define FILTER_NONE TEP_ERRNO__NO_FILTER
@@ -953,39 +953,39 @@ enum filter_trivial_type {
953 FILTER_TRIVIAL_BOTH, 953 FILTER_TRIVIAL_BOTH,
954}; 954};
955 955
956enum tep_errno pevent_filter_add_filter_str(struct event_filter *filter, 956enum tep_errno tep_filter_add_filter_str(struct event_filter *filter,
957 const char *filter_str); 957 const char *filter_str);
958 958
959enum tep_errno pevent_filter_match(struct event_filter *filter, 959enum tep_errno tep_filter_match(struct event_filter *filter,
960 struct tep_record *record); 960 struct tep_record *record);
961 961
962int pevent_filter_strerror(struct event_filter *filter, enum tep_errno err, 962int tep_filter_strerror(struct event_filter *filter, enum tep_errno err,
963 char *buf, size_t buflen); 963 char *buf, size_t buflen);
964 964
965int pevent_event_filtered(struct event_filter *filter, 965int tep_event_filtered(struct event_filter *filter,
966 int event_id); 966 int event_id);
967 967
968void pevent_filter_reset(struct event_filter *filter); 968void tep_filter_reset(struct event_filter *filter);
969 969
970int pevent_filter_clear_trivial(struct event_filter *filter, 970int tep_filter_clear_trivial(struct event_filter *filter,
971 enum filter_trivial_type type); 971 enum filter_trivial_type type);
972 972
973void pevent_filter_free(struct event_filter *filter); 973void tep_filter_free(struct event_filter *filter);
974 974
975char *pevent_filter_make_string(struct event_filter *filter, int event_id); 975char *tep_filter_make_string(struct event_filter *filter, int event_id);
976 976
977int pevent_filter_remove_event(struct event_filter *filter, 977int tep_filter_remove_event(struct event_filter *filter,
978 int event_id); 978 int event_id);
979 979
980int pevent_filter_event_has_trivial(struct event_filter *filter, 980int tep_filter_event_has_trivial(struct event_filter *filter,
981 int event_id, 981 int event_id,
982 enum filter_trivial_type type); 982 enum filter_trivial_type type);
983 983
984int pevent_filter_copy(struct event_filter *dest, struct event_filter *source); 984int tep_filter_copy(struct event_filter *dest, struct event_filter *source);
985 985
986int pevent_update_trivial(struct event_filter *dest, struct event_filter *source, 986int tep_update_trivial(struct event_filter *dest, struct event_filter *source,
987 enum filter_trivial_type type); 987 enum filter_trivial_type type);
988 988
989int pevent_filter_compare(struct event_filter *filter1, struct event_filter *filter2); 989int tep_filter_compare(struct event_filter *filter1, struct event_filter *filter2);
990 990
991#endif /* _PARSE_EVENTS_H */ 991#endif /* _PARSE_EVENTS_H */
diff --git a/tools/lib/traceevent/parse-filter.c b/tools/lib/traceevent/parse-filter.c
index 5dc474027313..f3d812676169 100644
--- a/tools/lib/traceevent/parse-filter.c
+++ b/tools/lib/traceevent/parse-filter.c
@@ -66,7 +66,7 @@ static void show_error(char *error_buf, const char *fmt, ...)
66 } 66 }
67 67
68 va_start(ap, fmt); 68 va_start(ap, fmt);
69 vsnprintf(error_buf + len, PEVENT_FILTER_ERROR_BUFSZ - len, fmt, ap); 69 vsnprintf(error_buf + len, TEP_FILTER_ERROR_BUFSZ - len, fmt, ap);
70 va_end(ap); 70 va_end(ap);
71} 71}
72 72
@@ -176,10 +176,10 @@ add_filter_type(struct event_filter *filter, int id)
176} 176}
177 177
178/** 178/**
179 * pevent_filter_alloc - create a new event filter 179 * tep_filter_alloc - create a new event filter
180 * @pevent: The pevent that this filter is associated with 180 * @pevent: The pevent that this filter is associated with
181 */ 181 */
182struct event_filter *pevent_filter_alloc(struct tep_handle *pevent) 182struct event_filter *tep_filter_alloc(struct tep_handle *pevent)
183{ 183{
184 struct event_filter *filter; 184 struct event_filter *filter;
185 185
@@ -1259,16 +1259,16 @@ static void filter_init_error_buf(struct event_filter *filter)
1259} 1259}
1260 1260
1261/** 1261/**
1262 * pevent_filter_add_filter_str - add a new filter 1262 * tep_filter_add_filter_str - add a new filter
1263 * @filter: the event filter to add to 1263 * @filter: the event filter to add to
1264 * @filter_str: the filter string that contains the filter 1264 * @filter_str: the filter string that contains the filter
1265 * 1265 *
1266 * Returns 0 if the filter was successfully added or a 1266 * Returns 0 if the filter was successfully added or a
1267 * negative error code. Use pevent_filter_strerror() to see 1267 * negative error code. Use tep_filter_strerror() to see
1268 * actual error message in case of error. 1268 * actual error message in case of error.
1269 */ 1269 */
1270enum tep_errno pevent_filter_add_filter_str(struct event_filter *filter, 1270enum tep_errno tep_filter_add_filter_str(struct event_filter *filter,
1271 const char *filter_str) 1271 const char *filter_str)
1272{ 1272{
1273 struct tep_handle *pevent = filter->pevent; 1273 struct tep_handle *pevent = filter->pevent;
1274 struct event_list *event; 1274 struct event_list *event;
@@ -1349,7 +1349,7 @@ enum tep_errno pevent_filter_add_filter_str(struct event_filter *filter,
1349 1349
1350 if (ret >= 0 && pevent->test_filters) { 1350 if (ret >= 0 && pevent->test_filters) {
1351 char *test; 1351 char *test;
1352 test = pevent_filter_make_string(filter, event->event->id); 1352 test = tep_filter_make_string(filter, event->event->id);
1353 if (test) { 1353 if (test) {
1354 printf(" '%s: %s'\n", event->event->name, test); 1354 printf(" '%s: %s'\n", event->event->name, test);
1355 free(test); 1355 free(test);
@@ -1371,7 +1371,7 @@ static void free_filter_type(struct filter_type *filter_type)
1371} 1371}
1372 1372
1373/** 1373/**
1374 * pevent_filter_strerror - fill error message in a buffer 1374 * tep_filter_strerror - fill error message in a buffer
1375 * @filter: the event filter contains error 1375 * @filter: the event filter contains error
1376 * @err: the error code 1376 * @err: the error code
1377 * @buf: the buffer to be filled in 1377 * @buf: the buffer to be filled in
@@ -1379,8 +1379,8 @@ static void free_filter_type(struct filter_type *filter_type)
1379 * 1379 *
1380 * Returns 0 if message was filled successfully, -1 if error 1380 * Returns 0 if message was filled successfully, -1 if error
1381 */ 1381 */
1382int pevent_filter_strerror(struct event_filter *filter, enum tep_errno err, 1382int tep_filter_strerror(struct event_filter *filter, enum tep_errno err,
1383 char *buf, size_t buflen) 1383 char *buf, size_t buflen)
1384{ 1384{
1385 if (err <= __TEP_ERRNO__START || err >= __TEP_ERRNO__END) 1385 if (err <= __TEP_ERRNO__START || err >= __TEP_ERRNO__END)
1386 return -1; 1386 return -1;
@@ -1397,7 +1397,7 @@ int pevent_filter_strerror(struct event_filter *filter, enum tep_errno err,
1397} 1397}
1398 1398
1399/** 1399/**
1400 * pevent_filter_remove_event - remove a filter for an event 1400 * tep_filter_remove_event - remove a filter for an event
1401 * @filter: the event filter to remove from 1401 * @filter: the event filter to remove from
1402 * @event_id: the event to remove a filter for 1402 * @event_id: the event to remove a filter for
1403 * 1403 *
@@ -1407,8 +1407,8 @@ int pevent_filter_strerror(struct event_filter *filter, enum tep_errno err,
1407 * Returns 1: if an event was removed 1407 * Returns 1: if an event was removed
1408 * 0: if the event was not found 1408 * 0: if the event was not found
1409 */ 1409 */
1410int pevent_filter_remove_event(struct event_filter *filter, 1410int tep_filter_remove_event(struct event_filter *filter,
1411 int event_id) 1411 int event_id)
1412{ 1412{
1413 struct filter_type *filter_type; 1413 struct filter_type *filter_type;
1414 unsigned long len; 1414 unsigned long len;
@@ -1437,12 +1437,12 @@ int pevent_filter_remove_event(struct event_filter *filter,
1437} 1437}
1438 1438
1439/** 1439/**
1440 * pevent_filter_reset - clear all filters in a filter 1440 * tep_filter_reset - clear all filters in a filter
1441 * @filter: the event filter to reset 1441 * @filter: the event filter to reset
1442 * 1442 *
1443 * Removes all filters from a filter and resets it. 1443 * Removes all filters from a filter and resets it.
1444 */ 1444 */
1445void pevent_filter_reset(struct event_filter *filter) 1445void tep_filter_reset(struct event_filter *filter)
1446{ 1446{
1447 int i; 1447 int i;
1448 1448
@@ -1454,11 +1454,11 @@ void pevent_filter_reset(struct event_filter *filter)
1454 filter->event_filters = NULL; 1454 filter->event_filters = NULL;
1455} 1455}
1456 1456
1457void pevent_filter_free(struct event_filter *filter) 1457void tep_filter_free(struct event_filter *filter)
1458{ 1458{
1459 pevent_unref(filter->pevent); 1459 pevent_unref(filter->pevent);
1460 1460
1461 pevent_filter_reset(filter); 1461 tep_filter_reset(filter);
1462 1462
1463 free(filter); 1463 free(filter);
1464} 1464}
@@ -1515,18 +1515,18 @@ static int copy_filter_type(struct event_filter *filter,
1515} 1515}
1516 1516
1517/** 1517/**
1518 * pevent_filter_copy - copy a filter using another filter 1518 * tep_filter_copy - copy a filter using another filter
1519 * @dest - the filter to copy to 1519 * @dest - the filter to copy to
1520 * @source - the filter to copy from 1520 * @source - the filter to copy from
1521 * 1521 *
1522 * Returns 0 on success and -1 if not all filters were copied 1522 * Returns 0 on success and -1 if not all filters were copied
1523 */ 1523 */
1524int pevent_filter_copy(struct event_filter *dest, struct event_filter *source) 1524int tep_filter_copy(struct event_filter *dest, struct event_filter *source)
1525{ 1525{
1526 int ret = 0; 1526 int ret = 0;
1527 int i; 1527 int i;
1528 1528
1529 pevent_filter_reset(dest); 1529 tep_filter_reset(dest);
1530 1530
1531 for (i = 0; i < source->filters; i++) { 1531 for (i = 0; i < source->filters; i++) {
1532 if (copy_filter_type(dest, source, &source->event_filters[i])) 1532 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 1537
1538 1538
1539/** 1539/**
1540 * pevent_update_trivial - update the trivial filters with the given filter 1540 * tep_update_trivial - update the trivial filters with the given filter
1541 * @dest - the filter to update 1541 * @dest - the filter to update
1542 * @source - the filter as the source of the update 1542 * @source - the filter as the source of the update
1543 * @type - the type of trivial filter to update. 1543 * @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 * Returns 0 on success and -1 if there was a problem updating, but 1547 * Returns 0 on success and -1 if there was a problem updating, but
1548 * events may have still been updated on error. 1548 * events may have still been updated on error.
1549 */ 1549 */
1550int pevent_update_trivial(struct event_filter *dest, struct event_filter *source, 1550int tep_update_trivial(struct event_filter *dest, struct event_filter *source,
1551 enum filter_trivial_type type) 1551 enum filter_trivial_type type)
1552{ 1552{
1553 struct tep_handle *src_pevent; 1553 struct tep_handle *src_pevent;
1554 struct tep_handle *dest_pevent; 1554 struct tep_handle *dest_pevent;
@@ -1585,7 +1585,7 @@ int pevent_update_trivial(struct event_filter *dest, struct event_filter *source
1585 return -1; 1585 return -1;
1586 } 1586 }
1587 1587
1588 str = pevent_filter_make_string(source, event->id); 1588 str = tep_filter_make_string(source, event->id);
1589 if (!str) 1589 if (!str)
1590 continue; 1590 continue;
1591 1591
@@ -1598,7 +1598,7 @@ int pevent_update_trivial(struct event_filter *dest, struct event_filter *source
1598} 1598}
1599 1599
1600/** 1600/**
1601 * pevent_filter_clear_trivial - clear TRUE and FALSE filters 1601 * tep_filter_clear_trivial - clear TRUE and FALSE filters
1602 * @filter: the filter to remove trivial filters from 1602 * @filter: the filter to remove trivial filters from
1603 * @type: remove only true, false, or both 1603 * @type: remove only true, false, or both
1604 * 1604 *
@@ -1606,8 +1606,8 @@ int pevent_update_trivial(struct event_filter *dest, struct event_filter *source
1606 * 1606 *
1607 * Returns 0 on success and -1 if there was a problem. 1607 * Returns 0 on success and -1 if there was a problem.
1608 */ 1608 */
1609int pevent_filter_clear_trivial(struct event_filter *filter, 1609int tep_filter_clear_trivial(struct event_filter *filter,
1610 enum filter_trivial_type type) 1610 enum filter_trivial_type type)
1611{ 1611{
1612 struct filter_type *filter_type; 1612 struct filter_type *filter_type;
1613 int count = 0; 1613 int count = 0;
@@ -1653,14 +1653,14 @@ int pevent_filter_clear_trivial(struct event_filter *filter,
1653 return 0; 1653 return 0;
1654 1654
1655 for (i = 0; i < count; i++) 1655 for (i = 0; i < count; i++)
1656 pevent_filter_remove_event(filter, ids[i]); 1656 tep_filter_remove_event(filter, ids[i]);
1657 1657
1658 free(ids); 1658 free(ids);
1659 return 0; 1659 return 0;
1660} 1660}
1661 1661
1662/** 1662/**
1663 * pevent_filter_event_has_trivial - return true event contains trivial filter 1663 * tep_filter_event_has_trivial - return true event contains trivial filter
1664 * @filter: the filter with the information 1664 * @filter: the filter with the information
1665 * @event_id: the id of the event to test 1665 * @event_id: the id of the event to test
1666 * @type: trivial type to test for (TRUE, FALSE, EITHER) 1666 * @type: trivial type to test for (TRUE, FALSE, EITHER)
@@ -1668,9 +1668,9 @@ int pevent_filter_clear_trivial(struct event_filter *filter,
1668 * Returns 1 if the event contains a matching trivial type 1668 * Returns 1 if the event contains a matching trivial type
1669 * otherwise 0. 1669 * otherwise 0.
1670 */ 1670 */
1671int pevent_filter_event_has_trivial(struct event_filter *filter, 1671int tep_filter_event_has_trivial(struct event_filter *filter,
1672 int event_id, 1672 int event_id,
1673 enum filter_trivial_type type) 1673 enum filter_trivial_type type)
1674{ 1674{
1675 struct filter_type *filter_type; 1675 struct filter_type *filter_type;
1676 1676
@@ -2015,14 +2015,14 @@ static int test_filter(struct event_format *event, struct filter_arg *arg,
2015} 2015}
2016 2016
2017/** 2017/**
2018 * pevent_event_filtered - return true if event has filter 2018 * tep_event_filtered - return true if event has filter
2019 * @filter: filter struct with filter information 2019 * @filter: filter struct with filter information
2020 * @event_id: event id to test if filter exists 2020 * @event_id: event id to test if filter exists
2021 * 2021 *
2022 * Returns 1 if filter found for @event_id 2022 * Returns 1 if filter found for @event_id
2023 * otherwise 0; 2023 * otherwise 0;
2024 */ 2024 */
2025int pevent_event_filtered(struct event_filter *filter, int event_id) 2025int tep_event_filtered(struct event_filter *filter, int event_id)
2026{ 2026{
2027 struct filter_type *filter_type; 2027 struct filter_type *filter_type;
2028 2028
@@ -2035,7 +2035,7 @@ int pevent_event_filtered(struct event_filter *filter, int event_id)
2035} 2035}
2036 2036
2037/** 2037/**
2038 * pevent_filter_match - test if a record matches a filter 2038 * tep_filter_match - test if a record matches a filter
2039 * @filter: filter struct with filter information 2039 * @filter: filter struct with filter information
2040 * @record: the record to test against the filter 2040 * @record: the record to test against the filter
2041 * 2041 *
@@ -2046,8 +2046,8 @@ int pevent_event_filtered(struct event_filter *filter, int event_id)
2046 * NO_FILTER - if no filters exist 2046 * NO_FILTER - if no filters exist
2047 * otherwise - error occurred during test 2047 * otherwise - error occurred during test
2048 */ 2048 */
2049enum tep_errno pevent_filter_match(struct event_filter *filter, 2049enum tep_errno tep_filter_match(struct event_filter *filter,
2050 struct tep_record *record) 2050 struct tep_record *record)
2051{ 2051{
2052 struct tep_handle *pevent = filter->pevent; 2052 struct tep_handle *pevent = filter->pevent;
2053 struct filter_type *filter_type; 2053 struct filter_type *filter_type;
@@ -2364,7 +2364,7 @@ static char *arg_to_str(struct event_filter *filter, struct filter_arg *arg)
2364} 2364}
2365 2365
2366/** 2366/**
2367 * pevent_filter_make_string - return a string showing the filter 2367 * tep_filter_make_string - return a string showing the filter
2368 * @filter: filter struct with filter information 2368 * @filter: filter struct with filter information
2369 * @event_id: the event id to return the filter string with 2369 * @event_id: the event id to return the filter string with
2370 * 2370 *
@@ -2373,7 +2373,7 @@ static char *arg_to_str(struct event_filter *filter, struct filter_arg *arg)
2373 * NULL is returned if no filter is found or allocation failed. 2373 * NULL is returned if no filter is found or allocation failed.
2374 */ 2374 */
2375char * 2375char *
2376pevent_filter_make_string(struct event_filter *filter, int event_id) 2376tep_filter_make_string(struct event_filter *filter, int event_id)
2377{ 2377{
2378 struct filter_type *filter_type; 2378 struct filter_type *filter_type;
2379 2379
@@ -2389,7 +2389,7 @@ pevent_filter_make_string(struct event_filter *filter, int event_id)
2389} 2389}
2390 2390
2391/** 2391/**
2392 * pevent_filter_compare - compare two filters and return if they are the same 2392 * tep_filter_compare - compare two filters and return if they are the same
2393 * @filter1: Filter to compare with @filter2 2393 * @filter1: Filter to compare with @filter2
2394 * @filter2: Filter to compare with @filter1 2394 * @filter2: Filter to compare with @filter1
2395 * 2395 *
@@ -2397,7 +2397,7 @@ pevent_filter_make_string(struct event_filter *filter, int event_id)
2397 * 1 if the two filters hold the same content. 2397 * 1 if the two filters hold the same content.
2398 * 0 if they do not. 2398 * 0 if they do not.
2399 */ 2399 */
2400int pevent_filter_compare(struct event_filter *filter1, struct event_filter *filter2) 2400int tep_filter_compare(struct event_filter *filter1, struct event_filter *filter2)
2401{ 2401{
2402 struct filter_type *filter_type1; 2402 struct filter_type *filter_type1;
2403 struct filter_type *filter_type2; 2403 struct filter_type *filter_type2;