Add lttng_event_get_exclusion_name*() to liblttng-ctl
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Sat, 29 Aug 2015 22:32:37 +0000 (18:32 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 3 Mar 2016 22:19:42 +0000 (17:19 -0500)
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
include/lttng/event.h
src/lib/lttng-ctl/lttng-ctl.c

index a85f0f3b569ff002471a2f49af679ae35082177b..bf37a116792d0961703b39ef494589fde12aa5d9 100644 (file)
@@ -307,6 +307,25 @@ extern int lttng_list_events(struct lttng_handle *handle,
 extern int lttng_event_get_filter_string(struct lttng_event *event,
                const char **filter_string);
 
+/*
+ * Get the number of exclusion names of a specific LTTng event.
+ *
+ * Returns the number of exclusion names on success, or a negative
+ * LTTng error code on error.
+ */
+extern int lttng_event_get_exclusion_name_count(struct lttng_event *event);
+
+/*
+ * Get an LTTng event's exclusion name at a given index.
+ *
+ * If the call is successful, then the exclusion name string's address
+ * is put in *exclusion_name. The caller does NOT own *exclusion_name.
+ *
+ * Returns 0 on success, or a negative LTTng error code on error.
+ */
+extern int lttng_event_get_exclusion_name(struct lttng_event *event,
+               size_t index, const char **exclusion_name);
+
 /*
  * List the available tracepoints of a specific lttng domain.
  *
index 02b3fed4cd3a76a7ff5d828fbabed8723ca38750..c7665922f4f014f5b5dd07c6ffae69d6e6887e73 100644 (file)
@@ -1817,6 +1817,67 @@ end:
        return ret;
 }
 
+int lttng_event_get_exclusion_name_count(struct lttng_event *event)
+{
+       int ret;
+       struct lttcomm_event_extended_header *ext_header;
+
+       if (!event) {
+               ret = -LTTNG_ERR_INVALID;
+               goto end;
+       }
+
+       ext_header = event->extended.ptr;
+       if (!ext_header) {
+               /*
+                * This can happen since the lttng_event structure is
+                * used for other tasks where this pointer is never set.
+                */
+               ret = 0;
+               goto end;
+       }
+
+       if (ext_header->nb_exclusions > INT_MAX) {
+               ret = -LTTNG_ERR_OVERFLOW;
+               goto end;
+       }
+       ret = (int) ext_header->nb_exclusions;
+end:
+       return ret;
+}
+
+int lttng_event_get_exclusion_name(struct lttng_event *event,
+               size_t index, const char **exclusion_name)
+{
+       int ret = 0;
+       struct lttcomm_event_extended_header *ext_header;
+       void *at;
+
+       if (!event || !exclusion_name) {
+               ret = -LTTNG_ERR_INVALID;
+               goto end;
+       }
+
+       ext_header = event->extended.ptr;
+       if (!ext_header) {
+               ret = -LTTNG_ERR_INVALID;
+               goto end;
+       }
+
+       if (index >= ext_header->nb_exclusions) {
+               ret = -LTTNG_ERR_INVALID;
+               goto end;
+       }
+
+       at = (void *) ext_header + sizeof(*ext_header);
+       at += ext_header->filter_len;
+       at += index * LTTNG_SYMBOL_NAME_LEN;
+       *exclusion_name = at;
+
+end:
+       return ret;
+}
+
 /*
  * Sets the tracing_group variable with name.
  * This function allocates memory pointed to by tracing_group.
This page took 0.026921 seconds and 4 git commands to generate.