X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=lib%2Fcontext.c;h=45aab34bdfc71c1b78bc9c409d42e70230b307b3;hp=5820fb3e5533ba97693044ce0e419ca0382545d8;hb=34d9941856a9274398e63f2c2a86300dc157eafd;hpb=731087d8e045649286a83aa9909b8b0d79b3368d diff --git a/lib/context.c b/lib/context.c index 5820fb3e..45aab34b 100644 --- a/lib/context.c +++ b/lib/context.c @@ -137,14 +137,24 @@ int bt_context_add_trace(struct bt_context *ctx, const char *path, if (ret != 0) goto error; - ret = fmt->convert_index_timestamp(td); - if (ret < 0) - goto error; + if (fmt->convert_index_timestamp) { + ret = fmt->convert_index_timestamp(td); + if (ret < 0) + goto error; + } - handle->real_timestamp_begin = fmt->timestamp_begin(td, handle, BT_CLOCK_REAL); - handle->real_timestamp_end = fmt->timestamp_end(td, handle, BT_CLOCK_REAL); - handle->cycles_timestamp_begin = fmt->timestamp_begin(td, handle, BT_CLOCK_CYCLES); - handle->cycles_timestamp_end = fmt->timestamp_end(td, handle, BT_CLOCK_CYCLES); + if (fmt->timestamp_begin) + handle->real_timestamp_begin = fmt->timestamp_begin(td, + handle, BT_CLOCK_REAL); + if (fmt->timestamp_end) + handle->real_timestamp_end = fmt->timestamp_end(td, handle, + BT_CLOCK_REAL); + if (fmt->timestamp_begin) + handle->cycles_timestamp_begin = fmt->timestamp_begin(td, + handle, BT_CLOCK_CYCLES); + if (fmt->timestamp_end) + handle->cycles_timestamp_end = fmt->timestamp_end(td, handle, + BT_CLOCK_CYCLES); return handle->id; @@ -217,6 +227,8 @@ void remove_trace_handle(struct bt_trace_handle *handle) { int ret; + if (!handle->td->ctx) + return; /* Remove from containers */ bt_trace_collection_remove(handle->td->ctx->tc, handle->td); /* Close the trace */