Update python bindings for session and trace format descriptor
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Thu, 18 Aug 2022 14:07:35 +0000 (10:07 -0400)
committerJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Fri, 19 Aug 2022 16:11:10 +0000 (12:11 -0400)
TODO: this is the bare minimum change. It would be interesting to maybe
adopt a bindings style ala bt2 instead of exposing the C api as-is.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: I8b3b555e4f78cc4e1b610ac94ef388fab78a1451

extras/bindings/swig/python/lttng.i.in

index b555f4aae02c85ab0762d8115def223b18ec7504..4389ac278151931b38d1b72cdd5a1e98ca1460cd 100644 (file)
@@ -18,6 +18,7 @@ multiple concurrent processes and threads. Tracing across multiple systems is al
 %include "typemaps.i"
 %include "stdint.i"
 %include "pyabc.i"
+%include "cstring.i"
 %{
 #define SWIG_FILE_WITH_INIT
 #include <lttng/lttng.h>
@@ -178,6 +179,37 @@ enum lttng_event_context_type {
 };
 
 
+%rename("SESSION_DESCRIPTOR_STATUS_INVALID") LTTNG_SESSION_DESCRIPTOR_STATUS_INVALID;
+%rename("SESSION_DESCRIPTOR_STATUS_OK") LTTNG_SESSION_DESCRIPTOR_STATUS_OK;
+%rename("SESSION_DESCRIPTOR_STATUS_UNSET") LTTNG_SESSION_DESCRIPTOR_STATUS_UNSET;
+enum lttng_session_descriptor_status {
+       /* Invalid session descriptor parameter. */
+       LTTNG_SESSION_DESCRIPTOR_STATUS_INVALID = -1,
+       LTTNG_SESSION_DESCRIPTOR_STATUS_OK = 0,
+       /* Session descriptor parameter is unset. */
+       LTTNG_SESSION_DESCRIPTOR_STATUS_UNSET = 1,
+};
+
+// Opaque objects
+%nodefaultctor lttng_trace_format_descriptor;
+%extend lttng_trace_format_descriptor {
+   ~lttng_trace_format_descriptor() {
+      lttng_trace_format_descriptor_destroy(self);
+   }
+}
+%ignore lttng_trace_format_descriptor_destroy;
+
+struct lttng_trace_format_descriptor{};
+
+%nodefaultctor lttng_session_descriptor;
+%extend lttng_session_descriptor {
+   ~lttng_session_descriptor() {
+      lttng_session_descriptor_destroy(self);
+   }
+}
+%ignore lttng_session_descriptor_destroy;
+
+struct lttng_session_descriptor{};
 
 
 // =============================================
@@ -460,6 +492,156 @@ If either or both of the arguments are null, attr content is zeroe'd."
 void lttng_channel_set_default_attr(struct lttng_domain *domain, struct lttng_channel_attr *attr);
 
 
+%feature("docstring")"session_descriptor_create(str name)
+
+Create a session descriptor in no-output mode.
+
+The 'name' parameter can be left NULL to auto-generate a session name.
+
+Returns an lttng_session_descriptor instance on success, NULL on error."
+
+%newobject lttng_session_descriptor_create;
+struct lttng_session_descriptor * lttng_session_descriptor_create(const char *name);
+
+%feature("docstring")"session_descriptor_local_create(str name, str path)
+
+Create a session descriptor with a local output destination.
+
+The 'name' parameter can be left NULL to auto-generate a session name.
+
+The 'path' must either be an absolute path or it can be left NULL to
+use the default local output destination.
+
+Returns an lttng_session_descriptor instance on success, NULL on error."
+
+%newobject lttng_session_descriptor_local_create;
+struct lttng_session_descriptor * lttng_session_descriptor_local_create(const char *name, const char *path);
+
+%feature("docstring")"session_descriptor_network_create(str name, str control_url, str data_url)
+
+Create a session descriptor with a remote output destination.
+
+The 'name' parameter can be left NULL to auto-generate a session name.
+
+The 'control_url' and 'data_url' must conform to the URL format
+described above or can be left NULL to use the default network output.
+
+Returns an lttng_session_descriptor instance on success, NULL on error. "
+%newobject lttng_session_descriptor_network_create;
+struct lttng_session_descriptor * lttng_session_descriptor_network_create(const char *name, const char *control_url, const char *data_url);
+
+%feature("docstring")"session_descriptor_snapshot_create(str name)
+
+Create a snapshot session descriptor without a default output.
+
+The 'name' parameter can be left NULL to auto-generate a session name.
+
+Returns an lttng_session_descriptor instance on success, NULL on error."
+%newobject lttng_session_descriptor_snapshot_create;
+struct lttng_session_descriptor * lttng_session_descriptor_snapshot_create(const char *name);
+
+%feature("docstring")"session_descriptor_snapshot_local_create(str name)
+
+Create a snapshot session descriptor with a local output destination.
+
+The 'name' parameter can be left NULL to auto-generate a session name.
+
+The 'path' must either be an absolute path or it can be left NULL to
+use the default local output destination as the default snapshot output.
+
+Returns an lttng_session_descriptor instance on success, NULL on error."
+
+%newobject lttng_session_descriptor_snapshot_local_create;
+struct lttng_session_descriptor * lttng_session_descriptor_snapshot_local_create(const char *name, const char *path);
+
+%feature("docstring")"session_descriptor_snapshot_network_create(str name, str control_url, str data_url)
+
+Create a snapshot session descriptor with a remote output destination.
+
+The 'name' parameter can be left NULL to auto-generate a session name.
+
+The 'control_url' and 'data_url' must conform to the URL format
+described above or can be left NULL to use the default network output as
+the default snapshot output.
+
+Returns an lttng_session_descriptor instance on success, NULL on error."
+%newobject lttng_session_descriptor_snapshot_network_create;
+struct lttng_session_descriptor * lttng_session_descriptor_snapshot_network_create(const char *name, const char *control_url, const char *data_url);
+
+%feature("docstring")"session_descriptor_live_create(str name)
+
+Create a live session descriptor without an output.
+
+The 'name' parameter can be left NULL to auto-generate a session name.
+
+The 'live_timer_interval_us' parameter is the live timer's period, specified
+in microseconds.
+
+This parameter can't be 0. There is no default value defined for a live
+timer's period.
+
+Returns an lttng_session_descriptor instance on success, NULL on error. "
+%newobject lttng_session_descriptor_live_create;
+struct lttng_session_descriptor * lttng_session_descriptor_live_create( const char *name, unsigned long long live_timer_interval_us);
+
+%feature("docstring")"session_descriptor_live_network_create(str name, str
+%control_uri, str data_url, int live_timer_interval_us)
+
+Create a live session descriptor with a remote output destination.
+
+The 'name' parameter can be left NULL to auto-generate a session name.
+
+The 'control_url' and 'data_url' must conform to the URL format
+described above or can be left NULL to use the default network output.
+
+The 'live_timer_interval_us' parameter is the live timer's period, specified
+in microseconds.
+
+This parameter can't be 0. There is no default value defined for a live
+timer's period.
+
+Returns an lttng_session_descriptor instance on success, NULL on error."
+%newobject lttng_session_descriptor_live_network_create;
+struct lttng_session_descriptor * lttng_session_descriptor_live_network_create( const char *name, const char *control_url, const char *data_url, unsigned long long live_timer_interval_us); 
+
+%delobject lttng_session_descriptor_destroy;
+void lttng_session_descriptor_destroy(struct lttng_session_descriptor *descriptor);
+
+%feature("docstring")"session_descriptor_get_name(str name, str
+/*
+ * Get a session descriptor's session name.
+ *
+ * The 'name' parameter is used as an output parameter and will point to
+ * the session descriptor's session name on success
+ * (LTTNG_SESSION_DESCRIPTOR_STATUS_OK). Its content of is left unspecified
+ * for other return codes. The pointer returned through 'name' is only
+ * guaranteed to remain valid until the next method call on the session
+ * descriptor.
+ *
+ * Returns LTTNG_SESSION_DESCRIPTOR_STATUS_OK on success,
+ * LTTNG_SESSION_DESCRIPTOR_STATUS_INVALID if 'descriptor' or 'name' are
+ * NULL, and LTTNG_SESSION_DESCRIPTOR_STATUS_UNSET if the descriptor's
+ * name parameter is unset.
+ */
+ "
+// name must not be freed
+%cstring_output_allocate(char **name,);
+enum lttng_session_descriptor_status lttng_session_descriptor_get_session_name( const struct lttng_session_descriptor *descriptor, const char **name); 
+
+enum lttng_session_descriptor_status lttng_session_descriptor_set_trace_format_descriptor(struct lttng_session_descriptor *session_descriptor, const struct lttng_trace_format_descriptor *trace_format_descriptor);
+
+%newobject lttng_trace_format_ctf_1_descriptor_create;
+struct lttng_trace_format_descriptor *lttng_trace_format_ctf_1_descriptor_create(void);
+
+%newobject lttng_trace_format_ctf_2_descriptor_create;
+struct lttng_trace_format_descriptor *lttng_trace_format_ctf_2_descriptor_create(void);
+
+%delobject lttng_trace_format_descriptor_destroy;
+void lttng_trace_format_descriptor_destroy(struct lttng_trace_format_descriptor *descriptor);
+
+enum lttng_error_code lttng_create_session_ext(struct lttng_session_descriptor *session_descriptor);
+
+
 // =============================================
 //     Python redefinition of some functions
 //     (List and Handle-related)
This page took 0.030786 seconds and 5 git commands to generate.