Remove Babeltrace 1 files and reorganize the tree This is one of the patches that you won't easily forget. This patch removes the remaining legacy files, moving them if we still need them, and reorganizes the tree as such: * formats/ is removed * formats/ctf/ir/ is moved to lib/ctf-ir/ * formats/ctf/writer/ is moved to lib/ctf-writer/ * types/ is removed Because some of the CTF IR and CTF writer objects are so coupled, both components are in libbabeltrace now. The build system creates a symbolic link from libbabeltrace-ctf (where CTF writer used to reside) to libbabeltrace, so that `-lbabeltrace-ctf` still works for the current users of CTF writer. converter/babeltrace-log.c still exists, but it's not build as of this patch because it uses the legacy API. We need to change this to use CTF writer and add it to the Makefile again. Some debug info files are gone because they also use the legacy API. They are updated anyway as part of the upcoming debug info component class. The Python bindings are not covered by this patch: a subsequent patch should fix them at once. Some tests which used the legacy API are removed. The legacy include files are removed, except for include/babeltrace/ctf/event.h which could be included by CTF writer users. The file simply includes all the CTF writer header files now. The functions to serialize integer and floating point number fields are moved to lib/ctf-writer/serialize.c where a light `struct bt_ctf_stream_pos` exists along with a few helper functions for this renamed legacy object. The serialization functions use BT 2 objects now so that the dependency on the legacy API can be dropped. The serialization functions accept a native byte order parameter now. When a field type has a "native" byte order, the real (passed) native byte order must be used. This ensures that: * CTF IR objects do not need to propagate the trace's native byte order to all the contained field types. * Two references to the same field type which are part of two different trace objects can have a native byte order without causing byte order overwriting bugs. The CTF IR code is simplified with this change. Also the bt_ctf_trace_set_byte_order() function refuses the BT_CTF_BYTE_ORDER_NATIVE byte order. I also added internal inline functions to quickly access the parent of some CTF IR object without getting a new reference: * bt_ctf_event_borrow_event_class() * bt_ctf_event_class_borrow_stream_class() * bt_ctf_stream_class_borrow_trace() Since the CTF parser test in formats/ctf/metadata/ was a legacy tool, it's removed in this patch. It's not used anymore by test_ctf_writer (only the converter runs to validate the generated trace). Leaks are fixed in test_ctf_ir_ref and test_trace_listener. Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Handle negative time and offset from Epoch Handle cases where a trace have a negative offset from Epoch. If Epoch is arbitrary (e.g. embedded system starting at 0, without any network access), the "0" can be used as correlation point between various components, and some components could start before the correlation point. Therefore, especially in traces where the time is meant to be shown in nanoseconds or cycles from the correlation point, it also makes sense to have a negative time value. It introduces API-breaking changes in the C and Python APIs, since we need to be able to return negative time values, which were previously used as errors (-1ULL). The --offset and --offset-ns command line parameters can now take negative offset (seconds and nanoseconds) values too. The [sec.ns] format is used as fallback so we don't attempt to pass a negative time value to POSIX time-formatting APIs. This also fixes an inaccurate return value in an error path of bt_ctf_event_populate_event_header(). Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Remove unused function bt_trace_handle_get_id This function was removed from trace-handle.h as part of commit e3d12cf93f067601df4179ef4b7e2a30aa0065f7 which changed the trace-handle API to use handle_ids instead of pointers to a struct bt_trace_handle. 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 : cleanup teardown of context Fix the error path when a trace is opened but errors occur when we index it, and close all traces when the context is destroyed. Signed-off-by: Julien Desfossez <jdesfossez@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Get rid of clock-raw and use real clock 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. Signed-off-by: Julien Desfossez <jdesfossez@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fix: check if handle is valid Fixes: #317 [ Edit by Mathieu Desnoyers: put successful return at end of function, and error return with the test for error. ] Signed-off-by: Julien Desfossez <jdesfossez@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
API Fix : handle id to use the public functions The API functions were designed to be used with struct trace_handle as parameters, but no public function returns such a struct. This patch fixes that by allowing the user to pass the context and the handle_id. Acked-by: Yannick Brosseau <yannick.brosseau@gmail.com> Signed-off-by: Julien Desfossez <julien.desfossez@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
babeltrace lib cleanup, folded with open/remove trace functions Folded patch from Yannick Brosseau <yannick.brosseau@gmail.com>, along with various updates and cleanups, related to babeltrace lib. Original changelog from Yannick Brosseau: Move the trace_collection into its own file. Port the converter to uses the new functions Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
API : trace_handle Add the trace_handle structure to allow the user to manipulate a trace. Will be useful for getting information on specific trace files and remove traces from a trace_collection without rebuilding the trace_collection entirely. Signed-off-by: Julien Desfossez <julien.desfossez@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>