babeltrace.git
4 weeks agosrc.ctf.fs: make ctf_fs_ds_file_group::stream a bt2::Stream::Shared
Simon Marchi [Mon, 4 Dec 2023 21:34:02 +0000 (21:34 +0000)] 
src.ctf.fs: make ctf_fs_ds_file_group::stream a bt2::Stream::Shared

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Change-Id: I0f84b26ccf43b0469da15946fa825a1255e7ab3d
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8256
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12294

4 weeks agosrc.ctf.fs: remove ctf_fs_ds_index_destroy
Simon Marchi [Thu, 9 Jun 2022 13:24:46 +0000 (09:24 -0400)] 
src.ctf.fs: remove ctf_fs_ds_index_destroy

Remove ctf_fs_ds_index_destroy and ctf_fs_ds_index_deleter, since
ctf_fs_ds_index objects can simply be deleted now.

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Change-Id: I64eb93eb3f06174523e7f9ceaf94cf103a9e69eb
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8255
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12293

4 weeks agosrc.ctf.fs: make ctf_fs_ds_index::entries a vector of ctf_fs_ds_index_entry::UP
Simon Marchi [Tue, 9 Apr 2024 21:07:50 +0000 (17:07 -0400)] 
src.ctf.fs: make ctf_fs_ds_index::entries a vector of ctf_fs_ds_index_entry::UP

Change-Id: If56c5ab6c35b6d93bf38b264f384496d2d06f4eb
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8254
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12292

4 weeks agosrc.ctf.fs: make ctf_fs_ds_index_entry_create return a unique_ptr
Simon Marchi [Mon, 4 Dec 2023 21:13:53 +0000 (21:13 +0000)] 
src.ctf.fs: make ctf_fs_ds_index_entry_create return a unique_ptr

Introduce ctf_fs_ds_index_entry::UP and make
ctf_fs_ds_index_entry_create return that.  Modify a few functions in
data-stream-file.cpp that deal with this.

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Change-Id: I39598d860327cff5af32804f75b68b58e4ee0821
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8253
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12291

4 weeks agosrc.ctf.fs: make ctf_fs_ds_file_group::index a ctf_fs_ds_index::UP
Simon Marchi [Sat, 6 Apr 2024 04:08:54 +0000 (00:08 -0400)] 
src.ctf.fs: make ctf_fs_ds_file_group::index a ctf_fs_ds_index::UP

Change that field to be a unique_ptr.  Adjust some functions in fs.cpp
around that.

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Change-Id: Ie2cdfe0b81f1d817093de74faf6c12ef2e6169a1
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8252
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12290

4 weeks agosrc.ctf.fs: make ctf_fs_ds_index_create return a unique_ptr
Simon Marchi [Mon, 4 Dec 2023 20:20:20 +0000 (20:20 +0000)] 
src.ctf.fs: make ctf_fs_ds_index_create return a unique_ptr

Introduce ctf_fs_ds_index::UP, a unique_ptr with a deleter that calls
ctf_fs_ds_index_destroy.  Make ctf_fs_ds_index_create (and the
other functions creating an index in data-stream-file.cpp) return it.

Change-Id: Id04124aeaff3384e566a43fbbd6c1fedd2bf9bc3
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8251
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12289

4 weeks agosrc.ctf.fs: make ctf_fs_ds_file_group::ds_file_infos a vector of ctf_fs_ds_file_info::UP
Simon Marchi [Wed, 8 Jun 2022 19:56:51 +0000 (15:56 -0400)] 
src.ctf.fs: make ctf_fs_ds_file_group::ds_file_infos a vector of ctf_fs_ds_file_info::UP

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Change-Id: I8df18be3ea1e78c78a8f0e7f0bfe1d43c390555b
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8250
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12288

4 weeks agosrc.ctf.fs: make ctf_fs_ds_file_info_create return a unique_ptr
Simon Marchi [Mon, 11 Dec 2023 17:23:19 +0000 (12:23 -0500)] 
src.ctf.fs: make ctf_fs_ds_file_info_create return a unique_ptr

Introduce ctf_fs_ds_file_info::UP, make ctf_fs_ds_file_info_create
return it.  We don't need a custom deleter, because ctf_fs_ds_file_info
can simply be deleted.  ctf_fs_ds_file_info_destroy will disappear in
the next patches.

Change-Id: Iae4fdf68035d45762f2606685f712fd12976f008
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8249
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12287

4 weeks agosrc.ctf.fs: make ctf_fs_ds_file_info::path an std::string
Simon Marchi [Mon, 4 Dec 2023 20:06:58 +0000 (20:06 +0000)] 
src.ctf.fs: make ctf_fs_ds_file_info::path an std::string

Change-Id: If7e5c09024451b1c344a0446a75703929aff480e
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8248
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12286

4 weeks agosrc.ctf.fs: make ctf_fs_trace::ds_file_groups a vector of ctf_fs_ds_file_group::UP
Simon Marchi [Tue, 9 Apr 2024 21:04:13 +0000 (17:04 -0400)] 
src.ctf.fs: make ctf_fs_trace::ds_file_groups a vector of ctf_fs_ds_file_group::UP

Replace the GPtrArray with an std::vector of unique_ptr, simplifying
memory management.

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Change-Id: I47a6b60a35b6d776a7234af1950e460da8c1e1f4
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8247
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12285

4 weeks agosrc.ctf.fs: make ctf_fs_ds_file_group_create return a ctf_fs_ds_file_group::UP
Simon Marchi [Thu, 7 Dec 2023 20:33:44 +0000 (20:33 +0000)] 
src.ctf.fs: make ctf_fs_ds_file_group_create return a ctf_fs_ds_file_group::UP

Introduced ctf_fs_ds_file_group::UP, a unique_ptr type with a deleter
that calls ctf_fs_ds_file_group_destroy.  Change
ctf_fs_ds_file_group_create to return that type.

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Change-Id: Ic89ec8edc5d7dd779c836beb962dcad7e45ab996
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8245
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12284

4 weeks agosrc.ctf.fs: make ctf_fs_component::port_data a vector
Simon Marchi [Tue, 12 Dec 2023 04:43:15 +0000 (04:43 +0000)] 
src.ctf.fs: make ctf_fs_component::port_data a vector

Replace a GPtrArray with a vector of unique pointers of
ctf_fs_port_data, simplifying memory management.

Change-Id: I4f832f32b0ca893242cc3e61e8aaac495fe86003
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8243
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12283

4 weeks agosrc.ctf.fs: move `ctf_fs_ds_*` structures and functions to data-stream-file.hpp
Simon Marchi [Fri, 5 Apr 2024 18:42:41 +0000 (14:42 -0400)] 
src.ctf.fs: move `ctf_fs_ds_*` structures and functions to data-stream-file.hpp

Change-Id: I15392536482968db492fe806ee5fa5e0ecff643e
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12282
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 weeks agosrc.ctf.fs: switch to using ctf_fs_trace::UP where possible
Simon Marchi [Mon, 4 Dec 2023 19:34:29 +0000 (19:34 +0000)] 
src.ctf.fs: switch to using ctf_fs_trace::UP where possible

Change a few function in fs.cpp to use ctf_fs_trace::UP.  Change a use of
GPtrArray to an std::vector.

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Change-Id: I7bd8fdefea538cc778bbca5157b92e960052e1cc
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8242
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12281

4 weeks agosrc.ctf.fs: make ctf_fs_trace_create return ctf_fs_trace::UP
Simon Marchi [Mon, 4 Dec 2023 19:24:52 +0000 (19:24 +0000)] 
src.ctf.fs: make ctf_fs_trace_create return ctf_fs_trace::UP

Change-Id: I342285ece6b6d68c2375658cb0aff2b363b4b156
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8241
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12280

4 weeks agosrc.ctf.fs: make ctf_fs_component::trace a unique_ptr
Simon Marchi [Tue, 9 Apr 2024 21:03:42 +0000 (17:03 -0400)] 
src.ctf.fs: make ctf_fs_component::trace a unique_ptr

Define ctf_fs_trace::UP to be a unique_ptr type with a deleter that
calls ctf_fs_trace_destroy (the custom deleter will go away once
ctf_fs_trace is properly destructible).  Change ctf_fs_component::trace
to be of this type.

Change-Id: Iaf8111922b320781d7e9333bcdc5db129192509d
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8240
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12279

4 weeks agosrc.ctf.fs: move struct ctf_fs_trace and struct ctf_fs_port_data up
Simon Marchi [Tue, 12 Dec 2023 04:39:00 +0000 (04:39 +0000)] 
src.ctf.fs: move struct ctf_fs_trace and struct ctf_fs_port_data up

Move them so they are before ctf_fs_component.  This enables the
following patches to use a unique_ptr to hold them in ctf_fs_component.

Change-Id: If97956d0c74795f8ee18ecebe035c8b186d85a2b
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8239
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12278

4 weeks agosrc.ctf.fs: use DataLen in ctf_fs_ds_index_entry
Simon Marchi [Thu, 7 Dec 2023 20:33:04 +0000 (20:33 +0000)] 
src.ctf.fs: use DataLen in ctf_fs_ds_index_entry

Change-Id: I6ff4bdbad5358faa6f504b1ae52b6a4151fef27b
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8205
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12277

4 weeks agocpp-common/bt2c: add `DataLen` class (general-purpose data length)
Philippe Proulx [Mon, 5 Feb 2024 17:39:07 +0000 (12:39 -0500)] 
cpp-common/bt2c: add `DataLen` class (general-purpose data length)

This patch adds the `bt2c::DataLen` class so that you can make sure your
function accepts an expected data length instead of specifying that you
need bits or bytes:

    Something buildSomething(bt2c::DataLen len, ...)
    {
        using namespace bt2c::literals::datalen;

        if (...) {
            len += 16_MiBytes;
        } else {
            len *= 2;
        }

        // ...
    }

    // ...

    const auto something = buildSomething(DataLen::fromBytes(sz), ...);

As you can see above, you can use the `bt2c::literals::datalen`
namespace to access handy data length user literals.

The `bt2c::DataLen` constructor is private: you need to use the
bt2c::DataLen::fromBits() and bt2c::DataLen::fromBytes()
static methods to build an instance.

Because a `bt2c::DataLen` instance is just an `unsigned long long`
value in memory, the intention of this API is to copy data length
instances as much as possible. Therefore, I suppose it's cheaper to
accept a `const bt2c::DataLen` parameter than
`const bt2c::DataLen&` which would add an indirection.

The constructor and many methods are `constexpr` to make this useable in
constant context.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I1375fb5697c0d952f3669dc587603839d511dd18
Reviewed-on: https://review.lttng.org/c/babeltrace/+/7726
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12250

4 weeks agoctf: add ClkClsConfig and use it
Simon Marchi [Mon, 11 Dec 2023 17:22:44 +0000 (12:22 -0500)] 
ctf: add ClkClsConfig and use it

Different parts of the code in the ctf plugin (in fs-src, lttng-live and
common) use these three values:

 - clock offset (seconds)
 - clock offset (nanoseconds)
 - force origin to be Unix epoch

Gather these three values in a new structure, `ClkClsConfig`, so that
these they can easily be passed around.  This replaces the existing
ctf_fs_metadata_config structure, which contained the exact same thing,
but was specific to the fs component class.

Change-Id: If9b4d88c9fd5eb3352c5de4007dc4343fac485c1
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8228
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12276

4 weeks agosrc.ctf.fs: remove uneeded check in create_streams_for_trace
Simon Marchi [Thu, 9 Jun 2022 17:52:02 +0000 (13:52 -0400)] 
src.ctf.fs: remove uneeded check in create_streams_for_trace

At this point, we certainly have a stream class.

The ir_sc field is set in ctf_stream_class_to_ir.
ctf_stream_class_to_ir is called by ctf_trace_class_translate, which is
called by ctf_visitor_generate_ir_visit_node if ctx->trace_class is set.
That trace_class field is set if a self_comp was passed to
ctf_visitor_generate_ir_create, in the decoder_config object.  Going up
the stack, we get to ctf_fs_metadata_set_trace_class, called by
ctf_fs_trace_create, called by ctf_fs_component_create_ctf_fs_trace.

create_streams_for_trace is called by ctf_fs_trace_create, which always
passes a self_comp to ctf_fs_component_create_ctf_fs_trace, ensuring we
always end up with a stream class.

ctf_fs_component_create_ctf_fs_trace is also used in the context of
queries, where no self_comp if passed, and therefore no stream class is
created..  But in that context, create_streams_for_trace is not called.

Change-Id: I5e8ef72a1013fc156a7bc6ac0d4cbb231a5ab704
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8237
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12274
Tested-by: jenkins <jenkins@lttng.org>
4 weeks agosrc.ctf.fs: query.cpp: change assertions into exceptions
Simon Marchi [Tue, 9 Apr 2024 21:02:39 +0000 (17:02 -0400)] 
src.ctf.fs: query.cpp: change assertions into exceptions

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I21d5f8950ca8efa78713404a29c36442cba6502a
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8181
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12273
Tested-by: jenkins <jenkins@lttng.org>
CI-Build: Simon Marchi <simon.marchi@efficios.com>

4 weeks agocpp-common: add `dataFromFile()`
Francis Deslauriers [Fri, 9 Feb 2024 21:26:01 +0000 (16:26 -0500)] 
cpp-common: add `dataFromFile()`

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: Ief289d7d12a1cc964af16dc7dd74a4422c81920a
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8159
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12272
CI-Build: Simon Marchi <simon.marchi@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
4 weeks agosrc.ctf.fs: use C++ value wrappers in queries
Simon Marchi [Tue, 12 Dec 2023 04:27:56 +0000 (04:27 +0000)] 
src.ctf.fs: use C++ value wrappers in queries

 - Pass the query parameters as a bt2::ConstMapValue
 - Return the query result as a bt2::Value::Shared
 - Communicate errors via exceptions
 - Use std::string instead of GString to build the metadata text

Change-Id: If75da1efc1accb5c42dd98d830ab9abf2ffff932
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8165
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12271
Tested-by: jenkins <jenkins@lttng.org>
4 weeks agoctf: use unique_ptr to manage ctf_metadata_decoder lifetime
Simon Marchi [Mon, 11 Dec 2023 17:21:12 +0000 (12:21 -0500)] 
ctf: use unique_ptr to manage ctf_metadata_decoder lifetime

Introduce the ctf_metadata_decoder_up type, a unique_ptr with a deleter
that calls ctf_metadata_decoder_destroy.  Change
ctf_metadata_decoder_create to return a ctf_metadata_decoder_up, and
adjust callers / callees accordingly.

Note that this is temporary, ctf_metadata_decoder is going to be deleted
in a future refactor.  But in the mean time, it helps make the callers
use RAII and become more exception-safe.

Change-Id: Ia0e24b425c47b90dc71b10d1c7fd0a3000c89180
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8167
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12270
Tested-by: jenkins <jenkins@lttng.org>
4 weeks agosrc.ctf.fs: manage lifetime of open file with FileUP
Simon Marchi [Mon, 29 Jan 2024 16:58:13 +0000 (16:58 +0000)] 
src.ctf.fs: manage lifetime of open file with FileUP

Change-Id: Ic1c5d8be3761e449a154e1fd8cc1f0ec7c957197
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8173
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12269
Tested-by: jenkins <jenkins@lttng.org>
4 weeks agosrc.ctf.fs: use GCharUP to hold metadata path
Simon Marchi [Sat, 28 May 2022 18:15:14 +0000 (14:15 -0400)] 
src.ctf.fs: use GCharUP to hold metadata path

Change-Id: I2cf43f7da567da3af2786a87026e25272925ed6f
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8171
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12268
Tested-by: jenkins <jenkins@lttng.org>
4 weeks agosrc.ctf.fs: make ctf_fs_make_port_name return a GCharUP
Simon Marchi [Mon, 11 Dec 2023 18:26:39 +0000 (13:26 -0500)] 
src.ctf.fs: make ctf_fs_make_port_name return a GCharUP

Make ctf_fs_make_port_name return a GCharUP, which then helps use
automatic memory management in the callers.

Change-Id: I9191ddbafa86a4788fc5e16fc561dfda7696cfa6
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8166
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12267
Tested-by: jenkins <jenkins@lttng.org>
4 weeks agosrc.ctf.fs: use unique_ptr to manage ctf_fs_component lifetime
Simon Marchi [Mon, 11 Dec 2023 17:21:01 +0000 (12:21 -0500)] 
src.ctf.fs: use unique_ptr to manage ctf_fs_component lifetime

Define ctf_fs_component::UP to be a unique_ptr with a deleter that calls
ctf_fs_destroy.  Change ctf_fs_component_create to return a
ctf_fs_component::UP and adjust the appropriate callers / callees.

Move where the ctf_fs_component instance is assigned as the "data" of
the self component.  Make it so it's assigned in ctf_fs_init (the
component initialization entry point), as the very last step.  This way,
ctf_fs_create can return a unique_ptr, and there's no ambiguity on who
owns the ctf_fs_component instance at any given time, and what happens
in case of failure.

Change-Id: I3ab1d70b0e7aa7772b7fa09deec70db7ea5a022c
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8164
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12266
Tested-by: jenkins <jenkins@lttng.org>
4 weeks agoctf: use unique_ptr to manage ctf_visitor_generate_ir lifetime
Simon Marchi [Tue, 9 Apr 2024 20:29:35 +0000 (16:29 -0400)] 
ctf: use unique_ptr to manage ctf_visitor_generate_ir lifetime

Define ctf_visitor_generate_ir::UP as a unique_ptr type with a custom
deleter that calls ctf_visitor_generate_ir_destroy.  Make
ctf_visitor_generate_ir_create return a ctf_visitor_generate_ir::UP and
adjust relevant callers / callees.

Change-Id: I9db22bd66e69473e67c2571e0b2bb7682863cff7
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8163
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12265
Tested-by: jenkins <jenkins@lttng.org>
4 weeks agoctf: move ctf_visitor_generate_ir to header file
Simon Marchi [Tue, 9 Apr 2024 20:29:13 +0000 (16:29 -0400)] 
ctf: move ctf_visitor_generate_ir to header file

Move ctf_visitor_generate_ir to the `ast.h` header file, the header file
containing all the declarations for the CTF 1 metadata visitors.  This
will allow exposing it as a proper C++ class and remove the accessor
functions.

Change-Id: Ic13494d0040ee9e2214ecca45d8ea2e7b75ec4fa
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8162
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12264
Tested-by: jenkins <jenkins@lttng.org>
4 weeks agoctf: add try/catch at entry points
Simon Marchi [Tue, 12 Dec 2023 04:17:44 +0000 (04:17 +0000)] 
ctf: add try/catch at entry points

Add try / catch at the entry points of the CTF component classes to
convert thrown exceptions in the proper statuses.  The handled
exceptions are:

 - std::bad_alloc: converted to MEMORY_ERROR
 - bt2::Error: converted to ERROR

Any other exception (for example, coming from a third-party library we
would eventually use) should be caught and converted to a
bt2_common::Error.

Change-Id: I06c2ccb43947f5a9e61568967f2812ccb0821b36
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12263
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 weeks agosink.text.details: don't write empty strings
Philippe Proulx [Mon, 18 Mar 2024 17:59:52 +0000 (13:59 -0400)] 
sink.text.details: don't write empty strings

This patch makes a `sink.text.details` not write the value of a trace
environment entry or of a value object when it's an empty string.

This is mostly because I don't like to keep plain text files with
significant trailing whitespaces in this repository, and
`data/plugins/src.ctf.lttng-live/cli-multi-domains.expect` had some,
for example:

    trace_creation_datetime:️▒
    trace_name:▒

where `▒` is a space.

Of course we'll have the same issue if a user string contains only
whitespaces instead of being empty, but since it's unlikely that we'll
do this in our own tests, this patch is good enough for me.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I6be83e2721bc6ce98e1459a7df42e32ccf6b661d
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12249
CI-Build: Simon Marchi <simon.marchi@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
4 weeks agosink.ctf.fs: use bt2c::Logger
Simon Marchi [Wed, 3 Apr 2024 19:34:14 +0000 (15:34 -0400)] 
sink.ctf.fs: use bt2c::Logger

Use `bt2c::Logger` throughout the `sink.ctf.fs` code.

When printing C strings that may be NULL (e.g. result of
`bt_trace_get_name()`), we currently rely on glibc printf's behavior of
printing `(null)` when passed a NULL pointer for `%s`.  {fmt} doesn't
accept a nullptr `const char *`.  Add the `bt2c::maybeNull()` function
to emulate the existing behavior.

Change-Id: I6ab259c8db526a3b4c0de9295a4360180c56b398
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12241
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 weeks agocpp-common/bt2: make `FieldPathScope` a wise enum
Simon Marchi [Thu, 4 Apr 2024 03:03:44 +0000 (23:03 -0400)] 
cpp-common/bt2: make `FieldPathScope` a wise enum

Change-Id: Ia07b63ff3afe01401ba633d0787ed726143abb05
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12247
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
4 weeks agocpp-common/bt2: make `ValueType` a wise enum
Simon Marchi [Thu, 4 Apr 2024 02:16:13 +0000 (22:16 -0400)] 
cpp-common/bt2: make `ValueType` a wise enum

Change-Id: I0a0b060a094022844b159cedba87de566d4cfbac
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12246
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 weeks agosink.ctf.fs: initialize structure fields
Simon Marchi [Fri, 27 May 2022 15:38:44 +0000 (11:38 -0400)] 
sink.ctf.fs: initialize structure fields

In preparation to using some C++ objects as fields.  Allocate with new
and deallocate with delete where relevant.

Change-Id: I924a6088b17e1d3ae4b8a239cf059fc3a7ecc8c6
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12239
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 weeks agoctf: rename `ctx` structures
Simon Marchi [Thu, 2 Nov 2023 20:00:27 +0000 (20:00 +0000)] 
ctf: rename `ctx` structures

Rename the various structures named `ctx` to something else, to avoid
ODR problems when C++-ifying them.

Change-Id: I1b30c38ba6b88687b5baa5b965b805b0a9097ffe
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12236
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 weeks agocpp-common/bt2: make `UniqueConstError::_mError` a pointer
Simon Marchi [Wed, 3 Apr 2024 17:07:36 +0000 (13:07 -0400)] 
cpp-common/bt2: make `UniqueConstError::_mError` a pointer

Make this field a pointer instead of a reference, in order to make
`UniqueConstError` assignable.  I don't really have a need for this, but
it seems more correct.

Change-Id: I29ae7a7380f75fa6b680116168a309e70c381f11
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12235
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
4 weeks agoctf: use `bt2c::Logger` throughout `src.ctf.fs`, `src.ctf.lttng-live`
Simon Marchi [Thu, 28 Mar 2024 18:31:12 +0000 (14:31 -0400)] 
ctf: use `bt2c::Logger` throughout `src.ctf.fs`, `src.ctf.lttng-live`

A lot of functions and structures have parameters or fields of type
`bt_self_component`, `bt_self_component_class` and `bt_logging_level`
for the sole purpose of logging.  This becomes quite verbose, especially
when a function can be used in both self component and self component
class context, then it will have both of these parameters.

The `bt2c::Logger` class exists to encapsulate this context in a single
value that can be passed around.  Use it as much as practically possible
(as well as the corresponding logging macros) throughout the sources of
the ctf plugin, as well as in the common directory that they depend on.

Update all format strings to use {fmt}'s format string syntax.

Change all "enum to string" functions to be `format_as()` functions
understood by {fmt}.  Move these functions near the type they format,
for convenience.

Remove all the macros that appear at the beginning of source files that
influence the logging (such as `BT_COMP_LOG_SELF_COMP` and `BT_LOG_TAG`).

The log tags were previously defined per-source file, whereas they are
now defined per `Logger` object.  I tried to re-use the existing log
tags when it made sense, but in some places the log tags are now a bit
more granular.

Remove the `ctf_plugin_metadata_log_level` variable, controlled by the
`BABELTRACE_PLUGIN_CTF_METADATA_LOG_LEVEL` environment variable.  This
variable controlled the logging level in the lexer and parser (generated
by flex and bison).   It existed because the generated lexer and parser
don't provide an easy way to pass user data around.

Work around this by define the following variable:

   thread_local const ctf_scanner *currentCtfScanner;

and making the logging in the lexer and parser code use
`currentCtfScanner->logger`.  Set `currentCtfScanner` when entering the
parser in `ctf_scanner_append_ast()` and install an RAII cleanup to
reset it.

Change-Id: I0f6844d2cb83d2bf52b81ae9dee4179c7b1f2e12
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12199
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 weeks agocpp-common/bt2c: make `Logger::Level` a wise enum
Simon Marchi [Thu, 4 Apr 2024 03:03:08 +0000 (23:03 -0400)] 
cpp-common/bt2c: make `Logger::Level` a wise enum

Change-Id: I5298a6af1a6e5a8127d20f546746d5050d767f06
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12245
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
4 weeks agocpp-common/bt2: make `MessageType` a wise enum
Simon Marchi [Thu, 4 Apr 2024 03:02:27 +0000 (23:02 -0400)] 
cpp-common/bt2: make `MessageType` a wise enum

Change-Id: I46182e774ae480b20461ce44add48cea47bb0f3a
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12244
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 weeks agocpp-common/bt2c: add format_as() template functions for wise enums
Simon Marchi [Thu, 4 Apr 2024 03:01:05 +0000 (23:01 -0400)] 
cpp-common/bt2c: add format_as() template functions for wise enums

Add some format_as() functions in the bt2 and bt2c namespaces that will
apply to all wise enums defined in that namespace.

Change-Id: I4952f062fc36e94925d2f0b093ac09d0fae6fdc0
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12248
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
4 weeks agocpp-common/vendor: add copy of wise_enum
Simon Marchi [Wed, 3 Apr 2024 20:18:23 +0000 (16:18 -0400)] 
cpp-common/vendor: add copy of wise_enum

Add a copy of wise_enum, a smart enum library that allows doing cool
things like getting the number of enumerators of an enum, iterating on
enumerators, and converting enumerators to string while effectively
keeping vanilla `enum`/`enum class` behind the scenes (no enum-like
class).

The version is 3.1.0, which corresponds to the git tag `3.1.0`, which
corresponds to this git commit:

  https://github.com/quicknir/wise_enum/commit/34ac79f7ea2658a148359ce82508cc9301e31dd3

Change-Id: I9b92d5cd012dee427cdd725c17eeae9f2a529cb0
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12242
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 weeks agocpp-common/bt2: move some enum classes out of enclosing classes
Simon Marchi [Wed, 3 Apr 2024 20:12:12 +0000 (16:12 -0400)] 
cpp-common/bt2: move some enum classes out of enclosing classes

Settle on the standard of having these enumerations out of the classes
that use them.

Change-Id: I241bdca560bf7f9e892d8884c86662166ad2d2c4
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12240
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
4 weeks agocpp-common/bt2c: use relative include for uuid.hpp in fmt.hpp
Simon Marchi [Wed, 3 Apr 2024 19:10:54 +0000 (15:10 -0400)] 
cpp-common/bt2c: use relative include for uuid.hpp in fmt.hpp

Change-Id: Ic5b5dee8cd967ab8bc5ab476747e4b09e7aa1127
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12237
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
4 weeks agocpp-common/bt2c: add `BT_CPPLOGE_ERRNO_APPEND_CAUSE_SPEC`
Simon Marchi [Wed, 3 Apr 2024 16:05:13 +0000 (12:05 -0400)] 
cpp-common/bt2c: add `BT_CPPLOGE_ERRNO_APPEND_CAUSE_SPEC`

Add the `BT_CPPLOGE_ERRNO_APPEND_CAUSE_SPEC` macro, allowing to log an
error and append an error cause based on `errno`, without throwing.

Change-Id: I5837ef4b78a6d89b5574072f23d4aba6665e6bb4
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12232
Tested-by: jenkins <jenkins@lttng.org>
4 weeks agocpp-common/bt2c: add `BT_CPPLOGE_APPEND_CAUSE_SPEC`
Simon Marchi [Wed, 3 Apr 2024 17:12:05 +0000 (13:12 -0400)] 
cpp-common/bt2c: add `BT_CPPLOGE_APPEND_CAUSE_SPEC`

Add the `BT_CPPLOGE_APPEND_CAUSE_SPEC` macro, allowing to log an error,
append a cause, but not throw.

Change-Id: I6a09dd8775a85202c2049e902ab9edfcbd32080b
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12231
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
4 weeks agocpp-common/bt2c: Logger: remove `noThrow` suffixes
Simon Marchi [Thu, 4 Apr 2024 02:29:21 +0000 (22:29 -0400)] 
cpp-common/bt2c: Logger: remove `noThrow` suffixes

I think that the `noThrow` suffixes are unnecessary.  Since the methods
that throw (or rethrow) have the `AndThrow` (or `AndRethrow`) suffixes,
it is implied that those that don't, don't.

Simplify some macro comments to omit "without appending nor throwing",
for the same reason (if the macro name doesn't contain "APPEND_CAUSE",
it doesn't append a cause, if it doesn't contain "THROW", it doesn't
throw).

Change-Id: Ia71cf733e857e89578648eda12bf64b2bfc65027
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12229
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
4 weeks agocpp-common/bt2c: fix some function names in comments
Simon Marchi [Thu, 4 Apr 2024 02:28:31 +0000 (22:28 -0400)] 
cpp-common/bt2c: fix some function names in comments

Change-Id: I1d66d431e36794daf3b35ab5b3600bcea3bc42d1
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12225
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
4 weeks agoChange naming convention for enum class enumerators
Simon Marchi [Thu, 28 Mar 2024 18:55:27 +0000 (14:55 -0400)] 
Change naming convention for enum class enumerators

Change the naming convention for enum class enumerators to not use
`ALL_CAPS`, as suggested by the C++ Core Guidelines [1].  Instead, use
camel case starting with a capital letter.

Update `CONTRIBUTING.adoc` to reflect this change.

gcc emits warnings like this:

    /home/smarchi/src/babeltrace/src/cpp-common/bt2/trace-ir.hpp:880:9: error: declaration of 'bt2::CommonEventClass<LibObjT>::LogLevel::Error' shadows a global declaration [-Werror=shadow]
      880 |         Error = BT_EVENT_CLASS_LOG_LEVEL_ERROR,
          |         ^~~~~
    In file included from /home/smarchi/src/babeltrace/src/cpp-common/bt2/clock-class.hpp:20,
                     from /home/smarchi/src/babeltrace/src/clock-correlation-validator/clock-correlation-validator.cpp:7:
    /home/smarchi/src/babeltrace/src/cpp-common/bt2/exc.hpp:14:7: note: shadowed declaration is here
       14 | using Error = bt2c::Error;
          |       ^~~~~

Whether or not this is a compiler bug is not clear [2], but in our case
we know it's fine.  Add and use `BT_DIAG_IGNORE_SHADOW` in some places
to silence these warnings.

[1] https://cpp-core-guidelines-docs.vercel.app/enum#Renum-caps
[2] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55776

Change-Id: I59bb7f3c8572106c325596bc80a4d70714d86dee
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12212
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
4 weeks agoFix: cpp-common/bt2c: copy `_mSelfCompCls` when constructing `Logger`
Simon Marchi [Thu, 28 Mar 2024 18:30:22 +0000 (14:30 -0400)] 
Fix: cpp-common/bt2c: copy `_mSelfCompCls` when constructing `Logger`

Change-Id: Ic7e8ddc09a4f943f845821e16323cf2d5c1a667c
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12211
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
4 weeks agobuild: make out-of-tree builds with Python bindings work on msys2
Simon Marchi [Thu, 11 Apr 2024 16:57:08 +0000 (12:57 -0400)] 
build: make out-of-tree builds with Python bindings work on msys2

When doing an out of tree build on msys2 with
`--enable-python-bindings`, where the path to configure is absolute, I
get:

    Making all in bindings/python/bt2
    make[3]: Entering directory '/home/smarchi/build/babeltrace-mingw-w64-ucrt-x86_64/src/bindings/python/bt2'
    touch copy-static-deps.stamp
      SWIG      bt2/native_bt.c
    CC="ccache gcc" CFLAGS="-IC:/msys64/ucrt64/include/glib-2.0 -IC:/msys64/ucrt64/lib/glib-2.0/include -fvisibility=hidden -pthread -IC:/msys64/ucrt64/include/glib-2.0 -IC:/msys64/ucrt64/lib/glib-2.0/include   -Wall -Wextra -Wmissing-prototypes -Wmissing-declarations -Wnull-derefere
nce -Wundef -Wredundant-decls -Wshadow -Wjump-misses-init -Wsuggest-attribute=format -Wnested-externs -Wwrite-strings -Wformat=2 -Wstrict-aliasing -Wmissing-noreturn -Winit-self -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wsuggest-override -Wno-sign-compare -Wno-cast-functi
on-type -Wno-maybe-uninitialized -Wold-style-definition -Wstrict-prototypes -g -O2 -Wno-shadow -Wno-null-dereference -Wno-deprecated-declarations -Wno-redundant-decls -Wno-missing-field-initializers -Wno-unused-parameter -Wno-undef" CPPFLAGS="-I/home/smarchi/src/babeltrace/include -I
../../../../src -I/home/smarchi/src/babeltrace/src -include common/config.h  -I/home/smarchi/src/babeltrace/src/bindings/python/bt2/bt2" LDFLAGS="-L../../../../src/lib/.libs  -lgmodule-2.0 -lglib-2.0 -lintl -LC:/msys64/ucrt64/lib -lpython3.11  -lversion -lshlwapi -lpathcch -lbcrypt -
lm   -lgmodule-2.0 -lglib-2.0 -lintl" /ucrt64/bin/python ./setup.py build --force
    [...]
    ccache gcc -IC:/msys64/ucrt64/include/glib-2.0 -IC:/msys64/ucrt64/lib/glib-2.0/include -fvisibility=hidden -pthread -IC:/msys64/ucrt64/include/glib-2.0 -IC:/msys64/ucrt64/lib/glib-2.0/include -Wall -Wextra -Wmissing-prototypes -Wmissing-declarations -Wnull-dereference -Wundef -Wr
edundant-decls -Wshadow -Wjump-misses-init -Wsuggest-attribute=format -Wnested-externs -Wwrite-strings -Wformat=2 -Wstrict-aliasing -Wmissing-noreturn -Winit-self -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wsuggest-override -Wno-sign-compare -Wno-cast-function-type -Wno-ma
ybe-uninitialized -Wold-style-definition -Wstrict-prototypes -g -O2 -Wno-shadow -Wno-null-dereference -Wno-deprecated-declarations -Wno-redundant-decls -Wno-missing-field-initializers -Wno-unused-parameter -Wno-undef -IC:/msys64/ucrt64/include/glib-2.0 -IC:/msys64/ucrt64/lib/glib-2.0
/include -fvisibility=hidden -pthread -IC:/msys64/ucrt64/include/glib-2.0 -IC:/msys64/ucrt64/lib/glib-2.0/include -Wall -Wextra -Wmissing-prototypes -Wmissing-declarations -Wnull-dereference -Wundef -Wredundant-decls -Wshadow -Wjump-misses-init -Wsuggest-attribute=format -Wnested-ext
erns -Wwrite-strings -Wformat=2 -Wstrict-aliasing -Wmissing-noreturn -Winit-self -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wsuggest-override -Wno-sign-compare -Wno-cast-function-type -Wno-maybe-uninitialized -Wold-style-definition -Wstrict-prototypes -g -O2 -Wno-shadow -W
no-null-dereference -Wno-deprecated-declarations -Wno-redundant-decls -Wno-missing-field-initializers -Wno-unused-parameter -Wno-undef -IC:/msys64/home/smarchi/src/babeltrace/include -I../../../../src -I/home/smarchi/src/babeltrace/src -include common/config.h -I/home/smarchi/src/bab
eltrace/src/bindings/python/bt2/bt2 -IC:/msys64/ucrt64/include/python3.11 -c /home/smarchi/src/babeltrace/src/bindings/python/bt2/bt2/logging.c -o build/temp.mingw_x86_64_ucrt-3.11/home/smarchi/src/babeltrace/src/bindings/python/bt2/bt2/logging.o
    cc1.exe: warning: command-line option '-Wsuggest-override' is valid for C++/ObjC++ but not for C
    cc1.exe: fatal error: /home/smarchi/src/babeltrace/src/bindings/python/bt2/bt2/logging.c: No such file or directory
    compilation terminated.
    error: command 'C:\\msys64\\ucrt64\\bin/ccache.exe' failed with exit code 1
    make[3]: *** [Makefile:735: build-python-bindings.stamp] Error 1
    make[3]: Leaving directory '/home/smarchi/build/babeltrace-mingw-w64-ucrt-x86_64/src/bindings/python/bt2'

For 'in-tree' builds all the paths are relative and thus compatible with
native windows binaries while in an 'out-of-tree' build some of the
paths are absolute and thus incompatible. The MSYS2 shell does a lot of
'magic' conversion [1] on paths passed as arguments and through environment
variables but the heuristics are limited and it doesn't apply when
binaries are called directly without using the shell.

The first issue is the include paths in the CFLAGS and CPPFLAGS
environment variables which don't get converted because they start with
'-I'.

The second issue is that the path to 'logging.c' in the generated
'setup.py is absolute:

    sources=["bt2/native_bt.c", "/home/smarchi/src/babeltrace/src/bindings/python/bt2/bt2/logging.c"],

When distutils invokes gcc to compile this file, it spawns it directly,
not through a shell, so no automatic Unix -> Windows path conversion
takes place.

Fix both of those issues by modifying 'setup.py' to detect the MSYS2
environment and convert absolute path to Windows style using the
'cygpath' command.

[1] https://www.msys2.org/docs/filesystem-paths/

Change-Id: I9003878a6582a0dc3f4ee18b07885f332348b8bf
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12397
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
6 weeks agosrc/Makefile.am: build {fmt} without `-Wmissing-noreturn`
Philippe Proulx [Wed, 3 Apr 2024 13:50:23 +0000 (09:50 -0400)] 
src/Makefile.am: build {fmt} without `-Wmissing-noreturn`

Until <https://github.com/fmtlib/fmt/pull/3917> is merged and becomes
part of a release, let's just ignore missing `[[noreturn]]` warnings
when building {fmt}.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ia63f6248a59d8b42b35523e0a1972daa94f957bf
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12223
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Michael Jeanson <mjeanson@efficios.com>
7 weeks agoFix: cpp-common/bt2c/logging.hpp: remove one definition of `BT_CPPLOGE_APPEND_CAUSE_A...
Simon Marchi [Wed, 27 Mar 2024 20:04:13 +0000 (20:04 +0000)] 
Fix: cpp-common/bt2c/logging.hpp: remove one definition of `BT_CPPLOGE_APPEND_CAUSE_AND_THROW_SPEC`

`BT_CPPLOGE_APPEND_CAUSE_AND_THROW_SPEC` has two identical definitions,
remove one.

Change-Id: Ia5b7caae53b65169081e9d8214896887fa062ad4
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12198
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
7 weeks agoFix: cpp-common/bt2c/logging.hpp: don't set `_mSelfComp` when creating `Logger` for...
Simon Marchi [Tue, 26 Mar 2024 21:35:59 +0000 (21:35 +0000)] 
Fix: cpp-common/bt2c/logging.hpp: don't set `_mSelfComp` when creating `Logger` for message iterator

Only one context in `Logger` must be set.  Similarly, when creating a
`Logger` for a component, we don't set `_mSelfCompCls`.

Change-Id: Ie826986d301cb996b594127c72094b90974b8e87
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12197
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
7 weeks agocompat: rename socket.h to socket.hpp
Simon Marchi [Mon, 29 Jan 2024 21:31:06 +0000 (16:31 -0500)] 
compat: rename socket.h to socket.hpp

`socket.h` is only included in C++ code, so make it a C++ file.  This
makes it possible for an upcoming patch to make it use `bt2c::Logger`.

Change-Id: I42c9fd08a343357c116cf85675f36997cc1f3f2e
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12196
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
7 weeks agoctf: allocate some structures with new
Simon Marchi [Tue, 24 Oct 2023 02:18:14 +0000 (22:18 -0400)] 
ctf: allocate some structures with new

Allocate some key structures in the ctf plugin with new (and free with
delete), so we can start using non-POD fields in them.  Initialize all
fields to 0 / nullptr to replicate what g_new0 did.

Add ctf_fs_ds_index_entry_destroy, to abstract how this object is
destroyed (it is currently being g_free'd at multiple places) and to use
it as a g_ptr_array_new_with_free_func callback.

Change-Id: Ic0f893655db22c964641639aa0625d820af71587
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8021
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12195
Tested-by: jenkins <jenkins@lttng.org>
7 weeks agoctf: remove unused `struct ctf_metadata_decoder`
Simon Marchi [Wed, 11 May 2022 14:08:43 +0000 (10:08 -0400)] 
ctf: remove unused `struct ctf_metadata_decoder`

I noticed this struct was unused.  There is another `struct
ctf_metadata_decoder` in src/plugins/ctf/decoder.cpp, that is actually
used.

Change-Id: Ief9a4e37e7414b8fcd729581bb040c1100722327
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8020
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12191
Tested-by: jenkins <jenkins@lttng.org>
7 weeks agosrc/plugins/ctf/common: restructure subtree
Philippe Proulx [Mon, 11 Dec 2023 17:54:03 +0000 (12:54 -0500)] 
src/plugins/ctf/common: restructure subtree

This patch restructures the `src/plugins/ctf/common` subtree as such:

`src`:
    Everything common to source component classes.

`src/metadata/tsdl`:
    TSDL-specific code.

    As of this patch, everything which was part of
    `src/plugins/ctf/common/metadata` is moved here, but some code will
    be shared with CTF 2 sources eventually and move back to
    `src/plugins/ctf/common/src/metadata`.

`print.hpp` isn't needed anymore.

This new structure will make it easier to add common `ctf` plugin code
for both source and sink component classes, as well as to add code
specific to CTF 2 and common to both CTF 1 and CTF 2.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I4246d6ba37ff26efa5d4b7b4be2ec8600d3207e4
Reviewed-on: https://review.lttng.org/c/babeltrace/+/7839
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12190
CI-Build: Simon Marchi <simon.marchi@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
7 weeks agosink.text.pretty: abort on unknown field class type
Simon Marchi [Fri, 11 Mar 2022 17:03:35 +0000 (12:03 -0500)] 
sink.text.pretty: abort on unknown field class type

I don't think there a legimitate case for the print_field function to
encounter an invalid field class type.  Change it to abort instead of
returning an error.

Change-Id: I333d2221b828841aff38a7d8b0a17032af3aafb1
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/7580
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/7573

7 weeks agosink.ctf.fs: remove unused `fs_sink_ctf_field_class::index_in_parent` field
Francis Deslauriers [Thu, 24 Feb 2022 20:06:03 +0000 (15:06 -0500)] 
sink.ctf.fs: remove unused `fs_sink_ctf_field_class::index_in_parent` field

This field is not used anywhere and looks like a leftover from a
previous iteration of the sink. Let's remove it.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I64592c1561bd66e083e965903d8a9dc050a5756d
Reviewed-on: https://review.lttng.org/c/babeltrace/+/7387
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12189
Tested-by: jenkins <jenkins@lttng.org>
CI-Build: Simon Marchi <simon.marchi@efficios.com>

7 weeks agoconfigure.ac: build with `-DFMT_EXCEPTIONS=0`
Simon Marchi [Wed, 27 Mar 2024 19:14:24 +0000 (19:14 +0000)] 
configure.ac: build with `-DFMT_EXCEPTIONS=0`

Coverity flags some functions marked `noexcept` that call `fmt::format`,
since `fmt::format` can throw `fmt::format_error` exceptions.  We're not
interested in handling format errors at runtime, we'd rather just get a
crash and fix it.  Build the entire project (including `libfmt.la`) with
`-DFMT_EXCEPTIONS=0` to make {fmt} crash instead of throw, should a
format error occur.

Tested by introducing a format error somewhere and running to it.  The
result is very pretty:

    $ tests/plugins/flt.utils.muxer/test-clock-compatibility
    1..150
    /home/smarchi/src/babeltrace/src/cpp-common/vendor/fmt/format-inl.h:40: assertion failed: invalid format stringterminate called without an active exception
    [1]    1189949 IOT instruction  tests/plugins/flt.utils.muxer/test-clock-compatibility

Change-Id: Ibcb0104a6bf644b025112d0b35e4fbe622c20be9
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12194
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-by: Michael Jeanson <mjeanson@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
7 weeks agoFix: bt_value_map_borrow_entry_value(): use `@bt_pre_is_map_val`
Philippe Proulx [Wed, 27 Mar 2024 20:46:32 +0000 (16:46 -0400)] 
Fix: bt_value_map_borrow_entry_value(): use `@bt_pre_is_map_val`

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I48f15e9938d78245fd5f86a35935bf56fd304261

7 weeks ago.clang-tidy: enable cppcoreguidelines-avoid-const-or-ref-data-members
Simon Marchi [Fri, 15 Mar 2024 20:11:33 +0000 (16:11 -0400)] 
.clang-tidy: enable cppcoreguidelines-avoid-const-or-ref-data-members

Enable:

  https://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines/avoid-const-or-ref-data-members.html

Set the `AllowMissingMoveFunctionsWhenCopyIsDeleted`, so it's less
verbose when you just want to delete everything.

Set `AllowSoleDefaultDtor`, because we have legitimate cases (when
defining virtual base classes) where we only define a default
destructor.  Perhaps there's a pitfall I don't see when allowing this?

Change-Id: I4a8d20c0be628ac807db4c6b52548e3b7d7ee286
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12090
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
7 weeks agoAdd clang-tidy config file
Simon Marchi [Fri, 15 Mar 2024 17:26:31 +0000 (13:26 -0400)] 
Add clang-tidy config file

Copied from:

  https://git.lttng.org/?p=lttng-tools.git;a=blob;f=.clang-tidy;h=75f559c5d961041df8e37280ef27cb0cac8cdd96;hb=20c4b46aee1a984bc558b483826c1078f24d35e9

And adapted for Babeltrace:

 - Define `BT_ASSERT` and `BT_ASSERT_DBG` as assertion macros.
 - Remove `HeaderFilterRegex`.  We might want to use this setting, but
   I'm not sure what its value would be for Babeltrace.
 - Fix a . -> , typo

Change-Id: I73f1776bc4b7cb1bdc0d5728f9a46b17157088c8
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12078
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
7 weeks agoflt.utils.muxer: use clock correlation validator
Simon Marchi [Tue, 12 Mar 2024 21:24:12 +0000 (17:24 -0400)] 
flt.utils.muxer: use clock correlation validator

Change the clock correlation validation code in `flt.utils.muxer` to use
the clock correlation validation library.

Change-Id: I5452f530de5fb035f66da5fc6f63bba48711e503
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11991
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
7 weeks agoflt.utils.muxer: don't reset clock expectation when seeking beginning
Simon Marchi [Fri, 22 Mar 2024 18:28:37 +0000 (14:28 -0400)] 
flt.utils.muxer: don't reset clock expectation when seeking beginning

When seeking the beginning, there is no reason to reset the clock
expectations.  The clocks seen after a seek beginning should be
compatible with those seen before.

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Change-Id: I2ea587ea7b7f62ae509632836ae4364292903001
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12148
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
7 weeks agocpp-common/bt2c: add `format_as()` functions for `Uuid` and `UuidView`
Simon Marchi [Fri, 22 Mar 2024 02:29:30 +0000 (22:29 -0400)] 
cpp-common/bt2c: add `format_as()` functions for `Uuid` and `UuidView`

Change-Id: I6530144e78d6aa10dedb320b90a4c208aa572e9d
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12138
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
7 weeks agotests/plugins/flt.utils.muxer: add test for clock (in)compatibility cases
Simon Marchi [Tue, 12 Mar 2024 21:23:02 +0000 (17:23 -0400)] 
tests/plugins/flt.utils.muxer: add test for clock (in)compatibility cases

Add a test for the various clock class incompatibility cases checked by
the `MsgIter::_makeSureClkClsIsExpected` method in the `flt.utils.muxer`
component class.

The scenarios are equivalent to the triggers in
`tests/lib/conds/conds-trigger.cpp`, used to test the preconditions in
the library.  Since the scenarios are equivalent, it would probably be
possible to share some code with that file, but I haven't tried it.

In essence, for each scenario, the test creates a graph where a muxer
component receives two messages with incompatible clock
configurations.  The test expects that an exception is thrown, and
checks whether the root cause contains an expected string.

Change-Id: I8bd98fa52719ab2cedb7cbb09310a560b437eb28
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12005
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
7 weeks agoplugins/common/muxing: compare "origin is Unix epoch" property of clock classes
Simon Marchi [Fri, 15 Mar 2024 03:37:59 +0000 (23:37 -0400)] 
plugins/common/muxing: compare "origin is Unix epoch" property of clock classes

If two clock classes only differ by their "origin is Unix epoch"
property, they will compare equal as far as `compare_clock_classes` is
concerned.  Add a comparison for that.

Change-Id: Iecac8fd4aa3064b221291264f4fc6758e32a0943
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12067
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
7 weeks agoplugins/common/muxing: compare stream class clock classes
Simon Marchi [Wed, 13 Mar 2024 19:59:22 +0000 (15:59 -0400)] 
plugins/common/muxing: compare stream class clock classes

When comparing two streams and all else is equal about the stream and
their classes, compare the clock classes attached to the stream classes.

My use case for this is that I'm writing a test where two source
components send a stream beginning message to a muxer components.  The
only difference between the two is the clock classes associated to the
stream classes.  Some stream classes have an associated clock class,
some don't.  In other cases, the stream classes differ only by some
properties of their clock classes.  I want to be sure that the messages
will come out of the muxer's priority heap in a stable order.

Change-Id: I113704dac4ff952573c3dd96acd33b295425a863
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12054
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
7 weeks agoplugins/common/muxing: split `compare_clock_snapshots_and_clock_classes()`
Simon Marchi [Wed, 13 Mar 2024 20:05:31 +0000 (16:05 -0400)] 
plugins/common/muxing: split `compare_clock_snapshots_and_clock_classes()`

A subsequent commit will want to re-use the code to compare two clock
classes.  Split `compare_clock_snapshots_and_clock_classes()` in two, to
make the comparing clock classes part independent from the comparing
clock snapshots part.

Change-Id: I7888d7d3d1339ccb6c27054919349745cb7875eb
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12053
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
7 weeks agosink.utils.counter: remove unnecessary check in counter_consume()
Simon Marchi [Tue, 5 Mar 2024 21:05:05 +0000 (16:05 -0500)] 
sink.utils.counter: remove unnecessary check in counter_consume()

Given the lifecycle of a component, I'm pretty sure this condition can
never be true.  For counter_consume() to be called,
counter_graph_is_configured() must execute successfully.  If
counter_graph_is_configured() executes successfully, `counter->msg_iter`
is necessarily set.

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Change-Id: Ibd3cbcfdeefa8d79143e39c6fb846ca5eeebd249
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12010
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
7 weeks agosink.utils.dummy: remove unnecessary check in dummy_consume()
Simon Marchi [Tue, 5 Mar 2024 21:05:05 +0000 (16:05 -0500)] 
sink.utils.dummy: remove unnecessary check in dummy_consume()

Given the lifecycle of a component, I'm pretty sure this condition can
never be true.  For dummy_consume() to be called,
dummy_graph_is_configured() must execute successfully.  If
dummy_graph_is_configured() executes successfully, `dummy->msg_iter` is
necessarily set.

Change-Id: I5c11c6b76c8cb267f0185c1a35bc2f5e70826509
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12009
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
7 weeks agosink.utils.counter: append error cause when call to bt_message_iterator_next()` fails
Simon Marchi [Tue, 5 Mar 2024 20:50:13 +0000 (15:50 -0500)] 
sink.utils.counter: append error cause when call to bt_message_iterator_next()` fails

Same as the previous patch, but for the counter component.

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Change-Id: I95f27091512aebc9d01c7b05d98955fdfdcab5da
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12008
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
7 weeks agosink.utils.dummy: append error cause when call to bt_message_iterator_next()` fails
Simon Marchi [Tue, 5 Mar 2024 20:50:13 +0000 (15:50 -0500)] 
sink.utils.dummy: append error cause when call to bt_message_iterator_next()` fails

I'm looking at some error stacks for a graph involving a dummy
component, and I noticed that it did not produce an error cause when
failing to consume.  I think it would be nice if it did, to avoid having
a gap in the error stack.

Change-Id: I1b7af3218f9937a21d3dee7406a2b03e122671c6
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12007
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
7 weeks agocpp-common/bt2: use universal reference for `Graph::addComponent()` initialization...
Simon Marchi [Wed, 13 Mar 2024 04:27:54 +0000 (00:27 -0400)] 
cpp-common/bt2: use universal reference for `Graph::addComponent()` initialization data

I noticed it was not possible to pass data to `Graph::addComponent`
using a temporary object:

    graph->addComponent(*srcCompCls, "source-1", TestSourceData {});

My understanding of it is that the compiler does not consider the
overload with the `InitDataT&` parameter for this, because the temporary
object can't bind to the lvalue reference.

Change these methods to take forwarding references instead.

Change-Id: Icc80239812c325b777ed83e8634302a0c9d72f14
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12049
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
7 weeks agoFix: flt.utils.muxer: reject two different clock classes with unknown origin and...
Simon Marchi [Tue, 12 Mar 2024 18:45:24 +0000 (14:45 -0400)] 
Fix: flt.utils.muxer: reject two different clock classes with unknown origin and no UUID

When getting a message with a clock class whose origin is unknown and
that has no UUID, the expectation of a `flt.utils.muxer` component
should be that all subsequent messages with an associated clock class
will have the exact same clock class instance.  Currently, it accepts
any other clock class instance that has an unknown origin and no UUID.

This is a change that is equivalent to what was done in commit
29e191fceb61 ("Fix: lib: strengthen clock expectation check for no Unix
epoch / no UUID case") in the library iterator code.

When first seeing a clock class with unknown origin and no UUID, make
the muxer message iterator save the clock class instance, holding a
strong reference, and ensure that all clock classes seen after are the
same instance.

Change-Id: I676471cc0c3b88a83cd0b452dee8d6b1ed549e4d
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12044
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
7 weeks agocpp-common/bt2c: add `CStringView::startsWith`
Simon Marchi [Wed, 6 Mar 2024 18:14:11 +0000 (13:14 -0500)] 
cpp-common/bt2c: add `CStringView::startsWith`

Change-Id: I4a39561085850c06adc1f6e36466fba9a2e6dfa0
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12011
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
7 weeks agocpp-common/bt2: add C++ bindings around `bt_error *`
Simon Marchi [Tue, 12 Mar 2024 22:17:42 +0000 (18:17 -0400)] 
cpp-common/bt2: add C++ bindings around `bt_error *`

Add C++ bindings to access the error on the current thread.

 - Take the current thread error with takeCurrentThreadError(),
   returning a `UniqueConstError`.
 - Move the current thread error back with moveErrorToCurrentThread().
 - Access the error cause by iterating or subscripting
   `UniqueConstError`, which yields objects of type `ConstErrorCause` (a
   borrowed object type).
 - Access the common error cause information using methods of
   `ConstErrorCause`, including the error cause actor type.
 - Obtain a more specific error cause object with
   `ConstErrorCause::as*()`.

Change-Id: Ie18e22ef8901bc9c8d7c85432d515ca763b484c2
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12006
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
7 weeks agolib/graph/iterator.c: fix indentation (spaces -> tabs)
Simon Marchi [Thu, 21 Mar 2024 19:20:36 +0000 (15:20 -0400)] 
lib/graph/iterator.c: fix indentation (spaces -> tabs)

Change-Id: Ic6b408ef73e54e59161dca18fe19a45285d39c22
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12123
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
7 weeks agolib/graph/iterator: use clock correlation validator util
Simon Marchi [Thu, 21 Mar 2024 19:17:16 +0000 (15:17 -0400)] 
lib/graph/iterator: use clock correlation validator util

Make `graph/iterator.{c,h}` use the clock correlation validator
convenience library.

 - Replace the fields of `struct bt_message_iterator` that track the
   clock expectation state with a single `struct
   bt_clock_correlation_validator` field, only present if babeltrace is
   built in dev mode.

 - Initialize `bt_message_iterator::correlation_validator` in
   create_self_component_input_port_message_iterator.  Finalize it in
   `bt_message_iterator_destroy`.

 - Replace the bulk of
   `assert_post_dev_clock_classes_are_compatible_one` with one call to
   `bt_clock_correlation_validator_validate_message`.  If the latter
   returns an error, trigger an assertion failure based on the return
   error type and associated information.

The modifications in the Makefiles (adding `dummy.cpp`) are to force
linking with the C++ compiler driver.  This is necessary, since the
`libbabeltrace2.so` library now requires some symbols from the C++
standard library (e.g. `libstdc++.so`).  The `dummy.cpp` does not
actually need to exist.  This trick is described in the automake doc
[1].

[1] https://www.gnu.org/software/automake/manual/automake.html#Libtool-Convenience-Libraries

Change-Id: I46a3a553d5e18eb6860d65d928ef33d941e9e951
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11990
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
7 weeks agolib/graph/iterator: don't reset clock expectation when seeking beginning
Simon Marchi [Fri, 22 Mar 2024 18:28:37 +0000 (14:28 -0400)] 
lib/graph/iterator: don't reset clock expectation when seeking beginning

When asking an iterator to seeking the beginning, there is no reason to
reset the clock expectations.  The clocks seen after a seek beginning
should be compatible with those seen before.

Change-Id: I91d45b22c477048d92bc567a3ee26ec9641c1055
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12147
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
7 weeks agoclock-correlation-validator: add clock correlation validation util
Simon Marchi [Fri, 1 Mar 2024 15:59:51 +0000 (10:59 -0500)] 
clock-correlation-validator: add clock correlation validation util

`lib/graph/iterator.c` and `plugins/utils/muxer/msg-iter.cpp` have
equivalent code to verify that the various clock classes they see are
correlatable.  Add a util to factor out this logic.

Since the lib is written in C and the muxer component in C++, we need
both interfaces.  I chose to write the core of the library with a proper
C++ interface (since that's the future!) and make a small C wrapper
around it.  If/when we migrate some parts of the lib to C++, we will be
able to drop this C wrapper.

Change-Id: Iab8968ef33c9f7d4e2e8e06e0942de749a090841
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11753
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
7 weeks agocpp-common/bt2: add `wrap(bt_graph *)`
Simon Marchi [Tue, 12 Mar 2024 22:13:56 +0000 (18:13 -0400)] 
cpp-common/bt2: add `wrap(bt_graph *)`

Change-Id: I85e6e38576d71f64a7cd8cb0139104bce98aac36
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12046
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
7 weeks agocpp-common/bt2: don't use wrap in bindings code
Simon Marchi [Wed, 13 Mar 2024 04:18:06 +0000 (00:18 -0400)] 
cpp-common/bt2: don't use wrap in bindings code

Using `wrap()` in bindings code causes cyclic include problems, stop
using it.

For instance, we want to add `wrap(bt_graph *)`, so `wrap.hpp` needs to
include `graph.hpp`.  But `graph.hpp` currently uses and includes
`wrap.hpp`.

Change-Id: I5b7005617ed38eb791edf5802a05a8a8dd3115fd
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12045
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
7 weeks agocpp-common/bt2: make `getSupportedMipVersions` methods take a `ConstMapValue`
Simon Marchi [Wed, 13 Mar 2024 04:14:36 +0000 (00:14 -0400)] 
cpp-common/bt2: make `getSupportedMipVersions` methods take a `ConstMapValue`

The "get_supported_mip_versions" component class methods always receive
a map value.  The equivalent methods in the C++ bindings should
therefore take a `ConstMapValue.

Change-Id: Ia3ba17048337d3abb72cefa2ae88c7b3187833f2
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12048
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
7 weeks agocpp-common/bt2: remove unnecessary mentions of `bt2::`
Simon Marchi [Wed, 13 Mar 2024 04:12:33 +0000 (00:12 -0400)] 
cpp-common/bt2: remove unnecessary mentions of `bt2::`

Don't use `bt2::` when already inside the `bt2` namespace.

Change-Id: I63444e141ae13b6e508d4508488fb562ae9403d7
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12047
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
7 weeks agocpp-common/bt2: make `{OptionalBorrowedObject,SharedObject}::operator bool` explicit
Simon Marchi [Tue, 12 Mar 2024 20:17:50 +0000 (16:17 -0400)] 
cpp-common/bt2: make `{OptionalBorrowedObject,SharedObject}::operator bool` explicit

This code doesn't really make sense (what I really wanted to do was to
compare the underlying lib pointers), but I made this mistake on more
than one occasion:

    if (someOptionalBorrowedObject == someSharedObject)

What happens is: since `operator bool` for both types is implicit, they
get implicitly converted to bool.  As a result, the condition checks if
both objects contain an object or don't contain an object.  I consider
this a pitfall, as it compiles but it is likely never what we'll want to
do.

Make `operator bool` for both types explicit to avoid that.  This is
what is done in the STL for `shared_ptr` [1] and `optional` [2].

Note that even if `operator bool` is explicit, it remains implicitly
convertible to bool in certain contexts [3], such as an if condition.

[1] https://en.cppreference.com/w/cpp/memory/shared_ptr/operator_bool
[2] https://en.cppreference.com/w/cpp/utility/optional/operator_bool
[3] https://stackoverflow.com/questions/39995573/when-can-i-use-explicit-operator-bool-without-a-cast

Change-Id: I2b2377323ca620162442cb7f0305763c034d13d8
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12043
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
7 weeks agoflt.utils.muxer: use `streamClassDefaultClockClass()` methods
Simon Marchi [Fri, 1 Mar 2024 15:58:31 +0000 (10:58 -0500)] 
flt.utils.muxer: use `streamClassDefaultClockClass()` methods

Use them where possible, as a shortcut to
`.stream().cls().defaultClockClass()`.

Change-Id: I2923f3882dfd4dde31057962a1dd41f7b9edbd9a
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11965
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
7 weeks agocpp-common/bt2: add `streamClassDefaultClockClass()` methods
Simon Marchi [Fri, 1 Mar 2024 15:56:17 +0000 (10:56 -0500)] 
cpp-common/bt2: add `streamClassDefaultClockClass()` methods

Add `streamClassDefaultClockClass()` methods on all relevant message
types, calling the
`bt_message_*_borrow_stream_class_default_clock_class_const` library
functions.

Change-Id: Iee1636048838d263b4407c60f8760870bd4ddb01
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11964
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
7 weeks agotests: improve debuggability of `cli/test-trace-copy.sh`
Simon Marchi [Fri, 1 Mar 2024 15:49:47 +0000 (10:49 -0500)] 
tests: improve debuggability of `cli/test-trace-copy.sh`

When something fails in `cli/test-trace-copy.sh`, we don't really know
why, as everything is sent to `/dev/null`.

Make the test record stderr and print it (using tap's `diag`) when
something fails.

Add the `diag_file` helper to make that easy.

Change-Id: I2eb85cd5fffb136cddf2457089681ee57c21e4f7
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11963
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
7 weeks agocpp-common/bt2c: use `ComparableWithCStringView` on `operator!=` meant for `CStringView`
Simon Marchi [Fri, 1 Mar 2024 15:42:13 +0000 (10:42 -0500)] 
cpp-common/bt2c: use `ComparableWithCStringView` on `operator!=` meant for `CStringView`

I don't recall exactly when I needed this, but it occured to me once
that the `operator!=` we provide for `CStringView` was getting picked up
for some unrelated type.  It just seems dangerous to provide a generic
templated operator like that that can match literally anything.

Use the same `ComparableWithCStringView` conditions here that we use for
`operator==` just above, so that it only gets used for what it was
intended for.

Change-Id: I798f1c8195c541f6188499dcfabfe1233a95a492
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11962
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
7 weeks agocpp-common/bt2: add static_assert in `CommonClockClass::uuid(const std::uint8_t *)`
Simon Marchi [Thu, 29 Feb 2024 19:58:04 +0000 (14:58 -0500)] 
cpp-common/bt2: add static_assert in `CommonClockClass::uuid(const std::uint8_t *)`

Change-Id: I66399af51ab21c52e8fbc61cc61cae1b94f1e2e7
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11956
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
7 weeks agotests/lib/conds: test clock compatibility post conditions
Simon Marchi [Thu, 21 Mar 2024 18:15:52 +0000 (14:15 -0400)] 
tests/lib/conds: test clock compatibility post conditions

Add tests for the clock class compatibility post conditions in
`iterator.c`.  There is one test for each `BT_ASSERT_POST_DEV` in
`assert_post_dev_clock_classes_are_compatible_one`.

`addClockClsCompatTriggers()` adds a bunch of triggers that make a
message iterator return two messages with incompatible clock classes.
The message types that play a role in the clock compatibility checks are
"stream beginning" and "message iterator inactivity".
`addClockClsCompatTriggers()` adds all possible combinations of using
these two message types for the first and second message.  Since it's
not possible to send a message iterator inactivity message without a
clock class, some cases are skipped.

The change in `Makefile.am` is needed for the test to work in builds
with `--enable-built-in-plugins`, for the `RunIn` utility to be able to
find the `utils` plugin.  This was not needed before, because all the
existing triggers make the program stop before `RunIn` attempts to load
the `utils` plugin.

Change-Id: Ib6c22923e4e9f02de64a87efddaee3c23d3891ea
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11811
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
7 weeks agoFix: lib/graph/iterator: consider clock classes from message iterator inactivity...
Simon Marchi [Thu, 21 Mar 2024 14:56:13 +0000 (10:56 -0400)] 
Fix: lib/graph/iterator: consider clock classes from message iterator inactivity messages for clock correlation validation

Make the clock correlation validation code consider clock classes from
message iterator inactivity messages.  This is equivalent to what the
muxer component class does (see `MsgIter::_validateMsgClkCls()`).

Change-Id: I172d0015eb45508da7c412172b24aa4b0236ae9f
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12120
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
7 weeks agocpp-common/bt2s: control span-lite's contract check based on BT_DEBUG_MODE
Simon Marchi [Thu, 21 Mar 2024 18:21:36 +0000 (14:21 -0400)] 
cpp-common/bt2s: control span-lite's contract check based on BT_DEBUG_MODE

Enable or disable span-lite's contract checking feature based on
BT_DEBUG_MODE.  When contract checking is enabled and a contract
assertion fails, span-lite calls `std::terminate()`.

Change-Id: Ieba9a08712823daf4b77f135155cd15ec97900f5
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12119
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
7 weeks agotests/lib/conds: make `condMain()` take a span for args
Simon Marchi [Thu, 21 Mar 2024 19:13:26 +0000 (15:13 -0400)] 
tests/lib/conds: make `condMain()` take a span for args

Make `argv` a span, instead of having `argc` + `argv`.  There is no
point in this change except that it seemed possible and I wanted to do
it.

Change-Id: I1e7e76638e9e6365df05bb5c7b175d44b6badf6f
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12118
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
7 weeks agocpp-common/bt2c: enable span-lite's `make_span()` function
Simon Marchi [Thu, 21 Mar 2024 14:37:54 +0000 (10:37 -0400)] 
cpp-common/bt2c: enable span-lite's `make_span()` function

Enable span-lite's `make_span()` function, which exists to compensate
for the lack of class template argument deduction in C++ pre 17.  This
allows creating spans without being too verbose.  This is not a standard
function, but the day we switch to C++ 17 and want to use `std::span`,
we can just replace all uses of `make_span()` with calls to
`std::span`'s constructor.

Make one version of `nonstd::make_span` (expected to be used in an
upcoming patch) available as `bt2c::makeSpan()`.

Change-Id: Ie28c1884d2c03c38a4b839096afae887fa54cc04
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12117
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
This page took 0.049208 seconds and 4 git commands to generate.