deliverable/babeltrace.git
21 months agosrc.ctf.fs: make get_stream_instance_unique_name return `const std::string &`
Simon Marchi [Tue, 26 Jul 2022 21:18:00 +0000 (17:18 -0400)] 
src.ctf.fs: make get_stream_instance_unique_name return `const std::string &`

We always return the first stream's name.  Return a reference to that
name instead of a new object and a copy of the string.

Change-Id: I657265b74e0566a36f2ae05f6b5b1b6d21f53c66
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8290
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
21 months agosrc.ctf.fs: use GStringUP in ctf_fs_component_create_ctf_fs_trace_one_path
Simon Marchi [Thu, 9 Jun 2022 15:24:48 +0000 (11:24 -0400)] 
src.ctf.fs: use GStringUP in ctf_fs_component_create_ctf_fs_trace_one_path

Change-Id: I6405c80bdfc519fe45ebadadcfd2e396da9a74cb
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8289
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
21 months agocpp-common: add GStringUP
Simon Marchi [Thu, 9 Jun 2022 15:23:33 +0000 (11:23 -0400)] 
cpp-common: add GStringUP

Add a type to automatically manage the lifetime of GString objects.

Change-Id: I60e08f7d62c290c0194ed0cd62b0d0491b9af2bd
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8288
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
21 months agosrc.ctf.fs: remove ctf_fs_trace_destroy
Simon Marchi [Thu, 9 Jun 2022 15:21:19 +0000 (11:21 -0400)] 
src.ctf.fs: remove ctf_fs_trace_destroy

Remove it and the custom deleter, since ctf_fs_trace instances can now
be simply deleted.

Change-Id: I59f3f89b4b3faee45b3708245242cee009d218b7
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8287
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
21 months agosrc.ctf.fs: make ctf_fs_trace::metadata a unique_ptr
Simon Marchi [Thu, 9 Jun 2022 15:19:30 +0000 (11:19 -0400)] 
src.ctf.fs: make ctf_fs_trace::metadata a unique_ptr

Introduce ctf_fs_metadata::UP and change the ctf_fs_trace::metadata
field to be of that type.

Change-Id: I0221ef7786cc8fb4c2e8a9264573ab5c2e5420d6
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8286
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
21 months agosrc.ctf.fs: remove ctf_fs_metadata_init and ctf_fs_metadata_fini
Simon Marchi [Fri, 10 Jun 2022 16:55:45 +0000 (12:55 -0400)] 
src.ctf.fs: remove ctf_fs_metadata_init and ctf_fs_metadata_fini

Change-Id: Ie34c0a5c5aea60aa2fc771d35a39b61ec0eca336
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8285
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
21 months agosrc.ctf.fs: make ctf_fs_metadata::trace_class a bt2::TraceClass::Shared
Simon Marchi [Thu, 28 Jul 2022 14:19:30 +0000 (10:19 -0400)] 
src.ctf.fs: make ctf_fs_metadata::trace_class a bt2::TraceClass::Shared

Change-Id: I1ee6a21525757197213c35acfa1f0a17d7052541
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8284
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
21 months agosrc.ctf.fs: make ctf_visitor_generate_ir::trace_class a bt2::TraceClass::Shared
Simon Marchi [Tue, 26 Jul 2022 21:17:36 +0000 (17:17 -0400)] 
src.ctf.fs: make ctf_visitor_generate_ir::trace_class a bt2::TraceClass::Shared

Change-Id: I9b414384b025f39c3cfb9900659235a17426b649
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8283
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
21 months agosrc.ctf.fs: remove ctf_fs_metadata::text
Simon Marchi [Thu, 9 Jun 2022 15:05:38 +0000 (11:05 -0400)] 
src.ctf.fs: remove ctf_fs_metadata::text

Change-Id: Id15010c2d5c1f9fccd60adfb0920b1dca2f2074b
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8282
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
21 months agosrc.ctf.fs: make ctf_fs_trace::path an std::string
Simon Marchi [Tue, 26 Jul 2022 21:16:56 +0000 (17:16 -0400)] 
src.ctf.fs: make ctf_fs_trace::path an std::string

Change-Id: I9938c37f4effca7e83ed2e495feb5dd596d2320e
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8281
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
21 months agosrc.ctf.fs: make ctf_fs_trace::trace a bt2::Trace::Shared
Simon Marchi [Thu, 9 Jun 2022 14:56:43 +0000 (10:56 -0400)] 
src.ctf.fs: make ctf_fs_trace::trace a bt2::Trace::Shared

Change-Id: I4fabe113da7b5adb794377706ab07fac9b59df02
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8280
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
21 months agosrc.ctf.fs: introduce and use ctf_fs_msg_iter_data::UP
Simon Marchi [Thu, 9 Jun 2022 14:52:55 +0000 (10:52 -0400)] 
src.ctf.fs: introduce and use ctf_fs_msg_iter_data::UP

Introduce ctf_fs_msg_iter_data::UP and use it in ctf_fs_iterator_init
and ctf_fs_iterator_finalize.

Change-Id: I448cedc164d93f9ba26da5640578889b0fff580c
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8279
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
21 months agosrc.ctf.fs: use ctf_msg_iter_up in decode_clock_snapshot_after_event
Simon Marchi [Thu, 9 Jun 2022 14:50:16 +0000 (10:50 -0400)] 
src.ctf.fs: use ctf_msg_iter_up in decode_clock_snapshot_after_event

Change-Id: I4f230d16b96764d5097cb30b8a063d41268bb237
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8278
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
21 months agosrc.ctf.fs: use ctf_msg_iter_up in add_ds_file_to_ds_file_group
Simon Marchi [Thu, 9 Jun 2022 14:48:38 +0000 (10:48 -0400)] 
src.ctf.fs: use ctf_msg_iter_up in add_ds_file_to_ds_file_group

Change-Id: I3970358b6eab556fd5971d94a8e35b720c6f9450
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8277
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
21 months agosrc.ctf.fs: make ctf_fs_msg_iter_data::msg_iter a ctf_msg_iter_up
Simon Marchi [Thu, 9 Jun 2022 14:38:40 +0000 (10:38 -0400)] 
src.ctf.fs: make ctf_fs_msg_iter_data::msg_iter a ctf_msg_iter_up

Change-Id: I44ef5f74fdee99a4bf5962cf03757acc7ba774b2
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8276
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
21 months agosrc.ctf.fs: make ctf_msg_iter_create return a unique_ptr
Simon Marchi [Tue, 26 Jul 2022 21:15:49 +0000 (17:15 -0400)] 
src.ctf.fs: make ctf_msg_iter_create return a unique_ptr

Introduce ctf_msg_iter_up, a unique_ptr type with a deleter that calls
ctf_msg_iter_destroy.  Make ctf_msg_iter_create return that.

Change-Id: Ibba15a84c58804a88f18c6ed47b9197fe46541b3
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8275
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
21 months agosrc.ctf.fs: remove ctf_fs_destroy
Simon Marchi [Thu, 9 Jun 2022 14:31:24 +0000 (10:31 -0400)] 
src.ctf.fs: remove ctf_fs_destroy

Remove it, since a ctf_fs_destroy instance can simply be deleted.

Change-Id: Ic6b879dbdff5e5172c2f07c810f97ceaf45a77f9
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8274
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
21 months agosrc.ctf.fs: remove ctf_fs_ds_group_medops_data_destroy
Simon Marchi [Thu, 9 Jun 2022 14:27:25 +0000 (10:27 -0400)] 
src.ctf.fs: remove ctf_fs_ds_group_medops_data_destroy

Remove it, simply delete `data` in the custom deleter.  Note that we
still use a custom deleter because ctf_fs_ds_group_medops_data is in the
.cpp file, and therefore not visible to other compilation units.  We
could move it to the .hpp to avoid this, but it's going to be removed
soon anyway, so it's not worth it.

Change-Id: Ib5741e0e0a535cb84b2a4e27ff6ff9620eaaebce
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8273
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
21 months agosrc.ctf.fs: make ctf_fs_ds_group_medops_data_create return a unique_ptr
Simon Marchi [Fri, 10 Jun 2022 16:53:57 +0000 (12:53 -0400)] 
src.ctf.fs: make ctf_fs_ds_group_medops_data_create return a unique_ptr

Introduce ctf_fs_ds_group_medops_data_up, a unique_ptr type with a
deleter that calls ctf_fs_ds_group_medops_data_destroy.  Make
ctf_fs_ds_group_medops_data_create return (by parameter) a value of this
type.

Change ctf_fs_msg_iter_data::msg_iter_medops_data to be of this type too,
since the result of ctf_fs_ds_group_medops_data_create is put directly in
that field.

Change-Id: I971e2e6db622f5cfe492eaede239852886a24483
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8272
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
21 months agostc.ctf.fs: make ctf_fs_ds_group_medops_data::file a ctf_fs_ds_file::UP
Simon Marchi [Thu, 9 Jun 2022 14:19:51 +0000 (10:19 -0400)] 
stc.ctf.fs: make ctf_fs_ds_group_medops_data::file a ctf_fs_ds_file::UP

Change-Id: Ibe6b3882c29725f7563fb141bd823ec2adeabc6a
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8271
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
21 months agosrc.ctf.fs: use ctf_fs_ds_file::UP in add_ds_file_to_ds_file_group
Simon Marchi [Thu, 9 Jun 2022 14:47:03 +0000 (10:47 -0400)] 
src.ctf.fs: use ctf_fs_ds_file::UP in add_ds_file_to_ds_file_group

Change-Id: I8b7a55f28b746cc6b93bfb4459bfc41789d7d4f2
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8270
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
21 months agosrc.ctf.fs: use ctf_fs_ds_file::UP in decode_clock_snapshot_after_event
Simon Marchi [Thu, 9 Jun 2022 14:41:37 +0000 (10:41 -0400)] 
src.ctf.fs: use ctf_fs_ds_file::UP in decode_clock_snapshot_after_event

Change-Id: I0b476dd18ee4dfd53ac7bffb12d9fae9b1a1b359
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8269
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
21 months agosrc.ctf.fs: make ctf_fs_ds_file_create return a unique_ptr
Simon Marchi [Thu, 9 Jun 2022 14:18:20 +0000 (10:18 -0400)] 
src.ctf.fs: make ctf_fs_ds_file_create return a unique_ptr

Introduce ctf_fs_ds_file::UP, make ctf_fs_ds_file_create return it.

Change-Id: I0139e9504d65425bf53fb21a5b81a4e48da4fe4e
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8268
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
21 months agosrc.ctf.fs: rename ctf_fs_ds_file_destroy to ~ctf_fs_ds_file
Simon Marchi [Thu, 9 Jun 2022 13:56:09 +0000 (09:56 -0400)] 
src.ctf.fs: rename ctf_fs_ds_file_destroy to ~ctf_fs_ds_file

This makes the ctf_fs_ds_file type deletable.

Change-Id: Ibaedb136777a39db11a1bd30355c7123e186e489
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8267
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
21 months agosrc.ctf.fs: remove ctf_fs_file_destroy
Simon Marchi [Thu, 9 Jun 2022 14:12:06 +0000 (10:12 -0400)] 
src.ctf.fs: remove ctf_fs_file_destroy

Remove it, and the custom deleter, now that a ctf_fs_file can be simply
deleted.

Change-Id: Iaef8b0cdbe525272019e0258665b45cbaee6ad05
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8266
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
21 months agosrc.ctf.fs: make ctf_fs_file::path an std::string
Simon Marchi [Tue, 26 Jul 2022 21:15:31 +0000 (17:15 -0400)] 
src.ctf.fs: make ctf_fs_file::path an std::string

Change-Id: Ifbe7cd2c184031465428c28701131a82ba219b02
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8265
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
21 months agosrc.ctf.fs: make ctf_fs_file::fp a FileUP
Simon Marchi [Tue, 26 Jul 2022 21:13:08 +0000 (17:13 -0400)] 
src.ctf.fs: make ctf_fs_file::fp a FileUP

Change-Id: I7c0467a20942cf107d8f10951c8a393e3da7c608
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8264
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
21 months agosrc.ctf.fs: make get_file return ctf_fs_file::UP
Simon Marchi [Thu, 9 Jun 2022 14:03:19 +0000 (10:03 -0400)] 
src.ctf.fs: make get_file return ctf_fs_file::UP

Change-Id: I9f115907d062db0a227a49adb7d5786342ca4147
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8263
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
21 months agosrc.ctf.fs: use ctf_fs_file::UP in create_ds_file_groups
Simon Marchi [Tue, 26 Jul 2022 21:11:39 +0000 (17:11 -0400)] 
src.ctf.fs: use ctf_fs_file::UP in create_ds_file_groups

Change-Id: I45b50e6c808d5ae17ac755b96e03f260a0972c15
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8262
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
21 months agosrc.ctf.fs:: make ctf_fs_ds_file::file a ctf_fs_file::UP
Simon Marchi [Thu, 9 Jun 2022 13:54:20 +0000 (09:54 -0400)] 
src.ctf.fs:: make ctf_fs_ds_file::file a ctf_fs_file::UP

Change-Id: Id6a62715e3e2a29216debe1c72986215d7f47459
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8261
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
21 months agosrc.ctf.fs: make ctf_fs_file_create return a unique_ptr
Simon Marchi [Fri, 10 Jun 2022 16:52:36 +0000 (12:52 -0400)] 
src.ctf.fs: make ctf_fs_file_create return a unique_ptr

Introduce ctf_fs_file::UP, make ctf_fs_file_create return that, adjust
impacted callers.

Change-Id: Ice241fd596af3d54e9c7bc7f562ca010bb5833aa
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8260
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
21 months agosrc.ctf.fs: move ctf_fs_file to file.hpp
Simon Marchi [Thu, 9 Jun 2022 13:50:45 +0000 (09:50 -0400)] 
src.ctf.fs: move ctf_fs_file to file.hpp

This helps resolve some cyclic include problem between file.hpp and
fs.hpp in the next patches (and I think it makes sense to put it there).

Change-Id: I2904d17eb3ea51699464fba17a992ddf3b691f60
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8259
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
21 months agosrc.ctf.fs: make ctf_fs_ds_file::stream a bt2::Stream::Shared
Simon Marchi [Wed, 3 Aug 2022 01:30:45 +0000 (21:30 -0400)] 
src.ctf.fs: make ctf_fs_ds_file::stream a bt2::Stream::Shared

Change-Id: I2df309d73c7a1b987e4d25c63251e13bf47a38a3
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8258
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
21 months agosrc.ctf.fs: remove ctf_fs_ds_file_group_destroy
Simon Marchi [Thu, 9 Jun 2022 13:34:22 +0000 (09:34 -0400)] 
src.ctf.fs: remove ctf_fs_ds_file_group_destroy

Remove ctf_fs_ds_file_group_destroy and the custom deleter, now that
ctf_fs_ds_file_group can be simply deleted.

Change-Id: I41100be8a99276ef17df4c9aa37a7f4db0275869
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8257
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
21 months agosrc.ctf.fs: make ctf_fs_ds_file_group::stream a bt2::Stream::Shared
Simon Marchi [Wed, 3 Aug 2022 01:30:14 +0000 (21:30 -0400)] 
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>
21 months 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>
21 months agosrc.ctf.fs: make ctf_fs_ds_index::entries a vector of ctf_fs_ds_index_entry::UP
Simon Marchi [Tue, 26 Jul 2022 21:05:49 +0000 (17:05 -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>
21 months agosrc.ctf.fs: make ctf_fs_ds_index_entry_create return a unique_ptr
Simon Marchi [Wed, 8 Jun 2022 20:22:32 +0000 (16:22 -0400)] 
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>
21 months agosrc.ctf.fs: make ctf_fs_ds_file_group::index a ctf_fs_ds_index::UP
Simon Marchi [Wed, 8 Jun 2022 20:12:43 +0000 (16:12 -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>
21 months agosrc.ctf.fs: make ctf_fs_ds_index_create return a unique_ptr
Simon Marchi [Wed, 8 Jun 2022 20:04:22 +0000 (16:04 -0400)] 
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 in 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>
21 months 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>
21 months agosrc.ctf.fs: make ctf_fs_ds_file_info_create return a unique_ptr
Simon Marchi [Tue, 26 Jul 2022 21:05:36 +0000 (17:05 -0400)] 
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>
21 months agosrc.ctf.fs: make ctf_fs_ds_file_info::path an std::string
Simon Marchi [Fri, 10 Jun 2022 16:48:37 +0000 (12:48 -0400)] 
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>
21 months agosrc.ctf.fs: make ctf_fs_trace::ds_file_groups a vector of ctf_fs_ds_file_group::UP
Simon Marchi [Tue, 26 Jul 2022 21:05:15 +0000 (17:05 -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>
21 months agosrc.ctf.fs: use ctf_fs_ds_file_group::UP in fs.cpp
Simon Marchi [Wed, 8 Jun 2022 19:15:20 +0000 (15:15 -0400)] 
src.ctf.fs: use ctf_fs_ds_file_group::UP in fs.cpp

Adjust functions in fs.cpp to use ctf_fs_ds_file_group::UP to denote
ownership.

Change-Id: I1b4593eaa8c566a91af27502f03b056d26472120
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8246
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
21 months agosrc.ctf.fs: make ctf_fs_ds_file_group_create return a ctf_fs_ds_file_group::UP
Simon Marchi [Fri, 10 Jun 2022 16:47:14 +0000 (12:47 -0400)] 
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>
21 months agosrc.ctf.fs: make ctf_fs_component::port_data a vector
Simon Marchi [Thu, 4 Aug 2022 18:01:19 +0000 (14:01 -0400)] 
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>
21 months agosrc.ctf.fs: switch to using ctf_fs_trace::UP where possible
Simon Marchi [Tue, 26 Jul 2022 21:04:35 +0000 (17:04 -0400)] 
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>
21 months agosrc.ctf.fs: make ctf_fs_trace_create return ctf_fs_trace::UP
Simon Marchi [Wed, 8 Jun 2022 18:18:33 +0000 (14:18 -0400)] 
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>
21 months agosrc.ctf.fs: make ctf_fs_component::trace a unique_ptr
Simon Marchi [Wed, 8 Jun 2022 17:50:27 +0000 (13:50 -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>
21 months agosrc.ctf.fs: move struct ctf_fs_trace and struct ctf_fs_port_data up
Simon Marchi [Wed, 8 Jun 2022 17:49:25 +0000 (13:49 -0400)] 
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>
21 months agosrc.ctf.fs: use DataLen in ctf_fs_ds_index_entry
Simon Marchi [Tue, 26 Jul 2022 21:04:13 +0000 (17:04 -0400)] 
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>
21 months agoctf: add ClkClsConfig and use it
Simon Marchi [Wed, 3 Aug 2022 01:29:48 +0000 (21:29 -0400)] 
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>
21 months agosrc.ctf.fs: Add `readPktProps()`
Francis Deslauriers [Mon, 30 May 2022 20:30:46 +0000 (16:30 -0400)] 
src.ctf.fs: Add `readPktProps()`

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I0e98db658cc50e44bc8d77c8dea53c1984af28aa
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8190
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
21 months agosrc.ctf.fs: Add `LoggingItemVisitor`
Simon Marchi [Wed, 1 Jun 2022 18:09:41 +0000 (14:09 -0400)] 
src.ctf.fs: Add `LoggingItemVisitor`

While developing, I found it useful to print the sequence of items seen
by a given visitor, so I would make the various visitor methods print
some information.  Instead of re-implementing it in the various
visitors, I eventually extracted the functionality in its own visitor
(the one this patch adds).

This visitor logs details about the visited items.  Indentation is used
to represent the items that are logically nested in other ones.  For
example, everything between a ScopeBeginItem / ScopeEndItem pair gets
nested.

The logging is done unconditionally.  The intent is that the caller uses
something like:

  if (BT_LOG_ON_TRACE) {
      item.accept(loggingVisitor);
  }

to log at a given log level.

Philippe's changes:

* Add usage comments to `logging-item-visitor.hpp`.

* Move enumerator-to-string functions to `logging-item-visitor.cpp`.

* Move templates and everything `static` to `logging-item-visitor.cpp`.

* Log more details about some items.

* Reduce code redundancy.

* Use the standard Babeltrace 2 log statement format (therefore removing
  indentation).

* Log with BT_CLOGT() instead of BT_CLOGD().

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ie8a95217564bfbaa59f78793d7ba0b47aad1d882
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8202
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
21 months agotests: add `--port` option to lttng_live_server.py
Simon Marchi [Thu, 30 Jun 2022 17:15:46 +0000 (13:15 -0400)] 
tests: add `--port` option to lttng_live_server.py

This is useful when testing manually, to force using a specific port.
When not specified, we stiill use an OS-assigned port, so it doesn't
change the behavior when used by the testsuite.

Change-Id: Ic530bf13ddfa37fa1095c1e52a6c78f284e2c312
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8215
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
21 months 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>
21 months agocpp-common/bt2: field.hpp: Add assignment operator for Enum field
Francis Deslauriers [Wed, 1 Jun 2022 13:27:57 +0000 (09:27 -0400)] 
cpp-common/bt2: field.hpp: Add assignment operator for Enum field

Used to set the value of enumeration fields using integers.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: Iaec161ca8e9e0d13770ac4f82a9c5556a1a20001
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8199
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
21 months agocpp-common: Add `bt2::CommonStringField::append()` method
Francis Deslauriers [Tue, 31 May 2022 14:52:15 +0000 (10:52 -0400)] 
cpp-common: Add `bt2::CommonStringField::append()` method

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I42217dd06cf53511718d97839bda4f9d0a0ed784
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8196
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
21 months agocpp-common: message.hpp: add `asDiscardedPackets()` function
Francis Deslauriers [Mon, 30 May 2022 20:00:28 +0000 (16:00 -0400)] 
cpp-common: message.hpp: add `asDiscardedPackets()` function

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I909290879d90806124119b00d91f5ad17d176abc
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8189
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
21 months agotrace-ir.hpp: pass `UuidView` object to `CommonTrace::uuid()` method
Francis Deslauriers [Mon, 30 May 2022 19:58:31 +0000 (15:58 -0400)] 
trace-ir.hpp: pass `UuidView` object to `CommonTrace::uuid()` method

To simplify the code, the ctf::ir::TraceCls returns a Uuid, so accepting
a UuidView here makes it trivial to pass the return of one to the other.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I1f7a8fa51d932d764d77cd8dafe087cbf89f77b7
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8188
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
21 months agoFix: trace-ir.hpp: spurious reference on object creation
Francis Deslauriers [Mon, 30 May 2022 19:55:14 +0000 (15:55 -0400)] 
Fix: trace-ir.hpp: spurious reference on object creation

We create a variant field class, which initially has refcount == 1.  We
then call `.shared()`, which creates another reference, bringing the
refcount to 2.

Fix that by using the `Shared::createWithoutRef()` method.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: Idfe8184497a00d3192e390017d7717c7ff9a3344
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8187
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
21 months agoFix: trace-ir.hpp: no need to provide a bt2::Trace to create a bt2::Trace
Francis Deslauriers [Mon, 30 May 2022 19:28:27 +0000 (15:28 -0400)] 
Fix: trace-ir.hpp: no need to provide a bt2::Trace to create a bt2::Trace

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I3d1af5c8c9057a7a252f2e2a72313cc71bf396f8
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8186
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
21 months agoFix: field.hpp: various typos
Francis Deslauriers [Mon, 30 May 2022 17:53:46 +0000 (13:53 -0400)] 
Fix: field.hpp: various typos

 * `Common{Unsigned, Signed}IntegerField` is derived by the
   `Common{Unsigned,Signed}EnumerationField` class so can't be final.

 * `CommonSignedIntegerField::value` should be `int64_t`.

 * Calling single precision function instead of double.

 * `CommonStringField::operator=` methods can throw.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: Ib354f0bd4edc8f625494acedac1052c7f45ec67d
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8185
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
21 months agoFix: integer-range-set.hpp: calling `_get_ref()` rather than `_put_ref()`
Francis Deslauriers [Mon, 30 May 2022 17:41:36 +0000 (13:41 -0400)] 
Fix: integer-range-set.hpp: calling `_get_ref()` rather than `_put_ref()`

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: Ic7c381d7dd7f2c5780f7678e48b76d23e8f3ca00
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8183
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
21 months agosrc.ctf.fs: query.cpp: change assertions into exceptions
Simon Marchi [Tue, 26 Jul 2022 21:02:35 +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>
21 months agocpp-common/bt2: pass wrappers by value instead of by reference
Philippe Proulx [Mon, 30 May 2022 12:08:10 +0000 (08:08 -0400)] 
cpp-common/bt2: pass wrappers by value instead of by reference

This is the convention elsewhere when using those wrappers as they only
contain a single pointer.

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

21 months agocpp-common: add `dataFromFile()`
Francis Deslauriers [Fri, 27 May 2022 16:28:26 +0000 (12:28 -0400)] 
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>
21 months agosrc.ctf.fs: use C++ value wrappers in queries
Simon Marchi [Tue, 26 Jul 2022 21:02:05 +0000 (17:02 -0400)] 
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

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>
21 months agocpp-common: add SharedObj::release
Simon Marchi [Sat, 28 May 2022 14:01:44 +0000 (10:01 -0400)] 
cpp-common: add SharedObj::release

It will sometimes be needed to extract the ownership of a lib object
from a SharedObj, and get the underlying lib object pointer.  For
example:

 - The value returned by queries
 - Messages returned by iterators

Add a SharedObj::release method for that.  The return type is a borrowed
object (e.g. bt2::Value::Shared::release returns a bt2::Value), but
conceptually the caller then owns the reference and is responsible for
manually managing it.

After a release, a Shared object becomes invalid, same as when it is moved
from.

Change-Id: Id31855512b8dd3d5223f2e759ff48f81ceadbfbf
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8169
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
21 months agoctf: use unique_ptr to manage ctf_metadata_decoder lifetime
Simon Marchi [Tue, 26 Jul 2022 21:00:01 +0000 (17:00 -0400)] 
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>
21 months agosrc.ctf.fs: manage lifetime of open file with FileUP
Simon Marchi [Tue, 26 Jul 2022 20:59:25 +0000 (16:59 -0400)] 
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>
21 months agocpp-common: add FileUP
Simon Marchi [Sat, 28 May 2022 18:18:17 +0000 (14:18 -0400)] 
cpp-common: add FileUP

Add a unique_ptr type to manage the lifetime of a `FILE *`, with a
custom deleter that calls fclose.

Change-Id: Idded4546d2a709cd0652975ef83c3ad6a0f511bc
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8172
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
21 months 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>
21 months agosrc.ctf.fs: make ctf_fs_make_port_name return a GCharUP
Simon Marchi [Tue, 26 Jul 2022 20:59:09 +0000 (16:59 -0400)] 
src.ctf.fs: make ctf_fs_make_port_name return a GCharUP

Introduce GCharUP, a unique_ptr type with a deleter that calls g_free.
It can be used to manage g_char buffer allocated by GLib.

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>
21 months agocpp-common: add GCharUP
Simon Marchi [Sat, 28 May 2022 14:36:08 +0000 (10:36 -0400)] 
cpp-common: add GCharUP

Add GCharUP, a unique_ptr type that wraps a g_char pointer and has a
deleter that calls g_free.  It can be used to provide automatic memory
management of buffers returned by the GLib API.

Change-Id: I9d98be2f972cc008877b55a20eceeb3dce256cdb
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8170
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
21 months agosrc.ctf.fs: use unique_ptr to manage ctf_fs_component lifetime
Simon Marchi [Fri, 10 Jun 2022 16:41:15 +0000 (12:41 -0400)] 
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>
21 months agoctf: use unique_ptr to manage ctf_visitor_generate_ir lifetime
Simon Marchi [Tue, 26 Jul 2022 20:58:53 +0000 (16:58 -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 custome
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>
21 months agoctf: move ctf_visitor_generate_ir to header file
Simon Marchi [Sat, 28 May 2022 01:51:27 +0000 (21:51 -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>
21 months agocpp-common/bt2: use classes from `cpp-common/exc.hpp`
Philippe Proulx [Mon, 30 May 2022 11:46:26 +0000 (07:46 -0400)] 
cpp-common/bt2: use classes from `cpp-common/exc.hpp`

This patch:

* Renames `lib-error.hpp` to `exc.hpp` as this could contain non-error
  exceptions in the future.

* Changes `bt2::Error`, `bt2::MemoryError`, and `bt2::OverflowError` to
  be aliases of `bt2_common::Error`, `bt2_common::MemoryError`, and
  `bt2_common::OverflowError`.

  This makes it possible for some code to catch only the common
  `bt2_common` errors to handle both library and user/internal
  exceptions.

  Note that those exceptions don't carry much information themselves;
  they're usually just a signal that an exception occurred, while the
  details are part of the libbabeltrace2 error of the current thread.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I5bc1d39c8d978c21604614c68012509edc1776d5
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8176
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
21 months agoAdd `bt2_common::OverflowError`
Philippe Proulx [Mon, 30 May 2022 11:41:01 +0000 (07:41 -0400)] 
Add `bt2_common::OverflowError`

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I9c524bed2374b7472e5603740c1c146f49371fe5
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8175
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
21 months agoctf: add try/catch at entry points
Simon Marchi [Wed, 3 Aug 2022 01:29:22 +0000 (21:29 -0400)] 
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_common::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>
21 months agosink.ctf.fs: use LogCfg
Simon Marchi [Fri, 27 May 2022 15:50:41 +0000 (11:50 -0400)] 
sink.ctf.fs: use LogCfg

Change-Id: I6ab259c8db526a3b4c0de9295a4360180c56b398
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
21 months agosink.ctf.fs: initialize TraceIrToCtfIrCtx fields, remove memset
Simon Marchi [Fri, 27 May 2022 15:53:51 +0000 (11:53 -0400)] 
sink.ctf.fs: initialize TraceIrToCtfIrCtx fields, remove memset

This is in preparation to using some C++ objects as fields.

Change-Id: Ib473d43a7991e8363df5efc8eb18604799e2dc0e
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
21 months agosrc.ctf.sink: allocate fs_sink_comp with new
Simon Marchi [Fri, 27 May 2022 15:38:44 +0000 (11:38 -0400)] 
src.ctf.sink: allocate fs_sink_comp with new

In preparation to using some C++ objects as fields.

Change-Id: I924a6088b17e1d3ae4b8a239cf059fc3a7ecc8c6
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
21 months agoctf: rename `ctx` structures
Simon Marchi [Fri, 27 May 2022 15:30:28 +0000 (11:30 -0400)] 
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>
21 months agoCleanup: src.ctf.fs: remove unused decoder functions
Francis Deslauriers [Wed, 11 May 2022 22:00:24 +0000 (18:00 -0400)] 
Cleanup: src.ctf.fs: remove unused decoder functions

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I8c2610883c8730a36e3e4336c2dc48b67d3e6236
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8038
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
21 months agosrc.ctf.*: add old CTF IR const functions
Francis Deslauriers [Tue, 10 May 2022 21:22:47 +0000 (17:22 -0400)] 
src.ctf.*: add old CTF IR const functions

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I73f825b4127cff772904579c90806bd367a7fe36
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8012
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
21 months agosrc.ctf.fs: implement `MetadataStreamDecoder` class
Francis Deslauriers [Tue, 17 May 2022 18:17:29 +0000 (14:17 -0400)] 
src.ctf.fs: implement `MetadataStreamDecoder` class

This class offers a `decode()` method that decodes a potentially
packetized metadata stream as a `std::string`.

After decoding a buffer, the `pktInfo()` method may return packet
information of the packetized metadata stream.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: Iee867271fe6493b19c4bd77151409886b7c01ed9
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8050
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
21 months agocpp-common: add `readFixedLenInt()` function
Francis Deslauriers [Wed, 25 May 2022 15:20:53 +0000 (11:20 -0400)] 
cpp-common: add `readFixedLenInt()` function

This function template reads an integer from a buffer without assuming
its byte order.

For example, this is needed when reading the magic number from a data
buffer of unknown byte order. If needed, the user then has to manually
swap byte order of that integer to get its native byte order

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: Ia94ee3a3ffc7caaa46a46defead3e23da0a4c2b2
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8111
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
21 months agosrc/plugins/ctf/common/src: add item sequence iterator API
Philippe Proulx [Mon, 25 Apr 2022 15:16:46 +0000 (11:16 -0400)] 
src/plugins/ctf/common/src: add item sequence iterator API

This patch adds the item sequence iterator API, internal to the `ctf`
plugin, to be used by the source components (`src.ctf.fs` and
`sink.ctf.fs`).

An item sequence iterator can decode a sequence of packets using:

* A medium, which provides binary stream data to the iterator.
* A CTF IR trace class, which describes how to decode said data.

This makes it possible to completely decode CTF data streams without
ever needing to create trace IR objects. In other words, it's a
standalone CTF decoding library which, minus a few utilities borrowed
from the Babeltrace project, could even be reused in other projects.

The value of an item sequence iterator is an item. The item sequence
iterator doesn't actually create items as it advances: it has one
instance of each concrete item class and sets a pointer to one of
those as it advances (it's a single-pass input iterator).

Seek a specific packet beginning with the seekPkt() method.

Methods which make the iterator decode may append a cause to the error
of the current thread and throw `bt2_common::Error`.

NOTE: Currently, this isn't an STL-compliant iterator class: you
can't copy an instance and you can't get an end iterator, because
there's no item sequence (container) class (you need to use the
isEnded() method). Also, the typical STL type aliases such as `value`
and `reference` aren't part of the class.

This API and its implementation are inspired by the yactfr
(<https://github.com/eepp/yactfr>) element sequence iterator API,
conveniently written by the same author.

Please read the class comments of `ctf::src::ItemSeqIter` and
`ctf::src::Medium` to learn how to use this API and how it works
internally.

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

21 months agoAdd CTF IR classes specific to `src.ctf.*`
Philippe Proulx [Wed, 13 Apr 2022 01:03:21 +0000 (21:03 -0400)] 
Add CTF IR classes specific to `src.ctf.*`

This patch uses the `ctf::ir` API to expose a source-specific CTF IR API
under the `ctf::src` namespace, to be used by both the `src.ctf.fs` and
the `src.ctf.lttng-live` component classes.

This specific CTF IR API augments the common `ctf::ir` API with
user mixins to add the following:

* Any field class has a "deep type".

  See the comment of `ctf::src::FcDeepType` to understand why we need
  such an enumeration.

* The field class, clock class, event record class, data stream class,
  and trace class classes have an optional equivalent libbabeltrace2
  class object.

  This is a bridge between the CTF IR world and the libbabeltrace2 world
  to be able to create corresponding libbabeltrace2 messages when
  decoding a data stream with the CTF IR classes.

  If a field class has no equivalent libbabeltrace2 class, then the
  values of its instances aren't transported through messages as field
  objects.

* A clock class object may hold its equivalent libbabeltrace2 class
  (owned, shared reference).

* A trace class object may hold its equivalent libbabeltrace2 class
  (owned, shared reference).

* Boolean and integer field classes have an optional value saving
  index.

  See the comment of `ctf::src::ValSavingIndexes` to learn more.

* Dynamic-length, optional, and variant field classes have a
  saved dependency value index.

  Again, see the comment of `ctf::src::ValSavingIndexes` to learn more.

* A trace class contains the maximum number of saved values for its
  instance.

  Once more, see the comment of `ctf::src::ValSavingIndexes` to learn
  more.

The new API adds templateless aliases for all the configurable CTF IR
types, for example `src::ctf::FixedLenIntFc`.

The new API also offers user mixin agnostic functions to create all its
CTF IR objects. For example, call ctf::src::createDynLenBlobFc() to
create a `ctf::src` dynamic-length BLOB field class.

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

21 months agoAdd common `ctf::ir` CTF IR classes
Philippe Proulx [Wed, 30 Mar 2022 20:17:10 +0000 (16:17 -0400)] 
Add common `ctf::ir` CTF IR classes

This patch adds common CTF IR class templates to the new
`src/plugins/ctf/common/metadata/ctf-ir.hpp` header.

The purpose of those new class templates is to have a common CTF IR
class hierarchy for both `src.ctf.fs` and `sink.ctf.fs`. This CTF IR
model is based on the CTF 2 model.

Although the file looks intimidating, it's pretty straightforward:

* The class hierarchy, under the `ctf::ir` namespace, (omitting template
  parameters) is as such:

      TraceCls
      DataStreamCls
      EventRecordCls
      ClkCls
      FieldLoc
      StructFieldMemberCls
      VariantFcOpt
      Fc
        FixedLengthBitArrayFc
          FixedLengthBoolFc
          FixedLengthFloatFc
          FixedLengthIntFc
            FixedLengthUIntFc
              FixedLengthUEnumFc
            FixedLengthSIntFc
              FixedLengthSEnumFc
        VarLengthIntFc
          VarLengthUIntFc
            VarLengthUEnumFc
          VarLengthSIntFc
            FixedLengthSEnumFc
        NullTerminatedStrFc
        NonNullTerminatedStrFc
          StaticLenStrFc
          DynLenStrFc
        BlobFc
          StaticLenBlobFc
          DynLenBlobFc
        ArrayFc
          StaticLenArrayFc
          DynLenArrayFc
        StructFc
        OptionalFc
          OptionalWithBoolSelFc
          OptionalWithIntSelFc
            OptionalWithUIntSelFc
            OptionalWithSIntSelFc
        VariantFc
          VariantWithUIntSelFc
          VariantWithSIntSelFc

* Each class template has the `UserMixinsT` template parameter.

  `UserMixinsT` is expected to be a user mixin container, a type
  defining the following nested types (user mixins):

  * `FieldLoc`
  * `Fc`
  * `FixedLenBitArrayFc`
  * `FixedLenBoolFc`
  * `FixedLenIntFc`
  * `FixedLenUIntFc`
  * `VarLenIntFc`
  * `VarLenUIntFc`
  * `StaticLenStrFc`
  * `DynLenStrFc`
  * `StaticLenBlobFc`
  * `DynLenBlobFc`
  * `StaticLenArrayFc`
  * `DynLenArrayFc`
  * `StructFieldMemberCls`
  * `StructFc`
  * `OptionalFc`
  * `OptionalWithBoolSelFc`
  * `OptionalWithUIntSelFc`
  * `OptionalWithSIntSelFc`
  * `VariantFcOpt`
  * `VariantWithUIntSelFc`
  * `VariantWithSIntSelFc`
  * `ClkCls`
  * `EventRecordCls`
  * `DataStreamCls`
  * `TraceCls`

* Most class templates inherit a given user mixin. For example,
  `FixedLenBoolFc` inherits `UserMixinsT::FixedLenBoolFc`.

  This makes it possible for the user to inject data and methods in the
  class while keeping the hierarchy and common features.

* A class template which inherits a user mixin M has a constructor which
  accepts an instance of M by value to initialize this part of the
  object.

  If a class template C which inherits a user mixin also inherits
  another class template inheriting another user mixin, then the
  constructor of C accepts both mixins. For example,
  FixedLenUEnumFc::FixedLenUEnumFc() accepts four mixins: field class,
  fixed-length bit array field class, fixed-length integer field class,
  and fixed-length unsigned integer field class.

* `Fc` has the typical asXyz() and isXyz() methods.

  To make isXyz() methods more efficient, `FcType` enumerators are
  bitwise compositions of `FcTypeTraits` values (traits/features).

* The `FcVisitor` and `ConstFcVisitor` base classes are available to
  visit field classes through the virtual Fc::accept() methods.

* There are a few internal mixins to share common members:

  `WithUserAttrsMixin`:
      Optional user attributes.

  `IntFcMixin`:
      Preferred display base.

  `UIntFcMixin`:
      Unsigned integer field roles.

  `EnumFcMixin`:
      Mappings.

  `StaticLenFcMixin`:
      Integral length.

  `DynLenFcMixin`:
      Length field location.

* The API offers `DefUserMixins` which defines empty user mixins to act
  as a base user mixin container structure.

Now, this is how you would use this API:

* Define your own user mixin container structure which inherits
  `ctf::ir::DefUserMixins`, defining the user mixins you need to add
  data and methods to specific common classes.

* Define aliases for each `ctf::ir` class template you need, using your
  user mixin container structure as the `UserMixinsT` template
  parameter.

* Create convenient object creation functions to construct specific CTF
  IR objects from parameters, hiding the internal user mixin details.

As an example, this builds and works as expected:

    #include <string>
    #include <iostream>

    #include "ctf-2-meta.hpp"

    // user mixin container
    struct MyMixins : ctf::ir::DefUserMixins
    {
        // structure field class mixin
        class StructFc
        {
        public:
            explicit StructFc(std::string favoriteKebSinger) :
                _mFavoriteKebSinger {std::move(favoriteKebSinger)}
            {
            }

            const std::string& favoriteKebSinger() const noexcept
            {
                return _mFavoriteKebSinger;
            }

        private:
            std::string _mFavoriteKebSinger;
        };
    };

    // custom object aliases
    using MyNullTerminatedStrFc = ctf::ir::NullTerminatedStrFc<MyMixins>;
    using MyStructFc = ctf::ir::StructFc<MyMixins>;
    using MyTraceCls = ctf::ir::TraceCls<MyMixins>;

    int main()
    {
        // create structure field class, constructing a `MyMixins::StructFc`
        MyStructFc::MemberClasses memberClasses;

        memberClasses.emplace_back(
            MyMixins::StructFieldMemberCls {}, "meow",
            bt2_common::makeUnique<MyNullTerminatedStrFc>(MyMixins::Fc {}));

        auto pktHeaderFc = bt2_common::makeUnique<MyStructFc>(
            MyMixins::Fc {},
            MyMixins::StructFc {"Claude Dubois"},
            std::move(memberClasses)
        );

        // create trace class
        MyTraceCls tc {
            MyMixins::TraceCls {}, {}, {}, {}, std::move(pktHeaderFc)
        };

        // read custom user property
        std::cout << tc.pktHeaderFc()->favoriteKebSinger() << std::endl;
    }

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

21 months agofield-class.hpp: add missing support for user attributes
Philippe Proulx [Fri, 20 May 2022 13:11:40 +0000 (09:11 -0400)] 
field-class.hpp: add missing support for user attributes

This patch adds the missing
bt2::CommonStructureFieldClassMember::userAttributes() and
bt2::CommonVariantFieldClassOption::userAttributes() methods to set and
borrow user attributes of structure field member classes and variant
field class options.

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

21 months agoAdd bt2::Common{Field,FieldClass,Value,Message}<>::as<>()
Philippe Proulx [Fri, 20 May 2022 01:50:36 +0000 (21:50 -0400)] 
Add bt2::Common{Field,FieldClass,Value,Message}<>::as<>()

Those new as() method templates conceptually cast their object to the
first template parameter. Those are shorthands to use specific types
within a template function, for example:

    template <typename FieldT, typename ValT>
    void g(bt2::Field field, const ValT val)
    {
        // ...
        field.as<FieldT>() = val;
        // ...
    }

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ifc1f49487ac6ef9c143bf4c2faa3373f4eaccd9e
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8099
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
21 months agobt2_common::UuidView::str(): make bt_uuid_to_str() write to ret. val.
Philippe Proulx [Thu, 19 May 2022 18:17:33 +0000 (14:17 -0400)] 
bt2_common::UuidView::str(): make bt_uuid_to_str() write to ret. val.

No copy!

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

21 months agobt2::internal::BorrowedObj: add static assertions for generic copy ops.
Philippe Proulx [Thu, 19 May 2022 16:22:29 +0000 (12:22 -0400)] 
bt2::internal::BorrowedObj: add static assertions for generic copy ops.

This patch adds static assertions to `borrowed-obj.hpp` so as to make
compiler errors more readable when assigning a const wrapper to a
non-const wrapper, for example:

    bt2::Value v = bt2::ConstMapValue {somePtr};

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

21 months agobt2::internal::BorrowedObj: use default copy operations explicitly
Philippe Proulx [Thu, 19 May 2022 16:11:40 +0000 (12:11 -0400)] 
bt2::internal::BorrowedObj: use default copy operations explicitly

What was called the generic copy constructor and assignment operator
are in fact constructor templates, not true copy operations.

This is because C++ requires that a copy constructor/assignment operator
be a "non-template non-static member function".

This patch is not a fix because the generated default copy operations
were fine (just copy the underlying libbabeltrace2 pointer). Just use
the default ones explicitly and fix the comments so that we know what's
going on.

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

21 months agosrc/cpp-common/bt2/internal/*-obj.hpp: template param. names not needed
Philippe Proulx [Thu, 19 May 2022 16:06:59 +0000 (12:06 -0400)] 
src/cpp-common/bt2/internal/*-obj.hpp: template param. names not needed

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

21 months agofield-class.hpp: support optional variant FC option name
Philippe Proulx [Tue, 17 May 2022 18:09:05 +0000 (14:09 -0400)] 
field-class.hpp: support optional variant FC option name

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

This page took 0.053352 seconds and 5 git commands to generate.