}
}
-static int add_ds_file_to_ds_file_group(struct ctf_fs_trace *ctf_fs_trace, const char *path)
+static int add_ds_file_to_ds_file_group(struct ctf_fs_trace *ctf_fs_trace, const char *path,
+ const bt2_common::LogCfg& logCfg)
{
- 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();
return 0;
}
-static int create_ds_file_groups(struct ctf_fs_trace *ctf_fs_trace)
+static int create_ds_file_groups(struct ctf_fs_trace *ctf_fs_trace,
+ const bt2_common::LogCfg& logCfg)
{
- const bt2_common::LogCfg& logCfg = ctf_fs_trace->logCfg;
-
/* Check each file in the path directory, except specific ones */
GError *error = NULL;
bt2_common::GDirUP dir {g_dir_open(ctf_fs_trace->path.c_str(), 0, &error)};
continue;
}
- ret = add_ds_file_to_ds_file_group(ctf_fs_trace, file->path.c_str());
+ ret = add_ds_file_to_ds_file_group(ctf_fs_trace, file->path.c_str(), logCfg);
if (ret) {
BT_CLOGE_APPEND_CAUSE("Cannot add stream file `%s` to stream file group",
file->path.c_str());
set_trace_name(**ctf_fs_trace->trace, name, logCfg);
}
- int ret = create_ds_file_groups(ctf_fs_trace.get());
+ int ret = create_ds_file_groups(ctf_fs_trace.get(), logCfg);
if (ret) {
return nullptr;
}
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,
+ enum target_event target_event,
+ const bt2_common::LogCfg& logCfg, 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);
static int decode_packet_first_event_timestamp(struct ctf_fs_trace *ctf_fs_trace,
const ClkCls& default_cc,
const ctf_fs_ds_index_entry& index_entry,
- uint64_t *cs, int64_t *ts_ns)
+ const bt2_common::LogCfg& logCfg, uint64_t *cs,
+ int64_t *ts_ns)
{
- return decode_clock_snapshot_after_event(ctf_fs_trace, default_cc, index_entry, FIRST_EVENT, cs,
- ts_ns);
+ return decode_clock_snapshot_after_event(ctf_fs_trace, default_cc, index_entry, FIRST_EVENT,
+ logCfg, cs, ts_ns);
}
static int decode_packet_last_event_timestamp(struct ctf_fs_trace *ctf_fs_trace,
const ClkCls& default_cc,
const ctf_fs_ds_index_entry& index_entry,
- uint64_t *cs, int64_t *ts_ns)
+ const bt2_common::LogCfg& logCfg, uint64_t *cs,
+ int64_t *ts_ns)
{
- return decode_clock_snapshot_after_event(ctf_fs_trace, default_cc, index_entry, LAST_EVENT, cs,
- ts_ns);
+ return decode_clock_snapshot_after_event(ctf_fs_trace, default_cc, index_entry, LAST_EVENT,
+ logCfg, cs, ts_ns);
}
/*
* - before lttng-module 2.10.10
* - before lttng-module 2.9.13
*/
-static int fix_index_lttng_event_after_packet_bug(struct ctf_fs_trace *trace)
+static int fix_index_lttng_event_after_packet_bug(struct ctf_fs_trace *trace,
+ const bt2_common::LogCfg& logCfg)
{
- const bt2_common::LogCfg& logCfg = trace->logCfg;
-
for (ctf_fs_ds_file_group::UP& ds_file_group : trace->ds_file_groups) {
BT_ASSERT(ds_file_group);
ctf_fs_ds_index& index = ds_file_group->index;
* Decode packet to read the timestamp of the last event of the
* entry.
*/
- int ret = decode_packet_last_event_timestamp(
- trace, default_cc, last_entry, &last_entry.timestamp_end, &last_entry.timestamp_end_ns);
+ int ret = decode_packet_last_event_timestamp(trace, default_cc, last_entry, logCfg,
+ &last_entry.timestamp_end,
+ &last_entry.timestamp_end_ns);
if (ret) {
BT_CLOGE_APPEND_CAUSE(
"Failed to decode stream's last packet to get its last event's clock snapshot.");
* Known buggy tracer versions:
* - before barectf 2.3.1
*/
-static int fix_index_barectf_event_before_packet_bug(struct ctf_fs_trace *trace)
+static int fix_index_barectf_event_before_packet_bug(struct ctf_fs_trace *trace,
+ const bt2_common::LogCfg& logCfg)
{
- const bt2_common::LogCfg& logCfg = trace->logCfg;
-
for (ctf_fs_ds_file_group::UP& ds_file_group : trace->ds_file_groups) {
ctf_fs_ds_index& index = ds_file_group->index;
* 2. Set the current entry `begin` timestamp to the
* timestamp of the first event of the current packet.
*/
- int ret = decode_packet_first_event_timestamp(trace, default_cc, curr_entry,
+ int ret = decode_packet_first_event_timestamp(trace, default_cc, curr_entry, logCfg,
&curr_entry.timestamp_begin,
&curr_entry.timestamp_begin_ns);
if (ret) {
* Affected versions:
* - All current and future lttng-ust and lttng-modules versions.
*/
-static int fix_index_lttng_crash_quirk(struct ctf_fs_trace *trace)
+static int fix_index_lttng_crash_quirk(struct ctf_fs_trace *trace, const bt2_common::LogCfg& logCfg)
{
- const bt2_common::LogCfg& logCfg = trace->logCfg;
-
for (ctf_fs_ds_file_group::UP& ds_file_group : trace->ds_file_groups) {
BT_ASSERT(ds_file_group);
ctf_fs_ds_index& index = ds_file_group->index;
* Decode packet to read the timestamp of the
* last event of the stream file.
*/
- int ret = decode_packet_last_event_timestamp(trace, default_cc, last_entry,
+ int ret = decode_packet_last_event_timestamp(trace, default_cc, last_entry, logCfg,
&last_entry.timestamp_end,
&last_entry.timestamp_end_ns);
if (ret) {
/* Check if the trace may be affected by old tracer bugs. */
if (is_tracer_affected_by_lttng_event_after_packet_bug(¤t_tracer_info)) {
BT_LOGI_STR("Trace may be affected by LTTng tracer packet timestamp bug. Fixing up.");
- ret = fix_index_lttng_event_after_packet_bug(ctf_fs->trace.get());
+ ret = fix_index_lttng_event_after_packet_bug(ctf_fs->trace.get(), logCfg);
if (ret) {
BT_CLOGE_APPEND_CAUSE("Failed to fix LTTng event-after-packet bug.");
return ret;
if (is_tracer_affected_by_barectf_event_before_packet_bug(¤t_tracer_info)) {
BT_LOGI_STR("Trace may be affected by barectf tracer packet timestamp bug. Fixing up.");
- ret = fix_index_barectf_event_before_packet_bug(ctf_fs->trace.get());
+ ret = fix_index_barectf_event_before_packet_bug(ctf_fs->trace.get(), logCfg);
if (ret) {
BT_CLOGE_APPEND_CAUSE("Failed to fix barectf event-before-packet bug.");
return ret;
}
if (is_tracer_affected_by_lttng_crash_quirk(¤t_tracer_info)) {
- ret = fix_index_lttng_crash_quirk(ctf_fs->trace.get());
+ ret = fix_index_lttng_crash_quirk(ctf_fs->trace.get(), logCfg);
if (ret) {
BT_CLOGE_APPEND_CAUSE("Failed to fix lttng-crash timestamp quirks.");
return ret;
}
bt_self_component_set_data(selfComp, ctf_fs.release());
-
return BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_OK;
} catch (const std::bad_alloc&) {
return BT_COMPONENT_CLASS_INITIALIZE_METHOD_STATUS_MEMORY_ERROR;
#include <babeltrace2/babeltrace.h>
#include "cpp-common/data-len.hpp"
#include "data-stream-file.hpp"
-#include "../common/src/metadata/tsdl/ctf-1-metadata-stream-parser.hpp"
+#include "../common/src/metadata/metadata-stream-parser.hpp"
#include "../common/src/metadata/metadata-stream-parser-utils.hpp"
#include "../common/src/msg-iter.hpp"
+#include "../common/src/clk-cls-cfg.hpp"
#include "cpp-common/glib-up.hpp"
#define CTF_FS_METADATA_FILENAME "metadata"
using UP = std::unique_ptr<ctf_fs_trace>;
explicit ctf_fs_trace(const ctf::src::ClkClsCfg clkClsCfg, bt_self_component *selfComp,
- const bt2_common::LogCfg& logCfgParam) noexcept :
- logCfg {logCfgParam},
+ const bt2_common::LogCfg& logCfg) noexcept :
+ _mLogCfg {logCfg},
_mClkClsCfg {clkClsCfg}, _mSelfComp {selfComp}
{
}
void parseMetadata(const uint8_t *begin, const uint8_t *end)
{
- _mParseRet =
- ctf::src::parseMetadataStream(_mClkClsCfg, _mSelfComp, begin, end, this->logCfg);
+ _mParseRet = ctf::src::parseMetadataStream(_mClkClsCfg, _mSelfComp, begin, end, _mLogCfg);
}
- const bt2_common::LogCfg logCfg;
-
nonstd::optional<bt2::Trace::Shared> trace;
std::vector<ctf_fs_ds_file_group::UP> ds_file_groups;
uint64_t next_stream_id = 0;
private:
+ const bt2_common::LogCfg _mLogCfg;
const ctf::src::ClkClsCfg _mClkClsCfg;
bt_self_component *_mSelfComp;
nonstd::optional<ctf::src::MetadataStreamParser::ParseRet> _mParseRet;