Babeltrace python binding

The Babeltrace Python module can be used to directly control
the Babeltrace API inside Python, using 'import babeltrace'.

Therefore, it becomes possible to create a Context, add a
trace to it, iterate on it, read events and so on from
within Python.

SWIG >= 2.0 is used to create the wrapper and its
'warning md variable unused' bug is patched in Makefile.am

In the interface file, struct and enum are directly copied
from the include files. All changes to struct bt_iter_pos
and to enums in ctf/events.h and clock-types.h  must also
be made in the interface file.

Signed-off-by: Danny Serres <danny.serres@efficios.com>
Signed-off-by: Yannick Brosseau <yannick.brosseau@gmail.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Merge branch 'master' into bindings/python
Merge branch 'master' into bindings/python

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fix: Python bindings build fix. Reflects SEEK_END API change.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Merge branch 'master' into bindings/python
Fix: Mismatching function signatures used by python bindings

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fix: Python 3 binding compatibility and clean intermediate files.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fix: Removed Python bindings to static constructor and destructor.

Resolves an undefined symbol on Python module load.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fix: Double free when calling bt_context_remove_trace()

ctf_close_trace was being called twice when calling
bt_context_remove_trace thus causing free() to be called on an invalid
pointer.

Calling bt_context_remove_trace() would call ctf_close_trace() once via
the close_handle callback registered on the ctf format struct and a
second call would take place from bt_trace_handle_destroy() which is
registered as the value_destroy_func on the trace_handles hash table of
the current context.

bt_trace_handle_destroy() now only deallocates the trace handle and does
not perform the trace closing. This makes the
bt_trace_handle_create/destroy and bt_context_add/remove_trace parts of
the public API symmetric.

The crash is reproducible by invoking the tests-python.py script.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fix: Unified types expected by the Definition Python interface.

This change makes the Python iterator test case execute successfully.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fix: Added a null pointer check to bt_ctf_field_name

This function is called indirectly when calling __repr__ (print) in the
python bindings on the definition object returned by the
get_top_level_scope method thus resulting in a segmentation fault when
the name attribute is not set.

Fixes #373

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Added Python 3.0 or better requirement to the README file

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Added Python interpreter version directives and reorganized example scripts

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Remove extra -I for python bindings

Same fix as for lttng-tools commit f7cbc765ad2526667f1f20b3a89c596b3422ac34

Signed-off-by: Yannick Brosseau <yannick.brosseau@gmail.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Merge branch 'master' into bindings/python

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Make python bindings compile with trunk

Signed-off-by: Xiaona Han <xiaonahappy13@gmail.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Add bt_unregister_format function support

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Merge branch 'master' into bindings/python

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Add missing call to _bt_ctf_get_decl_from_def() when calling _bt_ctf_get_int_len().

The python code that call _bt_ctf_get_int_len() fails to wrap self._d
with the call to _bt_ctf_get_decl_from_def.

Acked-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Signed-off-by: Amit Margalit <amitm@il.ibm.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fix (python): use of braces in format strings

Using braces in format strings without specifying a number (e.g. "The
number {} is incorrect".format(some_variable)) is available since Python
2.7, and older Python 2.6 required a number, zero-based (e.g. "The
number {0} is incorrect").

This patch adds these numbers for the sake of older systems.

Acked-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Signed-off-by: Amit Margalit <amitm@il.ibm.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>