The functions that give access to the properties of the fields (int
signedness, base, char len, etc), were only working with definition
struct which prevented their use before actually reading the events.
This patch changes the prototypes of these functions to use
declarations instead of definitions and provides a converter
function to access the declaration from a definition.
Fix: allow specifying more than one input trace path
We need to fix this right away: leaving the OUTPUT cmd line argument
take away the possibility to specify multiple input trace paths, with is
a very common use-case when merging traces from various nodes.
Now, output can be changed by specifying -w, --output OUTPUT. This is a
rare use-case anyway, to allowing multiple input paths outweight the
need for cmd line arg compatibility, even at this stage.
If a partial error happens (some traces cannot be opened), wait for 3
seconds before showing the conversion output, to ensure users can see
the warnings.
Fix: --clock-force-correlate to handle trace collections gathered from various nodes
Currently, traces generated by lttng have the "absolute" flag set to 0,
because they are based on the monotonic clock, which is not perfectly
correlated across nodes.
Fix a couple of minor issue in the handling of --clock-force-correlate
that now allow to use it to force correlation of traces taken with the
monotonic clock source, with "offset" approximation populated using NTP
time.
Hui Zhu [Thu, 23 Aug 2012 12:07:32 +0000 (08:07 -0400)]
Fix trace-collection.h: No such file or directory that build code with libbabeltrace
After I install the babeltrace and try to build a code, I got this:
gcc -Wall -g 1.c -lbabeltrace -lbabeltrace-ctf
In file included from 1.c:11:0:
/usr/local/include/babeltrace/babeltrace.h:23:41: fatal error:
babeltrace/trace-collection.h: No such file or directory
compilation terminated.
I check the code, looks most of function of trace-collection.h is
covered by context.h.
Julien Desfossez [Sat, 18 Aug 2012 13:16:42 +0000 (09:16 -0400)]
Fix: don't free unallocated index
When opening a mmap trace, the index is not created so does not need to
be freed, just add a check before freeing it.
For clarity, this patch also allocates the packet_real_index just after
the packet_cycles_index instead of waiting for the convert timestamp
function.
Julien Desfossez [Wed, 15 Aug 2012 21:32:01 +0000 (17:32 -0400)]
Fix: add mmap_base_offset to ctf_stream_pos
When dealing with mmap traces, the whole trace buffer is mmapped in
babeltrace and we may need to read it one subbuffer at a time.
In order to do that, we need to keep a reference of the base of the
current subbuffer inside the mmap region.
Danny Serres [Fri, 10 Aug 2012 22:10:23 +0000 (18:10 -0400)]
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.
Julien Desfossez [Fri, 10 Aug 2012 21:36:48 +0000 (17:36 -0400)]
Fix: safety checks for opening mmap traces
When adding a mmap trace in the context, we don't have any tracefile and
index, some safety checks were missing in the path handling and
timestamp manipulation.
The clock-raw does not make much sense except internally, using this
clock for seeks and with the public API is more complicated than
necessary.
This patch replaces the clock-raw by a clock-cycles (does not scale the
timestamp with the frequency) and make sure all the calls that
manipulate timestamps use the timestamp in nanoseconds with the offset
applied.
That way the user of the API don't need to bother with the "raw"
timestamp which won't be convenient when dealing with multiple traces
taken in different timezones.
Traces output before and after this patch are exactly the same
and multiple API calls have been tested with real timestamps and
everything seems to work fine.
Avoid an eventual double-free if heap_init fails in bt_iter_set_pos.
[ Note by Mathieu Desnoyers: the current implementation of heap_init
ensures that ptrs is set to NULL when it fails, so there is currently
no double-free situation. But let's not rely on this implementation
detail that might change in the future. ]
Iterating over all the streams of the trace_collection was a mistake
since we could not identify the end of the streams (so we would always
save the position of the last event).
When we save the new position, we now iterate over each stream active in
a copy of the current heap to save their position. That way we don't
save the position for streams read entirely.
Fixes: #293 Fixes: #296
[ Edit by Mathieu Desnoyers: fix memory leaks on errors ]
This flag is not appropriately used in the context of the library and is
not required. We now introduce a "poison" value to know when the
last_offset value is bogus.
Add verification so we free the array only if iterator is of type BT_SEEK_RESTORE
Add return statement at the end of case
Set type of bt_iter_pos returned by bt_iter_get_pos
[ Mathieu Desnoyers edit: check the iter_pos->type before the restore
pointer in bt_iter_free_pos. The && operator is a sequence point, so
the first check is done before the second. Since we might not be
using the union for restore if type != BT_SEEK_RESTORE, check the
type first before accessing the (possibly wrong) union field. ]
- various return values were untested
- seek_file_stream_by_timestamp off-by-one
- multi-trace logic issue
- not testing the return value of g_ptr_array_index() for NULL (possible
NULL pointer dereference)
Julien Desfossez [Thu, 14 Jun 2012 12:09:44 +0000 (08:09 -0400)]
Fix babeltrace iterator lib: seek at time 0
When seeking by timestamp, we assumed that the timestamp passed as an
argument was a real timestamp from the trace. However LTTV uses
timestamp 0 to refer to the beginning of the trace. This fix ensures
that we read at least the first event after the seek.
- If a subdirectory is empty, just warn and continue anyway.
- On partial error, babeltrace now returns a nonzero error value to the
parent process, even though it proceeds anyway.
Fix: support 64-bit events discarded counter types
Previously, counters coming for 64-bit architectures would be treated in
the same way as 32-bit counters, and would therefore miss 32-bit
overflows (only happens if 2^32 events or more are lost within in a
packet).
The hashtable storing the trace handle is created with a destroy
function that frees the elements when they are removed. Manually calling
the destroy function after removing a handle for the table causes
double-free problems.
- Update manpage, help, and cmd line arg parsing.
- Clarify that the default behavior is "payload,context", implying
that specifying -n ... overrides the default behavior.
When opening a trace collection, if one of the traces has an error,
don't forbid opening the entire collection because of it: just print a
warning and continue.
This patchs allows the user to list the fields (in all scopes) for each
event declarations (so as soon as the trace is opened).
It uses a lazy allocation, so the memory for storing the fields is only
allocated if the users asks for the list and it is allocated per event.
Julien Desfossez [Fri, 30 Mar 2012 19:50:12 +0000 (15:50 -0400)]
fix/breakage API : replace bt_ctf_event
Following the namespace cleanup, the bt_ctf_event structure is now a
ctf_event_definition structure. Users of the API only have to do this
substitution.