babeltrace.git
10 years agoMerge real index and cycles index into a single index
Mathieu Desnoyers [Wed, 29 Jan 2014 02:14:48 +0000 (21:14 -0500)] 
Merge real index and cycles index into a single index

Merge those two into a single index array, rather than having partially
duplicated data.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoFix: import index containing only a header
Julien Desfossez [Fri, 7 Feb 2014 16:12:58 +0000 (11:12 -0500)] 
Fix: import index containing only a header

If the index file is present, we have to make sure we imported at least
one index before using the stream_class.

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
10 years agoRemove outdated Python bindings test
Jérémie Galarneau [Tue, 4 Feb 2014 17:53:34 +0000 (12:53 -0500)] 
Remove outdated Python bindings test

This test is based on the old version of the Python bindings which
was part of the experimental branch.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
10 years agoFix: replace assert with proper error handling
Julien Desfossez [Fri, 17 Jan 2014 18:11:39 +0000 (13:11 -0500)] 
Fix: replace assert with proper error handling

If we receive the wrong packet, we should send the error and exit
cleanly instead of asserting.

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
10 years agoFix: lttng-live: unbounded use of sscanf() in parse_url()
Mathieu Desnoyers [Thu, 16 Jan 2014 19:52:24 +0000 (14:52 -0500)] 
Fix: lttng-live: unbounded use of sscanf() in parse_url()

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoFix: lttng-live should accept 0 in addresses
Julien Desfossez [Tue, 7 Jan 2014 19:16:03 +0000 (14:16 -0500)] 
Fix: lttng-live should accept 0 in addresses

Fixes #708

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoRemove default to display field names in live
Julien Desfossez [Tue, 7 Jan 2014 18:04:38 +0000 (13:04 -0500)] 
Remove default to display field names in live

Let Babeltrace option parsing code to set this option instead of
overriding it.

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
10 years agoRemove null checks on g_new0
Mathieu Desnoyers [Sat, 14 Dec 2013 15:38:31 +0000 (10:38 -0500)] 
Remove null checks on g_new0

g_new0 never returns NULL. We need to either always check for NULL, or
never. Remove all NULL checks on pointers returned by g_new0. Coverity
was complaining because we were dereferencing a pointer in an error path
after checking it against NULL, which is certainly never OK.

Found by coverity:

** CID 1136988:  Dereference after null check  (FORWARD_NULL)
/formats/lttng-live/lttng-live.c: 152 in lttng_live_open_trace_read()

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoCleanup: iterator unused pointer value
Mathieu Desnoyers [Sat, 14 Dec 2013 15:55:04 +0000 (10:55 -0500)] 
Cleanup: iterator unused pointer value

Found by Coverity:

** CID 1136757:  Unused pointer value  (UNUSED_VALUE)
/lib/iterator.c: 831 in bt_iter_next()

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoFix: lttng-live: resource leak
Mathieu Desnoyers [Sat, 14 Dec 2013 15:51:37 +0000 (10:51 -0500)] 
Fix: lttng-live: resource leak

Found by Coverity:

** CID 1136987:  Resource leak  (RESOURCE_LEAK)
/formats/lttng-live/lttng-live-functions.c: 372 in lttng_live_attach_session()
/formats/lttng-live/lttng-live-functions.c: 386 in lttng_live_attach_session()
/formats/lttng-live/lttng-live-functions.c: 383 in lttng_live_attach_session()

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoFix: lttng-live uninitialized scalar variable
Mathieu Desnoyers [Sat, 14 Dec 2013 15:47:00 +0000 (10:47 -0500)] 
Fix: lttng-live uninitialized scalar variable

Found by coverity:

** CID 1136985:  Uninitialized scalar variable  (UNINIT)
/formats/lttng-live/lttng-live-functions.c: 128 in lttng_live_establish_connection()

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoFix: lttng-live non NULL-terminated strings
Mathieu Desnoyers [Sat, 14 Dec 2013 15:44:17 +0000 (10:44 -0500)] 
Fix: lttng-live non NULL-terminated strings

Found by coverity.

** CID 1136986:  String not null terminated  (STRING_NULL)
/formats/lttng-live/lttng-live-functions.c: 375 in lttng_live_attach_session()

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agolttng-live: fix unchecked mkdir return value
Mathieu Desnoyers [Sat, 14 Dec 2013 15:36:13 +0000 (10:36 -0500)] 
lttng-live: fix unchecked mkdir return value

Found by coverity:
** CID 1136989:  Unchecked return value from library  (CHECKED_RETURN)
/formats/lttng-live/lttng-live-functions.c: 374 in lttng_live_attach_session()

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agolttng-live input plugin
Julien Desfossez [Thu, 12 Dec 2013 20:32:35 +0000 (15:32 -0500)] 
lttng-live input plugin

This new input format allows Babeltrace to connect a lttng-relayd and
attach to a running live session.

In order to use it, you need to create a live session (refer to LTTng
documentation for that) and then :
babeltrace -i lttng-live net://hostname

Where hostname is the hostname or IP address of the lttng-relayd
receiving the live trace.

When you do this command, it will list the active sessions on the relay.
To attach to a particular session, redo the same command, but add after
the hostname the session ID of the session you want to read.
For example, to attach to the session 42 :
babeltrace -i lttng-live net://hostname/42

If you want to know what is going on in the background, you can add the
-v for a verbose output.

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoLive: let read API detect inactive streams, allow streams without fd
Julien Desfossez [Thu, 12 Dec 2013 20:32:34 +0000 (15:32 -0500)] 
Live: let read API detect inactive streams, allow streams without fd

In live streaming, there are cases where a stream will be inactive from
beginning to end and so will never call bt_iter_next. For those cases,
we have to detect when we are reading an inactive stream which happens
when all other active streams have been closed.

We don't want to have the same checks in two places, so this fix removes
the return of EAGAIN in bt_iter_next and instead returns a NULL event
with the new BT_ITER_FLAG_RETRY flag set.

Also, handle cases where streams and traces have no associated file
descriptors.

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoAdd Jérémie Galarneau as co-maintainer
Mathieu Desnoyers [Wed, 11 Dec 2013 20:22:36 +0000 (15:22 -0500)] 
Add Jérémie Galarneau as co-maintainer

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoFix: disallow re-using same event ID in same stream
Mathieu Desnoyers [Tue, 10 Dec 2013 21:45:08 +0000 (16:45 -0500)] 
Fix: disallow re-using same event ID in same stream

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoFix: check for unknown enum/variant fields
Mathieu Desnoyers [Mon, 9 Dec 2013 12:31:11 +0000 (07:31 -0500)] 
Fix: check for unknown enum/variant fields

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoFix: libbabeltrace lib build dependencies
Mathieu Desnoyers [Mon, 9 Dec 2013 12:28:51 +0000 (07:28 -0500)] 
Fix: libbabeltrace lib build dependencies

The "no-as-needed" is only needed for plugins, not for libraries we
depend upon, so it is not really needed here. Using LIBADD instead
ensures that libbabeltrace gets rebuilt whenever the content of
libbabeltrace_types (statically linked) is modified.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoFixes in babeltrace core to support non-CTF traces
Julien Desfossez [Tue, 3 Dec 2013 22:34:57 +0000 (17:34 -0500)] 
Fixes in babeltrace core to support non-CTF traces

Since we will have an effort soon to cleanup the Babeltrace plugin
mechanism, this patch adds just the bits required in Babeltrace to not
crash if a non-ctf is opened. We also add the support of net:// URIs.
That way, an input plugin can just implement the open_trace callback
and process its own input trace without requiring a CTF iterator.

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoAdd a private pointer to the ctf_stream_pos
Julien Desfossez [Tue, 3 Dec 2013 22:34:56 +0000 (17:34 -0500)] 
Add a private pointer to the ctf_stream_pos

This allows a custom packet_seek function to fetch private information
about the current stream.

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoBe more widely accepting for missing variant/enum fields
Mathieu Desnoyers [Wed, 4 Dec 2013 16:09:16 +0000 (17:09 +0100)] 
Be more widely accepting for missing variant/enum fields

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoCleanup: remove index_read (unused var)
Mathieu Desnoyers [Tue, 3 Dec 2013 16:41:16 +0000 (17:41 +0100)] 
Cleanup: remove index_read (unused var)

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoRefuse 0 integer size
Mathieu Desnoyers [Tue, 3 Dec 2013 16:13:12 +0000 (17:13 +0100)] 
Refuse 0 integer size

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoFix ctf-writer: possible use after free
Jérémie Galarneau [Fri, 29 Nov 2013 18:26:42 +0000 (13:26 -0500)] 
Fix ctf-writer: possible use after free

ctf_stream_pos' base_mma member must be copied from stream->pos before
updating the final packet and content sizes. The original base_mma
structure will be reallocated if the packet is resized.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoFix data_offset when importing the indexes
Julien Desfossez [Fri, 29 Nov 2013 22:43:39 +0000 (17:43 -0500)] 
Fix data_offset when importing the indexes

When importing an index, we don't have the data_offset and we want to
mmap the tracefile only when needed, so we introduce a new function to
only compute this information when we are going to use a new packet.

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoMerge branch 'master' into bindings/python
Mathieu Desnoyers [Fri, 29 Nov 2013 06:19:33 +0000 (07:19 +0100)] 
Merge branch 'master' into bindings/python

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoPython-bindings fix: Out of tree build fails to find babeltrace.i
Jérémie Galarneau [Thu, 28 Nov 2013 18:19:10 +0000 (13:19 -0500)] 
Python-bindings fix: Out of tree build fails to find babeltrace.i

This fixes the out of tree builds by using the appropriate top_srcdir
and top_builddir variables in the bindings' Makefile.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoTest: Validate that enumeration mapping strings are properly escaped
Jérémie Galarneau [Thu, 28 Nov 2013 20:46:41 +0000 (15:46 -0500)] 
Test: Validate that enumeration mapping strings are properly escaped

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoFix ctf-writer: Quote strings provided as enumeration mappings
Jérémie Galarneau [Thu, 28 Nov 2013 20:46:40 +0000 (15:46 -0500)] 
Fix ctf-writer: Quote strings provided as enumeration mappings

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoFix: read/write mode check
Mathieu Desnoyers [Thu, 28 Nov 2013 00:00:49 +0000 (19:00 -0500)] 
Fix: read/write mode check

It's on the "prot" field, not flags. Moreover, it needs to be done with
a == / != comparison, not a mask.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoCleanup: do not duplicate code in float fix
Mathieu Desnoyers [Wed, 27 Nov 2013 19:38:53 +0000 (14:38 -0500)] 
Cleanup: do not duplicate code in float fix

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoFix: floats should set content size in tmp definition
Mathieu Desnoyers [Wed, 27 Nov 2013 19:37:52 +0000 (14:37 -0500)] 
Fix: floats should set content size in tmp definition

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoHandle empty streams on iterator init
Julien Desfossez [Wed, 27 Nov 2013 16:40:12 +0000 (11:40 -0500)] 
Handle empty streams on iterator init

In live trace streaming, we can create an iterator with inactive
streams. This patch allows inactive streams to be considered as valid.

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoHandle packets containing only a header
Julien Desfossez [Wed, 27 Nov 2013 16:40:11 +0000 (11:40 -0500)] 
Handle packets containing only a header

In live streaming with LTTng, if we do a stop and then a destroy, we
receive a packet that contains only a header. With this patch, we will
ask for a new packet when we see this case.

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoHandle the inactive streams
Julien Desfossez [Wed, 27 Nov 2013 16:40:10 +0000 (11:40 -0500)] 
Handle the inactive streams

When content_size == 0, just set the timestamp_end of the packet and
reinsert the stream in the heap.
This is required to handle the beacons of inactivity generated in
LTTng live trace streaming.

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoFix: test content size vs headers len
Mathieu Desnoyers [Wed, 27 Nov 2013 09:50:54 +0000 (04:50 -0500)] 
Fix: test content size vs headers len

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoFix: check packet index len
Mathieu Desnoyers [Wed, 27 Nov 2013 09:26:53 +0000 (04:26 -0500)] 
Fix: check packet index len

Found by coverity:

** CID 1132646:  Untrusted value as argument  (TAINTED_SCALAR)
/formats/ctf/ctf.c: 1715 in import_stream_packet_inde)

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoFix: uncheck null pointer
Mathieu Desnoyers [Wed, 27 Nov 2013 09:22:54 +0000 (04:22 -0500)] 
Fix: uncheck null pointer

Found by coverity:

** CID 1132647:  Dereference null return value  (NULL_RETURNS)
/formats/ctf/ctf.c: 1852 in ctf_open_file_stream_read()

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoFix: test for less than 1 byte packets
Mathieu Desnoyers [Wed, 27 Nov 2013 09:07:08 +0000 (04:07 -0500)] 
Fix: test for less than 1 byte packets

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoFix: reversed logic in packet vs content size
Mathieu Desnoyers [Wed, 27 Nov 2013 08:38:23 +0000 (03:38 -0500)] 
Fix: reversed logic in packet vs content size

As described in CTF section 5.2

"If the packet size field is missing, the whole stream only contains a
single packet. If the content size field is missing, the packet is
filled (no padding). The content and packet sizes include all headers."

Here is the correct semantic:

* Content size and packet size are available:

  Packet is filled with data up to content size, and then with padding
  up to packet size.

* Content size available, no packet size field:

  The stream has a single packet. It is filled up to content size, and
  the rest is padding.

* Packet size available, no content size field:

  Packet filled completely, no padding.

Fixes #683

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoFix: clarify end of packet error
Mathieu Desnoyers [Wed, 27 Nov 2013 08:32:06 +0000 (03:32 -0500)] 
Fix: clarify end of packet error

Fixes #686

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoFix: string packet boundary handling, bits vs bytes
Mathieu Desnoyers [Wed, 27 Nov 2013 08:28:45 +0000 (03:28 -0500)] 
Fix: string packet boundary handling, bits vs bytes

Fixes #684

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoFix: add stricter checks on packet boundaries
Mathieu Desnoyers [Wed, 27 Nov 2013 08:19:31 +0000 (03:19 -0500)] 
Fix: add stricter checks on packet boundaries

Fixes #699

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoParse CTF indexes
Julien Desfossez [Tue, 26 Nov 2013 17:08:06 +0000 (12:08 -0500)] 
Parse CTF indexes

If a trace file has an associated index (same filename and .idx suffix
in the "index" folder), we open it and use it instead of generating
the index at open.
The index folder is not mandatory and can be destroyed without any
problem.

To use with LTTng, make sure you have lttng-tools commit :
50adc26400482c07210afcda8ef1d3322f75871d
Mon Nov 25 15:32:38 2013 -0500
Rename LTTng index in CTF index

Versions between commit 309167d2a6f59d0c8cbf64eb23ba912cdea76a34 and
this commit have a different index format that will never be merged in
Babeltrace, so if you have traces recorded between this period of
time, just remove the index directory.

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoCleanup: fix typo
Mathieu Desnoyers [Tue, 26 Nov 2013 18:11:21 +0000 (13:11 -0500)] 
Cleanup: fix typo

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoFix: fail when reading 0 byte event
Mathieu Desnoyers [Tue, 26 Nov 2013 17:36:28 +0000 (12:36 -0500)] 
Fix: fail when reading 0 byte event

Rather than looping forever.

Fixes #685

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoPython-bindings fix: outdated dist target babeltrace.i
Jérémie Galarneau [Sat, 23 Nov 2013 21:30:59 +0000 (16:30 -0500)] 
Python-bindings fix: outdated dist target babeltrace.i

This fixes the dist target for the python bindings. The
python-complements.h/.c files must be distributed, but not installed,
in order to build the python bindings.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoPython-bindings: Refactor the CTFWriter API
Jérémie Galarneau [Fri, 22 Nov 2013 05:02:33 +0000 (00:02 -0500)] 
Python-bindings: Refactor the CTFWriter API

Refactor the CTFWriter API to be more in line with the reader
modifications.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
10 years agoFix: bt_ctf_field_generic_validate should return < 0 on error
Jérémie Galarneau [Fri, 22 Nov 2013 04:46:37 +0000 (23:46 -0500)] 
Fix: bt_ctf_field_generic_validate should return < 0 on error

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
10 years agoFix: Take the iterator's end position into account
Jérémie Galarneau [Fri, 22 Nov 2013 01:19:25 +0000 (20:19 -0500)] 
Fix: Take the iterator's end position into account

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
10 years agoFix: Use the bt_iter_set_pos function to set the begin_pos
Jérémie Galarneau [Thu, 21 Nov 2013 23:07:20 +0000 (18:07 -0500)] 
Fix: Use the bt_iter_set_pos function to set the begin_pos

The current implementation of bt_iter_init asserts on begin_pos
that are not BT_SEEK_BEGIN. This uses the iterator set_pos function
to achieve the intended behavior.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
10 years agoPython-bindings: Move declaration bindings out of the _Definition class
Jérémie Galarneau [Thu, 21 Nov 2013 20:45:50 +0000 (15:45 -0500)] 
Python-bindings: Move declaration bindings out of the _Definition class

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
10 years agoPython-bindings: Refactor the FieldDecl and EventDecl classes
Jérémie Galarneau [Thu, 21 Nov 2013 03:15:43 +0000 (22:15 -0500)] 
Python-bindings: Refactor the FieldDecl and EventDecl classes

Renamed the FieldDecl and EventDecl classes to FieldDeclaration and
EventDeclaration. Getters are now exposed as properties.

Fixed an out of bounds array access.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
10 years agoPython-bindings: Move the _scopes array out of the Event class
Jérémie Galarneau [Thu, 21 Nov 2013 02:33:16 +0000 (21:33 -0500)] 
Python-bindings: Move the _scopes array out of the Event class

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
10 years agoPython-bindings: Refactor the Event class
Jérémie Galarneau [Thu, 21 Nov 2013 01:35:51 +0000 (20:35 -0500)] 
Python-bindings: Refactor the Event class

The Event class now implements the collections.Mapping interface and
provides properties where appropriate.

The Definition class is now private and renamed to _Definition.

The examples are modified to take these changes into account.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
10 years agoPython-bindings: Refactor the TraceHandle class to use properties
Jérémie Galarneau [Wed, 20 Nov 2013 06:09:31 +0000 (01:09 -0500)] 
Python-bindings: Refactor the TraceHandle class to use properties

TraceHandle now exposes properties instead of getters. It also keeps
a reference to its parent TraceCollection.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
10 years agoPython-bindings: Refactor the Context class
Jérémie Galarneau [Wed, 20 Nov 2013 05:28:05 +0000 (00:28 -0500)] 
Python-bindings: Refactor the Context class

The context class is now called TraceCollection and provides generator
functions to iterate over the traces' events. This makes it possible to
get rid of the Iterator, IterPos and File classes.

The examples are adapted to match the changes.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
10 years agoTest ctf-writer: Verify that enumerations are validated before use
Jérémie Galarneau [Mon, 18 Nov 2013 04:23:30 +0000 (23:23 -0500)] 
Test ctf-writer: Verify that enumerations are validated before use

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoFix ctf-writer: Reject enumerations containing no mappings
Jérémie Galarneau [Mon, 18 Nov 2013 04:23:03 +0000 (23:23 -0500)] 
Fix ctf-writer: Reject enumerations containing no mappings

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoFix lint warnings
Jérémie Galarneau [Fri, 15 Nov 2013 00:40:57 +0000 (19:40 -0500)] 
Fix lint warnings

** CID 1125105: Unchecked close() return value
formats/ctf/writer/stream.c: 521

** CID 1124085: Use after free
formats/ctf/writer/event-fields.c: 1128

** CID 1124088: Dereference before null check
formats/ctf/writer/stream.c: 371

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoExpose text arrays the same way as regular arrays
Jérémie Galarneau [Tue, 12 Nov 2013 21:22:10 +0000 (16:22 -0500)] 
Expose text arrays the same way as regular arrays

Store the content of text arrays both in the "elems" array and in a
string. While it does duplicate the data, this makes it possible to
access arrays containing UTF-8 or ASCII data the same way as regular
arrays.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
10 years agoDon't generate Python bindings by default
Jérémie Galarneau [Wed, 25 Sep 2013 18:21:47 +0000 (14:21 -0400)] 
Don't generate Python bindings by default

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
10 years agoAdd a usage example for the CTF Writer Python bindings
Jérémie Galarneau [Wed, 25 Sep 2013 00:51:13 +0000 (20:51 -0400)] 
Add a usage example for the CTF Writer Python bindings

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
10 years agoAdd CTF Writer Python bindings
Jérémie Galarneau [Tue, 17 Sep 2013 22:34:25 +0000 (18:34 -0400)] 
Add CTF Writer Python bindings

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
10 years agoRename the ctf class to CTFReader
Jérémie Galarneau [Tue, 17 Sep 2013 15:47:07 +0000 (11:47 -0400)] 
Rename the ctf class to CTFReader

This prevents name collisions with the upcoming CTFWriter classes.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
10 years agoFix: Python bindings array access functions write out of bounds
Jérémie Galarneau [Mon, 16 Sep 2013 23:59:00 +0000 (19:59 -0400)] 
Fix: Python bindings array access functions write out of bounds

The array access functions in the Python complements are writing
past the last element to add a NULL pointer and then using it from the
Python code to detect the end of the array. This may cause stability
issues.

This changes the functions to return multiple values (array and length)
in Python using SWIG's built-in OUTPUT typemaps.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
10 years agoAdd support for structure fields in the Python bindings
Jérémie Galarneau [Fri, 13 Sep 2013 19:39:39 +0000 (15:39 -0400)] 
Add support for structure fields in the Python bindings

get_value() returns a dictionary when the field is a structure.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
10 years agoAdd support for variant fields in the Python bindings
Jérémie Galarneau [Fri, 13 Sep 2013 01:37:21 +0000 (21:37 -0400)] 
Add support for variant fields in the Python bindings

get_value() now returns the variant's selected field's value
when called on a variant.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
10 years agoAdd support for floating point fields in the Python bindings
Jérémie Galarneau [Fri, 13 Sep 2013 21:35:41 +0000 (17:35 -0400)] 
Add support for floating point fields in the Python bindings

get_value() now returns a floating point field's value.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
10 years agoFix: Use of functions not provided by glib 2.22
Jérémie Galarneau [Mon, 11 Nov 2013 16:16:41 +0000 (11:16 -0500)] 
Fix: Use of functions not provided by glib 2.22

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoFix: Throw a FieldError exception when get_value() fails
Jérémie Galarneau [Fri, 13 Sep 2013 21:32:58 +0000 (17:32 -0400)] 
Fix: Throw a FieldError exception when get_value() fails

Throw an exception whenever bt_ctf_field_get_error() reports an error.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
10 years agoRemove Python 2 specific examples
Jérémie Galarneau [Mon, 19 Aug 2013 19:48:12 +0000 (15:48 -0400)] 
Remove Python 2 specific examples

These examples rely on the cairoplot module which is not compatible with
Python 3.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
10 years agoAdd a python bindings sequence test
Xiaona Han [Fri, 2 Aug 2013 21:42:32 +0000 (05:42 +0800)] 
Add a python bindings sequence test

This example is meant to test whether we can get a sequence's values in
the python binding well or not. It is used in conjunction with the
sequence test in the dir tests/ctf-traces/succeed/sequence.

Signed-off-by: Xiaona Han <xiaonahappy13@163.com>
Acked-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
10 years agoSupport for the sequence type
Xiaona Han [Fri, 26 Jul 2013 10:32:36 +0000 (18:32 +0800)] 
Support for the sequence type

Add support for getting a sequence's value in the python binding.

Signed-off-by: Xiaona Han <xiaonahappy13@163.com>
Acked-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
10 years agoAdd a generic get_value() implementation
Xiaona Han [Fri, 26 Jul 2013 10:32:36 +0000 (18:32 +0800)] 
Add a generic get_value() implementation

Use get_value to get a field's value. Currently it does not support
compound types. Also it does not support floating point, since getting
a float's value is not implemented in babeltrace now.

Edit by Jérémie Galarneau: Arrays' value should not be returned using
get_char_array(). Implemented get_array_element_at() which returns a
Definition object corresponding to the array's element.

Exposed the bt_array_index function in the Python bindings

Signed-off-by: Xiaona Han <xiaonahappy13@163.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
10 years agoSupport getting the value of enums
Xiaona Han [Fri, 26 Jul 2013 09:48:02 +0000 (17:48 +0800)] 
Support getting the value of enums

Use 'get_enum_str' to get the string matching the current enumeration.

Signed-off-by: Xiaona Han <xiaonahappy13@163.com>
Acked-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
10 years agoRemove the unnecessary underscore prefix
Xiaona Han [Fri, 26 Jul 2013 08:07:43 +0000 (16:07 +0800)] 
Remove the unnecessary underscore prefix

When getting the fields of an event by name, it is not necessary
to add an underscore prefix. This removes the underscore prefix of
the field names in the examples.

Signed-off-by: Xiaona Han <xiaonahappy13@163.com>
Acked-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
10 years agoReturn event fields by field name
Xiaona Han [Thu, 25 Jul 2013 23:56:04 +0000 (07:56 +0800)] 
Return event fields by field name

Since a field may be present both in an event and its stream's scope,
this returns a list which contains all the fields by the name. The
examples are also changed to match this new API.

Signed-off-by: Xiaona Han <xiaonahappy13@163.com>
Acked-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
10 years agoMerge branch 'master' into bindings/python
Jérémie Galarneau [Tue, 12 Nov 2013 16:23:52 +0000 (11:23 -0500)] 
Merge branch 'master' into bindings/python

10 years agoctf writer BSD compatibily: remove O_DIRECTORY
Mathieu Desnoyers [Wed, 6 Nov 2013 19:52:59 +0000 (14:52 -0500)] 
ctf writer BSD compatibily: remove O_DIRECTORY

Not strictly needed, especially since we are creating the directory
ourself.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoFix ctf writer lints
Mathieu Desnoyers [Sat, 2 Nov 2013 02:52:06 +0000 (22:52 -0400)] 
Fix ctf writer lints

Coverity found:

**CHECKED_RETURN
formats/ctf/writer/writer.c
**bt_ctf_writer_destroy()

**CHECKED_RETURN
formats/ctf/writer/stream.c
**bt_ctf_stream_destroy()

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agolinter fix: comparison of fd >= 0
Mathieu Desnoyers [Sat, 2 Nov 2013 02:50:35 +0000 (22:50 -0400)] 
linter fix: comparison of fd >= 0

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agotest ctf writer: fix lints
Mathieu Desnoyers [Thu, 31 Oct 2013 20:52:42 +0000 (16:52 -0400)] 
test ctf writer: fix lints

Coverity found the following defects:

** CID 1124096: Null pointer dereference (FORWARD_NULL)
/tests/lib/test_ctf_writer.c: 140

** CID 1124095: Dereference after null check (FORWARD_NULL)
/tests/lib/test_ctf_writer.c: 139

** CID 1124094: Dereference after null check (FORWARD_NULL)
/tests/lib/test_ctf_writer.c: 211

** CID 1124093: Argument cannot be negative (NEGATIVE_RETURNS)
/tests/lib/test_ctf_writer.c: 144

** CID 1124092: Argument cannot be negative (NEGATIVE_RETURNS)
/tests/lib/test_ctf_writer.c: 144

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoctf-writer: fix linter defects
Mathieu Desnoyers [Thu, 31 Oct 2013 19:04:01 +0000 (15:04 -0400)] 
ctf-writer: fix linter defects

Coverity found the following defects:

** CID 1124098: Unchecked return value (CHECKED_RETURN)
/formats/ctf/writer/event-types.c: 200

** CID 1124097: Unchecked return value (CHECKED_RETURN)
/formats/ctf/writer/writer.c: 376

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoctf-writer: Coding style fix
Mathieu Desnoyers [Thu, 31 Oct 2013 19:02:38 +0000 (15:02 -0400)] 
ctf-writer: Coding style fix

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoTests: Add a CTF Writer test
Jérémie Galarneau [Wed, 16 Oct 2013 18:35:02 +0000 (14:35 -0400)] 
Tests: Add a CTF Writer test

The test will be ran as part of the "tests" test plan.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Reviewed-by: Christian Babeux <christian.babeux@efficios.com>
Reviewed-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoAdd CTF Writer implementation
Jérémie Galarneau [Wed, 16 Oct 2013 18:35:01 +0000 (14:35 -0400)] 
Add CTF Writer implementation

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Reviewed-by: Christian Babeux <christian.babeux@efficios.com>
Reviewed-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoAdd public CTF Writer API headers
Jérémie Galarneau [Wed, 16 Oct 2013 18:35:00 +0000 (14:35 -0400)] 
Add public CTF Writer API headers

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Reviewed-by: Christian Babeux <christian.babeux@efficios.com>
Reviewed-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoFix: Don't create a new packet if ctf_move_pos() seeks out of a packet
Jérémie Galarneau [Tue, 15 Oct 2013 17:23:46 +0000 (13:23 -0400)] 
Fix: Don't create a new packet if ctf_move_pos() seeks out of a packet

This change ensures that ctf_move_pos() does not create a new packet
when ctf_move_pos() moves out of the current packet's bounds. The next
call to ctf_pos_access_ok() will report EFAULT which can then be
handled appropriately by the caller.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Reviewed-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoFix: Uninitialized ctf_stream_pos structure in ctf_float_write()
Jérémie Galarneau [Tue, 15 Oct 2013 17:23:33 +0000 (13:23 -0400)] 
Fix: Uninitialized ctf_stream_pos structure in ctf_float_write()

This structure is passed to _ctf_float_copy() which uses the
uninitialized mmap_offset and offset values to read the source
floating point value.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Reviewed-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoFix: Use the packet's final size when mmap-ing the next packet
Jérémie Galarneau [Tue, 15 Oct 2013 17:23:18 +0000 (13:23 -0400)] 
Fix: Use the packet's final size when mmap-ing the next packet

ctf_packet_seek() assumed that a packet would be of fixed size
"WRITE_PACKET_LEN" when seeking to the next packet in write mode.
This ensures that the real size used.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Reviewed-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoFix: Close traces on context destruction
Jérémie Galarneau [Thu, 10 Oct 2013 16:08:30 +0000 (12:08 -0400)] 
Fix: Close traces on context destruction

bt_trace_handle_destroy is called on destruction of the trace_handle
hash table's elements. This function only frees the trace handle,
leaving the input traces open.

This fix sets remove_trace_handle as the value_destroy_func ensuring
that the format's close_trace function is called before the trace_handle
is destroyed.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agogcc warning fix: -Wextra
Mathieu Desnoyers [Tue, 8 Oct 2013 21:33:55 +0000 (17:33 -0400)] 
gcc warning fix: -Wextra

For the "ordered comparison of pointer with integer zero" warning, fix
this by comparing (type) -1 against (type) 0 instead of just 0, so if
"type" is a pointer type, this pointer type will be applied to the right
operand too, thus fixing the warning.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoDeclare enum type to use from C++
Francis Giraldeau [Fri, 13 Sep 2013 20:19:20 +0000 (16:19 -0400)] 
Declare enum type to use from C++

Anonymous enum can't be referenced from C++. to fix this issue, declare enum
bt_iter_pos_type and use this type in struct bt_iter_pos.

Signed-off-by: Francis Giraldeau <francis.giraldeau@gmail.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoFix: test_seek should only output one TAP plan
Christian Babeux [Mon, 26 Aug 2013 18:15:14 +0000 (14:15 -0400)] 
Fix: test_seek should only output one TAP plan

On critical failure paths, the test_seek test was outputting multiple
TAP plans, which according to the specification [1] is invalid. This
causes parsing issues on very strict TAP parsers.

[1] - http://podwiki.hexten.net/TAP/TAP.html?page=TAP

Signed-off-by: Christian Babeux <christian.babeux@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoRevert "Add missing declaration of ssize_t as unsigned long for SWIG"
Mathieu Desnoyers [Mon, 26 Aug 2013 17:46:54 +0000 (13:46 -0400)] 
Revert "Add missing declaration of ssize_t as unsigned long for SWIG"

This reverts commit 515d3e63070e76440856bb9a123e9b3fb82d5fb5.

Jeremie pointed out that he recommended _not_ to merge this patch.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 years agoAdd missing declaration of ssize_t as unsigned long for SWIG
Amit Margalit [Tue, 20 Aug 2013 07:41:30 +0000 (10:41 +0300)] 
Add missing declaration of ssize_t as unsigned long for SWIG

The file babeltrace.i.in contains a declaration of bt_get_int_len()
returning ssize_t, which SWIG does not recognize as an integer (perhaps
only in some cases).

Add a typedef to generate correct code.

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>
10 years agoFix (python): use of braces in format strings
Amit Margalit [Tue, 20 Aug 2013 06:30:38 +0000 (09:30 +0300)] 
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>
10 years agoAdd missing call to _bt_ctf_get_decl_from_def() when calling _bt_ctf_get_int_len().
Amit Margalit [Tue, 20 Aug 2013 06:29:02 +0000 (09:29 +0300)] 
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>
This page took 0.042276 seconds and 4 git commands to generate.