}
static
-int convert_cycles_to_ns(bt_clock_class *clock_class,
+int convert_cycles_to_ns(struct ctf_clock_class *clock_class,
uint64_t cycles, int64_t *ns)
{
- return bt_clock_class_cycles_to_ns_from_origin(clock_class, cycles,
- ns);
+ return bt_util_clock_cycles_to_ns_from_origin(cycles,
+ clock_class->frequency, clock_class->offset_seconds,
+ clock_class->offset_cycles, ns);
}
static
BT_LOGD("Building index from .idx file of stream file %s",
ds_file->file->path->str);
-
- ret = bt_msg_iter_borrow_packet_header_context_fields(
- ds_file->msg_iter, NULL, NULL);
+ ret = bt_msg_iter_get_packet_properties(ds_file->msg_iter, &props);
if (ret) {
- BT_LOGD_STR("Cannot borrow first packet's header and context "
- "fields.");
+ BT_LOGD_STR("Cannot read first packet's header and context fields.");
goto error;
}
- ret = bt_msg_iter_get_packet_properties(ds_file->msg_iter, &props);
- BT_ASSERT(ret == 0);
sc = ctf_trace_class_borrow_stream_class_by_id(ds_file->metadata->tc,
props.stream_class_id);
BT_ASSERT(sc);
BT_ASSERT(packet_size >= 0);
entry->packet_size = packet_size;
- /* Convert the packet's bound to nanoseconds since Epoch. */
- ret = convert_cycles_to_ns(sc->default_clock_class,
- props->snapshots.beginning_clock,
- &entry->timestamp_begin_ns);
- if (ret) {
- BT_LOGD_STR("Failed to convert raw timestamp to nanoseconds since Epoch.");
- goto end;
+ if (props->snapshots.beginning_clock != UINT64_C(-1)) {
+ /* Convert the packet's bound to nanoseconds since Epoch. */
+ ret = convert_cycles_to_ns(sc->default_clock_class,
+ props->snapshots.beginning_clock,
+ &entry->timestamp_begin_ns);
+ if (ret) {
+ BT_LOGD_STR("Failed to convert raw timestamp to nanoseconds since Epoch.");
+ goto end;
+ }
+ } else {
+ entry->timestamp_begin_ns = UINT64_C(-1);
}
- ret = convert_cycles_to_ns(sc->default_clock_class,
- props->snapshots.end_clock,
- &entry->timestamp_end_ns);
- if (ret) {
- BT_LOGD_STR("Failed to convert raw timestamp to nanoseconds since Epoch.");
- goto end;
+ if (props->snapshots.end_clock != UINT64_C(-1)) {
+ ret = convert_cycles_to_ns(sc->default_clock_class,
+ props->snapshots.end_clock,
+ &entry->timestamp_end_ns);
+ if (ret) {
+ BT_LOGD_STR("Failed to convert raw timestamp to nanoseconds since Epoch.");
+ goto end;
+ }
+ } else {
+ entry->timestamp_end_ns = UINT64_C(-1);
}
end:
struct ctf_fs_ds_index_entry *entry;
struct bt_msg_iter_packet_properties props;
- iter_status = bt_msg_iter_borrow_packet_header_context_fields(
- ds_file->msg_iter, NULL, NULL);
+ iter_status = bt_msg_iter_get_packet_properties(
+ ds_file->msg_iter, &props);
if (iter_status != BT_MSG_ITER_STATUS_OK) {
if (iter_status == BT_MSG_ITER_STATUS_EOF) {
break;
goto error;
}
- ret = bt_msg_iter_get_packet_properties(ds_file->msg_iter,
- &props);
- BT_ASSERT(ret == 0);
-
current_packet_offset =
bt_msg_iter_get_current_packet_offset(
ds_file->msg_iter);
}
BT_HIDDEN
-enum bt_message_iterator_status ctf_fs_ds_file_next(
+bt_message_iterator_status ctf_fs_ds_file_next(
struct ctf_fs_ds_file *ds_file,
bt_message **msg)
{
enum bt_msg_iter_status msg_iter_status;
- enum bt_message_iterator_status status;
+ bt_message_iterator_status status;
msg_iter_status = bt_msg_iter_get_next_message(
ds_file->msg_iter, ds_file->pc_msg_iter, msg);
return status;
}
-BT_HIDDEN
-int ctf_fs_ds_file_borrow_packet_header_context_fields(
- struct ctf_fs_ds_file *ds_file,
- bt_field **packet_header_field,
- bt_field **packet_context_field)
-{
- enum bt_msg_iter_status msg_iter_status;
- int ret = 0;
-
- BT_ASSERT(ds_file);
- msg_iter_status = bt_msg_iter_borrow_packet_header_context_fields(
- ds_file->msg_iter, packet_header_field, packet_context_field);
- switch (msg_iter_status) {
- case BT_MSG_ITER_STATUS_EOF:
- case BT_MSG_ITER_STATUS_OK:
- break;
- case BT_MSG_ITER_STATUS_AGAIN:
- abort();
- case BT_MSG_ITER_STATUS_INVAL:
- case BT_MSG_ITER_STATUS_ERROR:
- default:
- goto error;
- break;
- }
-
- goto end;
-
-error:
- ret = -1;
-
-end:
- return ret;
-}
-
BT_HIDDEN
void ctf_fs_ds_index_destroy(struct ctf_fs_ds_index *index)
{