From: "Steven Rostedt (Google)" <rostedt@xxxxxxxxxxx> Add a way to get the number of registered functions in a tep handler. Signed-off-by: Steven Rostedt (Google) <rostedt@xxxxxxxxxxx> --- Documentation/libtraceevent-func_apis.txt | 5 ++++- include/traceevent/event-parse.h | 2 ++ src/event-parse-api.c | 14 ++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Documentation/libtraceevent-func_apis.txt b/Documentation/libtraceevent-func_apis.txt index 89e307afe63f..1fe450023772 100644 --- a/Documentation/libtraceevent-func_apis.txt +++ b/Documentation/libtraceevent-func_apis.txt @@ -4,7 +4,8 @@ libtraceevent(3) NAME ---- tep_find_function, tep_find_function_address, tep_set_function_resolver, -tep_reset_function_resolver, tep_register_function, tep_register_print_string - +tep_reset_function_resolver, tep_register_function, tep_register_print_string, +tep_get_function_count - function related tep APIs SYNOPSIS @@ -20,6 +21,7 @@ const char pass:[*]*tep_find_function*(struct tep_handle pass:[*]_tep_, unsigned unsigned long long *tep_find_function_address*(struct tep_handle pass:[*]_tep_, unsigned long long _addr_); int *tep_register_function*(struct tep_handle pass:[*]_tep_, char pass:[*]_name_, unsigned long long _addr_, char pass:[*]_mod_); int *tep_register_print_string*(struct tep_handle pass:[*]_tep_, const char pass:[*]_fmt_, unsigned long long _addr_); +int *tep_get_function_count*(struct tep_handle *_tep_) -- DESCRIPTION @@ -75,6 +77,7 @@ addresses and those strings. The _tep_ argument is the trace event parser context. The _fmt_ is the string to register, it is copied internally. The _addr_ is the address the string was located at. +*tep_get_function_count*() returns the number of registered functions in a tep handler. RETURN VALUE ------------ diff --git a/include/traceevent/event-parse.h b/include/traceevent/event-parse.h index 68b2f4383b42..0b911e1caa7c 100644 --- a/include/traceevent/event-parse.h +++ b/include/traceevent/event-parse.h @@ -566,6 +566,8 @@ struct tep_event **tep_list_events_copy(struct tep_handle *tep, struct tep_format_field **tep_event_common_fields(struct tep_event *event); struct tep_format_field **tep_event_fields(struct tep_event *event); +int tep_get_function_count(struct tep_handle *tep); + enum tep_endian { TEP_LITTLE_ENDIAN = 0, TEP_BIG_ENDIAN diff --git a/src/event-parse-api.c b/src/event-parse-api.c index a765a683f05d..268a58609419 100644 --- a/src/event-parse-api.c +++ b/src/event-parse-api.c @@ -50,6 +50,20 @@ int tep_get_events_count(struct tep_handle *tep) return 0; } +/** + * tep_get_events_count - get the number of defined events + * @tep: a handle to the tep_handle + * + * This returns number of elements in event array + * If @tep is NULL, 0 is returned. + */ +int tep_get_function_count(struct tep_handle *tep) +{ + if (tep) + return tep->func_count; + return 0; +} + /** * tep_set_flag - set event parser flag * @tep: a handle to the tep_handle -- 2.34.1