deliverable/babeltrace.git
20 months agosrc.ctf.lttng-live: bump live protocol version ctf2.support
Jonathan Rajotte [Fri, 12 Aug 2022 20:36:44 +0000 (16:36 -0400)] 
src.ctf.lttng-live: bump live protocol version

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: I30136e8d8af42b6c2fccdfd8b21c3100008b6c3f

20 months agotests: add test with incomplete packet header
Simon Marchi [Mon, 15 Aug 2022 18:02:39 +0000 (14:02 -0400)] 
tests: add test with incomplete packet header

During developement we hit a problem where src.ctf.fs's medium returned
less data than the `minSize` parameter, when reading a faulty trace.
The trace added in this patch reproduces the problem.  It consists of a
full packet, followed by a single byte.  When trying to read a second
packet, the ItemSeqIter instance would ask the medium for at least two
bytes, but the medium would return a buffer with a single byte (the data
available until the end of file).  The fix was to make the medium
generate an error in this case.

Change-Id: I9a79360b18091f517846ca2be94fbf10fb9af349
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
20 months agotests: add clock-class before trace-class CTF2 test
Simon Marchi [Mon, 15 Aug 2022 15:04:19 +0000 (11:04 -0400)] 
tests: add clock-class before trace-class CTF2 test

Add a test with a CTF 2 metadata file where a clock-class fragment is
before the trace-class fragment.  A bug triggered by this patch was hit
during development.

Change-Id: If9fd2497ca31ad73d9db1198f90e2404d9a7a8c1
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
20 months agotests/src.ctf.fs: add CTF 2 tests for no stream class, no trace class
Simon Marchi [Tue, 16 Aug 2022 13:48:56 +0000 (09:48 -0400)] 
tests/src.ctf.fs: add CTF 2 tests for no stream class, no trace class

During development, we hit some crashes when the trace metadata did not
specify any data stream class fragment (with and without an explicit
trace class fragment).  Add tests for that.

Change-Id: Ic8ce4c7a2ae78b2f484a86e5b1306b7eae606528
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
20 months agotests/src.ctf.fs/test_fail: test with both autodiscovery and explicit component insta...
Simon Marchi [Tue, 16 Aug 2022 13:38:26 +0000 (09:38 -0400)] 
tests/src.ctf.fs/test_fail: test with both autodiscovery and explicit component instantiation

Specifying a path to a failing trace like this:

  babeltrace2 mytrace

vs

  babeltrace2 -c src.ctf.fs -p 'inputs=["mytrace"]'

... exercises different code paths.  If the failure is due to bad
metadata, the first one will error out during the support-info query
phrase, whereas the second one will error out in the component
initialization.  I think it would be good to exercise both in the test
with failing traces.

Rename the test_fail function to test_fail_method, and add a parameter
indicating which method of passing the trace path to use (autodisc vs
component).  Add a new test_fail function that tries with both methods.

Change-Id: Ieb65504a773b0915946f8ef543a7d0930ca0a7d7

20 months agotests/src.ctf.fs: add function to compute trace path in test_fail
Simon Marchi [Tue, 16 Aug 2022 13:34:55 +0000 (09:34 -0400)] 
tests/src.ctf.fs: add function to compute trace path in test_fail

Add a function that returns a trace path given a trace name and a ctf
version.  This is useful for subsequent patches that add tests with CTF
2 traces.

Change-Id: Ibc81d150152cd47e7113ebbc94bfe6995773655e
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
20 months agoctf: remove now unused files
Simon Marchi [Tue, 23 Aug 2022 14:52:58 +0000 (10:52 -0400)] 
ctf: remove now unused files

Change-Id: Ib66be547edae247049f4d5b0a21233a7c68e0811
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8649
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.lttng-live: use the new metadata stream parser and message iterator
Simon Marchi [Thu, 4 Aug 2022 20:30:53 +0000 (16:30 -0400)] 
src.ctf.lttng-live: use the new metadata stream parser and message iterator

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Change-Id: Id2e11205bed54654942077c5336495b7bdd3f38d
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8617
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agotests/cli/test_trace_read: use `bt_cli` and `isnt`
Simon Marchi [Thu, 4 Aug 2022 20:32:56 +0000 (16:32 -0400)] 
tests/cli/test_trace_read: use `bt_cli` and `isnt`

This makes the output more readable/analyzable on failure.

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I6bb7d76538c843a50e605756493de0755cc9ca11

20 months agotests/cli/test_output_ctf_metadata: use `bt_cli` and `diff`
Simon Marchi [Thu, 4 Aug 2022 20:31:41 +0000 (16:31 -0400)] 
tests/cli/test_output_ctf_metadata: use `bt_cli` and `diff`

This makes the output more readable/analyzable on failure.

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I2466a032d7cfc2b8b6eb2de4b473dd1bb0c193df

20 months agocpp-common: add bt2_common::messageTypeStr()
Simon Marchi [Wed, 3 Aug 2022 15:56:15 +0000 (11:56 -0400)] 
cpp-common: add bt2_common::messageTypeStr()

Change-Id: I6967d232922c7b5ad6b35cc100becb9ff8a6b968
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8651
CI-Build: Simon Marchi <simon.marchi@efficios.com>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agotests: Add CTF 2 version of live test trace
Francis Deslauriers [Wed, 22 Jun 2022 19:52:05 +0000 (15:52 -0400)] 
tests: Add CTF 2 version of live test trace

Change-Id: I93251e10db1fc5353c18e4821d692f071c623095
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8641
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
CI-Build: Simon Marchi <simon.marchi@efficios.com>

20 months agotests: adjust src.ctf.fs succeed tests to read CTF 2 traces
Simon Marchi [Tue, 2 Aug 2022 19:10:50 +0000 (15:10 -0400)] 
tests: adjust src.ctf.fs succeed tests to read CTF 2 traces

Change-Id: I3a78fb1641c3c1bae98be74b741ce2f4b8089ec0
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8509
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agotests: Add CTF 2 version of succeed test traces
Francis Deslauriers [Wed, 22 Jun 2022 19:52:05 +0000 (15:52 -0400)] 
tests: Add CTF 2 version of succeed test traces

The following traces were left out:
  succeed/warnings
  succeed/succeed3
  succeed/succeed4

Because they are testing CTF1 syntax.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I84504bd934958b6c04d8350610c397a8e851383e
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8465
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agotests: move CTF 1 test traces to their own directory
Simon Marchi [Tue, 16 Aug 2022 13:10:53 +0000 (09:10 -0400)] 
tests: move CTF 1 test traces to their own directory

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I4d7ca33c1187b7495dd49103ecec66316ff65001
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8433
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.lttng-live: remove some goto error-handling
Simon Marchi [Fri, 8 Jul 2022 15:30:04 +0000 (11:30 -0400)] 
src.ctf.lttng-live: remove some goto error-handling

Change-Id: I9b6d967d54c63d7f7544bb0d1a1eb778a8df64d4
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
20 months agosrc.ctf.lttng-live: viewer-connection.cpp: remove goto error-handling
Simon Marchi [Tue, 26 Jul 2022 21:52:39 +0000 (17:52 -0400)] 
src.ctf.lttng-live: viewer-connection.cpp: remove goto error-handling

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Change-Id: I87b05835a268fef92f906c16bb35a84c1df0a27f
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8485
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.lttng-live: use viewer_connection_close_socket more
Simon Marchi [Tue, 26 Jul 2022 21:51:07 +0000 (17:51 -0400)] 
src.ctf.lttng-live: use viewer_connection_close_socket more

Use viewer_connection_close_socket at all spots we close the control
socket, to de-duplicate code a little bit.

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Change-Id: I47ce5bf00edd367792a8f8262d746a61b0c474fd
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8484
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.lttng-live: make queries report errors with exceptions
Simon Marchi [Tue, 26 Jul 2022 21:50:53 +0000 (17:50 -0400)] 
src.ctf.lttng-live: make queries report errors with exceptions

Change-Id: Ibf633312304a6353842baa569860a2e1216785b0
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8478
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.lttng-live: make queries output a bt2::Value
Simon Marchi [Tue, 26 Jul 2022 21:48:45 +0000 (17:48 -0400)] 
src.ctf.lttng-live: make queries output a bt2::Value

Change-Id: If0baec1ca712e75e5873cc6c3e88cec18bb4f424
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8477
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.lttng-live: use C++ value wrappers for query parameters
Simon Marchi [Tue, 26 Jul 2022 21:47:03 +0000 (17:47 -0400)] 
src.ctf.lttng-live: use C++ value wrappers for query parameters

Change-Id: Ie64cef32650dbc62238429b10c30a0c8ffd5dac3
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8476
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.lttng-live: add bt_common_lttng_live_url_parts_deleter
Simon Marchi [Thu, 23 Jun 2022 16:32:45 +0000 (12:32 -0400)] 
src.ctf.lttng-live: add bt_common_lttng_live_url_parts_deleter

bt_common_lttng_live_url_parts can't be made a C++ object that
automatically manages its memory yet, since it's used in
babeltrace2-cfg-cli-args.c (C code).  Add an RAII type in lttng-live to
automatically call bt_common_destroy_lttng_live_url_parts in two places.

Change-Id: I233a5ba5a2829f4577c4ebbcc1ab0e630d039174
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8475
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.lttng-live: introduce lttng_live_msg_iter::UP and use it
Simon Marchi [Tue, 26 Jul 2022 21:46:29 +0000 (17:46 -0400)] 
src.ctf.lttng-live: introduce lttng_live_msg_iter::UP and use it

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Change-Id: Ie87efb7a6599a738dad60cc3533f8440c283da6c
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8474
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.lttng-live: add lttng_live_msg_iter destructor
Simon Marchi [Thu, 23 Jun 2022 15:23:36 +0000 (11:23 -0400)] 
src.ctf.lttng-live: add lttng_live_msg_iter destructor

Convert lttng_live_msg_iter_destroy to a destructor.

Change-Id: I4bd28e540517e11ede6c210c7645db98951c31f8
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8473
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.lttng-live: introduce live_viewer_connection::UP and use it
Simon Marchi [Tue, 26 Jul 2022 21:46:14 +0000 (17:46 -0400)] 
src.ctf.lttng-live: introduce live_viewer_connection::UP and use it

Change lttng_live_msg_iter::viewer_connection to be a
live_viewer_connection::UP and convert live_viewer_connection_create's
output parameter to that type.

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Change-Id: I0f91d4636c67ad9f820783932fa3c45464dfb3bb
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8472
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.lttng-live: add live_viewer_connection destructor
Simon Marchi [Tue, 26 Jul 2022 21:45:28 +0000 (17:45 -0400)] 
src.ctf.lttng-live: add live_viewer_connection destructor

Convert live_viewer_connection_destroy into a destructor.

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Change-Id: I84651d6a2184c75b61667ebf23c28737e5a227c5
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8471
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.lttng-live: make live_viewer_connection::{relay_hostname,target_hostname...
Simon Marchi [Thu, 23 Jun 2022 15:13:31 +0000 (11:13 -0400)] 
src.ctf.lttng-live: make live_viewer_connection::{relay_hostname,target_hostname,session_name,proto} GStringUPs

These values come from GStrings from the common code, not yet C++-ified,
so it's simpler for now to use GStringUP to automatically manage the
GString lifetimes locally.  If the common code ever becomes C++, it can
all be replaced with std::string.

Change-Id: I913ab51488fc934cd049e530a2b7583cc1cefff6
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8470
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.lttng-live: make live_viewer_connection::url an std::string
Simon Marchi [Thu, 23 Jun 2022 15:10:46 +0000 (11:10 -0400)] 
src.ctf.lttng-live: make live_viewer_connection::url an std::string

Change-Id: I863b77f2b109312809df088adf374461550aac88
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8469
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.lttng-live: make lttng_live_msg_iter::sessions an std::vector
Simon Marchi [Tue, 26 Jul 2022 21:44:19 +0000 (17:44 -0400)] 
src.ctf.lttng-live: make lttng_live_msg_iter::sessions an std::vector

Change-Id: I1c6f23eb1cad89d431699b07ce68673ae9f19963
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8468
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.lttng-live: introduce lttng_live_session::UP and use it
Simon Marchi [Thu, 23 Jun 2022 14:41:54 +0000 (10:41 -0400)] 
src.ctf.lttng-live: introduce lttng_live_session::UP and use it

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Change-Id: Ie270049fe8923f7608f372de4b459b645806367e
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8467
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.lttng-live: add lttng_live_session destructor
Simon Marchi [Tue, 26 Jul 2022 21:42:57 +0000 (17:42 -0400)] 
src.ctf.lttng-live: add lttng_live_session destructor

Convert lttng_live_destroy_session to a destructor.  Add a new
lttng_livelttng_live_destroy_session function that calls delete, it's
still needed for the GPtrArray (which will be removed in a subsequent
patch).

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Change-Id: Icb2d9c33fb3591e206698b37c9d658ff731184ad
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8466
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.lttng-live: make lttng_live_session::{hostname,session_name} std::strings
Simon Marchi [Tue, 26 Jul 2022 21:42:29 +0000 (17:42 -0400)] 
src.ctf.lttng-live: make lttng_live_session::{hostname,session_name} std::strings

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Change-Id: I5b0dd1b99d741042b0b2b37a48251ea96d4b3d4f
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8464
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.lttng-live: make lttng_live_session::traces an std::vector
Simon Marchi [Tue, 26 Jul 2022 21:40:10 +0000 (17:40 -0400)] 
src.ctf.lttng-live: make lttng_live_session::traces an std::vector

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Change-Id: I3b8ec1e61929fad1e024955dcfc6708cb125b5c9
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8463
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.lttng-live: introduce lttng_live_trace::UP and use it
Simon Marchi [Wed, 22 Jun 2022 21:18:39 +0000 (17:18 -0400)] 
src.ctf.lttng-live: introduce lttng_live_trace::UP and use it

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Change-Id: I0008ee962a004ac6e215a5ed32c15b6367fb245b
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8462
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.lttng-live: make lttng_live_trace::stream_iterators an std::vector
Simon Marchi [Wed, 22 Jun 2022 21:16:50 +0000 (17:16 -0400)] 
src.ctf.lttng-live: make lttng_live_trace::stream_iterators an std::vector

Change-Id: I745900032bc5d880a305e434afaeaeaef728708d
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8461
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agocpp-common: add vectorFastRemove
Simon Marchi [Tue, 28 Jun 2022 18:26:53 +0000 (14:26 -0400)] 
cpp-common: add vectorFastRemove

Add the vectorFastRemove function, in src/cpp-common/vector.hpp, as a
drop-in replacement for g_ptr_array_remove_index_fast, when replacing a
GPtrArray with an std::vector.

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Change-Id: Ibee249fd9a8168d02ad99abf36984bf7edd53b5b
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8493
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.lttng-live: introduce and use lttng_live_stream_iterator::UP
Simon Marchi [Tue, 26 Jul 2022 21:39:46 +0000 (17:39 -0400)] 
src.ctf.lttng-live: introduce and use lttng_live_stream_iterator::UP

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Change-Id: I50c0db7fb4a86d5081a3c049e1dc76b6311507aa
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8460
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.lttng-live: add lttng_live_stream_iterator destructor
Simon Marchi [Wed, 22 Jun 2022 21:00:06 +0000 (17:00 -0400)] 
src.ctf.lttng-live: add lttng_live_stream_iterator destructor

lttng_live_stream_iterator_destroy is still used for a GPtrArray, so it
is kept as a wrapper to the destructor for now.

Change-Id: Idc3fb90f2b15f44d92d9edd578783f4939474fdf
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8459
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.lttng-live: make lttng_live_stream_iterator::current_msg a bt2::Message:...
Simon Marchi [Tue, 26 Jul 2022 21:39:18 +0000 (17:39 -0400)] 
src.ctf.lttng-live: make lttng_live_stream_iterator::current_msg a bt2::Message::Shared

Wrapped in an optional, because it is not set at construction, and its
value changes over time.  Adjust a bunch of related functions involved
in creating the message that ends up there.

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Change-Id: I2dabd3b3e6d0d17ee2a23774863b160505a0b830
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8458
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.lttng-live: make lttng_live_stream_iterator::name an std::string
Simon Marchi [Tue, 26 Jul 2022 22:26:30 +0000 (18:26 -0400)] 
src.ctf.lttng-live: make lttng_live_stream_iterator::name an std::string

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Change-Id: I515319dc62f147e4423c9eadd3dc00648e46e789
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8457
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.lttng-live: make lttng_live_stream_iterator::buf an std::vector
Simon Marchi [Wed, 22 Jun 2022 20:35:51 +0000 (16:35 -0400)] 
src.ctf.lttng-live: make lttng_live_stream_iterator::buf an std::vector

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Change-Id: I944475345ed8dd5b1ae2824eb86cf9ead56cd92f
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8456
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.lttng-live: make lttng_live_stream_iterator::msg_iter a ctf_msg_iter_up
Simon Marchi [Tue, 26 Jul 2022 21:36:43 +0000 (17:36 -0400)] 
src.ctf.lttng-live: make lttng_live_stream_iterator::msg_iter a ctf_msg_iter_up

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Change-Id: I603a9daa109ebab118fe72e38ac175a7f7006335
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8455
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.lttng-live: make lttng_live_stream_iterator::stream a bt2::Stream::Shared
Simon Marchi [Wed, 22 Jun 2022 20:27:30 +0000 (16:27 -0400)] 
src.ctf.lttng-live: make lttng_live_stream_iterator::stream a bt2::Stream::Shared

Wrapped in an optional because it's not set at construction time.

Change-Id: Ia38f2feba1040749df692574e67861c81a73e8df
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8454
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.lttng-live: introduce lttng_live_metadata::UP and use it
Simon Marchi [Tue, 26 Jul 2022 21:36:29 +0000 (17:36 -0400)] 
src.ctf.lttng-live: introduce lttng_live_metadata::UP and use it

Change-Id: I3f902be075b8274485b6ce88b1b7fa1617e79cff
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8453
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.lttng-live: introduce lttng_live_component::UP and use it
Simon Marchi [Tue, 26 Jul 2022 21:36:06 +0000 (17:36 -0400)] 
src.ctf.lttng-live: introduce lttng_live_component::UP and use it

Change-Id: I1bdc817239fbba02fae9696e51559daa6b1b43b9
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8452
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.lttng-live: use GCharUP in lttng_live_component_create
Simon Marchi [Tue, 26 Jul 2022 21:35:47 +0000 (17:35 -0400)] 
src.ctf.lttng-live: use GCharUP in lttng_live_component_create

Change-Id: Ieffb41481d6696c46fd51483414a59fae1099ede
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8451
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.lttng-live: remove lttng_live_component_destroy_data
Simon Marchi [Wed, 22 Jun 2022 20:07:03 +0000 (16:07 -0400)] 
src.ctf.lttng-live: remove lttng_live_component_destroy_data

Change-Id: I9e57187adcaba990c1f48885cc6e8e94f96c0ac3
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8450
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.lttng-live: change lttng_live_component::params::url to std::string
Simon Marchi [Wed, 22 Jun 2022 20:05:43 +0000 (16:05 -0400)] 
src.ctf.lttng-live: change lttng_live_component::params::url to std::string

Change-Id: I5b5c7c15e99bd9cc79c5e20ea68326a244490ce8
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8449
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.fs: use CTF2 metadata stream parser
Simon Marchi [Mon, 15 Aug 2022 21:41:32 +0000 (17:41 -0400)] 
src.ctf.fs: use CTF2 metadata stream parser

Change-Id: Ieae140125ac14595845739534d6bb0ee65ae114d
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8372
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.fs: use the new metadata stream parser and message iterator
Simon Marchi [Tue, 23 Aug 2022 15:29:53 +0000 (11:29 -0400)] 
src.ctf.fs: use the new metadata stream parser and message iterator

Update the src.ctf.fs component class to use:

  - the new metadata stream parser / IR generator (ctf::src::CtfIrGenerator)
  - the new message iterator (ctf::src::MsgIter)

The new IR generator produces a trace class instance using the new CTF
IR type, ctf::src::TraceCls.  This instance is then fed to the message
iterator.  These two changes must therefore be done in lock step.

Add ctf::src::fs::Medium, a Medium for use with ctf::src::ItemSeqIter
that reads trace data from the filesystem.  It receives an index, which
can be thought of as the "playlist" of packets that form the logical
data stream.  Its buf method needs to be able to find a packet given a
requested offset in that logical data stream.  Therefore, add a new
`offsetInStream` field in the ctf_fs_ds_index_entry structure, and the
`updateOffsetsInStream` method to compute them.  Rename
ctf_fs_ds_index_entry::offset to offsetInFile, for clarity.

Once the buf method selected the right index entry (packet), it maps
that portion of the file, and see if the returned buffer can include
some of the following packets in the file, while at it.

Other details about the changes in this patch, in no particular order:

 - Make a copy of ctf_trace_class_configure_ir_trace that works on a
   ctf::src::TraceCls instead of a struct ctf_trace_class.  The old one
   will be removed once src.ctf.lttng-live no longer uses it.

 - Remove ctf_fs_metadata, the required fields (the decoder / IR
   generator) are now directly in ctf_fs_trace.

 - The quirks to apply are saved in the ctf_fs_component object
   directly.  They were previously saved in the old IR object (struct
   ctf_trace_class), but they are not in the new IR object.  They now
   need to be passed to all instantiated message iterators.

 - Remove ctf_fs_msg_iter_data::ds_file_group, add
   ctf_fs_msg_iter_data::port_data.  This allows message iterators to
   access the ctf_fs_component and therefore the quirks.  They can still
   access the ds_file_group through the port_data.

 - Replace ctf_fs_msg_iter_data::msg_iter (the old message iterator)
   with ctf_fs_msg_iter_data::msgIter (the new message iterator).

 - Remove ctf_fs_msg_iter_data::msg_iter_medops_data, this is the data
   for the medium (medops) for the old message iterator.

 - Adjust ctf_fs_iterator_init, ctf_fs_iterator_next,
   ctf_fs_iterator_finalize to the new message iterator.

 - Adjust ctf_fs_iterator_seek_beginning to the new message iterator.
   The simplest way I found to reset the state to the beginning state is
   to delete the message iterator and instantiate a new one.

 - Update add_ds_file_to_ds_file_group to use readPktProps to read the
   stream class and id.

 - Change decode_clock_snapshot_after_event, used for working around
   known tracer bugs, to use an ItemSeqIter.  Define two item visitors,
   ClockSnapshotAfterFirstEventItemVisitor and
   ClockSnapshotAfterLastEventItemVisitor, for the two cases.

Change-Id: I8e3ce344c940da2106bdf8320c28724ca360b48a
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8349
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.fs: make create_streams_for_trace use bt2::StreamClass to instantiate streams
Simon Marchi [Tue, 26 Jul 2022 21:31:20 +0000 (17:31 -0400)] 
src.ctf.fs: make create_streams_for_trace use bt2::StreamClass to instantiate streams

Wrap the stream class (ds_file_group->sc->ir_sc) in a bt2::StreamClass,
then use that to instantiate streams.

Change-Id: I9e9917dd96b0d1115b443463a0a2cd8f2da42323
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8437
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.fs: pass path to ctf_fs_ds_index_entry constructor
Simon Marchi [Tue, 21 Jun 2022 19:53:47 +0000 (15:53 -0400)] 
src.ctf.fs: pass path to ctf_fs_ds_index_entry constructor

Change-Id: Id8c29f502cc126775e2ded67813a6f8714f06705
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8436
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.fs: remove ctf_fs_ds_file_group_create, add constructor
Simon Marchi [Tue, 21 Jun 2022 19:33:10 +0000 (15:33 -0400)] 
src.ctf.fs: remove ctf_fs_ds_file_group_create, add constructor

Replace ctf_fs_ds_file_group_create with an equivalent constructor.

Change-Id: I06d69a05ba685552dc2d6b78800d79f20569a340
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8435
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.fs: change a pointer parameter to a reference, remove unused parameter
Simon Marchi [Mon, 20 Jun 2022 16:37:59 +0000 (12:37 -0400)] 
src.ctf.fs: change a pointer parameter to a reference, remove unused parameter

Change add_range's range parameter to a const ref.  Remove the output
parameter of populate_stream_info, its caller doesn't use it.

Change-Id: I9d9268b3f3e6f6446b2422e9bfb098359c71da02
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8425
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agoctf: rename ctx_create to ctf_visitor_generate_ir_create
Simon Marchi [Wed, 3 Aug 2022 01:33:14 +0000 (21:33 -0400)] 
ctf: rename ctx_create to ctf_visitor_generate_ir_create

There is an unnecessary level here, rename the existing ctx_create to
ctf_visitor_generate_ir_create.  Remove the existing
ctf_visitor_generate_ir_create.

Change-Id: I2ce578f30e1e9e25754dc9ad4f18610eb3a0be36
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8424
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agoctf: convert ctx_destroy to ~ctf_visitor_generate_ir
Simon Marchi [Tue, 23 Aug 2022 15:29:10 +0000 (11:29 -0400)] 
ctf: convert ctx_destroy to ~ctf_visitor_generate_ir

Convert ctx_destroy into a destructor for ctf_visitor_generate_ir.

Change-Id: I7963276587e44621381c3b47a734986c1696df64
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8423
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.fs: pass clkClsCfg to ctf_fs_component constructor
Simon Marchi [Mon, 20 Jun 2022 15:38:57 +0000 (11:38 -0400)] 
src.ctf.fs: pass clkClsCfg to ctf_fs_component constructor

Change-Id: I3a9d696780d044505d273a28804915bf2f9e9c16
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8422
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.fs: modernize read_src_fs_parameters
Simon Marchi [Tue, 26 Jul 2022 21:31:02 +0000 (17:31 -0400)] 
src.ctf.fs: modernize read_src_fs_parameters

Change the input parameter `params` to be bt2::ConstMapValue.  Change
the return type to be of a new structure type containing all processed
parameters, rather than using output parameters and rather than setting
the clkClsCfg inside the ctf_fs object directly.  Change the type of the
parameters of ctf_fs_component_create_ctf_fs_trace and other helper
functions accordingly.

Change-Id: I2ba5aca22f907ffcfbdd19c8d8077e17d0c47a71
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8421
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.fs: fs.cpp: replace some pointers with references
Simon Marchi [Sun, 19 Jun 2022 17:03:34 +0000 (13:03 -0400)] 
src.ctf.fs: fs.cpp: replace some pointers with references

Change-Id: Iaea9cd35b82c01effda10921dfb9e6d90c543731
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8420
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.fs: change two functions to take ctf_fs_ds_index by reference
Simon Marchi [Sun, 19 Jun 2022 03:47:39 +0000 (23:47 -0400)] 
src.ctf.fs: change two functions to take ctf_fs_ds_index by reference

Change-Id: I76211e8fb321b87618cccb23e547982b80535c91
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8419
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.fs: make set_trace_name use bt2::Trace
Simon Marchi [Sun, 19 Jun 2022 03:21:00 +0000 (23:21 -0400)] 
src.ctf.fs: make set_trace_name use bt2::Trace

Change-Id: I3f47878658a431f81a129fc9e644efe50608e7ce
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8418
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agoctf: make ctf_trace_class_configure_ir_trace use bt2::Trace
Simon Marchi [Tue, 26 Jul 2022 21:28:50 +0000 (17:28 -0400)] 
ctf: make ctf_trace_class_configure_ir_trace use bt2::Trace

Use the bt2::Trace wrapper instead of a raw `bt_trace *`.  Change the
return type to void, since failures are now reported using exceptions.

Change-Id: I2e30b0aa9a6f33e765ac32d274032ef4ab3aa9f8
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8417
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.lttng-live: make lttng_live_trace::trace a bt2::Trace::Shared
Simon Marchi [Tue, 26 Jul 2022 21:28:38 +0000 (17:28 -0400)] 
src.ctf.lttng-live: make lttng_live_trace::trace a bt2::Trace::Shared

Use the C++ wrapper to hold the reference to the trace.  Wrap it
in an optional, since it's not assigned at creation.

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Change-Id: Iadfe9add10e5a6e3112cc0626b2ece868a013b40
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8416
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.lttng-live: make lttng_live_trace::trace_class a bt2::TraceClass::Shared
Simon Marchi [Sun, 19 Jun 2022 03:09:57 +0000 (23:09 -0400)] 
src.ctf.lttng-live: make lttng_live_trace::trace_class a bt2::TraceClass::Shared

Use the C++ wrapper to hold the reference to the trace class.  Wrap it
in an optional, since it's not assigned at creation.

Note that the existing comment said it is a weak reference, but the code
shows otherwise.

Change-Id: Ic486a65ab40953c5d6a3ddb7d057d2caa85cf1c0
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8415
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.lttng-live: use std::string in list_append_session
Simon Marchi [Sun, 19 Jun 2022 02:50:16 +0000 (22:50 -0400)] 
src.ctf.lttng-live: use std::string in list_append_session

Change-Id: I2a930cff82e4f43ff303f62a7371eb67d8144c04
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8414
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.lttng-live: use std::vector in lttng_live_get_one_metadata_packet
Simon Marchi [Tue, 21 Jun 2022 00:26:56 +0000 (20:26 -0400)] 
src.ctf.lttng-live: use std::vector in lttng_live_get_one_metadata_packet

Use an std::vector to manage the buffer used to store the received data.

Change-Id: I04f99440573c722d982378ef9d8bb47f35b343aa
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8413
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.lttng-live: lttng_live_metadata_update: use std::vector as metadata buffer
Simon Marchi [Tue, 26 Jul 2022 21:28:18 +0000 (17:28 -0400)] 
src.ctf.lttng-live: lttng_live_metadata_update: use std::vector as metadata buffer

Use an std::vector to store the metadata contents in
lttng_live_metadata_update, instead of opening a memstream.  Modify
lttng_live_get_one_metadata_packet to append to a vector instead of
writing to a `FILE *`.  We still open a read-only memstream around the
vector's contents to pass a `FILE *` to
ctf_metadata_decoder_append_content.  Change that variable to be a
FileUP, so it's automatically closed on exit.

Change-Id: Ie7b57d25ea90fc82fb96bf19ff707edccdf46072
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8412
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agoctf: make ctf_visitor_generate_ir not use ctf_metadata_decoder_config
Simon Marchi [Tue, 23 Aug 2022 14:19:45 +0000 (10:19 -0400)] 
ctf: make ctf_visitor_generate_ir not use ctf_metadata_decoder_config

The ctf_metadata_decoder_config structure is going to disappear in the
following patches.  Make ctf_visitor_generate_ir (which we will keep for
now) stop using it.

Change-Id: If4053599d0077554882a9eabe79e4489aa655c72
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8405
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.fs: make ds_file_group_insert_ds_file_info_sorted a method of ctf_fs_ds_file_...
Simon Marchi [Fri, 17 Jun 2022 20:55:30 +0000 (16:55 -0400)] 
src.ctf.fs: make ds_file_group_insert_ds_file_info_sorted a method of ctf_fs_ds_file_group

Change-Id: I743359a80d39e307f4aa36b2deaa92429c536cea
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8404
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.fs: fs.cpp: declare variables on first use
Simon Marchi [Fri, 17 Jun 2022 19:05:15 +0000 (15:05 -0400)] 
src.ctf.fs: fs.cpp: declare variables on first use

Move variable declarations to be at or closer to their first use.

Change-Id: Iec7b1789a9cd007938b992292ad48a09d23f79e5
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8403
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.fs: data-stream-file.cpp: declare variables on first use
Simon Marchi [Tue, 26 Jul 2022 21:26:13 +0000 (17:26 -0400)] 
src.ctf.fs: data-stream-file.cpp: declare variables on first use

Move variables declarations to be at or closer to their first use.

Change-Id: I0649c4fda3b42c6bca02217481c08b575fda6a5d
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8402
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.fs: remove ctf_fs_ds_index::UP
Simon Marchi [Tue, 26 Jul 2022 21:25:48 +0000 (17:25 -0400)] 
src.ctf.fs: remove ctf_fs_ds_index::UP

We don't need to dynamically allocate ctf_fs_ds_index objects, we can
store / return / pass objects directly.  Remove ctf_fs_ds_index::UP and
update all users.

Change-Id: I7ce9de83b111c782299a1caebea3ead0fd945cb5
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8401
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.fs: store index entry objects instead of pointers
Simon Marchi [Tue, 26 Jul 2022 22:25:56 +0000 (18:25 -0400)] 
src.ctf.fs: store index entry objects instead of pointers

Change-Id: I4fea078cddf97292cc1f040ca998acef465d6808
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8348
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.fs: remove ctf_fs_ds_index_entry_create
Simon Marchi [Mon, 13 Jun 2022 16:49:45 +0000 (12:49 -0400)] 
src.ctf.fs: remove ctf_fs_ds_index_entry_create

This function is now a simple wrapper around constructing a
ctf_fs_ds_index_entry, remove it.

Change-Id: I20905864876588f7e6db79b6b344833275131871
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8347
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.fs: initialize ctf_fs_ds_index_entry::packet_seq_num to UINT64_MAX in class
Simon Marchi [Mon, 13 Jun 2022 16:47:53 +0000 (12:47 -0400)] 
src.ctf.fs: initialize ctf_fs_ds_index_entry::packet_seq_num to UINT64_MAX in class

Initialize the field directly to the right value.  The field was
originally initialized to 0 to mimic the g_new0 behavior.

Change-Id: Ia1df1be730b77ca0d69ae05dae12bd60ef9e9ed8
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8346
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.fs: Implement queries with new `MetadataStreamDecoder' and `Ctf1MetadataStrea...
Simon Marchi [Tue, 16 Aug 2022 14:28:37 +0000 (10:28 -0400)] 
src.ctf.fs: Implement queries with new `MetadataStreamDecoder' and `Ctf1MetadataStreamParser`

Rewrite the `babeltrace.support-info` query using the new
`Ctf1MetadataStreamParser` class.

Rewrite the `metadata-info` query using the new `MetadataStreamDecoder`
class.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I80530c6eef7ca62c4271a568e527e48e8ec2602a
Reviewed-on: https://review.lttng.org/c/babeltrace/+/7946
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months ago`ctf` plugin: add metadata stream parser utilities
Simon Marchi [Tue, 23 Aug 2022 15:26:45 +0000 (11:26 -0400)] 
`ctf` plugin: add metadata stream parser utilities

This patch adds:

ctf::src::getMetadataStreamMajorVersion():
    Returns the major version of a metadata stream based on its first
    byte.

ctf::src::createMetadataStreamParser(MetadataStreamMajorVersion, ...):
    Creates and returns a CTF metadata stream parser of which the
    concrete class depends on some major version.

ctf::src::createMetadataStreamParser(const std::uint8_t *, ...):
    Creates and returns a CTF metadata stream parser of which the
    concrete class depends on the first byte of some data.

ctf::src::parseMetadataStream():
    Parses a whole metadata stream, returning the resulting trace class
    and optional metadata stream UUID.

    This is the preferred way to parse a whole metadata stream as it
    calls the static parse() method of some concrete parser class which
    may contain more validation. For example,
    ctf::src::Ctf2MetadataStreamParser::parse() throws if there's no
    resulting trace class or if the current resulting trace class has no
    data stream classes (required by CTF2-SPEC-6.0 [1]).

[1]: https://diamon.org/ctf/files/CTF2-SPECRC-6.0rB.html#metadata-stream

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

Change-Id: I9249645496012f8bddccbdc866af087c3d3bc549

20 months agoAdd `ctf::src::Ctf2MetadataStreamParser` class (JSON text sequence)
Philippe Proulx [Sun, 19 Jun 2022 01:28:48 +0000 (21:28 -0400)] 
Add `ctf::src::Ctf2MetadataStreamParser` class (JSON text sequence)

This patch adds `ctf::src::Ctf2MetadataStreamParser` which inherits
`ctf::src::MetadataStreamParser` to implement a CTF 2 metadata stream
(JSON text sequence) parser.

The parser uses `Ctf2JsonAnyFragmentValReq` to validate each fragment,
and also performs other validation at the JSON level.

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

Change-Id: I9ab6b95a17f96a11d8c9db2baa27e28099b0dbcc

20 months agoAdd `ctf::src::Ctf1MetadataStreamParser` class (TSDL)
Philippe Proulx [Tue, 23 Aug 2022 13:50:13 +0000 (09:50 -0400)] 
Add `ctf::src::Ctf1MetadataStreamParser` class (TSDL)

This patch:

* Adds the `ctf::src::MetadataStreamParser` abstract base class
  to have a common base for CTF 1 and CTF 2 metadata stream parsers.

  Parse a metadata stream section with parseSection() (defers to the
  virtual _parseSection() method).

  Get the resulting, current trace class and metadata stream UUID
  with traceCls() and metadataStreamUuid().

  The constructor accepts an optional self component pointer so that
  parseSection() calls finalizeTraceCls() after calling the
  version-specific _parseSection().

* Adds the `ctf::src::Ctf1MetadataStreamParser` class which is a
  concrete TSDL metadata stream parser inheriting
  `ctf::src::MetadataStreamParser`.

  parseSection() requires one or more complete root blocks of TSDL
  contents.

  `ctf::src::Ctf1MetadataStreamParser` also implements the static
  ctf::src::Ctf1MetadataStreamParser::parse() which considers a whole
  metadata stream. While this static method currently doesn't add
  anything to creating a parser and calling parseSection() once, it
  could eventually contain more validation knowing that the metadata
  stream was completely parsed.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I55e0f2f05d64a0acc5949029e315aeefae424dda
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8000
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I24e175447f759220de5943ccb49c7888a5934ce5

20 months agoAdd `ctf::src::MetadataStreamParser` class
Simon Marchi [Tue, 23 Aug 2022 15:23:45 +0000 (11:23 -0400)] 
Add `ctf::src::MetadataStreamParser` class

WRITE ME

-----------------

The commit message of the old `Add ctf::src::finalizeTraceCls()` commit:

This new function finalizes a `ctf::src` CTF IR trace class after its
creation or when it gets new data stream classes or event record
classes.

The function:

* Sets the value saving indexes of dependencies (field classes) and the
  saved value index of dependent (dynamic-length, optional, and variant)
  field classes.

  It also links the dependent field classes to their dependencies by
  weak pointer.

* With a self component pointer, translates the contained objects to
  their trace IR equivalents.
-----------------

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I24e175447f759220de5943ccb49c7888a5934ce5
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
20 months agoctf: factor out clk offset normalization
Simon Marchi [Tue, 23 Aug 2022 15:06:46 +0000 (11:06 -0400)] 
ctf: factor out clk offset normalization

Change-Id: I5073a901f8c4c434ad35e102aaeb145a30055506
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
20 months agoImplement CTF 2 JSON requirements
Philippe Proulx [Fri, 27 May 2022 12:18:29 +0000 (08:18 -0400)] 
Implement CTF 2 JSON requirements

This patch implements all the CTF 2 JSON requirements.

The internal "public" API is the `Ctf2JsonAnyFragmentValReq` PImpl class
which validates a single CTF 2 fragment. That's all the CTF 2 metadata
stream parser will need.

Here's an example:

Code:
    Ctf2JsonAnyFragValReq {}.validate(*bt2_common::parseJson(jsonText));

JSON text:
    {
      "type": "data-stream-class",
      "namespace": "lol",
      "name": "salut",
      "packet-context-field-class": {
        "type": "structure",
        "member-classes": [
          {
            "name": "meow",
            "field-class": {
              "type": "null-terminated-string"
            }
          },
          {
            "name": "meow",
            "field-class": {
              "type": "dynamic-length-array",
              "length-field-location": ["data-stream-class", "lel"],
              "element-field-class": {
                "type": "fixed-length-signed-integer",
                "length": 23,
                "byte-order": "little-endian",
                "alignment": 24,
                "user-attributes": {}
              }
            }
          }
        ]
      }
    }

Exception message:
    [1:1] Invalid data stream class fragment:
    [5:33] In object property `packet-context-field-class`:
    [5:33] Invalid scope field class:
    [5:33] Invalid structure field class:
    [7:23] In object property `member-classes`:
    [14:7] In array element #2:
    [14:7] Invalid structure field member class:
    [16:24] In object property `field-class`:
    [16:24] Invalid dynamic-length array field class:
    [19:34] In object property `element-field-class`:
    [19:34] Invalid fixed-length signed integer field class:
    [23:26] In object property `alignment`:
    [23:26] Invalid alignment: 24 is not a power of two.

I'd say that Ctf2JsonAnyFragValReq::validate() can validate 95 % of a
CTF 2 metadata stream. See its class comment to learn what it can't do.

There are a few clang-format off/on comments because I hate what it does
with nested brace-enclosed lists.

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

20 months ago`ctf` plugin: add `ctf::src::MsgIter` class
Simon Marchi [Tue, 7 Jun 2022 19:15:47 +0000 (15:15 -0400)] 
`ctf` plugin: add `ctf::src::MsgIter` class

Original patch by Simon.

Philippe's changes over original patch (no functional change intended):

* Conform to the Babeltrace 2 coding style for new C++11 code and to
  some naming conventions of the common part of the `ctf` plugin.

* Add many public and internal comments.

* Rename `Quirks` class to `MsgIterQuirks`.

  Also, rename the quirks to the generic `pktEndDefClkValZero`,
  `eventRecordDefClkValGtNextPktBeginDefClkVal`, and
  `eventRecordDefClkValLtPktBeginDefClkVal` names to decouple this API
  from specific tracers.

* Remove `MsgIterItemVisitor`.

  Instead, MsgIter::_handleItem() dispatches the item to a specific
  handling method based on its numeric type.

  Move the relevant members of `MsgIterItemVisitor` into `MsgIter`
  itself.

* In `_StackFrame`, rename everything named "field" to "sub-field" so as
  to remove some ambiguity.

* Add MsgIter::_stackTop*() helper methods which defer to the
  corresponding method on the top stack frame.

* Add MsgIter::_stackPush() and MsgIter::_stackPop() helper methods.

* Add MsgIter::_addMsgToQueue() helper method.

* Only log item details when the `TRACE` level is enabled.

* Handle `PktMagicNumberItem`: validate the magic number value.

* Handle `MetadataStreamUuidItem`: validate the UUID.

  The `MsgIter` constructor now accepts an `expectedMetadataStreamUuid`
  parameter (optional UUID) which is the expected metadata stream UUID
  to compare to.

* Handle variable-length integer field items, adding the
  MsgIter::_handleUIntFieldItem() and MsgIter::_handleSIntFieldItem()
  helper method templates to do so.

* Handle BLOB field items.

  A new data member, `_mCurBlobFieldDataOffset`, tracks the current BLOB
  field data offset to write to when handling the next
  `BlobFieldSectionItem` (we can't append to a BLOB field like when
  handling `StrFieldSubstrItem`).

* Handle optional field items, adding a member to
  `MsgIter::_StackFrame::_Field`.

* In MsgIter::_StackFrame::goToNextSubField(), unconditionally increment
  `_mSubFieldIndex`: curSubField() doesn't care about `_mSubFieldIndex`
  for the variant/option field cases anyway.

  Therefore, make curSubFieldAndGoToNextSubField() reuse curSubField()
  and goToNextSubField() to remove some almost duplicate code.

Change-Id: If2dd82b43f4d19a16ec4420c13c9a3686034766d
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8227
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agocpp-common/bt2: add `CommonBlobField` and `CommonDynamicBlobField`
Philippe Proulx [Wed, 10 Aug 2022 15:18:57 +0000 (11:18 -0400)] 
cpp-common/bt2: add `CommonBlobField` and `CommonDynamicBlobField`

Use `CommonBlobField::data()` and `CommonBlobField::length()` to access
the data pointer and data length (bytes) of the BLOB field.

Use `CommonDynamicBlobField::length()` to set the length of a dynamic
BLOB field (like `CommonDynamicArrayField::length()`).

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

20 months agoFix: bt2::CommonOptionField::hasField(): use has_value()
Philippe Proulx [Wed, 10 Aug 2022 15:16:05 +0000 (11:16 -0400)] 
Fix: bt2::CommonOptionField::hasField(): use has_value()

Can't convert `nonstd::optional<ConstField>` to `bool` for some reason
in this context.

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

20 months agosrc.ctf.fs: remove goto error handling from data-stream-file.cpp
Simon Marchi [Tue, 26 Jul 2022 21:24:46 +0000 (17:24 -0400)] 
src.ctf.fs: remove goto error handling from data-stream-file.cpp

Same as previous patch, but for data-stream-file.cpp.

Change-Id: Ieb52faca6142ff33591fce2d880bcde664f2c1b7
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8320
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.fs: remove goto error handling from fs.cpp
Simon Marchi [Wed, 3 Aug 2022 01:31:26 +0000 (21:31 -0400)] 
src.ctf.fs: remove goto error handling from fs.cpp

gotos prevent declaring variables in the middle of functions, which is
sometimes necessary in C++.  Remove gotos used for error handling,
replace them with returning directly.

Change-Id: I15b5d6aa4897e5326fc03e2626045c83258d8eca
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8318
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.fs: use GMappedFileUP in build_index_from_idx_file
Simon Marchi [Thu, 9 Jun 2022 19:51:18 +0000 (15:51 -0400)] 
src.ctf.fs: use GMappedFileUP in build_index_from_idx_file

Change-Id: I24d4cf509839923e704870953b6c9fb379cf1880
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8312
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.fs: add GMappedFileUP
Simon Marchi [Thu, 9 Jun 2022 19:49:39 +0000 (15:49 -0400)] 
src.ctf.fs: add GMappedFileUP

Add GMappedFileUP, a unique_ptr type used to manage the lifetime of a
GMappedFile object.

Change-Id: Ibc47d3c6e052499013cb34782b112ff1e72eab46
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8311
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.fs: use std::string in build_index_from_idx_file
Simon Marchi [Thu, 9 Jun 2022 19:48:57 +0000 (15:48 -0400)] 
src.ctf.fs: use std::string in build_index_from_idx_file

Change-Id: Ifdb2c818f66efbc328b095408ae2834646fba4fe
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8310
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.fs: use GCharUP in build_index_from_idx_file
Simon Marchi [Tue, 26 Jul 2022 21:20:07 +0000 (17:20 -0400)] 
src.ctf.fs: use GCharUP in build_index_from_idx_file

Change-Id: Ifb4e1b3ac7d484af2d570d75cff21e310f752add
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8309
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.fs: remove ctf_fs_ds_index_create
Simon Marchi [Fri, 10 Jun 2022 16:56:48 +0000 (12:56 -0400)] 
src.ctf.fs: remove ctf_fs_ds_index_create

Remove ctf_fs_ds_index_create, since it's now just a wrapper around
constructing a ctf_fs_ds_index.

Change-Id: Ia256fde3286f3f77a514835806f8862678e02359
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8308
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.fs: remove ctf_fs_component_create
Simon Marchi [Tue, 26 Jul 2022 21:19:49 +0000 (17:19 -0400)] 
src.ctf.fs: remove ctf_fs_component_create

Remove this function, as it's now a simple wrapper around constructing a
ctf_fs_component.

Change-Id: Ifc6c751ff66f43c81c1a0abd6d7b27393b96f4ad
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8307
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.fs: remove ctf_fs_file_create
Simon Marchi [Tue, 26 Jul 2022 21:19:35 +0000 (17:19 -0400)] 
src.ctf.fs: remove ctf_fs_file_create

Remove this function, it's now just a wrapper around constructing a
ctf_fs_file.

Change-Id: I95e4d6eb26b0d359e0f480cac51af11f3a1db539
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8297
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.fs: make ctf_fs_make_port_name return std::string
Simon Marchi [Tue, 26 Jul 2022 21:19:05 +0000 (17:19 -0400)] 
src.ctf.fs: make ctf_fs_make_port_name return std::string

Change-Id: I9e2f4d2ac47e4f061e5dda1a3813d1a092ffe433
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8296
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.fs: use GDirUp in create_ds_file_groups
Simon Marchi [Thu, 9 Jun 2022 15:38:51 +0000 (11:38 -0400)] 
src.ctf.fs: use GDirUp in create_ds_file_groups

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

Add GDirUP, a unique_ptr type to manage the lifetime of GDir objects.

Change-Id: I8814db0bec41918203af2f6d43a97a3e8d13c8c1
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8294
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.fs: use std::vector<std::string> in ctf_fs_component_create_ctf_fs_trace
Simon Marchi [Tue, 26 Jul 2022 21:18:38 +0000 (17:18 -0400)] 
src.ctf.fs: use std::vector<std::string> in ctf_fs_component_create_ctf_fs_trace

Change-Id: I51af73cb2bdaf10318b19aa493129bdb8401cc3b
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8293
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.fs: use std::string in path_is_ctf_trace
Simon Marchi [Thu, 9 Jun 2022 15:32:46 +0000 (11:32 -0400)] 
src.ctf.fs: use std::string in path_is_ctf_trace

Change-Id: I796d135f7daee29a4481e61cf073e8bbd2e0f05f
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8292
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
20 months agosrc.ctf.fs: use std::string in set_trace_name
Simon Marchi [Tue, 26 Jul 2022 21:18:19 +0000 (17:18 -0400)] 
src.ctf.fs: use std::string in set_trace_name

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