_mPrecision {precision}, _mUuid {std::move(uuid)}
{
BT_ASSERT(_mFreq > 0);
- BT_ASSERT(_mOffset.cycles() < _mFreq);
+ //BT_ASSERT(_mOffset.cycles() < _mFreq);
}
/*
{
using UP = std::unique_ptr<ctf_visitor_generate_ir>;
- explicit ctf_visitor_generate_ir(const ctf::src::ClkClsCfg clkClsCfgParam,
- bt_self_component *selfCompParam,
+ explicit ctf_visitor_generate_ir(bt_self_component *selfCompParam,
const bt2_common::LogCfg& logCfgParam) noexcept :
logCfg {logCfgParam},
- selfComp {selfCompParam}, clkClsCfg {clkClsCfgParam}
+ selfComp {selfCompParam}
{
}
/* True if this is an LTTng trace */
bool is_lttng = false;
-
- const ctf::src::ClkClsCfg clkClsCfg;
};
BT_HIDDEN
-ctf_visitor_generate_ir::UP ctf_visitor_generate_ir_create(const ctf::src::ClkClsCfg clkClsCfg,
- bt_self_component *selfComp,
+ctf_visitor_generate_ir::UP ctf_visitor_generate_ir_create(bt_self_component *selfComp,
const bt2_common::LogCfg& logCfg);
BT_HIDDEN
bt_self_component * const selfComp,
const bt2c::LogCfg& logCfg) :
MetadataStreamParser {clkClsCfg, selfComp},
- _mLogCfg {logCfg}, _mOrigCtfIrGenerator {ctf_visitor_generate_ir_create(clkClsCfg, selfComp,
- logCfg)},
+ _mLogCfg {logCfg}, _mOrigCtfIrGenerator {ctf_visitor_generate_ir_create(nullptr, logCfg)},
_mScanner {ctf_scanner_alloc()}, _mStreamDecoder {logCfg}
{
}
* Copyright 2019 Philippe Proulx <pproulx@efficios.com>
*/
+#define BT_LOG_TAG "PLUGIN/CTF/META/CONFIG-IR-TRACE"
+#define BT_CLOG_CFG logCfg
+
#include <babeltrace2/babeltrace.h>
#include "ctf-meta-configure-ir-trace.hpp"
+#include "cpp-common/cfg-logging.hpp"
#include "cpp-common/uuid.hpp"
BT_HIDDEN
}
}
}
+
+BT_HIDDEN
+void ctf_trace_class_configure_ir_trace(const ctf::src::TraceCls& tc, bt2::Trace irTrace,
+ const bt2_common::LogCfg& logCfg)
+{
+ if (tc.uuid()) {
+ irTrace.uuid(*tc.uuid());
+ }
+
+ if (tc.env()) {
+ tc.env()->forEach([&irTrace, &logCfg](const bpstd::string_view name, bt2::ConstValue val) {
+ switch (val.type()) {
+ case bt2::ValueType::SIGNED_INTEGER:
+ irTrace.environmentEntry(name.c_str(), val.asSignedInteger().value());
+ break;
+
+ case bt2::ValueType::UNSIGNED_INTEGER:
+ {
+ auto uval = val.asUnsignedInteger().value();
+
+ if (uval > std::numeric_limits<std::int64_t>::max()) {
+ BT_CLOGW(
+ "Cannot convert unsigned integer environment entry value to signed integer without overflowing. Skipping environment entry: "
+ "entry-name=\"%s\", entry-value=%" PRIu64,
+ name.data(), uval);
+ break;
+ }
+
+ irTrace.environmentEntry(name.c_str(), static_cast<std::int64_t>(uval));
+ break;
+ }
+
+ case bt2::ValueType::STRING:
+ irTrace.environmentEntry(name.c_str(), val.asString().value().c_str());
+ break;
+
+ default:
+ bt_common_abort();
+ }
+ });
+ }
+}
#include "ctf-meta.hpp"
#include "cpp-common/bt2/trace-ir.hpp"
+#include "cpp-common/log-cfg.hpp"
+#include "plugins/ctf/common/src/metadata/ctf-ir.hpp"
BT_HIDDEN
void ctf_trace_class_configure_ir_trace(struct ctf_trace_class *tc, bt2::Trace ir_trace);
+BT_HIDDEN
+void ctf_trace_class_configure_ir_trace(const ctf::src::TraceCls& tc, bt2::Trace irTrace,
+ const bt2_common::LogCfg& logCfg);
+
#endif /* _CTF_META_CONFIGURE_IR_TRACE_H */
ctf_metadata_decoder_create(const struct ctf_metadata_decoder_config *config)
{
BT_ASSERT(config);
- BT_CLOGD_EX(config->logCfg,
- "Creating CTF metadata decoder: "
- "clock-class-offset-s=%" PRId64 ", "
- "clock-class-offset-ns=%" PRId64,
- config->clkClsCfg.offsetSec, config->clkClsCfg.offsetNanoSec);
+ BT_CLOGD_EX(config->logCfg, "Creating CTF metadata decoder");
ctf_metadata_decoder *mdec = new ctf_metadata_decoder {config->logCfg};
mdec->scanner = ctf_scanner_alloc();
mdec->bo = -1;
mdec->config = *config;
- mdec->visitor =
- ctf_visitor_generate_ir_create(config->clkClsCfg, config->self_comp, config->logCfg);
+ mdec->visitor = ctf_visitor_generate_ir_create(config->self_comp, config->logCfg);
if (!mdec->visitor) {
BT_CLOGE_APPEND_CAUSE("Failed to create a CTF IR metadata AST visitor: "
"mdec-addr=%p",
goto error;
}
- BT_CLOGD("Creating CTF metadata decoder: "
- "clock-class-offset-s=%" PRId64 ", "
- "clock-class-offset-ns=%" PRId64 ", addr=%p",
- config->clkClsCfg.offsetSec, config->clkClsCfg.offsetNanoSec, mdec);
+ BT_CLOGD("Created CTF metadata decoder: addr=%p", mdec);
goto end;
error:
/* Weak, used to create a bt_trace_class, if not nullptr. */
bt_self_component *self_comp = nullptr;
- ctf::src::ClkClsCfg clkClsCfg;
-
/* True to create trace class objects */
bool create_trace_class = false;
}
BT_HIDDEN
-ctf_visitor_generate_ir::UP ctf_visitor_generate_ir_create(const ctf::src::ClkClsCfg clkClsCfg,
- bt_self_component *selfComp,
+ctf_visitor_generate_ir::UP ctf_visitor_generate_ir_create(bt_self_component *selfComp,
const bt2_common::LogCfg& logCfg)
{
ctf_visitor_generate_ir::UP ctx =
- bt2_common::makeUnique<ctf_visitor_generate_ir>(clkClsCfg, selfComp, logCfg);
+ bt2_common::makeUnique<ctf_visitor_generate_ir>(selfComp, logCfg);
if (selfComp) {
bt_trace_class *trace_class = bt_trace_class_create(selfComp);
return cycles;
}
-static void apply_clock_class_is_absolute(struct ctf_visitor_generate_ir *ctx,
- struct ctf_clock_class *clock)
-{
- if (ctx->clkClsCfg.forceOriginIsUnixEpoch) {
- clock->is_absolute = true;
- }
-
- return;
-}
-
-static void apply_clock_class_offset(struct ctf_visitor_generate_ir *ctx,
- struct ctf_clock_class *clock)
-{
- uint64_t freq;
- int64_t offset_s_to_apply = ctx->clkClsCfg.offsetSec;
- uint64_t offset_ns_to_apply;
- int64_t cur_offset_s;
- uint64_t cur_offset_cycles;
- long long offsetSecLL;
- unsigned long long offsetCyclesULL;
-
- if (ctx->clkClsCfg.offsetSec == 0 && ctx->clkClsCfg.offsetNanoSec == 0) {
- goto end;
- }
-
- /* Transfer nanoseconds to seconds as much as possible */
- if (ctx->clkClsCfg.offsetNanoSec < 0) {
- const int64_t abs_ns = -ctx->clkClsCfg.offsetNanoSec;
- const int64_t abs_extra_s = abs_ns / INT64_C(1000000000) + 1;
- const int64_t extra_s = -abs_extra_s;
- const int64_t offset_ns = ctx->clkClsCfg.offsetNanoSec - (extra_s * INT64_C(1000000000));
-
- BT_ASSERT(offset_ns > 0);
- offset_ns_to_apply = (uint64_t) offset_ns;
- offset_s_to_apply += extra_s;
- } else {
- const int64_t extra_s = ctx->clkClsCfg.offsetNanoSec / INT64_C(1000000000);
- const int64_t offset_ns = ctx->clkClsCfg.offsetNanoSec - (extra_s * INT64_C(1000000000));
-
- BT_ASSERT(offset_ns >= 0);
- offset_ns_to_apply = (uint64_t) offset_ns;
- offset_s_to_apply += extra_s;
- }
-
- freq = clock->frequency;
- cur_offset_s = clock->offset_seconds;
- cur_offset_cycles = clock->offset_cycles;
-
- /* Apply offsets */
- cur_offset_s += offset_s_to_apply;
- cur_offset_cycles += cycles_from_ns(freq, offset_ns_to_apply);
-
- /*
- * Recalibrate offsets because the part in cycles can be greater
- * than the frequency at this point.
- */
- offsetSecLL = cur_offset_s;
- offsetCyclesULL = cur_offset_cycles;
- ctf::src::normalizeClkOffset(offsetSecLL, offsetCyclesULL, freq);
-
- /* Set final offsets */
- clock->offset_seconds = offsetSecLL;
- clock->offset_cycles = offsetCyclesULL;
-
-end:
- return;
-}
-
static int visit_clock_decl(struct ctf_visitor_generate_ir *ctx, struct ctf_node *clock_node)
{
int ret = 0;
BT_ASSERT(offsetCyclesULL < clock->frequency);
clock->offset_seconds = offsetSecLL;
clock->offset_cycles = offsetCyclesULL;
- apply_clock_class_offset(ctx, clock);
- apply_clock_class_is_absolute(ctx, clock);
g_ptr_array_add(ctx->ctf_tc->clock_classes, clock);
clock = NULL;
fs.cpp \
fs.hpp \
lttng-index.hpp \
- metadata.cpp \
- metadata.hpp \
query.hpp \
query.cpp
\ No newline at end of file
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
#include <glib.h>
#include <inttypes.h>
#include "compat/mman.h"
#include <babeltrace2/babeltrace.h>
#include "common/common.h"
#include "file.hpp"
-#include "metadata.hpp"
-#include "../common/src/msg-iter/msg-iter.hpp"
+#include "../common/src/pkt-props.hpp"
#include "common/assert.h"
#include "data-stream-file.hpp"
#include <string.h>
#include "cpp-common/cfg-logging.hpp"
#include "cpp-common/cfg-logging-error-reporting.hpp"
+#include "cpp-common/cfg-logging-error-reporting-throw.hpp"
#include "cpp-common/make-unique.hpp"
#include "fs.hpp"
-static inline size_t remaining_mmap_bytes(struct ctf_fs_ds_file *ds_file)
+using namespace bt2_common::literals::datalen;
+
+static bt2_common::DataLen getFileSize(const char * const path, const bt2_common::LogCfg logCfg)
+{
+ struct stat st;
+ if (stat(path, &st) != 0) {
+ BT_CLOGE_ERRNO_APPEND_CAUSE_AND_THROW(bt2::Error, "Failed to stat stream file", "path=%s",
+ path);
+ }
+
+ return bt2_common::DataLen::fromBytes(st.st_size);
+}
+
+ctf_fs_ds_file_info::ctf_fs_ds_file_info(std::string pathParam, bt2_common::LogCfg logCfg) :
+ path(std::move(pathParam)), size(getFileSize(path.c_str(), logCfg))
{
- BT_ASSERT_DBG(ds_file->mmap_len >= ds_file->request_offset_in_mapping);
- return ds_file->mmap_len - ds_file->request_offset_in_mapping;
}
/*
static bool offset_ist_mapped(struct ctf_fs_ds_file *ds_file, off_t offset_in_file)
{
+ if (!ds_file->mmap_addr)
+ return false;
+
return offset_in_file >= ds_file->mmap_offset_in_file &&
offset_in_file < (ds_file->mmap_offset_in_file + ds_file->mmap_len);
}
-static enum ctf_msg_iter_medium_status ds_file_munmap(struct ctf_fs_ds_file *ds_file)
+enum ds_file_status
+{
+ DS_FILE_STATUS_OK = 0,
+ DS_FILE_STATUS_ERROR = -1,
+ DS_FILE_STATUS_EOF = 1,
+};
+
+static ds_file_status ds_file_munmap(struct ctf_fs_ds_file *ds_file)
{
const bt2_common::LogCfg& logCfg = ds_file->logCfg;
BT_ASSERT(ds_file);
if (!ds_file->mmap_addr) {
- return CTF_MSG_ITER_MEDIUM_STATUS_OK;
+ return DS_FILE_STATUS_OK;
}
if (bt_munmap(ds_file->mmap_addr, ds_file->mmap_len)) {
": address=%p, size=%zu, file_path=\"%s\", file=%p", ds_file->mmap_addr,
ds_file->mmap_len, ds_file->file ? ds_file->file->path.c_str() : "NULL",
ds_file->file ? ds_file->file->fp.get() : NULL);
- return CTF_MSG_ITER_MEDIUM_STATUS_ERROR;
+ return DS_FILE_STATUS_ERROR;
}
ds_file->mmap_addr = NULL;
- return CTF_MSG_ITER_MEDIUM_STATUS_OK;
+ return DS_FILE_STATUS_OK;
}
/*
* mapping. If the currently mmap-ed region already contains
* `requested_offset_in_file`, the mapping is kept.
*
- * Set `ds_file->requested_offset_in_mapping` based on `request_offset_in_file`,
- * such that the next call to `request_bytes` will return bytes starting at that
- * position.
- *
* `requested_offset_in_file` must be a valid offset in the file.
*/
-static enum ctf_msg_iter_medium_status ds_file_mmap(struct ctf_fs_ds_file *ds_file,
- off_t requested_offset_in_file)
+static ds_file_status ds_file_mmap(struct ctf_fs_ds_file *ds_file, off_t requested_offset_in_file)
{
const bt2_common::LogCfg& logCfg = ds_file->logCfg;
BT_ASSERT(requested_offset_in_file < ds_file->file->size);
/*
- * If the mapping already contains the requested offset, just adjust
- * requested_offset_in_mapping.
+ * If the mapping already contains the requested range, we have nothing to
+ * do.
*/
if (offset_ist_mapped(ds_file, requested_offset_in_file)) {
- ds_file->request_offset_in_mapping =
- requested_offset_in_file - ds_file->mmap_offset_in_file;
- return CTF_MSG_ITER_MEDIUM_STATUS_OK;
+ return DS_FILE_STATUS_OK;
}
/* Unmap old region */
- ctf_msg_iter_medium_status status = ds_file_munmap(ds_file);
- if (status != CTF_MSG_ITER_MEDIUM_STATUS_OK) {
+ ds_file_status status = ds_file_munmap(ds_file);
+ if (status != DS_FILE_STATUS_OK) {
return status;
}
* Compute a mapping that has the required alignment properties and
* contains `requested_offset_in_file`.
*/
- ds_file->request_offset_in_mapping =
- requested_offset_in_file % bt_mmap_get_offset_align_size(logCfg.logLevel());
- ds_file->mmap_offset_in_file = requested_offset_in_file - ds_file->request_offset_in_mapping;
+ size_t alignment = bt_mmap_get_offset_align_size(logCfg.logLevel());
+ ds_file->mmap_offset_in_file =
+ requested_offset_in_file - (requested_offset_in_file % alignment);
ds_file->mmap_len =
MIN(ds_file->file->size - ds_file->mmap_offset_in_file, ds_file->mmap_max_len);
BT_ASSERT(ds_file->mmap_len > 0);
+ BT_ASSERT(requested_offset_in_file >= ds_file->mmap_offset_in_file);
+ BT_ASSERT(requested_offset_in_file < (ds_file->mmap_offset_in_file + ds_file->mmap_len));
ds_file->mmap_addr =
bt_mmap((void *) 0, ds_file->mmap_len, PROT_READ, MAP_PRIVATE,
BT_CLOGE("Cannot memory-map address (size %zu) of file \"%s\" (%p) at offset %jd: %s",
ds_file->mmap_len, ds_file->file->path.c_str(), ds_file->file->fp.get(),
(intmax_t) ds_file->mmap_offset_in_file, strerror(errno));
- return CTF_MSG_ITER_MEDIUM_STATUS_ERROR;
- }
-
- return CTF_MSG_ITER_MEDIUM_STATUS_OK;
-}
-
-/*
- * Change the mapping of the file to read the region that follows the current
- * mapping.
- *
- * If the file hasn't been mapped yet, then everything (mmap_offset_in_file,
- * mmap_len, request_offset_in_mapping) should have the value 0, which will
- * result in the beginning of the file getting mapped.
- *
- * return _EOF if the current mapping is the end of the file.
- */
-
-static enum ctf_msg_iter_medium_status ds_file_mmap_next(struct ctf_fs_ds_file *ds_file)
-{
- /*
- * If we're called, it's because more bytes are requested but we have
- * given all the bytes of the current mapping.
- */
- BT_ASSERT(ds_file->request_offset_in_mapping == ds_file->mmap_len);
-
- /*
- * If the current mapping coincides with the end of the file, there is
- * no next mapping.
- */
- if (ds_file->mmap_offset_in_file + ds_file->mmap_len == ds_file->file->size) {
- return CTF_MSG_ITER_MEDIUM_STATUS_EOF;
- }
-
- return ds_file_mmap(ds_file, ds_file->mmap_offset_in_file + ds_file->mmap_len);
-}
-
-static enum ctf_msg_iter_medium_status medop_request_bytes(size_t request_sz, uint8_t **buffer_addr,
- size_t *buffer_sz, void *data)
-{
- struct ctf_fs_ds_file *ds_file = (struct ctf_fs_ds_file *) data;
- const bt2_common::LogCfg& logCfg = ds_file->logCfg;
-
- BT_ASSERT(request_sz > 0);
-
- /*
- * Check if we have at least one memory-mapped byte left. If we don't,
- * mmap the next file.
- */
- if (remaining_mmap_bytes(ds_file) == 0) {
- /* Are we at the end of the file? */
- if (ds_file->mmap_offset_in_file >= ds_file->file->size) {
- BT_CLOGD("Reached end of file \"%s\" (%p)", ds_file->file->path.c_str(),
- ds_file->file->fp.get());
- return CTF_MSG_ITER_MEDIUM_STATUS_EOF;
- }
-
- ctf_msg_iter_medium_status status = ds_file_mmap_next(ds_file);
- switch (status) {
- case CTF_MSG_ITER_MEDIUM_STATUS_OK:
- break;
- case CTF_MSG_ITER_MEDIUM_STATUS_EOF:
- return CTF_MSG_ITER_MEDIUM_STATUS_EOF;
- default:
- BT_CLOGE("Cannot memory-map next region of file \"%s\" (%p)",
- ds_file->file->path.c_str(), ds_file->file->fp.get());
- return status;
- }
- }
-
- BT_ASSERT(remaining_mmap_bytes(ds_file) > 0);
- *buffer_sz = MIN(remaining_mmap_bytes(ds_file), request_sz);
-
- BT_ASSERT(ds_file->mmap_addr);
- *buffer_addr = ((uint8_t *) ds_file->mmap_addr) + ds_file->request_offset_in_mapping;
-
- ds_file->request_offset_in_mapping += *buffer_sz;
-
- return CTF_MSG_ITER_MEDIUM_STATUS_OK;
-}
-
-static bt_stream *medop_borrow_stream(bt_stream_class *stream_class, int64_t stream_id, void *data)
-{
- struct ctf_fs_ds_file *ds_file = (struct ctf_fs_ds_file *) data;
- bt_stream_class *ds_file_stream_class;
-
- ds_file_stream_class = (*ds_file->stream)->cls().libObjPtr();
-
- if (stream_class != ds_file_stream_class) {
- /*
- * Not supported: two packets described by two different
- * stream classes within the same data stream file.
- */
- return nullptr;
+ return DS_FILE_STATUS_ERROR;
}
- return (*ds_file->stream)->libObjPtr();
+ return DS_FILE_STATUS_OK;
}
-static enum ctf_msg_iter_medium_status medop_seek(off_t offset, void *data)
+void ctf_fs_ds_index::updateOffsetsInStream()
{
- struct ctf_fs_ds_file *ds_file = (struct ctf_fs_ds_file *) data;
+ bt2_common::DataLen offsetInStream = 0_bytes;
- BT_ASSERT(offset >= 0);
- BT_ASSERT(offset < ds_file->file->size);
-
- return ds_file_mmap(ds_file, offset);
-}
-
-BT_HIDDEN
-struct ctf_msg_iter_medium_ops ctf_fs_ds_file_medops = {
- medop_request_bytes,
- medop_seek,
- nullptr,
- medop_borrow_stream,
-};
-
-struct ctf_fs_ds_group_medops_data
-{
- explicit ctf_fs_ds_group_medops_data(const bt2_common::LogCfg& logCfgParam) noexcept :
- logCfg {logCfgParam}
- {
+ for (ctf_fs_ds_index_entry& entry : this->entries) {
+ entry.offsetInStream = offsetInStream;
+ offsetInStream += entry.packetSize;
}
-
- /* Weak, set once at creation time. */
- struct ctf_fs_ds_file_group *ds_file_group = nullptr;
-
- /*
- * Index (as in element rank) of the index entry of ds_file_groups'
- * index we will read next (so, the one after the one we are reading
- * right now).
- */
- guint next_index_entry_index = 0;
-
- /*
- * File we are currently reading. Changes whenever we switch to
- * reading another data file.
- *
- * Owned by this.
- */
- ctf_fs_ds_file::UP file;
-
- /* Weak, for context / logging / appending causes. */
- bt_self_message_iterator *self_msg_iter = nullptr;
- const bt2_common::LogCfg logCfg;
-};
-
-static enum ctf_msg_iter_medium_status medop_group_request_bytes(size_t request_sz,
- uint8_t **buffer_addr,
- size_t *buffer_sz, void *void_data)
-{
- struct ctf_fs_ds_group_medops_data *data = (struct ctf_fs_ds_group_medops_data *) void_data;
-
- /* Return bytes from the current file. */
- return medop_request_bytes(request_sz, buffer_addr, buffer_sz, data->file.get());
-}
-
-static bt_stream *medop_group_borrow_stream(bt_stream_class *stream_class, int64_t stream_id,
- void *void_data)
-{
- struct ctf_fs_ds_group_medops_data *data = (struct ctf_fs_ds_group_medops_data *) void_data;
-
- return medop_borrow_stream(stream_class, stream_id, data->file.get());
-}
-
-/*
- * Set `data->file` to prepare it to read the packet described
- * by `index_entry`.
- */
-
-static enum ctf_msg_iter_medium_status
-ctf_fs_ds_group_medops_set_file(struct ctf_fs_ds_group_medops_data *data,
- struct ctf_fs_ds_index_entry *index_entry)
-{
- BT_ASSERT(data);
- BT_ASSERT(index_entry);
-
- /* Check if that file is already the one mapped. */
- if (!data->file || strcmp(index_entry->path, data->file->file->path.c_str()) != 0) {
- /* Create the new file. */
- data->file =
- ctf_fs_ds_file_create(data->ds_file_group->ctf_fs_trace, data->ds_file_group->stream,
- index_entry->path, data->logCfg);
-
- if (!data->file) {
- const bt2_common::LogCfg& logCfg = data->logCfg;
- BT_CLOGE_APPEND_CAUSE("failed to create ctf_fs_ds_file.");
- return CTF_MSG_ITER_MEDIUM_STATUS_ERROR;
- }
- }
-
- /*
- * Ensure the right portion of the file will be returned on the next
- * request_bytes call.
- */
- return ds_file_mmap(data->file.get(), index_entry->offset.bytes());
-}
-
-static enum ctf_msg_iter_medium_status medop_group_switch_packet(void *void_data)
-{
- struct ctf_fs_ds_group_medops_data *data = (struct ctf_fs_ds_group_medops_data *) void_data;
-
- /* If we have gone through all index entries, we are done. */
- if (data->next_index_entry_index >= data->ds_file_group->index.entries.size()) {
- return CTF_MSG_ITER_MEDIUM_STATUS_EOF;
- }
-
- /*
- * Otherwise, look up the next index entry / packet and prepare it
- * for reading.
- */
- ctf_fs_ds_index_entry& index_entry =
- data->ds_file_group->index.entries[data->next_index_entry_index];
-
- ctf_msg_iter_medium_status status = ctf_fs_ds_group_medops_set_file(data, &index_entry);
- if (status != CTF_MSG_ITER_MEDIUM_STATUS_OK) {
- return status;
- }
-
- data->next_index_entry_index++;
-
- return CTF_MSG_ITER_MEDIUM_STATUS_OK;
-}
-
-void ctf_fs_ds_group_medops_data_deleter::operator()(ctf_fs_ds_group_medops_data *data)
-{
- delete data;
-}
-
-enum ctf_msg_iter_medium_status ctf_fs_ds_group_medops_data_create(
- struct ctf_fs_ds_file_group *ds_file_group, bt_self_message_iterator *self_msg_iter,
- const bt2_common::LogCfg& logCfg, ctf_fs_ds_group_medops_data_up& out)
-{
- BT_ASSERT(self_msg_iter);
- BT_ASSERT(ds_file_group);
- BT_ASSERT(!ds_file_group->index.entries.empty());
-
- out.reset(new ctf_fs_ds_group_medops_data {logCfg});
-
- out->ds_file_group = ds_file_group;
- out->self_msg_iter = self_msg_iter;
-
- /*
- * No need to prepare the first file. ctf_msg_iter will call
- * switch_packet before reading the first packet, it will be
- * done then.
- */
-
- return CTF_MSG_ITER_MEDIUM_STATUS_OK;
}
-void ctf_fs_ds_group_medops_data_reset(struct ctf_fs_ds_group_medops_data *data)
+static int convert_cycles_to_ns(const ctf::src::ClkCls& clockClass, uint64_t cycles, int64_t *ns)
{
- data->next_index_entry_index = 0;
-}
-
-struct ctf_msg_iter_medium_ops ctf_fs_ds_group_medops = {
- .request_bytes = medop_group_request_bytes,
-
- /*
- * We don't support seeking using this medops. It would probably be
- * possible, but it's not needed at the moment.
- */
- .seek = NULL,
-
- .switch_packet = medop_group_switch_packet,
- .borrow_stream = medop_group_borrow_stream,
-};
-
-static int convert_cycles_to_ns(struct ctf_clock_class *clock_class, uint64_t cycles, int64_t *ns)
-{
- return bt_util_clock_cycles_to_ns_from_origin(cycles, clock_class->frequency,
- clock_class->offset_seconds,
- clock_class->offset_cycles, ns);
+ return bt_util_clock_cycles_to_ns_from_origin(
+ cycles, clockClass.freq(), clockClass.offset().seconds(), clockClass.offset().cycles(), ns);
}
static nonstd::optional<ctf_fs_ds_index>
-build_index_from_idx_file(struct ctf_fs_ds_file *ds_file, struct ctf_fs_ds_file_info *file_info,
- struct ctf_msg_iter *msg_iter)
+build_index_from_idx_file(const ctf_fs_ds_file_info& fileInfo, const ctf::src::TraceCls& traceCls,
+ const bt2_common::LogCfg& logCfg)
{
- const bt2_common::LogCfg& logCfg = ds_file->logCfg;
-
- BT_CLOGI("Building index from .idx file of stream file %s", ds_file->file->path.c_str());
- ctf_msg_iter_packet_properties props;
- int ret = ctf_msg_iter_get_packet_properties(msg_iter, &props);
- if (ret) {
- BT_CLOGI_STR("Cannot read first packet's header and context fields.");
- return nonstd::nullopt;
- }
-
- ctf_stream_class *sc =
- ctf_trace_class_borrow_stream_class_by_id(ds_file->metadata->tc, props.stream_class_id);
- BT_ASSERT(sc);
- if (!sc->default_clock_class) {
- BT_CLOGI_STR("Cannot find stream class's default clock class.");
- return nonstd::nullopt;
- }
+ const char *path = fileInfo.path.c_str();
+ BT_CLOGI("Building index from .idx file of stream file %s", path);
/* Look for index file in relative path index/name.idx. */
- bt2_common::GCharUP basename {g_path_get_basename(ds_file->file->path.c_str())};
+ bt2_common::GCharUP basename {g_path_get_basename(path)};
if (!basename) {
- BT_CLOGE("Cannot get the basename of datastream file %s", ds_file->file->path.c_str());
+ BT_CLOGE("Cannot get the basename of datastream file %s", path);
return nonstd::nullopt;
}
- bt2_common::GCharUP directory {g_path_get_dirname(ds_file->file->path.c_str())};
+ bt2_common::GCharUP directory {g_path_get_dirname(path)};
if (!directory) {
- BT_CLOGE("Cannot get dirname of datastream file %s", ds_file->file->path.c_str());
+ BT_CLOGE("Cannot get dirname of datastream file %s", path);
return nonstd::nullopt;
}
return nonstd::nullopt;
}
+ /*
+ * We need the clock class to convert cycles to ns. For that, we need the
+ * stream class. Read the stream class id from the first packet's header.
+ * We don't know the size of that packet yet, so pretend that it spans the
+ * whole file (the reader will only read the header anyway).
+ */
+ ctf_fs_ds_index_entry tempIndexEntry {path, 0_bits, fileInfo.size};
+ ctf_fs_ds_index tempIndex;
+ tempIndex.entries.emplace_back(tempIndexEntry);
+
+ ctf::src::fs::Medium::UP medium =
+ bt2_common::makeUnique<ctf::src::fs::Medium>(tempIndex, logCfg);
+ ctf::src::PktProps props = ctf::src::readPktProps(traceCls, std::move(medium), 0_bytes, logCfg);
+
+ const ctf::src::DataStreamCls *sc = props.dataStreamCls;
+ BT_ASSERT(sc);
+ if (!sc->defClkCls()) {
+ BT_CLOGI_STR("Cannot find stream class's default clock class.");
+ return nonstd::nullopt;
+ }
+
ctf_fs_ds_index index;
ctf_fs_ds_index_entry *prev_index_entry = nullptr;
- bt2_common::DataLen totalPacketsSize = bt2_common::DataLen::fromBytes(0);
+ bt2_common::DataLen totalPacketsSize = 0_bytes;
for (size_t i = 0; i < file_entry_count; i++) {
struct ctf_packet_index *file_index = (struct ctf_packet_index *) file_pos;
}
bt2_common::DataLen offset = bt2_common::DataLen::fromBytes(be64toh(file_index->offset));
- if (i != 0 && offset < prev_index_entry->offset) {
+ if (i != 0 && offset < prev_index_entry->offsetInFile) {
BT_CLOGW("Invalid, non-monotonic, packet offset encountered in LTTng trace index file: "
"previous offset=%llu bytes, current offset=%llu bytes",
- prev_index_entry->offset.bytes(), offset.bytes());
+ prev_index_entry->offsetInFile.bytes(), offset.bytes());
return nonstd::nullopt;
}
- ctf_fs_ds_index_entry index_entry {file_info->path.c_str(), offset, packetSize};
+ ctf_fs_ds_index_entry index_entry {path, offset, packetSize};
index_entry.timestamp_begin = be64toh(file_index->timestamp_begin);
index_entry.timestamp_end = be64toh(file_index->timestamp_end);
if (index_entry.timestamp_end < index_entry.timestamp_begin) {
}
/* Convert the packet's bound to nanoseconds since Epoch. */
- ret = convert_cycles_to_ns(sc->default_clock_class, index_entry.timestamp_begin,
- &index_entry.timestamp_begin_ns);
+ int ret = convert_cycles_to_ns(*sc->defClkCls(), index_entry.timestamp_begin,
+ &index_entry.timestamp_begin_ns);
if (ret) {
BT_CLOGI_STR(
"Failed to convert raw timestamp to nanoseconds since Epoch during index parsing");
return nonstd::nullopt;
}
- ret = convert_cycles_to_ns(sc->default_clock_class, index_entry.timestamp_end,
+ ret = convert_cycles_to_ns(*sc->defClkCls(), index_entry.timestamp_end,
&index_entry.timestamp_end_ns);
if (ret) {
BT_CLOGI_STR(
}
/* Validate that the index addresses the complete stream. */
- if (ds_file->file->size != totalPacketsSize.bytes()) {
+ if (fileInfo.size != totalPacketsSize) {
BT_CLOGW("Invalid LTTng trace index file; indexed size != stream file size: "
- "file-size=%" PRIu64 " bytes, total-packets-size=%llu bytes",
- ds_file->file->size, totalPacketsSize.bytes());
+ "stream-file-size-bytes=%llu, total-packets-size-bytes=%llu",
+ fileInfo.size.bytes(), totalPacketsSize.bytes());
return nonstd::nullopt;
}
return index;
}
-static int init_index_entry(ctf_fs_ds_index_entry& entry, struct ctf_fs_ds_file *ds_file,
- struct ctf_msg_iter_packet_properties *props)
+static int init_index_entry(ctf_fs_ds_index_entry& entry, ctf::src::PktProps *props,
+ const ctf::src::DataStreamCls& dataStreamCls,
+ const bt2_common::LogCfg& logCfg)
{
- ctf_stream_class *sc =
- ctf_trace_class_borrow_stream_class_by_id(ds_file->metadata->tc, props->stream_class_id);
- BT_ASSERT(sc);
- const bt2_common::LogCfg& logCfg = ds_file->logCfg;
-
- if (props->snapshots.beginning_clock != UINT64_C(-1)) {
- entry.timestamp_begin = props->snapshots.beginning_clock;
+ if (props->snapshots.beginDefClk) {
+ entry.timestamp_begin = *props->snapshots.beginDefClk;
/* Convert the packet's bound to nanoseconds since Epoch. */
- int ret = convert_cycles_to_ns(sc->default_clock_class, props->snapshots.beginning_clock,
+ int ret = convert_cycles_to_ns(*dataStreamCls.defClkCls(), *props->snapshots.beginDefClk,
&entry.timestamp_begin_ns);
if (ret) {
BT_CLOGI_STR("Failed to convert raw timestamp to nanoseconds since Epoch.");
entry.timestamp_begin_ns = UINT64_C(-1);
}
- if (props->snapshots.end_clock != UINT64_C(-1)) {
- entry.timestamp_end = props->snapshots.end_clock;
+ if (props->snapshots.endDefClk) {
+ entry.timestamp_end = *props->snapshots.endDefClk;
/* Convert the packet's bound to nanoseconds since Epoch. */
- int ret = convert_cycles_to_ns(sc->default_clock_class, props->snapshots.end_clock,
+ int ret = convert_cycles_to_ns(*dataStreamCls.defClkCls(), *props->snapshots.endDefClk,
&entry.timestamp_end_ns);
if (ret) {
BT_CLOGI_STR("Failed to convert raw timestamp to nanoseconds since Epoch.");
}
static nonstd::optional<ctf_fs_ds_index>
-build_index_from_stream_file(struct ctf_fs_ds_file *ds_file, struct ctf_fs_ds_file_info *file_info,
- struct ctf_msg_iter *msg_iter)
+build_index_from_stream_file(const ctf_fs_ds_file_info& fileInfo,
+ const ctf::src::TraceCls& traceCls, const bt2_common::LogCfg& logCfg)
{
- const bt2_common::LogCfg& logCfg = ds_file->logCfg;
+ const char *path = fileInfo.path.c_str();
- BT_CLOGI("Indexing stream file %s", ds_file->file->path.c_str());
+ BT_CLOGI("Indexing stream file %s", path);
ctf_fs_ds_index index;
- bt2_common::DataLen currentPacketOffset = bt2_common::DataLen::fromBytes(0);
+ bt2_common::DataLen currentPacketOffset = 0_bytes;
while (true) {
- struct ctf_msg_iter_packet_properties props;
-
- if (currentPacketOffset.bytes() > ds_file->file->size) {
+ if (currentPacketOffset > fileInfo.size) {
BT_CLOGE_STR("Unexpected current packet's offset (larger than file).");
return nonstd::nullopt;
- } else if (currentPacketOffset.bytes() == ds_file->file->size) {
+ } else if (currentPacketOffset == fileInfo.size) {
/* No more data */
break;
}
- ctf_msg_iter_status iter_status = ctf_msg_iter_seek(msg_iter, currentPacketOffset.bytes());
- if (iter_status != CTF_MSG_ITER_STATUS_OK) {
- return nonstd::nullopt;
- }
-
- iter_status = ctf_msg_iter_get_packet_properties(msg_iter, &props);
- if (iter_status != CTF_MSG_ITER_STATUS_OK) {
- return nonstd::nullopt;
- }
+ /*
+ * Create a temporary index and medium to read the properties of the
+ * current packet. We don't know yet the size of the packet (that's
+ * one of the things we want to find out), so pretend it spans the rest
+ * of the file.
+ */
+ ctf_fs_ds_index_entry tempIndexEntry {path, currentPacketOffset,
+ fileInfo.size - currentPacketOffset};
+ ctf_fs_ds_index tempIndex;
+ tempIndex.entries.emplace_back(tempIndexEntry);
+ ctf::src::fs::Medium::UP medium =
+ bt2_common::makeUnique<ctf::src::fs::Medium>(tempIndex, logCfg);
+ ctf::src::PktProps props =
+ ctf::src::readPktProps(traceCls, std::move(medium), currentPacketOffset, logCfg);
/*
* Get the current packet size from the packet header, if set. Else,
* as the packet size.
*/
bt2_common::DataLen currentPacketSize =
- props.exp_packet_total_size >= 0 ?
- bt2_common::DataLen::fromBits(props.exp_packet_total_size) :
- bt2_common::DataLen::fromBytes(ds_file->file->size);
+ props.expectedTotalLen ? *props.expectedTotalLen : fileInfo.size;
- if ((currentPacketOffset + currentPacketSize).bytes() > ds_file->file->size) {
+ BT_CLOGI("Packet: offset-bytes=%llu, len-bytes=%llu, begin-clk=%lld, end-clk=%lld",
+ currentPacketOffset.bytes(), currentPacketSize.bytes(),
+ props.snapshots.beginDefClk ? *props.snapshots.beginDefClk : -1,
+ props.snapshots.endDefClk ? *props.snapshots.endDefClk : -1);
+
+ if (currentPacketOffset + currentPacketSize > fileInfo.size) {
BT_CLOGW("Invalid packet size reported in file: stream=\"%s\", "
"packet-offset-bytes=%llu, packet-size-bytes=%llu, "
- "file-size-bytes=%jd",
- ds_file->file->path.c_str(), currentPacketOffset.bytes(),
- currentPacketSize.bytes(), (intmax_t) ds_file->file->size);
+ "file-size-bytes=%llu",
+ path, currentPacketOffset.bytes(), currentPacketSize.bytes(),
+ fileInfo.size.bytes());
return nonstd::nullopt;
}
- ctf_fs_ds_index_entry index_entry {file_info->path.c_str(), currentPacketOffset,
- currentPacketSize};
+ ctf_fs_ds_index_entry index_entry {path, currentPacketOffset, currentPacketSize};
- int ret = init_index_entry(index_entry, ds_file, &props);
+ int ret = init_index_entry(index_entry, &props, *props.dataStreamCls, logCfg);
if (ret) {
return nonstd::nullopt;
}
}
BT_HIDDEN
-ctf_fs_ds_file::UP ctf_fs_ds_file_create(struct ctf_fs_trace *ctf_fs_trace,
- nonstd::optional<bt2::Stream::Shared> stream,
- const char *path, const bt2_common::LogCfg& logCfg)
+ctf_fs_ds_file::UP ctf_fs_ds_file_create(const char *path, const bt2_common::LogCfg& logCfg)
{
const size_t offset_align = bt_mmap_get_offset_align_size(logCfg.logLevel());
- ctf_fs_ds_file::UP ds_file = bt2_common::makeUnique<ctf_fs_ds_file>(logCfg);
+ ctf_fs_ds_file::UP ds_file =
+ bt2_common::makeUnique<ctf_fs_ds_file>(logCfg, offset_align * 2048);
ds_file->file = bt2_common::makeUnique<ctf_fs_file>(logCfg);
- ds_file->stream = std::move(stream);
- ds_file->metadata = ctf_fs_trace->metadata.get();
ds_file->file->path = path;
int ret = ctf_fs_file_open(ds_file->file.get(), "rb");
if (ret) {
return nullptr;
}
- ds_file->mmap_max_len = offset_align * 2048;
-
return ds_file;
}
-BT_HIDDEN
-nonstd::optional<ctf_fs_ds_index> ctf_fs_ds_file_build_index(struct ctf_fs_ds_file *ds_file,
- struct ctf_fs_ds_file_info *file_info,
- struct ctf_msg_iter *msg_iter)
+namespace ctf {
+namespace src {
+namespace fs {
+
+Medium::Medium(const ctf_fs_ds_index& index, const bt2_common::LogCfg& logCfg) :
+ _mIndex {index}, _mLogCfg {logCfg}
+
{
- const bt2_common::LogCfg& logCfg = ds_file->logCfg;
+ BT_ASSERT(!_mIndex.entries.empty());
+}
+
+ctf_fs_ds_index::EntriesT::const_iterator
+Medium::_mFindIndexEntryForOffset(bt2_common::DataLen offsetInStream) const noexcept
+{
+ return std::lower_bound(
+ _mIndex.entries.begin(), _mIndex.entries.end(), offsetInStream,
+ [](const ctf_fs_ds_index_entry& entry, bt2_common::DataLen offsetInStreamLambda) {
+ return (entry.offsetInStream + entry.packetSize - 1_bytes) < offsetInStreamLambda;
+ });
+}
+
+ctf::src::Buf Medium::buf(const bt2_common::DataLen requestedOffsetInStream,
+ const bt2_common::DataLen minSize)
+{
+ const bt2_common::LogCfg& logCfg = _mLogCfg;
+ BT_CLOGD("buf called: offset-bytes=%llu, min-size-bytes=%llu", requestedOffsetInStream.bytes(),
+ minSize.bytes());
+
+ /* The medium only gets asked about whole byte offsets and min sizes. */
+ BT_ASSERT_DBG(requestedOffsetInStream.extraBitCount() == 0);
+ BT_ASSERT_DBG(minSize.extraBitCount() == 0);
+
+ /*
+ * +-file 1-----+ +-file 2-----+------------+------------+
+ * | | | | | |
+ * | packet 1 | | packet 2 | packet 3 | packet 4 |
+ * | | | | | |
+ * +------------+ +------------+------v-----+------------+
+ * ^-----------------------------------^ requestedOffsetInStream (passed as parameter)
+ * ^----------------------------^ indexEntry.offsetInStream (known)
+ * ^------------^ indexEntry.offsetInFile (known)
+ * ^---------------^ fileStartInStream (computed)
+ * ^-------------------^ requestedOffsetInFile (computed)
+ *
+ * Then, assuming mmap maps this region:
+ * ^------------^
+ *
+ * ^-------------------^ startOfMappingInFile
+ * ^----------------^ requestedOffsetInMapping
+ * ^--------------------------------^ endOfMappingInFile
+ */
+ const ctf_fs_ds_index::EntriesT::const_iterator indexEntryIt =
+ this->_mFindIndexEntryForOffset(requestedOffsetInStream);
+ if (indexEntryIt == _mIndex.entries.end()) {
+ BT_CLOGD("no index entry containing this offset");
+ throw NoData();
+ }
+
+ const ctf_fs_ds_index_entry& indexEntry = *indexEntryIt;
- nonstd::optional<ctf_fs_ds_index> index =
- build_index_from_idx_file(ds_file, file_info, msg_iter);
+ _mCurrentDsFile = ctf_fs_ds_file_create(indexEntry.path, _mLogCfg);
+ if (!_mCurrentDsFile) {
+ BT_CLOGE_APPEND_CAUSE_AND_THROW(bt2::Error, "Failed to create ctf_fs_ds_file");
+ }
+
+ const bt2_common::DataLen fileStartInStream =
+ indexEntry.offsetInStream - indexEntry.offsetInFile;
+ const bt2_common::DataLen requestedOffsetInFile = requestedOffsetInStream - fileStartInStream;
+
+ ds_file_status status = ds_file_mmap(_mCurrentDsFile.get(), requestedOffsetInFile.bytes());
+ if (status != DS_FILE_STATUS_OK) {
+ throw bt2::Error("Failed to mmap file");
+ }
+
+ bt2_common::DataLen startOfMappingInFile =
+ bt2_common::DataLen::fromBytes(_mCurrentDsFile->mmap_offset_in_file);
+ bt2_common::DataLen requestedOffsetInMapping = requestedOffsetInFile - startOfMappingInFile;
+ bt2_common::DataLen exclEndOfMappingInFile =
+ startOfMappingInFile + bt2_common::DataLen::fromBytes(_mCurrentDsFile->mmap_len);
+
+ /*
+ * Find where to end the mapping. We can map the following entries as long as
+ *
+ * 1) there are following entries
+ * 2) they are located in the same file as our starting entry
+ * 3) they are (at least partially) within the mapping
+ */
+
+ ctf_fs_ds_index::EntriesT::const_iterator endIndexEntryIt = indexEntryIt;
+ while (true) {
+ ctf_fs_ds_index::EntriesT::const_iterator nextIndexEntryIt = endIndexEntryIt + 1;
+
+ if (nextIndexEntryIt == _mIndex.entries.end()) {
+ break;
+ }
+
+ if (nextIndexEntryIt->path != indexEntryIt->path) {
+ break;
+ }
+
+ if (nextIndexEntryIt->offsetInFile >= exclEndOfMappingInFile) {
+ break;
+ }
+
+ endIndexEntryIt = nextIndexEntryIt;
+ }
+
+ /*
+ * It's possible the mapping ends in the middle of our end entry. Choose
+ * the end of the mapping or the end of the end entry, whichever comes
+ * first, as the end of the returned buffer.
+ */
+ bt2_common::DataLen exclEndOfEndEntryInFile =
+ endIndexEntryIt->offsetInFile + endIndexEntryIt->packetSize;
+ bt2_common::DataLen bufEndInFile = std::min(exclEndOfMappingInFile, exclEndOfEndEntryInFile);
+ bt2_common::DataLen bufLen = bufEndInFile - requestedOffsetInFile;
+ const uint8_t *bufStart =
+ (const uint8_t *) _mCurrentDsFile->mmap_addr + requestedOffsetInMapping.bytes();
+
+ if (bufLen < minSize) {
+ BT_CLOGE_APPEND_CAUSE_AND_THROW(
+ bt2::Error,
+ "Insufficient data in file to fulfill request: path=\"%s\", requested-offset-in-file-bytes=%llu, "
+ "remaining-data-len-in-file-bytes=%llu, min-size-bytes=%llu",
+ indexEntry.path, requestedOffsetInFile.bytes(), bufLen.bytes(), minSize.bytes());
+ }
+
+ ctf::src::Buf buf {bufStart, bufLen};
+
+ BT_CLOGD("CtfFsMedium::buf returns: buf-addr=%p, buf-size-bytes=%llu\n", buf.addr(),
+ buf.size().bytes());
+
+ return buf;
+}
+
+} /* namespace fs */
+} /* namespace src */
+} /* namespace ctf */
+
+BT_HIDDEN
+nonstd::optional<ctf_fs_ds_index> ctf_fs_ds_file_build_index(const ctf_fs_ds_file_info& fileInfo,
+ const ctf::src::TraceCls& traceCls,
+ const bt2_common::LogCfg& logCfg)
+{
+ nonstd::optional<ctf_fs_ds_index> index = build_index_from_idx_file(fileInfo, traceCls, logCfg);
if (index) {
return index;
}
BT_CLOGI("Failed to build index from .index file; "
"falling back to stream indexing.");
- return build_index_from_stream_file(ds_file, file_info, msg_iter);
+ return build_index_from_stream_file(fileInfo, traceCls, logCfg);
}
ctf_fs_ds_file::~ctf_fs_ds_file()
(void) ds_file_munmap(this);
}
-BT_HIDDEN ctf_fs_ds_file_info::UP ctf_fs_ds_file_info_create(const char *path, int64_t begin_ns)
-{
- ctf_fs_ds_file_info::UP ds_file_info = bt2_common::makeUnique<ctf_fs_ds_file_info>();
-
- ds_file_info->path = path;
- ds_file_info->begin_ns = begin_ns;
-
- return ds_file_info;
-}
-
void ctf_fs_ds_file_group::insert_ds_file_info_sorted(ctf_fs_ds_file_info::UP ds_file_info)
{
/* Find the spot where to insert this ds_file_info. */
#include <babeltrace2/babeltrace.h>
#include <vector>
-#include "../common/src/msg-iter/msg-iter.hpp"
+#include "../common/src/item-seq/medium.hpp"
+#include "../common/src/metadata/ctf-ir.hpp"
#include "cpp-common/data-len.hpp"
#include "lttng-index.hpp"
#include "cpp-common/log-cfg.hpp"
{
using UP = std::unique_ptr<ctf_fs_ds_file_info>;
+ ctf_fs_ds_file_info(std::string pathParam, bt2_common::LogCfg logCfg);
+
std::string path;
+ bt2_common::DataLen size;
/* Guaranteed to be set, as opposed to the index. */
int64_t begin_ns = 0;
{
using UP = std::unique_ptr<ctf_fs_ds_file>;
- explicit ctf_fs_ds_file(const bt2_common::LogCfg& logCfgParam) noexcept : logCfg {logCfgParam}
+ explicit ctf_fs_ds_file(const bt2_common::LogCfg& logCfgParam,
+ const size_t mmapMaxLenParam) noexcept :
+ logCfg {logCfgParam},
+ mmap_max_len {mmapMaxLenParam}
{
}
const bt2_common::LogCfg logCfg;
- /* Weak */
- struct ctf_fs_metadata *metadata = nullptr;
-
ctf_fs_file::UP file;
- /* Owned by this */
- nonstd::optional<bt2::Stream::Shared> stream;
-
void *mmap_addr = nullptr;
/*
/* Offset in the file where the current mapping starts. */
off_t mmap_offset_in_file = 0;
-
- /*
- * Offset, in the current mapping, of the address to return on the next
- * request.
- */
- off_t request_offset_in_mapping = 0;
};
struct ctf_fs_ds_index_entry
{
- ctf_fs_ds_index_entry(const char *pathParam, bt2_common::DataLen offsetParam,
+ ctf_fs_ds_index_entry(const char *pathParam, bt2_common::DataLen offsetInFileParam,
bt2_common::DataLen packetSizeParam) :
path {pathParam},
- offset {offsetParam}, packetSize {packetSizeParam}
+ offsetInFile {offsetInFileParam}, offsetInStream {offsetInFileParam}, packetSize {
+ packetSizeParam}
{
+ BT_ASSERT(path);
}
/* Weak, belongs to ctf_fs_ds_file_info. */
const char *path;
/* Position of the packet from the beginning of the file. */
- bt2_common::DataLen offset;
+ bt2_common::DataLen offsetInFile;
+
+ /*
+ * Position of the packet from the beginning of the stream. Starts equal
+ * to `offsetInFile`, but can change when multiple data stream files
+ * belonging to the same stream are merged.
+ */
+ bt2_common::DataLen offsetInStream;
/* Size of the packet. */
bt2_common::DataLen packetSize;
struct ctf_fs_ds_index
{
- std::vector<ctf_fs_ds_index_entry> entries;
+ using EntriesT = std::vector<ctf_fs_ds_index_entry>;
+
+ EntriesT entries;
+
+ void updateOffsetsInStream();
};
struct ctf_fs_ds_file_group
{
using UP = std::unique_ptr<ctf_fs_ds_file_group>;
- ctf_fs_ds_file_group(struct ctf_fs_trace *ctfFsTrace, struct ctf_stream_class *scParam,
+ ctf_fs_ds_file_group(struct ctf_fs_trace *ctfFsTrace,
+ const ctf::src::DataStreamCls& dataStreamClsParam,
uint64_t streamInstanceId, ctf_fs_ds_index indexParam) :
-
- sc {scParam},
- stream_id(streamInstanceId), ctf_fs_trace {ctfFsTrace}, index {std::move(indexParam)}
-
+ dataStreamCls(dataStreamClsParam),
+ stream_id(streamInstanceId), ctf_fs_trace(ctfFsTrace), index(std::move(indexParam))
{
}
*/
std::vector<ctf_fs_ds_file_info::UP> ds_file_infos;
- /* Owned by this */
- struct ctf_stream_class *sc = nullptr;
+ const ctf::src::DataStreamCls& dataStreamCls;
/* Owned by this */
nonstd::optional<bt2::Stream::Shared> stream;
};
BT_HIDDEN
-ctf_fs_ds_file::UP ctf_fs_ds_file_create(struct ctf_fs_trace *ctf_fs_trace,
- nonstd::optional<bt2::Stream::Shared> stream,
- const char *path, const bt2_common::LogCfg& logCfg);
+ctf_fs_ds_file::UP ctf_fs_ds_file_create(const char *path, const bt2_common::LogCfg& logCfg);
BT_HIDDEN
-nonstd::optional<ctf_fs_ds_index>
-ctf_fs_ds_file_build_index(struct ctf_fs_ds_file *ds_file, struct ctf_fs_ds_file_info *ds_file_info,
- struct ctf_msg_iter *msg_iter);
+nonstd::optional<ctf_fs_ds_index> ctf_fs_ds_file_build_index(const ctf_fs_ds_file_info& file_info,
+ const ctf::src::TraceCls& traceCls,
+ const bt2_common::LogCfg& logCfg);
-BT_HIDDEN ctf_fs_ds_file_info::UP ctf_fs_ds_file_info_create(const char *path, int64_t begin_ns);
+namespace ctf {
+namespace src {
+namespace fs {
-/*
- * Medium operations to iterate on a single ctf_fs_ds_file.
- *
- * The data pointer when using this must be a pointer to the ctf_fs_ds_file.
- */
-extern struct ctf_msg_iter_medium_ops ctf_fs_ds_file_medops;
+struct Medium : public ctf::src::Medium
+{
+ Medium(const ctf_fs_ds_index& index, const bt2_common::LogCfg& logCfg);
-/*
- * Medium operations to iterate on the packet of a ctf_fs_ds_group.
- *
- * The iteration is done based on the index of the group.
- *
- * The data pointer when using these medops must be a pointer to a ctf_fs_ds
- * group_medops_data structure.
- */
-BT_HIDDEN
-extern struct ctf_msg_iter_medium_ops ctf_fs_ds_group_medops;
+ ctf::src::Buf buf(bt2_common::DataLen offset, bt2_common::DataLen minSize) override;
-struct ctf_fs_ds_group_medops_data_deleter
-{
- void operator()(ctf_fs_ds_group_medops_data *data);
-};
+private:
+ ctf_fs_ds_index::EntriesT::const_iterator
+ _mFindIndexEntryForOffset(bt2_common::DataLen offsetInStream) const noexcept;
-using ctf_fs_ds_group_medops_data_up =
- std::unique_ptr<ctf_fs_ds_group_medops_data, ctf_fs_ds_group_medops_data_deleter>;
+ const ctf_fs_ds_index& _mIndex;
+ const bt2_common::LogCfg _mLogCfg;
-BT_HIDDEN
-enum ctf_msg_iter_medium_status ctf_fs_ds_group_medops_data_create(
- struct ctf_fs_ds_file_group *ds_file_group, bt_self_message_iterator *self_msg_iter,
- const bt2_common::LogCfg& logCfg, ctf_fs_ds_group_medops_data_up& out);
+ ctf_fs_ds_file::UP _mCurrentDsFile;
+};
-BT_HIDDEN
-void ctf_fs_ds_group_medops_data_reset(struct ctf_fs_ds_group_medops_data *data);
+} /* namespace fs */
+} /* namespace src */
+} /* namespace ctf */
#endif /* CTF_FS_DS_FILE_H */
#include <inttypes.h>
#include <stdbool.h>
#include "fs.hpp"
-#include "metadata.hpp"
#include "data-stream-file.hpp"
#include "file.hpp"
-#include "../common/src/metadata/tsdl/decoder.hpp"
#include "../common/src/metadata/tsdl/ctf-meta-configure-ir-trace.hpp"
-#include "../common/src/msg-iter/msg-iter.hpp"
+#include "../common/src/msg-iter.hpp"
+#include "../common/src/metadata/ctf-ir.hpp"
+#include "../common/src/pkt-props.hpp"
#include "query.hpp"
#include "plugins/common/param-validation/param-validation.h"
#include "cpp-common/cfg-logging.hpp"
#include "cpp-common/cfg-logging-error-reporting.hpp"
#include "cpp-common/cfg-logging-error-reporting-throw.hpp"
#include "cpp-common/exc.hpp"
+#include "cpp-common/file-utils.hpp"
#include "cpp-common/make-unique.hpp"
+#include "cpp-common/bt2/message.hpp"
#include <vector>
#include <sstream>
+using namespace bt2_common::literals::datalen;
+using namespace ctf::src;
+using namespace ctf;
+
struct tracer_info
{
const char *name;
int64_t patch;
};
-static bt_message_iterator_class_next_method_status
-ctf_fs_iterator_next_one(struct ctf_fs_msg_iter_data *msg_iter_data, const bt_message **out_msg)
-{
- const bt2_common::LogCfg& logCfg = msg_iter_data->logCfg;
- ctf_msg_iter_status msg_iter_status =
- ctf_msg_iter_get_next_message(msg_iter_data->msg_iter.get(), out_msg);
- bt_message_iterator_class_next_method_status status;
-
- switch (msg_iter_status) {
- case CTF_MSG_ITER_STATUS_OK:
- /* Cool, message has been written to *out_msg. */
- status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK;
- break;
-
- case CTF_MSG_ITER_STATUS_EOF:
- status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_END;
- break;
-
- case CTF_MSG_ITER_STATUS_AGAIN:
- /*
- * Should not make it this far as this is
- * medium-specific; there is nothing for the user to do
- * and it should have been handled upstream.
- */
- bt_common_abort();
-
- case CTF_MSG_ITER_STATUS_ERROR:
- BT_CLOGE_APPEND_CAUSE("Failed to get next message from CTF message iterator.");
- status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR;
- break;
-
- case CTF_MSG_ITER_STATUS_MEMORY_ERROR:
- BT_CLOGE_APPEND_CAUSE("Failed to get next message from CTF message iterator.");
- status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_MEMORY_ERROR;
- break;
-
- default:
- bt_common_abort();
- }
-
- return status;
-}
-
BT_HIDDEN
bt_message_iterator_class_next_method_status
ctf_fs_iterator_next(bt_self_message_iterator *iterator, bt_message_array_const msgs,
{
struct ctf_fs_msg_iter_data *msg_iter_data =
(struct ctf_fs_msg_iter_data *) bt_self_message_iterator_get_data(iterator);
- const bt2_common::LogCfg& logCfg = msg_iter_data->logCfg;
+ uint64_t i = 0;
- try {
- if (G_UNLIKELY(msg_iter_data->next_saved_error)) {
- /*
+ if (G_UNLIKELY(msg_iter_data->next_saved_error)) {
+ /*
* Last time we were called, we hit an error but had some
* messages to deliver, so we stashed the error here. Return
* it now.
*/
- BT_CURRENT_THREAD_MOVE_ERROR_AND_RESET(msg_iter_data->next_saved_error);
- return msg_iter_data->next_saved_status;
- }
+ BT_CURRENT_THREAD_MOVE_ERROR_AND_RESET(msg_iter_data->next_saved_error);
+ return msg_iter_data->next_saved_status;
+ }
- bt_message_iterator_class_next_method_status status;
- uint64_t i = 0;
+ bt_message_iterator_class_next_method_status status =
+ BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK;
- do {
- status = ctf_fs_iterator_next_one(msg_iter_data, &msgs[i]);
- if (status == BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK) {
- i++;
+ do {
+ try {
+ nonstd::optional<bt2::ConstMessage::Shared> msg = msg_iter_data->msgIter->next();
+ if (G_LIKELY(msg)) {
+ msgs[i] = msg->release().libObjPtr();
+ ++i;
+ } else {
+ status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_END;
}
- } while (i < capacity && status == BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK);
+ } catch (const bt2::Error& error) {
+ status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR;
+ break;
+ } catch (const std::bad_alloc&) {
+ status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_MEMORY_ERROR;
+ break;
+ }
+ } while (i < capacity && status == BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK);
- if (i > 0) {
- /*
+ if (i > 0) {
+ /*
* Even if ctf_fs_iterator_next_one() returned something
* else than BT_MESSAGE_ITERATOR_NEXT_METHOD_STATUS_OK, we
* accumulated message objects in the output
* called, possibly without any accumulated
* message, in which case we'll return it.
*/
- if (status < 0) {
- /*
+ if (status < 0) {
+ /*
* Save this error for the next _next call. Assume that
* this component always appends error causes when
* returning an error status code, which will cause the
* current thread error to be non-NULL.
*/
- msg_iter_data->next_saved_error = bt_current_thread_take_error();
- BT_ASSERT(msg_iter_data->next_saved_error);
- msg_iter_data->next_saved_status = status;
- }
-
- *count = i;
- status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK;
+ msg_iter_data->next_saved_error = bt_current_thread_take_error();
+ BT_ASSERT(msg_iter_data->next_saved_error);
+ msg_iter_data->next_saved_status = status;
}
- return status;
- } catch (const std::bad_alloc&) {
- return BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_MEMORY_ERROR;
- } catch (const bt2_common::Error&) {
- BT_CLOGE_APPEND_CAUSE("Failed to fetch next messages");
- return BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_ERROR;
+ *count = i;
+ status = BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK;
}
+
+ return status;
+}
+
+static void instantiateMsgIter(ctf_fs_msg_iter_data *msg_iter_data)
+{
+ const bt2_common::LogCfg& logCfg = msg_iter_data->logCfg;
+ ctf_fs_ds_file_group *ds_file_group = msg_iter_data->port_data->ds_file_group;
+
+ Medium::UP medium = bt2_common::makeUnique<fs::Medium>(ds_file_group->index, logCfg);
+ msg_iter_data->msgIter.emplace(
+ msg_iter_data->self_msg_iter, *ds_file_group->ctf_fs_trace->cls(),
+ ds_file_group->ctf_fs_trace->metadataStreamUuid(), **ds_file_group->stream,
+ std::move(medium), msg_iter_data->port_data->ctf_fs->quirks, logCfg);
}
BT_HIDDEN
const bt2_common::LogCfg& logCfg = msg_iter_data->logCfg;
try {
- ctf_msg_iter_reset(msg_iter_data->msg_iter.get());
- ctf_fs_ds_group_medops_data_reset(msg_iter_data->msg_iter_medops_data.get());
+ instantiateMsgIter(msg_iter_data);
return BT_MESSAGE_ITERATOR_CLASS_SEEK_BEGINNING_METHOD_STATUS_OK;
} catch (const std::bad_alloc&) {
BT_HIDDEN
void ctf_fs_iterator_finalize(bt_self_message_iterator *it)
{
- ctf_fs_msg_iter_data::UP {
- ((struct ctf_fs_msg_iter_data *) bt_self_message_iterator_get_data(it))};
-}
-
-static bt_message_iterator_class_initialize_method_status
-ctf_msg_iter_medium_status_to_msg_iter_initialize_status(enum ctf_msg_iter_medium_status status)
-{
- switch (status) {
- case CTF_MSG_ITER_MEDIUM_STATUS_EOF:
- case CTF_MSG_ITER_MEDIUM_STATUS_AGAIN:
- case CTF_MSG_ITER_MEDIUM_STATUS_ERROR:
- return BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_ERROR;
- case CTF_MSG_ITER_MEDIUM_STATUS_MEMORY_ERROR:
- return BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_MEMORY_ERROR;
- case CTF_MSG_ITER_MEDIUM_STATUS_OK:
- return BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_OK;
- }
-
- bt_common_abort();
+ ctf_fs_msg_iter_data::UP {(ctf_fs_msg_iter_data *) bt_self_message_iterator_get_data(it)};
}
BT_HIDDEN
bt2_common::makeUnique<ctf_fs_msg_iter_data>(logCfg);
msg_iter_data->self_msg_iter = self_msg_iter;
- msg_iter_data->ds_file_group = port_data->ds_file_group;
-
- ctf_msg_iter_medium_status medium_status =
- ctf_fs_ds_group_medops_data_create(msg_iter_data->ds_file_group, self_msg_iter, logCfg,
- msg_iter_data->msg_iter_medops_data);
- BT_ASSERT(medium_status == CTF_MSG_ITER_MEDIUM_STATUS_OK ||
- medium_status == CTF_MSG_ITER_MEDIUM_STATUS_ERROR ||
- medium_status == CTF_MSG_ITER_MEDIUM_STATUS_MEMORY_ERROR);
- if (medium_status != CTF_MSG_ITER_MEDIUM_STATUS_OK) {
- BT_CLOGE_APPEND_CAUSE("Failed to create ctf_fs_ds_group_medops");
- return ctf_msg_iter_medium_status_to_msg_iter_initialize_status(medium_status);
- }
+ msg_iter_data->port_data = port_data;
- msg_iter_data->msg_iter = ctf_msg_iter_create(
- msg_iter_data->ds_file_group->ctf_fs_trace->metadata->tc,
- bt_common_get_page_size(logCfg.logLevel()) * 8, ctf_fs_ds_group_medops,
- msg_iter_data->msg_iter_medops_data.get(), self_msg_iter, logCfg);
- if (!msg_iter_data->msg_iter) {
- BT_CLOGE_APPEND_CAUSE("Cannot create a CTF message iterator.");
- return BT_MESSAGE_ITERATOR_CLASS_INITIALIZE_METHOD_STATUS_MEMORY_ERROR;
- }
+ instantiateMsgIter(msg_iter_data.get());
/*
* This iterator can seek forward if its stream class has a default
* clock class.
*/
- if (msg_iter_data->ds_file_group->sc->default_clock_class) {
+ if (msg_iter_data->port_data->ds_file_group->dataStreamCls.defClkCls()) {
bt_self_message_iterator_configuration_set_can_seek_forward(config, true);
}
*/
/* For the trace, use the uuid if present, else the path. */
- if (ds_file_group->ctf_fs_trace->metadata->tc->is_uuid_set) {
- char uuid_str[BT_UUID_STR_LEN + 1];
-
- bt_uuid_to_str(ds_file_group->ctf_fs_trace->metadata->tc->uuid, uuid_str);
- name << uuid_str;
+ nonstd::optional<bt2_common::Uuid> uuid = ds_file_group->ctf_fs_trace->cls()->uuid();
+ if (uuid) {
+ name << uuid->str();
} else {
name << ds_file_group->ctf_fs_trace->path;
}
* For the stream class, use the id if present. We can omit this field
* otherwise, as there will only be a single stream class.
*/
- if (ds_file_group->sc->id != UINT64_C(-1)) {
- name << " | " << ds_file_group->sc->id;
+ if (ds_file_group->dataStreamCls.id() != UINT64_C(-1)) {
+ name << " | " << ds_file_group->dataStreamCls.id();
}
/* For the stream, use the id if present, else, use the path. */
name << " | " << ds_file_group->stream_id;
} else {
BT_ASSERT(ds_file_group->ds_file_infos.size() == 1);
- const ctf_fs_ds_file_info& ds_file_info = *ds_file_group->ds_file_infos[0];
- name << " | " << ds_file_info.path;
+ ctf_fs_ds_file_info *ds_file_info = ds_file_group->ds_file_infos[0].get();
+ name << " | " << ds_file_info->path;
}
return name.str();
static int add_ds_file_to_ds_file_group(struct ctf_fs_trace *ctf_fs_trace, const char *path)
{
const bt2_common::LogCfg& logCfg = ctf_fs_trace->logCfg;
+ ctf_fs_ds_file_info::UP ds_file_info =
+ bt2_common::makeUnique<ctf_fs_ds_file_info>(path, logCfg);
+ const TraceCls& traceCls = *ctf_fs_trace->cls();
+ ctf_fs_ds_index tempIndex;
+ ctf_fs_ds_index_entry tempIndexEntry {path, 0_bytes, ds_file_info->size};
+ tempIndex.entries.emplace_back(tempIndexEntry);
+ Medium::UP medium = bt2_common::makeUnique<fs::Medium>(tempIndex, logCfg);
+ PktProps props = readPktProps(traceCls, std::move(medium), 0_bytes, logCfg);
+
+ const ctf::src::DataStreamCls *sc = props.dataStreamCls;
+ BT_ASSERT(sc);
- /*
- * Create a temporary ds_file to read some properties about the data
- * stream file.
- */
- ctf_fs_ds_file::UP ds_file = ctf_fs_ds_file_create(ctf_fs_trace, nonstd::nullopt, path, logCfg);
- if (!ds_file) {
- return -1;
- }
-
- /* Create a temporary iterator to read the ds_file. */
- ctf_msg_iter_up msg_iter = ctf_msg_iter_create(
- ctf_fs_trace->metadata->tc, bt_common_get_page_size(logCfg.logLevel()) * 8,
- ctf_fs_ds_file_medops, ds_file.get(), nullptr, logCfg);
- if (!msg_iter) {
- BT_CLOGE_STR("Cannot create a CTF message iterator.");
- return -1;
- }
-
- ctf_msg_iter_set_dry_run(msg_iter.get(), true);
-
- ctf_msg_iter_packet_properties props;
- int ret = ctf_msg_iter_get_packet_properties(msg_iter.get(), &props);
- if (ret) {
- BT_CLOGE_APPEND_CAUSE(
- "Cannot get stream file's first packet's header and context fields (`%s`).", path);
- return ret;
- }
+ nonstd::optional<unsigned long long> stream_instance_id = props.dataStreamId;
- ctf_stream_class *sc =
- ctf_trace_class_borrow_stream_class_by_id(ds_file->metadata->tc, props.stream_class_id);
- BT_ASSERT(sc);
- int64_t stream_instance_id = props.data_stream_id;
int64_t begin_ns = -1;
-
- if (props.snapshots.beginning_clock != UINT64_C(-1)) {
- BT_ASSERT(sc->default_clock_class);
- ret = bt_util_clock_cycles_to_ns_from_origin(
- props.snapshots.beginning_clock, sc->default_clock_class->frequency,
- sc->default_clock_class->offset_seconds, sc->default_clock_class->offset_cycles,
- &begin_ns);
+ if (props.snapshots.beginDefClk) {
+ BT_ASSERT(sc->defClkCls());
+ int ret = bt_util_clock_cycles_to_ns_from_origin(
+ *props.snapshots.beginDefClk, sc->defClkCls()->freq(),
+ sc->defClkCls()->offset().seconds(), sc->defClkCls()->offset().cycles(), &begin_ns);
if (ret) {
BT_CLOGE_APPEND_CAUSE("Cannot convert clock cycles to nanoseconds from origin (`%s`).",
path);
}
}
- ctf_fs_ds_file_info::UP ds_file_info = ctf_fs_ds_file_info_create(path, begin_ns);
- if (!ds_file_info) {
- return -1;
- }
-
nonstd::optional<ctf_fs_ds_index> index =
- ctf_fs_ds_file_build_index(ds_file.get(), ds_file_info.get(), msg_iter.get());
+ ctf_fs_ds_file_build_index(*ds_file_info, traceCls, logCfg);
if (!index) {
- BT_CLOGE_APPEND_CAUSE("Failed to index CTF stream file \'%s\'",
- ds_file->file->path.c_str());
+ BT_CLOGE_APPEND_CAUSE("Failed to index CTF stream file \'%s\'", path);
return -1;
}
* within a stream file group, so consider that this
* file must be the only one within its group.
*/
- stream_instance_id = -1;
+ stream_instance_id.reset();
}
- if (stream_instance_id == -1) {
+ if (!stream_instance_id) {
/*
* No stream instance ID or no beginning timestamp:
* create a unique stream file group for this stream
* group.
*/
ctf_fs_ds_file_group::UP new_ds_file_group = bt2_common::makeUnique<ctf_fs_ds_file_group>(
- ctf_fs_trace, sc, UINT64_C(-1), std::move(*index));
+ ctf_fs_trace, *sc, UINT64_C(-1), std::move(*index));
new_ds_file_group->insert_ds_file_info_sorted(std::move(ds_file_info));
ctf_fs_trace->ds_file_groups.emplace_back(std::move(new_ds_file_group));
return 0;
}
- BT_ASSERT(stream_instance_id != -1);
BT_ASSERT(begin_ns != -1);
/* Find an existing stream file group with this ID */
ctf_fs_ds_file_group *ds_file_group = NULL;
for (ctf_fs_ds_file_group::UP& candidate : ctf_fs_trace->ds_file_groups) {
- if (candidate->sc == sc && candidate->stream_id == stream_instance_id) {
+ if (&candidate->dataStreamCls == sc && candidate->stream_id == stream_instance_id) {
ds_file_group = candidate.get();
break;
}
if (!ds_file_group) {
ctf_fs_ds_file_group::UP new_ds_file_group = bt2_common::makeUnique<ctf_fs_ds_file_group>(
- ctf_fs_trace, sc, (uint64_t) stream_instance_id, std::move(*index));
+ ctf_fs_trace, *sc, *stream_instance_id, std::move(*index));
ds_file_group = new_ds_file_group.get();
ctf_fs_trace->ds_file_groups.emplace_back(std::move(new_ds_file_group));
} else {
bt_self_component *selfComp,
const bt2_common::LogCfg& logCfg)
{
- ctf_fs_trace::UP ctf_fs_trace = bt2_common::makeUnique<struct ctf_fs_trace>(logCfg);
+ ctf_fs_trace::UP ctf_fs_trace =
+ bt2_common::makeUnique<struct ctf_fs_trace>(clkClsCfg, selfComp, logCfg);
ctf_fs_trace->path = path;
- ctf_fs_trace->metadata = bt2_common::makeUnique<ctf_fs_metadata>();
- int ret = ctf_fs_metadata_set_trace_class(ctf_fs_trace.get(), clkClsCfg, selfComp, logCfg);
- if (ret) {
- return nullptr;
- }
+ std::string metadataPath = ctf_fs_trace->path;
+ metadataPath += G_DIR_SEPARATOR;
+ metadataPath += CTF_FS_METADATA_FILENAME;
- if (ctf_fs_trace->metadata->trace_class) {
- bt_trace *trace = bt_trace_create((*ctf_fs_trace->metadata->trace_class)->libObjPtr());
- if (!trace) {
- return nullptr;
- }
- ctf_fs_trace->trace = bt2::Trace::Shared::createWithoutRef(trace);
- }
+ std::vector<uint8_t> contents = bt2_common::dataFromFile(metadataPath.c_str());
+ ctf_fs_trace->parseMetadata(contents.data(), contents.data() + contents.size());
- if (ctf_fs_trace->trace) {
- ctf_trace_class_configure_ir_trace(ctf_fs_trace->metadata->tc, **ctf_fs_trace->trace);
+ BT_ASSERT(ctf_fs_trace->cls());
+ if (ctf_fs_trace->cls()->libCls()) {
+ bt2::TraceClass traceCls = *ctf_fs_trace->cls()->libCls();
+ ctf_fs_trace->trace = traceCls.instantiate();
+ ctf_trace_class_configure_ir_trace(*ctf_fs_trace->cls(), **ctf_fs_trace->trace, logCfg);
set_trace_name(**ctf_fs_trace->trace, name, logCfg);
}
- ret = create_ds_file_groups(ctf_fs_trace.get());
+ int ret = create_ds_file_groups(ctf_fs_trace.get());
if (ret) {
return nullptr;
}
static unsigned int metadata_count_stream_and_event_classes(struct ctf_fs_trace *trace)
{
- unsigned int num = trace->metadata->tc->stream_classes->len;
+ const TraceCls::DataStreamClsSet& dataStreamClasses = trace->cls()->dataStreamClasses();
+ unsigned int num = dataStreamClasses.size();
- for (guint i = 0; i < trace->metadata->tc->stream_classes->len; i++) {
- struct ctf_stream_class *sc =
- (struct ctf_stream_class *) trace->metadata->tc->stream_classes->pdata[i];
- num += sc->event_classes->len;
+ for (const DataStreamCls::UP& dsc : dataStreamClasses) {
+ num += dsc->eventRecordClasses().size();
}
return num;
* stream instance.
*/
if (candidate_dest->stream_id != src_group->stream_id ||
- candidate_dest->sc->id != src_group->sc->id) {
+ candidate_dest->dataStreamCls.id() != src_group->dataStreamCls.id()) {
continue;
}
* trace chunk.
*/
if (!dest_group) {
- ctf_stream_class *sc = ctf_trace_class_borrow_stream_class_by_id(
- dest_trace->metadata->tc, src_group->sc->id);
+ const DataStreamCls *sc = (*dest_trace->cls())[src_group->dataStreamCls.id()];
BT_ASSERT(sc);
ctf_fs_ds_file_group::UP new_dest_group = bt2_common::makeUnique<ctf_fs_ds_file_group>(
- dest_trace, sc, src_group->stream_id, ctf_fs_ds_index {});
+ dest_trace, *sc, src_group->stream_id, ctf_fs_ds_index {});
dest_group = new_dest_group.get();
dest_trace->ds_file_groups.emplace_back(std::move(new_dest_group));
}
unsigned int candidate_count;
/* A bit of sanity check. */
- BT_ASSERT(bt_uuid_compare(winner->metadata->tc->uuid, candidate->metadata->tc->uuid) == 0);
+ BT_ASSERT(winner->cls()->uuid() == candidate->cls()->uuid());
candidate_count = metadata_count_stream_and_event_classes(candidate);
LAST_EVENT,
};
-static int decode_clock_snapshot_after_event(struct ctf_fs_trace *ctf_fs_trace,
- struct ctf_clock_class *default_cc,
- const ctf_fs_ds_index_entry& index_entry,
- enum target_event target_event, uint64_t *cs,
- int64_t *ts_ns)
+struct ClockSnapshotAfterEventItemVisitor : public ItemVisitor
{
- const bt2_common::LogCfg& logCfg = ctf_fs_trace->logCfg;
-
- BT_ASSERT(ctf_fs_trace);
- BT_ASSERT(index_entry.path);
+ bool done() const
+ {
+ return _mDone;
+ }
- ctf_fs_ds_file::UP ds_file =
- ctf_fs_ds_file_create(ctf_fs_trace, nonstd::nullopt, index_entry.path, logCfg);
- if (!ds_file) {
- BT_CLOGE_APPEND_CAUSE("Failed to create a ctf_fs_ds_file");
- return -1;
+ nonstd::optional<unsigned long long> result() const
+ {
+ return _mResult;
}
- BT_ASSERT(ctf_fs_trace->metadata);
- BT_ASSERT(ctf_fs_trace->metadata->tc);
+protected:
+ nonstd::optional<unsigned long long> _mResult;
+ bool _mDone = false;
+};
- ctf_msg_iter_up msg_iter = ctf_msg_iter_create(
- ctf_fs_trace->metadata->tc, bt_common_get_page_size(logCfg.logLevel()) * 8,
+struct ClockSnapshotAfterFirstEventItemVisitor : public ClockSnapshotAfterEventItemVisitor
+{
+ void visit(const EventRecordInfoItem& item) override
+ {
+ _mResult = item.defClkVal();
+ _mDone = true;
+ }
+};
- ctf_fs_ds_file_medops, ds_file.get(), NULL, logCfg);
- if (!msg_iter) {
- /* ctf_msg_iter_create() logs errors. */
- return -1;
+/*
+ * Find the timestamp of the last event of the packet, if any, otherwise
+ * find the timestamp of the beginning of the packet.
+ */
+struct ClockSnapshotAfterLastEventItemVisitor : public ClockSnapshotAfterEventItemVisitor
+{
+ void visit(const PktInfoItem& item) override
+ {
+ _mLastSeen = item.beginDefClkVal();
}
- /*
- * Turn on dry run mode to prevent the creation and usage of Babeltrace
- * library objects (bt_field, bt_message_*, etc.).
- */
- ctf_msg_iter_set_dry_run(msg_iter.get(), true);
+ void visit(const EventRecordInfoItem& item) override
+ {
+ _mLastSeen = item.defClkVal();
+ }
- /* Seek to the beginning of the target packet. */
- enum ctf_msg_iter_status iter_status =
- ctf_msg_iter_seek(msg_iter.get(), index_entry.offset.bytes());
- if (iter_status) {
- /* ctf_msg_iter_seek() logs errors. */
- return -1;
+ void visit(const PktEndItem& item) override
+ {
+ _mResult = _mLastSeen;
+ _mDone = true;
}
+private:
+ nonstd::optional<unsigned long long> _mLastSeen;
+};
+
+static int decode_clock_snapshot_after_event(struct ctf_fs_trace *ctf_fs_trace,
+ const ClkCls& default_cc,
+ const ctf_fs_ds_index_entry& index_entry,
+ enum target_event target_event, uint64_t *cs,
+ int64_t *ts_ns)
+{
+ const bt2_common::LogCfg& logCfg = ctf_fs_trace->logCfg;
+
+ BT_ASSERT(ctf_fs_trace);
+ BT_ASSERT(ctf_fs_trace->cls());
+ BT_ASSERT(index_entry.path);
+
+ ctf_fs_ds_index tempIndex;
+ tempIndex.entries.emplace_back(index_entry);
+ Medium::UP medium = bt2_common::makeUnique<fs::Medium>(tempIndex, logCfg);
+ ItemSeqIter itemSeqIter(std::move(medium), *ctf_fs_trace->cls(), index_entry.offsetInFile,
+ logCfg);
+
+ std::unique_ptr<ClockSnapshotAfterEventItemVisitor> visitor;
switch (target_event) {
case FIRST_EVENT:
- /*
- * Start to decode the packet until we reach the end of
- * the first event. To extract the first event's clock
- * snapshot.
- */
- iter_status = ctf_msg_iter_curr_packet_first_event_clock_snapshot(msg_iter.get(), cs);
+ visitor = bt2_common::makeUnique<ClockSnapshotAfterFirstEventItemVisitor>();
break;
case LAST_EVENT:
- /* Decode the packet to extract the last event's clock snapshot. */
- iter_status = ctf_msg_iter_curr_packet_last_event_clock_snapshot(msg_iter.get(), cs);
+ visitor = bt2_common::makeUnique<ClockSnapshotAfterLastEventItemVisitor>();
break;
default:
bt_common_abort();
}
- if (iter_status) {
+
+ LoggingItemVisitor loggingVisitor(logCfg);
+
+ while (!visitor->done()) {
+ const Item *item = itemSeqIter.next();
+ BT_ASSERT(item);
+
+ if (BT_LOG_ON_TRACE) {
+ item->accept(loggingVisitor);
+ }
+
+ item->accept(*visitor);
+ }
+
+ if (!visitor->result()) {
+ BT_CLOGE_APPEND_CAUSE("Failed to get %s event clock snapshot.",
+ target_event == FIRST_EVENT ? "first" : "last");
return -1;
}
+ *cs = *visitor->result();
+
/* Convert clock snapshot to timestamp. */
int ret = bt_util_clock_cycles_to_ns_from_origin(
- *cs, default_cc->frequency, default_cc->offset_seconds, default_cc->offset_cycles, ts_ns);
+ *cs, default_cc.freq(), default_cc.offset().seconds(), default_cc.offset().cycles(), ts_ns);
if (ret) {
BT_CLOGE_APPEND_CAUSE("Failed to convert clock snapshot to timestamp");
return ret;
}
- return 0;
+ return ret;
}
static int decode_packet_first_event_timestamp(struct ctf_fs_trace *ctf_fs_trace,
- struct ctf_clock_class *default_cc,
+ const ClkCls& default_cc,
const ctf_fs_ds_index_entry& index_entry,
uint64_t *cs, int64_t *ts_ns)
{
}
static int decode_packet_last_event_timestamp(struct ctf_fs_trace *ctf_fs_trace,
- struct ctf_clock_class *default_cc,
+ const ClkCls& default_cc,
const ctf_fs_ds_index_entry& index_entry,
uint64_t *cs, int64_t *ts_ns)
{
*/
ctf_fs_ds_index_entry& last_entry = index.entries.back();
- BT_ASSERT(ds_file_group->sc->default_clock_class);
- ctf_clock_class *default_cc = ds_file_group->sc->default_clock_class;
+ BT_ASSERT(ds_file_group->dataStreamCls.defClkCls());
+ const ClkCls& default_cc = *ds_file_group->dataStreamCls.defClkCls();
/*
* Decode packet to read the timestamp of the last event of the
BT_ASSERT(!index.entries.empty());
- BT_ASSERT(ds_file_group->sc->default_clock_class);
- ctf_clock_class *default_cc = ds_file_group->sc->default_clock_class;
+ BT_ASSERT(ds_file_group->dataStreamCls.defClkCls());
+ const ClkCls& default_cc = *ds_file_group->dataStreamCls.defClkCls();
/*
* 1. Iterate over the index, starting from the second entry
const bt2_common::LogCfg& logCfg = trace->logCfg;
for (ctf_fs_ds_file_group::UP& ds_file_group : trace->ds_file_groups) {
- struct ctf_clock_class *default_cc;
-
BT_ASSERT(ds_file_group);
ctf_fs_ds_index& index = ds_file_group->index;
- BT_ASSERT(ds_file_group->sc->default_clock_class);
- default_cc = ds_file_group->sc->default_clock_class;
+ BT_ASSERT(ds_file_group->dataStreamCls.defClkCls());
+ const ClkCls& default_cc = *ds_file_group->dataStreamCls.defClkCls();
BT_ASSERT(!index.entries.empty());
*/
static int extract_tracer_info(struct ctf_fs_trace *trace, struct tracer_info *current_tracer_info)
{
+ nonstd::optional<bt2::ConstMapValue> optEnv = trace->cls()->env();
+ if (!optEnv) {
+ return -1;
+ }
+
+ bt2::ConstMapValue env = *optEnv;
+
/* Clear the current_tracer_info struct */
memset(current_tracer_info, 0, sizeof(*current_tracer_info));
* major version are needed. If one of these is missing, consider it an
* extraction failure.
*/
- ctf_trace_class_env_entry *entry =
- ctf_trace_class_borrow_env_entry_by_name(trace->metadata->tc, "tracer_name");
- if (!entry || entry->type != CTF_TRACE_CLASS_ENV_ENTRY_TYPE_STR) {
+ nonstd::optional<bt2::ConstValue> tracerName = env["tracer_name"];
+ if (!tracerName || !tracerName->isString()) {
return -1;
}
/* Set tracer name. */
- current_tracer_info->name = entry->value.str->str;
+ current_tracer_info->name = tracerName->asString().value().c_str();
- entry = ctf_trace_class_borrow_env_entry_by_name(trace->metadata->tc, "tracer_major");
- if (!entry || entry->type != CTF_TRACE_CLASS_ENV_ENTRY_TYPE_INT) {
+ nonstd::optional<bt2::ConstValue> tracerMajor = env["tracer_major"];
+ if (!tracerMajor || !tracerMajor->isInteger()) {
return -1;
}
/* Set major version number. */
- current_tracer_info->major = entry->value.i;
+ current_tracer_info->major =
+ tracerMajor->isSignedInteger() ?
+ tracerMajor->asSignedInteger().value() :
+ static_cast<std::int64_t>(tracerMajor->asUnsignedInteger().value());
- entry = ctf_trace_class_borrow_env_entry_by_name(trace->metadata->tc, "tracer_minor");
- if (!entry || entry->type != CTF_TRACE_CLASS_ENV_ENTRY_TYPE_INT) {
+ nonstd::optional<bt2::ConstValue> tracerMinor = env["tracer_minor"];
+ if (!tracerMinor || !tracerMinor->isInteger()) {
return 0;
}
/* Set minor version number. */
- current_tracer_info->minor = entry->value.i;
+ current_tracer_info->minor =
+ tracerMinor->isSignedInteger() ?
+ tracerMinor->asSignedInteger().value() :
+ static_cast<std::int64_t>(tracerMinor->asUnsignedInteger().value());
- entry = ctf_trace_class_borrow_env_entry_by_name(trace->metadata->tc, "tracer_patch");
- if (!entry) {
- /*
- * If `tracer_patch` doesn't exist `tracer_patchlevel` might.
- * For example, `lttng-modules` uses entry name
- * `tracer_patchlevel`.
- */
- entry = ctf_trace_class_borrow_env_entry_by_name(trace->metadata->tc, "tracer_patchlevel");
+ /*
+ * If `tracer_patch` doesn't exist `tracer_patchlevel` might.
+ * For example, `lttng-modules` uses entry name `tracer_patchlevel`.
+ */
+ nonstd::optional<bt2::ConstValue> tracerPatch = env["tracer_patch"];
+ if (!tracerPatch) {
+ tracerPatch = env["tracer_patchlevel"];
}
- if (!entry || entry->type != CTF_TRACE_CLASS_ENV_ENTRY_TYPE_INT) {
+ if (!tracerPatch || !tracerPatch->isInteger()) {
return 0;
}
/* Set patch version number. */
- current_tracer_info->patch = entry->value.i;
+ current_tracer_info->patch =
+ tracerPatch->isSignedInteger() ?
+ tracerPatch->asSignedInteger().value() :
+ static_cast<std::int64_t>(tracerPatch->asUnsignedInteger().value());
return 0;
}
BT_CLOGE_APPEND_CAUSE("Failed to fix LTTng event-after-packet bug.");
return ret;
}
- ctf_fs->trace->metadata->tc->quirks.lttng_event_after_packet = true;
+ ctf_fs->quirks.eventRecordDefClkValGtNextPktBeginDefClkVal = true;
}
if (is_tracer_affected_by_barectf_event_before_packet_bug(¤t_tracer_info)) {
BT_CLOGE_APPEND_CAUSE("Failed to fix barectf event-before-packet bug.");
return ret;
}
- ctf_fs->trace->metadata->tc->quirks.barectf_event_before_packet = true;
+ ctf_fs->quirks.eventRecordDefClkValLtPktBeginDefClkVal = true;
}
if (is_tracer_affected_by_lttng_crash_quirk(¤t_tracer_info)) {
BT_CLOGE_APPEND_CAUSE("Failed to fix lttng-crash timestamp quirks.");
return ret;
}
- ctf_fs->trace->metadata->tc->quirks.lttng_crash = true;
+ ctf_fs->quirks.pktEndDefClkValZero = true;
}
return 0;
if (traces.size() > 1) {
ctf_fs_trace *first_trace = traces[0].get();
- const uint8_t *first_trace_uuid = first_trace->metadata->tc->uuid;
/*
* We have more than one trace, they must all share the same
* UUID, verify that.
*/
- for (size_t i = 0; i < traces.size(); i++) {
- ctf_fs_trace *this_trace = traces[i].get();
- const uint8_t *this_trace_uuid = this_trace->metadata->tc->uuid;
-
- if (!this_trace->metadata->tc->is_uuid_set) {
+ for (const ctf_fs_trace::UP& this_trace : traces) {
+ if (!this_trace->cls()->uuid()) {
BT_CLOGE_APPEND_CAUSE(
"Multiple traces given, but a trace does not have a UUID: path=%s",
this_trace->path.c_str());
return -1;
}
- if (bt_uuid_compare(first_trace_uuid, this_trace_uuid) != 0) {
- char first_trace_uuid_str[BT_UUID_STR_LEN + 1];
- char this_trace_uuid_str[BT_UUID_STR_LEN + 1];
+ const bt2_common::Uuid first_trace_uuid = *first_trace->cls()->uuid();
+ const bt2_common::Uuid this_trace_uuid = *this_trace->cls()->uuid();
- bt_uuid_to_str(first_trace_uuid, first_trace_uuid_str);
- bt_uuid_to_str(this_trace_uuid, this_trace_uuid_str);
+ if (first_trace_uuid != this_trace_uuid) {
+ std::string firstTraceUUidStr = first_trace_uuid.str();
+ std::string thisTraceUuidStr = this_trace_uuid.str();
BT_CLOGE_APPEND_CAUSE("Multiple traces given, but UUIDs don't match: "
"first-trace-uuid=%s, first-trace-path=%s, "
"trace-uuid=%s, trace-path=%s",
- first_trace_uuid_str, first_trace->path.c_str(),
- this_trace_uuid_str, this_trace->path.c_str());
+ firstTraceUUidStr.c_str(), first_trace->path.c_str(),
+ thisTraceUuidStr.c_str(), this_trace->path.c_str());
return -1;
}
}
std::sort(ctf_fs->trace->ds_file_groups.begin(), ctf_fs->trace->ds_file_groups.end(),
compare_ds_file_groups_by_first_path);
+ /*
+ * Now that indexes are not going to change anymore, compute each entry's
+ * offset in the logical data stream.
+ */
+ for (ctf_fs_ds_file_group::UP& group : ctf_fs->trace->ds_file_groups) {
+ group->index.updateOffsetsInStream();
+ }
+
return 0;
}
/* Create the IR stream objects for ctf_fs_trace. */
-static int create_streams_for_trace(struct ctf_fs_trace *ctf_fs_trace)
+static void create_streams_for_trace(struct ctf_fs_trace *ctf_fs_trace)
{
- const bt2_common::LogCfg& logCfg = ctf_fs_trace->logCfg;
-
for (ctf_fs_ds_file_group::UP& ds_file_group : ctf_fs_trace->ds_file_groups) {
const std::string& name = get_stream_instance_unique_name(ds_file_group.get());
- BT_ASSERT(ds_file_group->sc->ir_sc);
+ BT_ASSERT(ds_file_group->dataStreamCls.libCls());
BT_ASSERT(ctf_fs_trace->trace);
-
- bt2::StreamClass sc {ds_file_group->sc->ir_sc};
+ bt2::StreamClass streamCls = *ds_file_group->dataStreamCls.libCls();
if (ds_file_group->stream_id == UINT64_C(-1)) {
/* No stream ID: use 0 */
ds_file_group->stream =
- sc.instantiate(**ctf_fs_trace->trace, ctf_fs_trace->next_stream_id);
+ streamCls.instantiate(**ctf_fs_trace->trace, ctf_fs_trace->next_stream_id);
ctf_fs_trace->next_stream_id++;
} else {
/* Specific stream ID */
- ds_file_group->stream = sc.instantiate(**ctf_fs_trace->trace, ds_file_group->stream_id);
+ ds_file_group->stream =
+ streamCls.instantiate(**ctf_fs_trace->trace, ds_file_group->stream_id);
}
- int ret = bt_stream_set_name((*ds_file_group->stream)->libObjPtr(), name.c_str());
- if (ret) {
- BT_CLOGE_APPEND_CAUSE("Cannot set stream's name: "
- "addr=%p, stream-name=\"%s\"",
- (*ds_file_group->stream)->libObjPtr(), name.c_str());
- return ret;
- }
+ (*ds_file_group->stream)->name(name);
}
-
- return 0;
}
static const bt_param_validation_value_descr inputs_elem_descr =
return nullptr;
}
- if (create_streams_for_trace(ctf_fs->trace.get())) {
- return nullptr;
- }
+ create_streams_for_trace(ctf_fs->trace.get());
if (create_ports_for_trace(ctf_fs.get(), ctf_fs->trace.get(), self_comp_src)) {
return nullptr;
#include <babeltrace2/babeltrace.h>
#include "cpp-common/data-len.hpp"
#include "data-stream-file.hpp"
-#include "metadata.hpp"
-#include "../common/src/metadata/tsdl/decoder.hpp"
+#include "../common/src/metadata/tsdl/ctf-1-metadata-stream-parser.hpp"
+#include "../common/src/metadata/metadata-stream-parser-utils.hpp"
+#include "../common/src/msg-iter.hpp"
#include "cpp-common/glib-up.hpp"
+#define CTF_FS_METADATA_FILENAME "metadata"
+
BT_HIDDEN
extern bool ctf_fs_debug;
-struct ctf_fs_metadata
+struct ctf_fs_trace
{
- using UP = std::unique_ptr<ctf_fs_metadata>;
-
- /* Owned by this */
- ctf_metadata_decoder_up decoder;
-
- /* Owned by this */
- nonstd::optional<bt2::TraceClass::Shared> trace_class;
+ using UP = std::unique_ptr<ctf_fs_trace>;
- /* Weak (owned by `decoder` above) */
- struct ctf_trace_class *tc = nullptr;
+ explicit ctf_fs_trace(const ctf::src::ClkClsCfg clkClsCfg, bt_self_component *selfComp,
+ const bt2_common::LogCfg& logCfgParam) noexcept :
+ logCfg {logCfgParam},
+ _mClkClsCfg {clkClsCfg}, _mSelfComp {selfComp}
+ {
+ }
- int bo = 0;
-};
+ const ctf::src::TraceCls *cls() const
+ {
+ BT_ASSERT(_mParseRet);
+ BT_ASSERT(_mParseRet->first);
+ return _mParseRet->first.get();
+ }
-struct ctf_fs_trace
-{
- using UP = std::unique_ptr<ctf_fs_trace>;
+ const nonstd::optional<bt2_common::Uuid>& metadataStreamUuid() const noexcept
+ {
+ BT_ASSERT(_mParseRet);
+ return _mParseRet->second;
+ }
- explicit ctf_fs_trace(const bt2_common::LogCfg& logCfgParam) noexcept : logCfg {logCfgParam}
+ void parseMetadata(const uint8_t *begin, const uint8_t *end)
{
+ _mParseRet =
+ ctf::src::parseMetadataStream(_mClkClsCfg, _mSelfComp, begin, end, this->logCfg);
}
const bt2_common::LogCfg logCfg;
- ctf_fs_metadata::UP metadata;
-
nonstd::optional<bt2::Trace::Shared> trace;
std::vector<ctf_fs_ds_file_group::UP> ds_file_groups;
/* Next automatic stream ID when not provided by packet header */
uint64_t next_stream_id = 0;
+
+private:
+ const ctf::src::ClkClsCfg _mClkClsCfg;
+ bt_self_component *_mSelfComp;
+ nonstd::optional<ctf::src::MetadataStreamParser::ParseRet> _mParseRet;
};
struct ctf_fs_port_data
ctf_fs_trace::UP trace;
ctf::src::ClkClsCfg clkClsCfg;
+ ctf::src::MsgIterQuirks quirks;
};
struct ctf_fs_msg_iter_data
/* Weak */
bt_self_message_iterator *self_msg_iter = nullptr;
- /* Weak, belongs to ctf_fs_trace */
- struct ctf_fs_ds_file_group *ds_file_group = nullptr;
+ /* Weak, belongs to ctf_fs_component */
+ ctf_fs_port_data *port_data = nullptr;
- ctf_msg_iter_up msg_iter;
+ nonstd::optional<ctf::src::MsgIter> msgIter;
/*
* Saved error. If we hit an error in the _next method, but have some
bt_message_iterator_class_next_method_status next_saved_status =
BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_OK;
const struct bt_error *next_saved_error = nullptr;
-
- ctf_fs_ds_group_medops_data_up msg_iter_medops_data;
};
BT_HIDDEN
+++ /dev/null
-/*
- * SPDX-License-Identifier: MIT
- *
- * Copyright 2016 Philippe Proulx <pproulx@efficios.com>
- * Copyright 2010-2011 EfficiOS Inc. and Linux Foundation
- */
-
-#define BT_CLOG_CFG logCfg
-#define BT_LOG_TAG "PLUGIN/SRC.CTF.FS/META"
-
-#include <stdio.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include "common/assert.h"
-#include <glib.h>
-#include "common/uuid.h"
-#include "compat/memstream.h"
-#include <babeltrace2/babeltrace.h>
-
-#include "fs.hpp"
-#include "file.hpp"
-#include "metadata.hpp"
-#include "../common/src/metadata/tsdl/decoder.hpp"
-#include "cpp-common/cfg-logging.hpp"
-#include "cpp-common/make-unique.hpp"
-
-BT_HIDDEN
-FILE *ctf_fs_metadata_open_file(const char *trace_path)
-{
- GString *metadata_path;
- FILE *fp = NULL;
-
- metadata_path = g_string_new(trace_path);
- if (!metadata_path) {
- goto end;
- }
-
- g_string_append(metadata_path, G_DIR_SEPARATOR_S CTF_FS_METADATA_FILENAME);
- fp = fopen(metadata_path->str, "rb");
- g_string_free(metadata_path, TRUE);
-end:
- return fp;
-}
-
-static ctf_fs_file::UP get_file(const char *trace_path, const bt2_common::LogCfg& logCfg)
-{
- ctf_fs_file::UP file = bt2_common::makeUnique<ctf_fs_file>(logCfg);
-
- if (!file) {
- goto error;
- }
-
- file->path = trace_path;
- file->path += G_DIR_SEPARATOR_S CTF_FS_METADATA_FILENAME;
-
- if (ctf_fs_file_open(file.get(), "rb")) {
- goto error;
- }
-
- goto end;
-
-error:
- file.reset();
-
-end:
- return file;
-}
-
-BT_HIDDEN
-int ctf_fs_metadata_set_trace_class(struct ctf_fs_trace *ctf_fs_trace,
- ctf::src::ClkClsCfg clkClsCfg, bt_self_component *selfComp,
- const bt2_common::LogCfg& logCfg)
-{
- int ret = 0;
-
- ctf_metadata_decoder_config decoder_config(logCfg);
- decoder_config.clkClsCfg = clkClsCfg;
- decoder_config.create_trace_class = true;
- decoder_config.self_comp = selfComp;
-
- ctf_fs_file::UP file = get_file(ctf_fs_trace->path.c_str(), logCfg);
- if (!file) {
- BT_CLOGE("Cannot create metadata file object.");
- ret = -1;
- goto end;
- }
-
- ctf_fs_trace->metadata->decoder = ctf_metadata_decoder_create(&decoder_config);
- if (!ctf_fs_trace->metadata->decoder) {
- BT_CLOGE("Cannot create metadata decoder object.");
- ret = -1;
- goto end;
- }
-
- ret =
- ctf_metadata_decoder_append_content(ctf_fs_trace->metadata->decoder.get(), file->fp.get());
- if (ret) {
- BT_CLOGE("Cannot update metadata decoder's content.");
- goto end;
- }
-
- ctf_fs_trace->metadata->trace_class =
- ctf_metadata_decoder_get_ir_trace_class(ctf_fs_trace->metadata->decoder.get());
- ctf_fs_trace->metadata->tc =
- ctf_metadata_decoder_borrow_ctf_trace_class(ctf_fs_trace->metadata->decoder.get());
- BT_ASSERT(ctf_fs_trace->metadata->tc);
-
-end:
- return ret;
-}
+++ /dev/null
-/*
- * SPDX-License-Identifier: MIT
- *
- * Copyright 2016 Philippe Proulx <pproulx@efficios.com>
- */
-
-#ifndef CTF_FS_METADATA_H
-#define CTF_FS_METADATA_H
-
-#include <stdbool.h>
-#include <stdio.h>
-#include <glib.h>
-#include "common/macros.h"
-#include "cpp-common/log-cfg.hpp"
-#include "../common/src/clk-cls-cfg.hpp"
-#include <babeltrace2/babeltrace.h>
-
-#define CTF_FS_METADATA_FILENAME "metadata"
-
-struct ctf_fs_trace;
-struct ctf_fs_metadata;
-
-BT_HIDDEN
-int ctf_fs_metadata_set_trace_class(struct ctf_fs_trace *ctf_fs_trace,
- ctf::src::ClkClsCfg clkClsCfg, bt_self_component *selfComp,
- const bt2_common::LogCfg& logCfg);
-
-BT_HIDDEN
-FILE *ctf_fs_metadata_open_file(const char *trace_path);
-
-BT_HIDDEN
-bool ctf_metadata_is_packetized(FILE *fp, int *byte_order);
-
-#endif /* CTF_FS_METADATA_H */
#include <sys/types.h>
#include <sys/stat.h>
#include "common/assert.h"
-#include "metadata.hpp"
#include "../common/src/metadata/tsdl/metadata-stream-decoder.hpp"
#include "../common/src/metadata/metadata-stream-parser-utils.hpp"
#include "common/common.h"
func: String
src: String
Event class `lttng_ust_statedump:bin_info` (ID 0):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: debug:line
Log level: Debug (line)
Payload field class: Structure (6 members):
baddr: Unsigned integer (64-bit, Base 16)
has_build_id: Unsigned integer (8-bit, Base 10)
has_debug_link: Unsigned integer (8-bit, Base 10)
Event class `my_provider:my_first_tracepoint` (ID 1):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: debug:line
Log level: Debug (line)
Payload field class: Structure (2 members):
my_string_field: String
vtid: Signed integer (32-bit, Base 10)
vpid: Signed integer (32-bit, Base 10)
Event class `heartbeat:msg` (ID 0):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: debug:line
Log level: Debug (line)
Payload field class: Structure (1 member):
msg: String
vtid: Signed integer (32-bit, Base 10)
vpid: Signed integer (32-bit, Base 10)
Event class `heartbeat:msg` (ID 0):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: debug:line
Log level: Debug (line)
Payload field class: Structure (1 member):
msg: String
vtid: Signed integer (32-bit, Base 10)
vpid: Signed integer (32-bit, Base 10)
Event class `heartbeat:msg` (ID 0):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: debug:line
Log level: Debug (line)
Payload field class: Structure (1 member):
msg: String
vtid: Signed integer (32-bit, Base 10)
vpid: Signed integer (32-bit, Base 10)
Event class `heartbeat:msg` (ID 0):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: debug:line
Log level: Debug (line)
Payload field class: Structure (1 member):
msg: String
vtid: Signed integer (32-bit, Base 10)
vpid: Signed integer (32-bit, Base 10)
Event class `heartbeat:msg` (ID 0):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: debug:line
Log level: Debug (line)
Payload field class: Structure (1 member):
msg: String
vtid: Signed integer (32-bit, Base 10)
vpid: Signed integer (32-bit, Base 10)
Event class `heartbeat:msg` (ID 0):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: debug:line
Log level: Debug (line)
Payload field class: Structure (1 member):
msg: String
vtid: Signed integer (32-bit, Base 10)
vpid: Signed integer (32-bit, Base 10)
Event class `heartbeat:msg` (ID 0):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: debug:line
Log level: Debug (line)
Payload field class: Structure (1 member):
msg: String
vtid: Signed integer (32-bit, Base 10)
vpid: Signed integer (32-bit, Base 10)
Event class `heartbeat:msg` (ID 0):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: debug:line
Log level: Debug (line)
Payload field class: Structure (1 member):
msg: String
Event common context field class: Structure (1 member):
vpid: Signed integer (32-bit, Base 10)
Event class `lttng_ust_statedump:procname` (ID 0):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: debug:line
Log level: Debug (line)
Payload field class: Structure (1 member):
procname: String
Offset (cycles): 0
Origin is Unix epoch: Yes
Event class `simple_uint32` (ID 0):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: critical
Log level: Critical
Payload field class: Structure (1 member):
value: Unsigned integer (32-bit, Base 10)
Event common context field class: Structure (1 member):
vpid: Signed integer (32-bit, Base 10)
Event class `lttng_ust_statedump:procname` (ID 0):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: debug:line
Log level: Debug (line)
Payload field class: Structure (1 member):
procname: String
Offset (cycles): 0
Origin is Unix epoch: No
Event class `simple_uint32` (ID 0):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: critical
Log level: Critical
Payload field class: Structure (1 member):
value: Unsigned integer (32-bit, Base 10)
Packet context field class: Structure (1 member):
cpu_id: Unsigned integer (32-bit, Base 10)
Event class `lttng_ust_statedump:start` (ID 0):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: debug:line
Log level: Debug (line)
Payload field class: Structure (0 members)
Event class `lttng_ust_statedump:bin_info` (ID 1):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: debug:line
Log level: Debug (line)
Payload field class: Structure (6 members):
baddr: Unsigned integer (64-bit, Base 16)
has_build_id: Unsigned integer (8-bit, Base 10)
has_debug_link: Unsigned integer (8-bit, Base 10)
Event class `lttng_ust_statedump:build_id` (ID 2):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: debug:line
Log level: Debug (line)
Payload field class: Structure (3 members):
baddr: Unsigned integer (64-bit, Base 16)
build_id: Dynamic array (with length field) (Length field path [Event payload: 1]):
Element: Unsigned integer (8-bit, Base 16)
Event class `lttng_ust_statedump:debug_link` (ID 3):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: debug:line
Log level: Debug (line)
Payload field class: Structure (3 members):
baddr: Unsigned integer (64-bit, Base 16)
crc: Unsigned integer (32-bit, Base 10)
filename: String
Event class `lttng_ust_statedump:end` (ID 4):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: debug:line
Log level: Debug (line)
Payload field class: Structure (0 members)
Event class `lttng_ust_lib:load` (ID 5):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: debug:line
Log level: Debug (line)
Payload field class: Structure (5 members):
baddr: Unsigned integer (64-bit, Base 16)
has_build_id: Unsigned integer (8-bit, Base 10)
has_debug_link: Unsigned integer (8-bit, Base 10)
Event class `lttng_ust_lib:build_id` (ID 6):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: debug:line
Log level: Debug (line)
Payload field class: Structure (3 members):
baddr: Unsigned integer (64-bit, Base 16)
build_id: Dynamic array (with length field) (Length field path [Event payload: 1]):
Element: Unsigned integer (8-bit, Base 16)
Event class `lttng_ust_lib:debug_link` (ID 7):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: debug:line
Log level: Debug (line)
Payload field class: Structure (3 members):
baddr: Unsigned integer (64-bit, Base 16)
crc: Unsigned integer (32-bit, Base 10)
filename: String
Event class `lttng_ust_lib:unload` (ID 8):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: debug:line
Log level: Debug (line)
Payload field class: Structure (1 member):
baddr: Unsigned integer (64-bit, Base 16)
Event class `lttng_ust_tracef:event` (ID 9):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: debug
Log level: Debug
Payload field class: Structure (2 members):
_msg_length: Unsigned integer (32-bit, Base 10)
msg: String
Event class `lttng_ust_tracelog:TRACE_EMERG` (ID 10):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: emergency
Log level: Emergency
Payload field class: Structure (5 members):
line: Signed integer (32-bit, Base 10)
_msg_length: Unsigned integer (32-bit, Base 10)
msg: String
Event class `lttng_ust_tracelog:TRACE_ALERT` (ID 11):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: alert
Log level: Alert
Payload field class: Structure (5 members):
line: Signed integer (32-bit, Base 10)
_msg_length: Unsigned integer (32-bit, Base 10)
msg: String
Event class `lttng_ust_tracelog:TRACE_CRIT` (ID 12):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: critical
Log level: Critical
Payload field class: Structure (5 members):
line: Signed integer (32-bit, Base 10)
_msg_length: Unsigned integer (32-bit, Base 10)
msg: String
Event class `lttng_ust_tracelog:TRACE_ERR` (ID 13):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: error
Log level: Error
Payload field class: Structure (5 members):
line: Signed integer (32-bit, Base 10)
_msg_length: Unsigned integer (32-bit, Base 10)
msg: String
Event class `lttng_ust_tracelog:TRACE_WARNING` (ID 14):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: warning
Log level: Warning
Payload field class: Structure (5 members):
line: Signed integer (32-bit, Base 10)
_msg_length: Unsigned integer (32-bit, Base 10)
msg: String
Event class `lttng_ust_tracelog:TRACE_NOTICE` (ID 15):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: notice
Log level: Notice
Payload field class: Structure (5 members):
line: Signed integer (32-bit, Base 10)
_msg_length: Unsigned integer (32-bit, Base 10)
msg: String
Event class `lttng_ust_tracelog:TRACE_INFO` (ID 16):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: info
Log level: Info
Payload field class: Structure (5 members):
line: Signed integer (32-bit, Base 10)
_msg_length: Unsigned integer (32-bit, Base 10)
msg: String
Event class `lttng_ust_tracelog:TRACE_DEBUG_SYSTEM` (ID 17):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: debug:system
Log level: Debug (system)
Payload field class: Structure (5 members):
line: Signed integer (32-bit, Base 10)
_msg_length: Unsigned integer (32-bit, Base 10)
msg: String
Event class `lttng_ust_tracelog:TRACE_DEBUG_PROGRAM` (ID 18):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: debug:program
Log level: Debug (program)
Payload field class: Structure (5 members):
line: Signed integer (32-bit, Base 10)
_msg_length: Unsigned integer (32-bit, Base 10)
msg: String
Event class `lttng_ust_tracelog:TRACE_DEBUG_PROCESS` (ID 19):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: debug:process
Log level: Debug (process)
Payload field class: Structure (5 members):
line: Signed integer (32-bit, Base 10)
_msg_length: Unsigned integer (32-bit, Base 10)
msg: String
Event class `lttng_ust_tracelog:TRACE_DEBUG_MODULE` (ID 20):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: debug:module
Log level: Debug (module)
Payload field class: Structure (5 members):
line: Signed integer (32-bit, Base 10)
_msg_length: Unsigned integer (32-bit, Base 10)
msg: String
Event class `lttng_ust_tracelog:TRACE_DEBUG_UNIT` (ID 21):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: debug:unit
Log level: Debug (unit)
Payload field class: Structure (5 members):
line: Signed integer (32-bit, Base 10)
_msg_length: Unsigned integer (32-bit, Base 10)
msg: String
Event class `lttng_ust_tracelog:TRACE_DEBUG_FUNCTION` (ID 22):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: debug:function
Log level: Debug (function)
Payload field class: Structure (5 members):
line: Signed integer (32-bit, Base 10)
_msg_length: Unsigned integer (32-bit, Base 10)
msg: String
Event class `lttng_ust_tracelog:TRACE_DEBUG_LINE` (ID 23):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: debug:line
Log level: Debug (line)
Payload field class: Structure (5 members):
line: Signed integer (32-bit, Base 10)
_msg_length: Unsigned integer (32-bit, Base 10)
msg: String
Event class `lttng_ust_tracelog:TRACE_DEBUG` (ID 24):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: debug
Log level: Debug
Payload field class: Structure (5 members):
line: Signed integer (32-bit, Base 10)
_msg_length: Unsigned integer (32-bit, Base 10)
msg: String
Event class `ust_tests_hello:tptest` (ID 25):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: debug:line
Log level: Debug (line)
Payload field class: Structure (23 members):
intfield: Signed integer (32-bit, Base 10)
doublefield: Double-precision real
boolfield: Unsigned integer (8-bit, Base 10)
Event class `ust_tests_hello:tptest_sighandler` (ID 26):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: debug:line
Log level: Debug (line)
Payload field class: Structure (0 members)
Packet context field class: Structure (1 member):
cpu_id: Unsigned integer (32-bit, Base 10)
Event class `lttng_ust_statedump:start` (ID 0):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: debug:line
Log level: Debug (line)
Payload field class: Structure (0 members)
Event class `lttng_ust_statedump:bin_info` (ID 1):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: debug:line
Log level: Debug (line)
Payload field class: Structure (6 members):
baddr: Unsigned integer (64-bit, Base 16)
has_build_id: Unsigned integer (8-bit, Base 10)
has_debug_link: Unsigned integer (8-bit, Base 10)
Event class `lttng_ust_statedump:build_id` (ID 2):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: debug:line
Log level: Debug (line)
Payload field class: Structure (3 members):
baddr: Unsigned integer (64-bit, Base 16)
build_id: Dynamic array (with length field) (Length field path [Event payload: 1]):
Element: Unsigned integer (8-bit, Base 16)
Event class `lttng_ust_statedump:debug_link` (ID 3):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: debug:line
Log level: Debug (line)
Payload field class: Structure (3 members):
baddr: Unsigned integer (64-bit, Base 16)
crc: Unsigned integer (32-bit, Base 10)
filename: String
Event class `lttng_ust_statedump:end` (ID 4):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: debug:line
Log level: Debug (line)
Payload field class: Structure (0 members)
Event class `lttng_ust_lib:load` (ID 5):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: debug:line
Log level: Debug (line)
Payload field class: Structure (5 members):
baddr: Unsigned integer (64-bit, Base 16)
has_build_id: Unsigned integer (8-bit, Base 10)
has_debug_link: Unsigned integer (8-bit, Base 10)
Event class `lttng_ust_lib:build_id` (ID 6):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: debug:line
Log level: Debug (line)
Payload field class: Structure (3 members):
baddr: Unsigned integer (64-bit, Base 16)
build_id: Dynamic array (with length field) (Length field path [Event payload: 1]):
Element: Unsigned integer (8-bit, Base 16)
Event class `lttng_ust_lib:debug_link` (ID 7):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: debug:line
Log level: Debug (line)
Payload field class: Structure (3 members):
baddr: Unsigned integer (64-bit, Base 16)
crc: Unsigned integer (32-bit, Base 10)
filename: String
Event class `lttng_ust_lib:unload` (ID 8):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: debug:line
Log level: Debug (line)
Payload field class: Structure (1 member):
baddr: Unsigned integer (64-bit, Base 16)
Event class `lttng_ust_tracef:event` (ID 9):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: debug
Log level: Debug
Payload field class: Structure (2 members):
_msg_length: Unsigned integer (32-bit, Base 10)
msg: String
Event class `lttng_ust_tracelog:TRACE_EMERG` (ID 10):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: emergency
Log level: Emergency
Payload field class: Structure (5 members):
line: Signed integer (32-bit, Base 10)
_msg_length: Unsigned integer (32-bit, Base 10)
msg: String
Event class `lttng_ust_tracelog:TRACE_ALERT` (ID 11):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: alert
Log level: Alert
Payload field class: Structure (5 members):
line: Signed integer (32-bit, Base 10)
_msg_length: Unsigned integer (32-bit, Base 10)
msg: String
Event class `lttng_ust_tracelog:TRACE_CRIT` (ID 12):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: critical
Log level: Critical
Payload field class: Structure (5 members):
line: Signed integer (32-bit, Base 10)
_msg_length: Unsigned integer (32-bit, Base 10)
msg: String
Event class `lttng_ust_tracelog:TRACE_ERR` (ID 13):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: error
Log level: Error
Payload field class: Structure (5 members):
line: Signed integer (32-bit, Base 10)
_msg_length: Unsigned integer (32-bit, Base 10)
msg: String
Event class `lttng_ust_tracelog:TRACE_WARNING` (ID 14):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: warning
Log level: Warning
Payload field class: Structure (5 members):
line: Signed integer (32-bit, Base 10)
_msg_length: Unsigned integer (32-bit, Base 10)
msg: String
Event class `lttng_ust_tracelog:TRACE_NOTICE` (ID 15):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: notice
Log level: Notice
Payload field class: Structure (5 members):
line: Signed integer (32-bit, Base 10)
_msg_length: Unsigned integer (32-bit, Base 10)
msg: String
Event class `lttng_ust_tracelog:TRACE_INFO` (ID 16):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: info
Log level: Info
Payload field class: Structure (5 members):
line: Signed integer (32-bit, Base 10)
_msg_length: Unsigned integer (32-bit, Base 10)
msg: String
Event class `lttng_ust_tracelog:TRACE_DEBUG_SYSTEM` (ID 17):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: debug:system
Log level: Debug (system)
Payload field class: Structure (5 members):
line: Signed integer (32-bit, Base 10)
_msg_length: Unsigned integer (32-bit, Base 10)
msg: String
Event class `lttng_ust_tracelog:TRACE_DEBUG_PROGRAM` (ID 18):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: debug:program
Log level: Debug (program)
Payload field class: Structure (5 members):
line: Signed integer (32-bit, Base 10)
_msg_length: Unsigned integer (32-bit, Base 10)
msg: String
Event class `lttng_ust_tracelog:TRACE_DEBUG_PROCESS` (ID 19):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: debug:process
Log level: Debug (process)
Payload field class: Structure (5 members):
line: Signed integer (32-bit, Base 10)
_msg_length: Unsigned integer (32-bit, Base 10)
msg: String
Event class `lttng_ust_tracelog:TRACE_DEBUG_MODULE` (ID 20):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: debug:module
Log level: Debug (module)
Payload field class: Structure (5 members):
line: Signed integer (32-bit, Base 10)
_msg_length: Unsigned integer (32-bit, Base 10)
msg: String
Event class `lttng_ust_tracelog:TRACE_DEBUG_UNIT` (ID 21):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: debug:unit
Log level: Debug (unit)
Payload field class: Structure (5 members):
line: Signed integer (32-bit, Base 10)
_msg_length: Unsigned integer (32-bit, Base 10)
msg: String
Event class `lttng_ust_tracelog:TRACE_DEBUG_FUNCTION` (ID 22):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: debug:function
Log level: Debug (function)
Payload field class: Structure (5 members):
line: Signed integer (32-bit, Base 10)
_msg_length: Unsigned integer (32-bit, Base 10)
msg: String
Event class `lttng_ust_tracelog:TRACE_DEBUG_LINE` (ID 23):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: debug:line
Log level: Debug (line)
Payload field class: Structure (5 members):
line: Signed integer (32-bit, Base 10)
_msg_length: Unsigned integer (32-bit, Base 10)
msg: String
Event class `lttng_ust_tracelog:TRACE_DEBUG` (ID 24):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: debug
Log level: Debug
Payload field class: Structure (5 members):
line: Signed integer (32-bit, Base 10)
_msg_length: Unsigned integer (32-bit, Base 10)
msg: String
Event class `ust_tests_hello:tptest` (ID 25):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: debug:line
Log level: Debug (line)
Payload field class: Structure (23 members):
intfield: Signed integer (32-bit, Base 10)
doublefield: Double-precision real
boolfield: Unsigned integer (8-bit, Base 10)
Event class `ust_tests_hello:tptest_sighandler` (ID 26):
+ User attributes:
+ babeltrace.org,2020:
+ log-level: debug:line
Log level: Debug (line)
Payload field class: Structure (0 members)
test_fail \
"valid-events-then-invalid-events" \
"${data_dir}/valid-events-then-invalid-events.expect" \
- "No event class with ID of event class ID to use in stream class: .*stream-class-id=0, event-class-id=255"
+ "At 24 bits: no event record class exists with ID 255 within the data stream class with ID 0."
test_fail \
"metadata-syntax-error" \
grep --silent "^ERROR: " "${stderr_file}"
ok "$?" "${test_name}: error stack is produced"
- grep --silent "No event class with ID of event class ID to use in stream class" "${stderr_file}"
+ grep --silent "At 48 bits: no event record class exists with ID 255 within the data stream class with ID 0." "${stderr_file}"
ok "$?" "${test_name}: expected error message is present"
}
bt_cli "$expected_stdout" "$expected_stderr" "${trace_dir}/succeed/multi-domains" -c sink.text.details --params "with-trace-name=false,with-stream-name=false"
bt_remove_cr "${expected_stdout}"
bt_remove_cr "${expected_stderr}"
+
+ # Hack. To be removed when src.ctf.lttng-live is updated to use the new
+ # IR generator.
+ "$BT_TESTS_SED_BIN" -i '/User attributes:/d' "${expected_stdout}"
+ "$BT_TESTS_SED_BIN" -i '/babeltrace.org,2020:/d' "${expected_stdout}"
+ "$BT_TESTS_SED_BIN" -i '/log-level: warning/d' "${expected_stdout}"
+
run_test "$test_text" "$cli_args_template" "$server_args" "$expected_stdout" "$expected_stderr"
diag "Inverse session order from lttng-relayd"
run_test "$test_text" "$cli_args_template" "$server_args_inverse" "$expected_stdout" "$expected_stderr"