babeltrace.git
2 weeks agolib: add bt_get_greatest_operative_mip_version_with_restriction()
Mathieu Desnoyers [Wed, 27 Mar 2024 23:09:06 +0000 (19:09 -0400)] 
lib: add bt_get_greatest_operative_mip_version_with_restriction()

This new function works like bt_get_greatest_operative_mip_version(),
but has an additional optional MIP version restriction range set.

For example, if all the components would support MIP 0 and 1,
bt_get_greatest_operative_mip_version() would return 1, while
bt_get_greatest_operative_mip_version_with_restriction() with the
`mip_version_restriction` parameter only containing [0, 0] would
return 0.

This new function provides more control over the preferred MIP version
to use while avoiding the complexity of exposing a direct "get supported
MIP versions" method call.

Philippe updated the documentation.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ic8bbdee6055a0816e398f0f27ac0ca8c45f0b85a
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12791
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
CI-Build: Simon Marchi <simon.marchi@efficios.com>

2 weeks agotests/utils/python/mctf.py: convert JSON array → JSON text seq.
Philippe Proulx [Mon, 13 May 2024 09:00:43 +0000 (05:00 -0400)] 
tests/utils/python/mctf.py: convert JSON array → JSON text seq.

This patch updates `mctf.py` so that it converts a JSON array found in
the part named `metadata` to a JSON text sequence.

This makes it possible to write a CTF 2 metadata part without the odd
RS characters, for example:

    --- metadata
    [
      {
        "type": "preamble",
        "version": 2
      },
      {
        "type": "trace-class"
      },
      {
        "type": "data-stream-class"
      },
      {
        "name": "test",
        "payload-field-class": {
          "member-classes": [
            {
              "field-class": {
                "type": "variable-length-unsigned-integer"
              },
              "name": "vu1a"
            },
            {
              "field-class": {
                "type": "variable-length-unsigned-integer"
              },
              "name": "vu1b"
            },
            {
              "field-class": {
                "type": "variable-length-unsigned-integer"
              },
              "name": "vu2"
            },
            {
              "field-class": {
                "type": "variable-length-unsigned-integer"
              },
              "name": "vu3"
            },
            {
              "field-class": {
                "type": "variable-length-unsigned-integer"
              },
              "name": "vu4"
            },
            {
              "field-class": {
                "type": "variable-length-unsigned-integer"
              },
              "name": "vu5"
            },
            {
              "field-class": {
                "type": "variable-length-unsigned-integer"
              },
              "name": "vu6"
            },
            {
              "field-class": {
                "type": "variable-length-unsigned-integer"
              },
              "name": "vu7"
            },
            {
              "field-class": {
                "type": "variable-length-unsigned-integer"
              },
              "name": "vu8"
            },
            {
              "field-class": {
                "type": "variable-length-unsigned-integer"
              },
              "name": "vu9"
            },
            {
              "field-class": {
                "type": "variable-length-unsigned-integer"
              },
              "name": "vu10"
            },
            {
              "field-class": {
                "type": "variable-length-signed-integer"
              },
              "name": "vi1a"
            },
            {
              "field-class": {
                "type": "variable-length-signed-integer"
              },
              "name": "vi1b"
            },
            {
              "field-class": {
                "type": "variable-length-signed-integer"
              },
              "name": "vi1c"
            },
            {
              "field-class": {
                "type": "variable-length-signed-integer"
              },
              "name": "vi2"
            },
            {
              "field-class": {
                "type": "variable-length-signed-integer"
              },
              "name": "vi3"
            },
            {
              "field-class": {
                "type": "variable-length-signed-integer"
              },
              "name": "vi4"
            },
            {
              "field-class": {
                "type": "variable-length-signed-integer"
              },
              "name": "vi5"
            },
            {
              "field-class": {
                "type": "variable-length-signed-integer"
              },
              "name": "vi6"
            },
            {
              "field-class": {
                "type": "variable-length-signed-integer"
              },
              "name": "vi7"
            },
            {
              "field-class": {
                "type": "variable-length-signed-integer"
              },
              "name": "vi8"
            },
            {
              "field-class": {
                "type": "variable-length-signed-integer"
              },
              "name": "vi9"
            },
            {
              "field-class": {
                "type": "variable-length-signed-integer"
              },
              "name": "vi10a"
            },
            {
              "field-class": {
                "type": "variable-length-signed-integer"
              },
              "name": "vi10b"
            },
            {
              "field-class": {
                "type": "variable-length-signed-integer"
              },
              "name": "vi10c"
            }
          ],
          "type": "structure"
        },
        "type": "event-record-class"
      }
    ]

    --- my-stream
    [0 : uleb128]                     # `vu1a`
    [77 : uleb128]                    # `vu1b`
    [177 : uleb128]                   # `vu2`
    [43123 : uleb128]                 # `vu3`
    [21829382 : uleb128]              # `vu4`
    [5121829382 : uleb128]            # `vu5`
    [95121829382 : uleb128]           # `vu6`
    [13895121829382 : uleb128]        # `vu7`
    [913895121855555 : uleb128]       # `vu8`
    [333333333333333333 : uleb128]    # `vu9`
    [18446744073709551615 : uleb128]  # `vu10`
    [0 : sleb128]                     # `vi1a`
    [-1 : sleb128]                    # `vi1b`
    [23 : sleb128]                    # `vi1c`
    [-156 : sleb128]                  # `vi2`
    [8556 : sleb128]                  # `vi3`
    [-100101001 : sleb128]            # `vi4`
    [8288491823 : sleb128]            # `vi5`
    [-171717171717 : sleb128]         # `vi6`
    [123456787654321 : sleb128]       # `vi7`
    [-1121231234123450 : sleb128]     # `vi8`
    [99999999999999999 : sleb128]     # `vi9`
    [9223372036853775807 : sleb128]   # `vi10a`
    [9223372036854775807 : sleb128]   # `vi10b`
    [-9223372036854775808 : sleb128]  # `vi10c`

Detecting `[` as the first character of the part is enough because a
CTF 1.8 TSDL metadata text never starts with `[`.

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

2 weeks agosrc.ctf.fs: always set the correct trace IR stream ID
Philippe Proulx [Sun, 12 May 2024 11:42:00 +0000 (07:42 -0400)] 
src.ctf.fs: always set the correct trace IR stream ID

In add_ds_file_to_ds_file_group(), we don't use the original CTF data
stream ID to set the trace IR stream ID whenever the beginning timestamp
is missing.

The comment says:

    if (begin_ns == -1) {
        /*
         * No beginning timestamp to sort the stream files
         * within a stream file group, so consider that this
         * file must be the only one within its group.
         */
        stream_instance_id.reset();
    }

This might be true, but there's no need to reset the data stream ID.

Then during data stream decoding, the trace IR stream ID always matches
the CTF IR data stream ID (if any), which enables some further checks.

Furthermore, a trace which goes from `src.ctf.fs` to `sink.ctf.fs` will
keep its original data stream IDs.

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

2 weeks agotests/.../data_from_mp.py: add CTF 2 support
Philippe Proulx [Sun, 12 May 2024 11:31:45 +0000 (07:31 -0400)] 
tests/.../data_from_mp.py: add CTF 2 support

This patch changes `tests/data/plugins/src.ctf.fs/field/data_from_mp.py`
to add CTF 2 support.

The script generates a CTF 2 trace when the stripped field class text
starts with `{` (full field class) or `"` (field class alias), which are
exclusive to the CTF 2 metadata syntax (any CTF 1.8 field class starts
with some keyword).

The same automatic field class aliases as the CTF 1.8 case
are available.

_make_ctf_2_metadata() doesn't need the `@` replacement trick of
_make_ctf_1_metadata() because CTF 2 array field classes aren't
different from any CTF 2 field class, for example:

    {
      "type": "static-length-array",
      "length": 4,
      "element-field-class": "u8"
    }

vs.

    u8 @[4]

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

2 weeks agosrc.ctf.*: make `ctf::src::ClkClsCfg` final
Philippe Proulx [Fri, 10 May 2024 20:06:25 +0000 (16:06 -0400)] 
src.ctf.*: make `ctf::src::ClkClsCfg` final

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

2 weeks agocpp-common/bt2c/libc-up.hpp: make `FileCloserDeleter` final
Philippe Proulx [Fri, 10 May 2024 19:38:50 +0000 (15:38 -0400)] 
cpp-common/bt2c/libc-up.hpp: make `FileCloserDeleter` final

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

2 weeks agobt2c/logging.hpp: replace `Logger::MemData` with `ConstBytes`
Philippe Proulx [Thu, 16 May 2024 15:37:58 +0000 (11:37 -0400)] 
bt2c/logging.hpp: replace `Logger::MemData` with `ConstBytes`

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

2 weeks agocpp-common/bt2c/data-len.hpp: `static inline` → `inline`
Simon Marchi [Wed, 29 May 2024 15:50:31 +0000 (11:50 -0400)] 
cpp-common/bt2c/data-len.hpp: `static inline` → `inline`

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

2 weeks agocpp-common/bt2c/c-string-view.hpp: remove useless `bt2c::`
Philippe Proulx [Fri, 10 May 2024 19:36:43 +0000 (15:36 -0400)] 
cpp-common/bt2c/c-string-view.hpp: remove useless `bt2c::`

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

2 weeks agocpp-common/bt2c/read-fixed-len-int.hpp: remove useless `bt2c::`
Philippe Proulx [Fri, 10 May 2024 19:30:40 +0000 (15:30 -0400)] 
cpp-common/bt2c/read-fixed-len-int.hpp: remove useless `bt2c::`

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

2 weeks agocpp-common/bt2c/read-fixed-len-int.hpp: fix comment style
Philippe Proulx [Fri, 10 May 2024 19:30:27 +0000 (15:30 -0400)] 
cpp-common/bt2c/read-fixed-len-int.hpp: fix comment style

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

2 weeks agoAdd static bt2c::Uuid::isValidUuidStr()
Philippe Proulx [Fri, 10 May 2024 19:26:11 +0000 (15:26 -0400)] 
Add static bt2c::Uuid::isValidUuidStr()

The bt2c::Uuid(bt2s::string_view) constructor wants the conversion
to work.

This new static method calls bt_uuid_from_str() directly and uses its
return value to validate the UUID string.

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

2 weeks agocpp-common/bt2c/uuid.hpp: `static inline` → `inline`
Philippe Proulx [Fri, 10 May 2024 19:24:51 +0000 (15:24 -0400)] 
cpp-common/bt2c/uuid.hpp: `static inline` → `inline`

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

2 weeks agobt2c::Uuid::Uuid(): accept `bt2s::string_view` instead of `CStringView`
Philippe Proulx [Fri, 10 May 2024 19:23:45 +0000 (15:23 -0400)] 
bt2c::Uuid::Uuid(): accept `bt2s::string_view` instead of `CStringView`

The input string doesn't need to be null-terminated.

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

2 weeks agocpp-common/bt2c/uuid.hpp: remove useless `bt2c::`
Philippe Proulx [Fri, 10 May 2024 19:13:32 +0000 (15:13 -0400)] 
cpp-common/bt2c/uuid.hpp: remove useless `bt2c::`

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

2 weeks agoMake bt_uuid_from_str() take begin/end pointers
Philippe Proulx [Fri, 10 May 2024 19:11:15 +0000 (15:11 -0400)] 
Make bt_uuid_from_str() take begin/end pointers

Make bt_uuid_from_str() take begin/end pointers (null terminator not
required) to make it possible to call it with a string view.

What used to be bt_uuid_from_str() is now bt_uuid_from_c_str() to avoid
changing existing the logic of call sites.

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

2 weeks agosink.text.details: adapt to latest libbabeltrace2 API
Philippe Proulx [Tue, 20 Jun 2023 20:39:16 +0000 (16:39 -0400)] 
sink.text.details: adapt to latest libbabeltrace2 API

This patch makes a `sink.text.details` component write the details of
the following MIP 1 features:

Clock class:
    • Namespace
    • UID
    • Precision if unknown
    • Accuracy
    • Custom origin (namespace, name, and UID)

Stream class:
    • UID

Event class:
    • UID

Bit array field class:
    • Flags (sorted, like enumeration field class mappings)

Trace:
    • Namespace
    • UID

The clock class term "offset from origin" is more accurate and modern
than "offset", therefore I'm changing this too and updating existing
expectation files accordingly.

Also, what used to be

    Origin is Unix epoch: Yes

with MIP 0 is now the same for any MIP:

    Origin: Unix epoch

When the origin is unknown, whatever the MIP version, there's no origin
line (like most missing/empty properties of `sink.text.details`).

Here's a hypothetical MIP-1 clock class output example:

    Default clock class:
      Namespace: lttng.org,2009
      Name: monotonic
      UID: boot-id:7d19f00b-f1c7-49ea-a0a1-5f1a6a062a29
      User attributes:
        lttng.org,2009:
          tag: provigo
          original-index: 4
      Description: Monotonic Clock
      Frequency (Hz): 1,000,000,000
      Precision (cycles): 0
      Accuracy (cycles): 1000
      Offset from origin (s): 1,564,079,206
      Offset from origin (cycles): 484,157,338
      Origin:
        Namespace: quebec.ca,2017
        Name: referendum
        UID: 1995

The component only writes UIDs when the `with-uid` parameter is true
(the default). This is analogous to the `with-uuid` parameter. You may
specify both `with-uuid` and `with-uid` parameters: the former only
applies under MIP 0 and the latter under MIP 1.

Also changing some tests which set `with-uuid` to false to also set
`with-uid` to false, should they work under MIP 1.

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

2 weeks agotests: run some Python tests with CTF 1 and CTF 2 traces
Simon Marchi [Tue, 24 Oct 2023 02:12:24 +0000 (22:12 -0400)] 
tests: run some Python tests with CTF 1 and CTF 2 traces

The goal of this patch is to run as many Python-based tests that use CTF
traces against both CTF 1 and CTF 2.  I would like to minimize the
amount of changes and boilerplate necessary in each individual test.

I've taken the approach to add a decorator named `test_all_ctf_versions`
to the test classes, inspired by the parameterized Python package [1].
Unlike the decorators, from parameterized, our decorator is hardcoded
for what we need.  When applied to a class, it makes two copies of all
`test_*` methods of that class, suffixed with `_ctf_1` and `_ctf_2`, and
removes the original method.  The two new methods are in fact wrapped in
a small wrapper that sets the `_ctf_version` attribute on the class
(with the value 1 or 2) for the duration of the method call.

The changes necessary in the test themselves are to make the test trace
paths dependent on `self._ctf_version`, instead of hard-coded.

[1] https://pypi.org/project/parameterized/

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

2 weeks agotests/src.ctf.fs: run test_force_origin_unix_epoch succeed test on CTF 1 and CTF...
Simon Marchi [Tue, 23 Aug 2022 12:41:49 +0000 (08:41 -0400)] 
tests/src.ctf.fs: run test_force_origin_unix_epoch succeed test on CTF 1 and CTF 2 traces

Modify test_force_origin_unix_epoch such that it tests with both the CTF
1 and CTF 2 version of the trace.

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

2 weeks 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>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12753
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
2 weeks 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>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12752
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
2 weeks agotests/src.ctf.fs: add CTF 2 tests for no stream class, no trace class
Simon Marchi [Sat, 4 Nov 2023 20:23:14 +0000 (20:23 +0000)] 
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>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12751
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
2 weeks agotests/src.ctf.fs/test_fail: test with both autodiscovery and explicit component insta...
Simon Marchi [Fri, 10 Nov 2023 16:33:48 +0000 (16:33 +0000)] 
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
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12750
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
2 weeks agotests/src.ctf.fs: add function to compute trace path in test-fail.sh
Simon Marchi [Thu, 2 Nov 2023 18:50:16 +0000 (18:50 +0000)] 
tests/src.ctf.fs: add function to compute trace path in test-fail.sh

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>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12749
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
2 weeks agoctf: remove now unused files
Simon Marchi [Tue, 21 May 2024 17:59:51 +0000 (13:59 -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>
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12748

2 weeks agosrc.ctf.lttng-live: use the new metadata stream parser and message iterator
Simon Marchi [Fri, 24 May 2024 21:21:56 +0000 (17:21 -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>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8648

2 weeks 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
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12747

2 weeks agotests/cli/test_output_ctf_metadata: use `bt_cli` and `diff`
Simon Marchi [Wed, 25 Oct 2023 02:11:44 +0000 (02:11 +0000)] 
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
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12746

2 weeks agotests: adjust src.ctf.fs succeed tests to read CTF 2 traces
Simon Marchi [Fri, 10 Nov 2023 16:32:38 +0000 (16:32 +0000)] 
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>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8646

2 weeks 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>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8645

2 weeks agotests: move CTF 1 test traces to their own directory
Francis Deslauriers [Fri, 9 Feb 2024 21:22:20 +0000 (16:22 -0500)] 
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>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8644

2 weeks agosrc.ctf.fs: make ctf_fs_trace's logger private
Simon Marchi [Tue, 21 May 2024 17:06:21 +0000 (13:06 -0400)] 
src.ctf.fs: make ctf_fs_trace's logger private

Rename `ctf_fs_trace::logger` to `ctf_fs_trace::_mLogger` and make
private.  Pass a logger down to some functions that would previously get
it from the trace.

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>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12745

2 weeks agosrc.ctf.fs: fix error path of ctf_fs_init
Simon Marchi [Fri, 30 Aug 2024 18:17:13 +0000 (14:17 -0400)] 
src.ctf.fs: fix error path of ctf_fs_init

If ctf_fs_create fails (returns nullptr), we don't want to call
bt_self_component_set_data.  Return early if that happens.

Change-Id: Ib5766c6795a841ee1c2abc30e1751f9f1930f985
Reviewed-on: https://review.lttng.org/c/babeltrace/+/13200
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
2 weeks agosrc.ctf.fs: use the new metadata stream parser and message iterator
Simon Marchi [Thu, 30 May 2024 18:26:09 +0000 (14:26 -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>
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12744

2 weeks agoctf: rename ctx_create to ctf_visitor_generate_ir_create
Simon Marchi [Thu, 18 Apr 2024 14:36:22 +0000 (14:36 +0000)] 
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>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12743

2 weeks agoctf: use `bt2s::make_unique` in one spot
Simon Marchi [Wed, 6 Dec 2023 19:43:34 +0000 (19:43 +0000)] 
ctf: use `bt2s::make_unique` in one spot

Change-Id: Ie753b3be9abc29d1e4fa6a208dcdd28f1af50e37
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12742
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
2 weeks agoctf: make ctf_visitor_generate_ir not use ctf_metadata_decoder_config
Simon Marchi [Wed, 17 Apr 2024 18:11:19 +0000 (14:11 -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>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12741

2 weeks agocpp-common/bt2c: Logger: factor out code to append cause
Simon Marchi [Tue, 21 May 2024 16:43:47 +0000 (12:43 -0400)] 
cpp-common/bt2c: Logger: factor out code to append cause

Factor out the code that appends an error cause to a helper method, so
that it can be re-used.

Change-Id: I055314bef66968ef2ef30b5dd1728680d2f79c7c
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12228
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
2 weeks agosrc.ctf.fs: Implement queries with new `MetadataStreamDecoder' and `Ctf1MetadataStrea...
Francis Deslauriers [Tue, 7 May 2024 15:17:57 +0000 (11:17 -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>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12740
Tested-by: jenkins <jenkins@lttng.org>
CI-Build: Simon Marchi <simon.marchi@efficios.com>

2 weeks agocpp-common/bt2c: make `dataFromFile()` take a `CStringView`
Simon Marchi [Thu, 25 Apr 2024 15:10:55 +0000 (15:10 +0000)] 
cpp-common/bt2c: make `dataFromFile()` take a `CStringView`

Make it easier to pass an `std::string` to `dataFromFile()`.

Change-Id: I0af7d913362e67b69c1f479e3be8024d9337b9d6
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12739
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
2 weeks agocpp-common/bt2c: optionally log and append errors in `dataFromFile()`
Simon Marchi [Thu, 25 Apr 2024 14:57:24 +0000 (14:57 +0000)] 
cpp-common/bt2c: optionally log and append errors in `dataFromFile()`

For some callers, a `dataFromFile()` error (`NoSuchFileOrDirectoryError`
typically) may be fatal, in which case it would be appropriate to log an
error and append an error cause.  For others callers, it might not be
fatal, they just want to catch the exception and carry on.

To accomodate this, pass a logger to `dataFromFile()` and add a
`fatalError` boolean parameter.  Log an error and append an error cause
on error if `fatalError` is true.  Otherwise, log at the debug level.

Change-Id: Id32639b16a928195bc430c1a2ce7671ced2ad43b
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12738
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
2 weeks ago`ctf` plugin: add metadata stream parser utilities
Philippe Proulx [Thu, 25 Apr 2024 15:45:38 +0000 (15:45 +0000)] 
`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‑2.0 [1]).

[1]: https://diamon.org/ctf/CTF2-SPEC-2.0.html#metadata-stream

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

2 weeks agoAdd `ctf::src::Ctf2MetadataStreamParser` class (JSON text sequence)
Philippe Proulx [Tue, 21 May 2024 17:57:03 +0000 (13:57 -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
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12736

2 weeks agoAdd bt2c::join()
Philippe Proulx [Fri, 10 May 2024 19:32:10 +0000 (15:32 -0400)] 
Add bt2c::join()

This new function template joins the strings of some container with
some delimiter.

The container needs a forward iterator and its elements need the data()
and size() methods.

The container may be empty.

For example:

    int main()
    {
        std::cout << bt2c::join(std::vector<std::string> {
            "salut", "meow", "mix"
        }, ", ") << '\n';
    }

will print

    salut, meow, mix

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

2 weeks agoAdd `ctf::src::Ctf1MetadataStreamParser` class (TSDL)
Philippe Proulx [Sun, 10 Dec 2023 05:51:52 +0000 (05:51 +0000)] 
Add `ctf::src::Ctf1MetadataStreamParser` class (TSDL)

This patch 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: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I55e0f2f05d64a0acc5949029e315aeefae424dda
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8000
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12734

2 weeks agoAdd `ctf::src::MetadataStreamParser` abstract base class
Philippe Proulx [Wed, 25 Oct 2023 15:41:53 +0000 (15:41 +0000)] 
Add `ctf::src::MetadataStreamParser` abstract base class

This is an abstract base class for any metadata stream parser.

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() may finalize the trace class after calling the
version-specific _parseSection().

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

• 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.

• Reconfigures the clock classes of the trace class.

• Normalizes the offsets of the clock classes of the trace class so that
  the cycle part is less than the frequency.

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

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

2 weeks agocpp-common/bt2/trace-ir.hpp: use "common event context"
Philippe Proulx [Fri, 10 May 2024 19:57:46 +0000 (15:57 -0400)] 
cpp-common/bt2/trace-ir.hpp: use "common event context"

This is easier to read.

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

2 weeks agocpp-common/bt2/field{,-class}.hpp: adapt to latest libbabeltrace2 API
Philippe Proulx [Mon, 18 Mar 2024 21:19:57 +0000 (17:19 -0400)] 
cpp-common/bt2/field{,-class}.hpp: adapt to latest libbabeltrace2 API

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

2 weeks agocpp-common/bt2/trace-ir.hpp: adapt to latest libbabeltrace2 API
Philippe Proulx [Wed, 17 Apr 2024 19:35:04 +0000 (15:35 -0400)] 
cpp-common/bt2/trace-ir.hpp: adapt to latest libbabeltrace2 API

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

2 weeks agocpp-common/bt2/clock-class.hpp: adapt to latest libbabeltrace2 API
Philippe Proulx [Wed, 17 Apr 2024 19:28:23 +0000 (15:28 -0400)] 
cpp-common/bt2/clock-class.hpp: adapt to latest libbabeltrace2 API

Read anything related to the origin with the new origin() method which
returns a clock origin view from which you may get the namespace, name,
UID, and whether or not it's unknown or the Unix epoch.

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

2 weeks agocpp-common/bt2: add support to get / set trace UID
Simon Marchi [Tue, 28 Nov 2023 04:39:27 +0000 (23:39 -0500)] 
cpp-common/bt2: add support to get / set trace UID

Wrap bt_trace_set_uid and bt_trace_get_uid.

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

2 weeks agolib: add support for bit array flags
Simon Marchi [Mon, 22 Jan 2024 21:20:58 +0000 (21:20 +0000)] 
lib: add support for bit array flags

Implement support for flags on bit array field classes, in order to
be able to add support for the fixed-length bit map field class (as
specified by CTF2-SPEC-2.0 [1]) in the CTF component classes.

A flag is a mapping between bit positions in a fixed-length bit map
field and a textual label.  A flag is considered active for a given
field if any of the bits in the flag's bit positions is set in the
field.  Flags may have overlapping bit positions, meaning that a single
bit can activate multiple flags.

Add the following public functions operating on bit array field classes:

 🥑 bt_field_class_bit_array_add_flag
 🥑 bt_field_class_bit_array_get_flag_count
 🥑 bt_field_class_bit_array_borrow_flag_by_index_const
 🥑 bt_field_class_bit_array_borrow_flag_by_label_const
 🥑 bt_field_class_bit_array_get_active_flag_labels_for_value_as_integer

Add the bt_field_class_bit_array_flag type.  Then, add the following
public functions operating on it:

 🥑 bt_field_class_bit_array_flag_get_label
 🥑 bt_field_class_bit_array_flag_borrow_index_ranges_const

Add the following public function operating on a bit array field:

 🥑 bt_field_bit_array_get_active_flag_labels

The
`bt_field_class_bit_array_get_active_flag_labels_for_value_as_integer`
function returns an array of label through an output parameter of type
`bt_field_class_bit_array_flag_label_array`.  The storage for it is
owned by the field class, so the result is only valid until the next
call to the function (or until the field class gets destroyed).  This
behavior is copied from the enum field class.

Philippe updated the documentation.

[1]: https://diamon.org/ctf/CTF2-SPEC-2.0.html

Change-Id: Ib88f3aecf692ea8b6453c0308fa7735fd40e55a9
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12727
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
2 weeks agolib: add bt_clock_class_has_same_identity function
Simon Marchi [Tue, 5 Sep 2023 14:59:59 +0000 (10:59 -0400)] 
lib: add bt_clock_class_has_same_identity function

Add the bt_clock_class_has_same_identity utility function, which tells
if two clock classes have the same identify.

The criteria for whether two clock classes have the same identity are
the same as in CTF 2:

    Two clock classes which satisfy all the following conditions are
    said to have the same identity:

     - Both share the same namespace property value, or both don’t have
       any namespace property.
     - Both have a name property and share the same value.
     - Both have a uid property and share the same value.

Philippe updated the documentation.

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

2 weeks agolib: add clock class accuracy property
Simon Marchi [Fri, 1 Sep 2023 19:37:38 +0000 (15:37 -0400)] 
lib: add clock class accuracy property

With the intent of supporting CTF 2, add the accuracy property to clock
classes.

 - Add the bt_clock_class_{g,s}et_accuracy getter and setter, both of
   which are restricted to MIP >= 1.
 - Add the accuracy field to struct bt_clock_class.
 - Make lib-logging print the accuracy of a clock class, if set.

Philippe updated the documentation.

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

2 weeks agolib: make clock class precision optional
Simon Marchi [Fri, 1 Sep 2023 19:16:26 +0000 (15:16 -0400)] 
lib: make clock class precision optional

With the intent of supporting CTF 2, make the precision property of
clock classes optional under MIP 1.

 - Change the precision field of struct bt_clock_class to
   bt_property_uint.
 - Adjust lib-logging to omit the precision if not set.
 - Change bt_clock_class_create to make the precision property available
   with MIP 0, so that the precision will always be available with MIP
   0 (still with an initial value of 0).
 - Restrict bt_clock_class_get_precision to MIP 0.
 - Add bt_clock_class_get_opt_precision, which returns a
   bt_property_availability value.  Note that
   bt_clock_class_get_opt_precision can be used with MIP 0, it will
   always return BT_PROPERTY_AVAILABILITY_AVAILABLE.

Not done in this patch: adapt the Python bindings.

Philippe updated the documentation.

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

2 weeks agolib: add event class UID property
Simon Marchi [Tue, 7 May 2024 20:42:24 +0000 (16:42 -0400)] 
lib: add event class UID property

Add a UID property to event class objects.  This is needed to
support CTF 2.

Philippe updated the documentation.

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

2 weeks agolib: add stream class UID property
Simon Marchi [Tue, 7 May 2024 20:41:55 +0000 (16:41 -0400)] 
lib: add stream class UID property

Add a UID property to stream class objects.  This is needed to
support CTF 2.

Philippe updated the documentation.

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

2 weeks agolib: add trace namespace property
Simon Marchi [Tue, 7 May 2024 20:22:04 +0000 (16:22 -0400)] 
lib: add trace namespace property

Add a new namespace property for trace objects.  This is needed to
support CTF 2.

Philippe updated the documentation.

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

2 weeks agolib: add clock class namespace and UID properties
Simon Marchi [Tue, 7 May 2024 20:18:47 +0000 (16:18 -0400)] 
lib: add clock class namespace and UID properties

Add the namespace and UID properties to clock class objects.  This is
needed to support CTF 2.

Philippe updated the documentation.

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

2 weeks agolib: add bt_trace_class_get_graph_mip_version
Simon Marchi [Wed, 31 May 2023 19:59:08 +0000 (15:59 -0400)] 
lib: add bt_trace_class_get_graph_mip_version

Add bt_trace_class_get_graph_mip_version, which returns the MIP version
for the graph the trace class is in.

This will be necessary for the Python bindings functions dealing with
trace IR that need to change their behavior according to the MIP
version.  Right now, the MIP version can be obtained from a self
component.  But some Python functions (for instance
_TraceClass.create_variant_field_class) only have a IR object to work
with, and it's not possible to get the self component from there.
Adding a function to get the self component from a trace class was
considered, but it was deemed to complex because of object lifetime and
refcount cycle issues.

Philippe updated the documentation.

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

2 weeks agoAdd ctf::src::normalizeClkOffset()
Simon Marchi [Mon, 11 Dec 2023 17:24:39 +0000 (12:24 -0500)] 
Add ctf::src::normalizeClkOffset()

Also, use it in `visitor-generate-ir.cpp` instead of the local
function.

Change-Id: I5073a901f8c4c434ad35e102aaeb145a30055506
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12718
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
2 weeks agoImplement CTF 2 JSON requirements
Philippe Proulx [Mon, 11 Dec 2023 21:51:28 +0000 (16:51 -0500)] 
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(*bt2c::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": "lel",
            "field-class": "uint16"
          },
          {
            "name": "meow",
            "field-class": {
              "type": "dynamic-length-array",
              "length-field-location": {"path": ["lel"]},
              "element-field-class": {
                "type": "fixed-length-signed-integer",
                "length": 23,
                "byte-order": "little-endian",
                "alignment": 24,
                "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`:
    [18:7] In array element #3:
    [18:7] Invalid structure field member class:
    [20:24] In object property `field-class`:
    [20:24] Invalid dynamic-length array field class:
    [23:34] In object property `element-field-class`:
    [23:34] Invalid fixed-length signed integer field class:
    [27:26] In object property `alignment`:
    [27: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
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12717

2 weeks ago`ctf` plugin: add `ctf::src::MsgIter` class
Simon Marchi [Wed, 22 May 2024 16:00:59 +0000 (12:00 -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.

• Handle UTF-16 and UTF-32 string data.

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

2 weeks agocpp-common/bt2c: add `UnicodeConv` class
Simon Marchi [Fri, 3 May 2024 16:54:10 +0000 (12:54 -0400)] 
cpp-common/bt2c: add `UnicodeConv` class

Add the `UnicodeConv` class, which currently implements conversion
from (UTF-16, UTF-32) × (BE, LE) to UTF-8.

The `UnicodeConv` class uses `g_iconv` from GLib internally to make
the conversions.  It has a vector member that is used as an output
buffer.  Public conversion methods accept a span of
`const std::uint8_t`, and return a span `std::uint8_t` which is a view
on that internal vector.

Add a test which:

✤ Converts some hardcoded UTF-16 and UTF-32 strings to UTF-8 and
  verifies the result against a reference UTF-8 string.

✤ Feeds the UTF-16 and UTF-32 conversion methods with truncated strings
  and verifies that they throw and append specific causes to the error
  of the current thread.

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

2 weeks agoFix: use `OptionalBorrowedObject::hasObject()` in `CommonOptionField::hasField()`
Simon Marchi [Tue, 26 Mar 2024 20:45:47 +0000 (20:45 +0000)] 
Fix: use `OptionalBorrowedObject::hasObject()` in `CommonOptionField::hasField()`

This is needed since `OptionalBorrowedObject::operator bool()` is
explicit.

Change-Id: Iabd899be72607b1d5eb1a42dec919c14d0e33868
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12714
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
2 weeks agocpp-common/bt2: add `CommonBlobField` and `CommonDynamicBlobField`
Philippe Proulx [Thu, 7 Dec 2023 20:38:33 +0000 (20:38 +0000)] 
cpp-common/bt2: add `CommonBlobField` and `CommonDynamicBlobField`

Use `CommonBlobField::data()` to access the data pointer and data length
(bytes) of the BLOB field as a `bt2s::span`. A `BlobField::data()`
returns `bt2s::span<std::uint8_t>` while `ConstBlobField::data()`
returns `bt2s::span<const std::uint8_t>`.

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: I3d9f9417e262a5fbbc9b7bb8f3d690d6628f7988
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12713

2 weeks agosrc.ctf.fs: Add `readPktProps()`
Francis Deslauriers [Wed, 22 May 2024 15:57:36 +0000 (11:57 -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>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12712

2 weeks agosrc.ctf.fs: Add `LoggingItemVisitor`
Simon Marchi [Tue, 21 May 2024 17:12:06 +0000 (13:12 -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>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12711

2 weeks 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>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12710

2 weeks agosrc.ctf.*: add old CTF IR const functions
Francis Deslauriers [Wed, 17 Apr 2024 17:53:23 +0000 (13:53 -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>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12709

2 weeks agosrc.ctf.fs: implement `MetadataStreamDecoder` class
Francis Deslauriers [Fri, 3 Nov 2023 19:15:49 +0000 (19:15 +0000)] 
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>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12257

2 weeks agosrc/plugins/ctf/common/src: add item sequence iterator API
Philippe Proulx [Wed, 17 Apr 2024 17:52:29 +0000 (13:52 -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 `src.ctf.lttng-live`).

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 `bt2c::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 check        │
│ whether or not the next() method returns `nullptr`). 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
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12256

2 weeks agocpp-common/bt2c/std-int.hpp: use dedicated enum. instead of `bool`
Philippe Proulx [Fri, 10 May 2024 19:41:10 +0000 (15:41 -0400)] 
cpp-common/bt2c/std-int.hpp: use dedicated enum. instead of `bool`

This makes the code clearer, for example

    bt2c::StdIntT<32, bt2c::Signedness::Signed>

vs.

    bt2c::StdIntT<32, true>

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

2 weeks agosrc.ctf.*: add `ctf::src::NullCpFinder`
Philippe Proulx [Fri, 10 May 2024 20:12:52 +0000 (16:12 -0400)] 
src.ctf.*: add `ctf::src::NullCpFinder`

An instance of this new class keeps a temporary code unit of length
`CodeUnitLenV` bytes to help finder a null codepoint (U+0000) in
contiguous buffers (especially when the encoded codepoint spans more
than one buffer).

See the comment of the new class to learn more.

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

2 weeks agoAdd bt2c::reverseFixedLenIntBits()
Philippe Proulx [Fri, 31 May 2024 19:43:23 +0000 (15:43 -0400)] 
Add bt2c::reverseFixedLenIntBits()

This new function reverses the first N least significant bits of a
64-bit integer value, sign-extending if needed, and returns the result.

I basically read [1], which shows the version of Knuth, and adapted that
code to our coding style and requirements.

[1]: https://matthewarcus.wordpress.com/2012/11/18/reversing-a-64-bit-word/

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

2 weeks agoAdd `cpp-common/bt2c/aliases.hpp` to contain common aliases
Philippe Proulx [Fri, 3 May 2024 16:44:12 +0000 (12:44 -0400)] 
Add `cpp-common/bt2c/aliases.hpp` to contain common aliases

The first one is

    using ConstBytes = bt2s::span<const std::uint8_t>;

which we need at various locations.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ic6cdaeca4b63c89bea8f51c7bb45f168039bd40f
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12705
CI-Build: Simon Marchi <simon.marchi@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
2 weeks agoAdd CTF IR classes specific to `src.ctf.*`
Philippe Proulx [Tue, 21 May 2024 17:33:14 +0000 (13:33 -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 "key value"
  saving index.

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

• Dynamic-length, optional, and variant field classes have a saved
  key value index.

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

• Field class and field location mixins have an optional text
  location member.

  This will help with precise metadata stream error reporting.

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

  Once more, see the comment of `ctf::src::KeyValSavingIndexes` 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
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12255
Tested-by: jenkins <jenkins@lttng.org>
CI-Build: Simon Marchi <simon.marchi@efficios.com>

2 weeks agoIncrease wise_enum limit to 512 enumerators
Philippe Proulx [Thu, 18 Apr 2024 19:05:30 +0000 (15:05 -0400)] 
Increase wise_enum limit to 512 enumerators

This is to support upcoming big enumerations.

This updated header was generated using the `create_generated.py` script
of the wise_enum 3.1.0 release as such:

    $ python3 create_generated.py 512 wise_enum_generated.h

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

2 weeks agocpp-common: add observable.hpp
Simon Marchi [Fri, 8 Dec 2023 19:11:21 +0000 (19:11 +0000)] 
cpp-common: add observable.hpp

Add the `Observable` class, which implements the observer pattern.  See
comments in the new file for details on usage.

Change-Id: I1f7a3faead9350f1f1217ffcf431fdcd3ddedab9
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12254
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
2 weeks agoAdd common `ctf::ir` CTF IR classes
Philippe Proulx [Fri, 3 Nov 2023 18:32:50 +0000 (18:32 +0000)] 
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 all the `ctf` plugin component classes. 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
        FixedLenBitArrayFc
          FixedLenBitMapFc
          FixedLenBoolFc
          FixedLenFloatFc
          FixedLenIntFc
            FixedLenUIntFc
            FixedLenSIntFc
        VarLengthIntFc
          VarLengthUIntFc
          VarLengthSIntFc
        StrFc
          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):

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

• 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 into 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,
  FixedLenUIntFc::FixedLenUIntFc() accepts three mixins: field class,
  fixed-length bit array field class, and fixed-length 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:

  `WithAttrsMixin`:
      Optional attributes.

  `WithPrefDispBaseMixin`:
      Preferred display base.

  `WithMappingsMixin`:
      Integer mappings.

  `WithLibCls`:
      libbabeltrace2 class.

  `UIntFcMixin`:
      Unsigned integer field roles.

  `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 "plugins/ctf/common/metadata/ctf-ir.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",
            bt2c::makeUnique<MyNullTerminatedStrFc>(MyMixins::Fc {}));

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

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

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

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ib4785c9a2f675bdc1415b149e9b57de1339f475e
Reviewed-on: https://review.lttng.org/c/babeltrace/+/7708
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12253
CI-Build: Simon Marchi <simon.marchi@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
2 weeks agocpp-common: Add Blob, StaticBlob, and DynamicBlob FC
Francis Deslauriers [Mon, 11 Dec 2023 17:14:13 +0000 (12:14 -0500)] 
cpp-common: Add Blob, StaticBlob, and DynamicBlob FC

This commit copies the implementation of the static and dynamic array
field class wrappers.

The FieldClassType enum size is specified to 64 bits to accommodate for
enumerator value larger than 32 bits. (e.g.
BT_FIELD_CLASS_TYPE_DYNAMIC_BLOB_WITHOUT_LENGTH_FIELD)

Here is the clang++ error
In file included from ../../../../src/cpp-common/bt2/trace-ir.hpp:19:
  ../../../../src/cpp-common/bt2/field-class.hpp:170:20: error: enumerator value evaluates to 2684354560, which cannot be narrowed to type 'int' [-Wc++11-narrowing]
      DynamicBlob = BT_FIELD_CLASS_TYPE_DYNAMIC_BLOB,
                    ^
  ../../../../src/cpp-common/bt2/field-class.hpp:171:41: error: enumerator value evaluates to 6979321856, which cannot be narrowed to type 'int' [-Wc++11-narrowing]
      DynamicBlobWithoutLengthField = BT_FIELD_CLASS_TYPE_DYNAMIC_BLOB_WITHOUT_LENGTH_FIELD,
                                      ^
  ../../../../src/cpp-common/bt2/field-class.hpp:172:38: error: enumerator value evaluates to 11274289152, which cannot be narrowed to type 'int' [-Wc++11-narrowing]
      DynamicBlobWithLengthField = BT_FIELD_CLASS_TYPE_DYNAMIC_BLOB_WITH_LENGTH_FIELD,
                                   ^

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

2 weeks agosrc/cpp-common/bt2: wrap variant with selector field loc. FC API
Philippe Proulx [Tue, 26 Mar 2024 20:04:49 +0000 (16:04 -0400)] 
src/cpp-common/bt2: wrap variant with selector field loc. FC API

This patch adds what's needed to the C++ libbabeltrace2 wrappers to
wrap:

* bt_field_class_variant_with_selector_field_borrow_selector_field_location_const()
* bt_field_class_variant_with_selector_field_location_integer_unsigned_create()
* bt_field_class_variant_with_selector_field_location_integer_signed_create()

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

2 weeks agosrc/cpp-common/bt2: wrap option with selector field loc. FC API
Philippe Proulx [Wed, 11 May 2022 16:21:15 +0000 (12:21 -0400)] 
src/cpp-common/bt2: wrap option with selector field loc. FC API

This patch adds what's needed to the C++ libbabeltrace2 wrappers to
wrap:

* bt_field_class_option_with_selector_field_borrow_selector_field_location_const()
* bt_field_class_option_without_selector_field_location_create()
* bt_field_class_option_with_selector_field_location_bool_create()
* bt_field_class_option_with_selector_field_location_integer_unsigned_create()
* bt_field_class_option_with_selector_field_location_integer_signed_create()

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Iaf20856ee2533a061560abf79c91a69b2dab20b5
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8018
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12701
CI-Build: Simon Marchi <simon.marchi@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
2 weeks agosrc/cpp-common/bt2: wrap dynamic array with length field loc. FC API
Philippe Proulx [Thu, 7 Dec 2023 20:26:27 +0000 (20:26 +0000)] 
src/cpp-common/bt2: wrap dynamic array with length field loc. FC API

This patch adds what's needed to the C++ libbabeltrace2 wrappers to
wrap:

* bt_field_class_array_dynamic_with_length_field_borrow_length_field_location_const()
* bt_field_class_array_dynamic_without_length_field_location_create()
* bt_field_class_array_dynamic_with_length_field_location_create()

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

2 weeks agosrc/cpp-common/bt2: add field location support
Philippe Proulx [Fri, 8 Dec 2023 18:50:58 +0000 (18:50 +0000)] 
src/cpp-common/bt2: add field location support

This patch adds the `bt2::ConstFieldLocation` wrapper class as well as
bt2::TraceClass::createFieldLocation().

I didn't implement a `bt2::CommonFieldLocation` template class because a
field location is immutable anyway, so we only need the const version.
bt2::TraceClass::createFieldLocation() returns a shared const field
location.

bt2::TraceClass::createFieldLocation() accepts a span of strings (either
`const char * const` or `const std::string`) to make the interface a
little nicer than a raw array of `const char *` and a matching size.
Creating a field location is a slow-path operation anyway.

Also adding bt2::wrap() accepting `const bt_field_location *`.

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

2 weeks agosrc/cpp-common/bt2/trace-ir.hpp: add nameSpace() methods where needed
Philippe Proulx [Tue, 26 Mar 2024 20:02:15 +0000 (16:02 -0400)] 
src/cpp-common/bt2/trace-ir.hpp: add nameSpace() methods where needed

The bt2::CommonEventClass::nameSpace() and
bt2::CommonStreamClass::nameSpace() methods make it possible to set and
get the namespace of event classes and stream classes (new feature
starting with MIP 1).

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

2 weeks ago`ctf` plugin: add `ctf::IntRangeSet` class template
Philippe Proulx [Fri, 3 Nov 2023 15:44:35 +0000 (15:44 +0000)] 
`ctf` plugin: add `ctf::IntRangeSet` class template

This new class template is conceptually the same as the libbabeltrace2
equivalent (`bt2::CommonIntegerRangeSet`), but it's templated and avoids
having to make libbabeltrace2 function calls to access data.

That being said, the contains() and intersects() methods don't have
their libbabeltrace2 equivalent.

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

2 weeks ago`ctf` plugin: add `ctf::IntRange` class template
Philippe Proulx [Thu, 30 Nov 2023 03:00:06 +0000 (03:00 +0000)] 
`ctf` plugin: add `ctf::IntRange` class template

This new class template is conceptually the same as the libbabeltrace2
equivalent (`bt2::ConstIntegerRange`), but it's templated and avoids
having to make libbabeltrace2 function calls to access data.

That being said, the contains() and intersects() methods don't have
their libbabeltrace2 equivalent.

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

2 weeks agosrc/cpp-common: add JSON value requirement aliases
Philippe Proulx [Fri, 8 Dec 2023 18:47:41 +0000 (18:47 +0000)] 
src/cpp-common: add JSON value requirement aliases

This patch defines JSON value requirement aliases of the generic value
requirement class templates (`val-req.hpp`) to validate JSON values.

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

2 weeks agoAdd `bt2c::ValReq` class template system
Philippe Proulx [Thu, 28 Mar 2024 17:53:31 +0000 (13:53 -0400)] 
Add `bt2c::ValReq` class template system

This set of class templates makes it possible to get basic requirement
classes to validate JSON-like value objects, that is, a system of null,
boolean, unsigned/signed integer, real, string, array, and object value
objects.

All the class templates accept a `ValT` parameter which is the base type
of the objects to validate, as well as `ValOpsT`, a structure which
defines specific value operations. See the `bt2c::ValReq` class template
comment to learn the requirements of `ValOpsT`.

Having class templates will make it possible to create both:

• JSON value requirements, to validate a CTF2‑SPEC‑2.0 [1] metadata
  stream within the `ctf` plugin.

• libbabeltrace2 value object (`bt2::ConstValue`) requirements, to
  validate component initialization parameters, for example.

A value requirement (`bt2c::ValReq` instance; omitting the namespace for
the rest of this message) is an object which offers the validate()
method to validate some value object.

The current concrete requirement class templates are (validating some
value V):

`ValHasTypeReq`:
`AnyIntValReq`:
`UIntValReq`:
    Validates the type of V.

`SIntValReq`:
    Validates the type of V (unsigned or signed integer) and that the
    raw value of V is between -9,223,372,036,854,775,808 and
    9,223,372,036,854,775,807.

`IntValInRangeReq`:
    Validates the type of V and that the raw value of the integer value
    object V is within a given range.

`ScalarValInSetReq`:
    Validates the type of V and that the raw value of the scalar value
    object V is an element of a given set.

`ArrayValReq`:
    Validates the type of V, that the size of V is within a given range,
    and, optionally, that all the elements of V satisfy a given value
    requirement.

`ObjValReq`:
    Validates the type of V and that the properties of V satisfy a given
    set of property requirements (no missing mandatory property, no
    unknown property if not allowed, valid property value).

ValReq::validate() throws `TextParseError` using the text location
of the value (provided by `ValOpsT`) to validate when it fails.

`ArrayValReq` and `ObjValReq` accept zero or more shared value
requirements: a user of this API may extend `ValReq` to create a custom
value requirement (just implement the virtual _validate() method). A
custom value requirement may reuse existing value requirements
internally.

Each value requirement class C has its static shared() method which
accepts the same parameters as the constructor(s) of C and returns a
`ValReq::SP` instance. Those shared() methods are helpers to make the
usage site clearer, for example (assuming some custom aliases for
specific value object types):

    MyUIntValInRangeReq::shared(0, 255)

    // vs.

    std::make_shared<MyUIntValInRangeReq>(0, 255)

Of course this system is not meant to semantically validate some value.
Even JSON Schema [2], which barectf pushes to its limit for example [3],
cannot do that. But those value requirement classes can certainly remove
a lot of redundant code.

Here are a few examples of value requirement object construction and
corresponding error messages to grasp how to use this API (assume some
custom aliases starting with `Json`):

Simple type check:
    Code:
        JsonValHasTypeReq {ValType::Str}

    Error example:
        [1:1] Expecting a string.

Exactly `true`:
    Code:
        JsonBoolValInSetReq {true}

    Error examples:
        [1:1] Expecting a boolean.

        [1:1] Unexpected value `false`: expecting `true`.

Byte:
    Code:
        JsonUIntValInRangeReq {0, 255}

    Error examples:
        [1:1] Expecting an unsigned integer.

        [1:1] Integer 256 is too large: expecting at most 255.

Display base:
    Code:
        JsonUIntValInSetReq {{2, 8, 10, 16}}

    Error examples:
        [1:1] Expecting an unsigned integer.

        [1:1] Unexpected value 5: expecting 2, 8, 10, or 16.

Choice amongst three strings:
    Code:
        JsonStrValInSetReq {JsonStrValInSetReq::Set {
            "Patrick", "Alec", "Annie"
        }}

    Error examples:
        [1:1] Expecting a string.

        [1:1] Unexpected value `Yves`: expecting `Alec`, `Annie`, or
              `Patrick`.

CTF 2 UUID:
    Code:
        JsonArrayValReq {
            16,
            JsonUIntValInRangeReq::shared(0, 255)
        }

    Error examples:
        [1:1] Expecting an array.

        [1:1] Size of array (2) is too small: expecting at least 16
              elements.

        [1:1] Size of array (19) is too large: expecting at most 16
              elements.

        [1:36] In array element #11:
        [1:36] Expecting an unsigned integer.

        [1:42] In array element #13:
        [1:42] Integer 257 is too large: expecting at most 255.

CTF2-SPECRC-5.0 field location:
    Code:
        JsonArrayValReq {
            2, nonstd::nullopt,
            JsonValHasTypeReq::shared(ValType::Str)
        }

    Error examples:
        [1:1] Expecting an array.

        [1:1] Size of array (1) is too small: expecting at least 2
              elements.

        [1:11] In array element #2:
        [1:11] Expecting a string.

CTF2-SPECRC-5.0 clock class fragment:
    Code:
        JsonObjValReq {
            {
                {"type", {
                    JsonStrValInSetReq::shared("clock-class"),
                    true
                }},

                {"frequency", {
                    JsonUIntValInRangeReq::shared(1, nonstd::nullopt),
                    true
                }},

                {"name", {
                    JsonValHasTypeReq::shared(ValType::Str)
                }},

                {"description", {
                    JsonValHasTypeReq::shared(ValType::Str)
                }},

                {"uuid", {
                    JsonArrayValReq::shared(
                        16,
                        JsonUIntValInRangeReq::shared(0, 255)
                    )
                }},

                {"origin-is-unix-epoch", {
                    JsonValHasTypeReq::shared(ValType::Bool)
                }},

                {"offset", {
                    JsonObjValReq::shared({
                        {"seconds", {
                            JsonValHasTypeReq::shared(ValType::UInt)
                        }},

                        {"cycles", {
                            JsonValHasTypeReq::shared(ValType::UInt)
                        }},
                    })
                }},

                {"precision", {
                    JsonValHasTypeReq::shared(ValType::UInt)
                }},

                {"user-attributes", {
                    JsonValHasTypeReq::shared(ValType::Obj)
                }},

                {"extensions", {
                    JsonValHasTypeReq::shared(ValType::Obj)
                }},
            }
        }

    Error examples:
        [1:1] Expecting an object.

        [1:1] Missing mandatory object property `type`.

        [1:1] Missing mandatory object property `frequency`.

        [1:22] Unknown object property `meow`.

        [1:10] In object property `type`:
        [1:10] Unexpected value `salut`: expecting `clock-class`.

        [1:38] In object property `frequency`:
        [1:32] Expecting an unsigned integer.

        [1:54] In object property `offset`:
        [1:63] Unknown object property `meow`.

        [1:54] In object property `offset`:
        [1:66] In object property `seconds`:
        [1:66] Expecting an unsigned integer.

        [1:50] In object property `uuid`:
        [1:63] In array element #5:
        [1:63] Integer 301 is too large: expecting at most 255.

[1]: https://diamon.org/ctf/CTF2-SPEC-2.0.html
[2]: https://json-schema.org/
[3]: https://github.com/efficios/barectf/tree/stable-3.0/barectf/schemas/config

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

2 weeks agoplugins: make text and utils component classes report support for MIP 1
Simon Marchi [Tue, 28 Nov 2023 05:18:52 +0000 (00:18 -0500)] 
plugins: make text and utils component classes report support for MIP 1

Make the following component classes report they support MIP 1
(everything from the text and utils plugins):

 - sink.text.details
 - source.text.dmesg
 - sink.text.pretty
 - sink.utils.counter
 - sink.utils.dummy
 - filter.utils.muxer
 - filter.utils.trimmer

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

2 weeks agosrc.text.pretty: handle BLOB fields
Simon Marchi [Fri, 11 Mar 2022 20:56:09 +0000 (15:56 -0500)] 
src.text.pretty: handle BLOB fields

Make the `src.text.pretty` components handle BLOB fields, by naively
printing all bytes in hex (without a 0x prefix).  Example output:

    da-ec-name: { blob_without_len = { 23 69 6e 63 6c 75 64 65 20 3c } }

It would be nice to limit the number of bytes dumped (and provide an
option to control it), because at some point it's useless for the user
to dump thousands of bytes on one line.  But this is enough to say that
the `src.text.pretty` component class supports BLOB field classes (and
MIP 1).

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

2 weeks agograph/mip: make bt_get_greatest_operative_mip_version compute operative MIP version
Simon Marchi [Fri, 9 Feb 2024 21:25:24 +0000 (16:25 -0500)] 
graph/mip: make bt_get_greatest_operative_mip_version compute operative MIP version

bt_get_greatest_operative_mip_version is currently implemented assuming
that the only existing MIP version is 0.  It only checks that all
component descriptors support version 0, and then returns 0 as the
computed operative MIP version.

Since the library now supports MIP versions 0 and 1,
bt_get_greatest_operative_mip_version needs to actually compute the
greatest commonly supported version.  Implement something that will work
for any number of MIP versions.

Change validate_operative_mip_version_in_array to
get_supported_mip_version_ranges, make it is solely reponsible for
calling the component class' get_supported_mip_versions method and
append the resulting range set to the `supported_ranges` array.  Or, if
the component class doesn't implement that method, append a range set
with only `[0, 0]`.

Once this is done, we have an array with range sets representing the
supported MIP versions for each soon-to-be component.  Compute (in the
new function find_greatest_compatible_mip_version) the greatest commonly
supported version, if any.

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

2 weeks agosink.text.details: handle missing variant field class option name
Philippe Proulx [Tue, 17 May 2022 17:50:07 +0000 (13:50 -0400)] 
sink.text.details: handle missing variant field class option name

Starting with MIP 1, a variant field class option name is optional.
Handle this in `write.c`, showing "Unnamed" with the
"none"/"missing"/"empty" color.

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

2 weeks agosink.text.details: show event class namespace
Simon Marchi [Wed, 9 Mar 2022 16:47:04 +0000 (11:47 -0500)] 
sink.text.details: show event class namespace

If the event class has namespace (a property introduced with MIP 1),
show it when dumping the event class info.

Example output:

    Event class `da-ec-name` (Namespace `da-ec-namespace`, ID 0):

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

2 weeks agosink.text.details: show stream class namespace
Simon Marchi [Wed, 9 Mar 2022 16:47:04 +0000 (11:47 -0500)] 
sink.text.details: show stream class namespace

If the stream class has a namespace (a property introduced with MIP 1),
show it when dumping the stream class info.

Add a `with-stream-class-namespace` parameter to the component class,
controlling whether to show the namespace or not.

Example output:

    Trace class:
      Stream class `da-name` (Namespace `da-namespace`, ID 0):

Philippe updated the manual page to document the
`with-stream-class-namespace` parameter.

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

2 weeks agosink.text.details: handle BLOB field class type
Simon Marchi [Sat, 5 Mar 2022 03:28:14 +0000 (22:28 -0500)] 
sink.text.details: handle BLOB field class type

Make the `sink.text.details` component class handle the BLOB field class
type, introduced in MIP 1.

When dumping the field class details, print the names of the new field
classes.  For the static BLOB field class, print the static length
value (similar to static arrays).

For BLOB fields:

 - if it is empty, print "Empty" (like a few other existing field kinds)
 - if it is not empty, print bytes as hex (without the 0x prefix), 16
   bytes per line.  This is similar to what `od -t x1` outputs, minus
   the address/offset column.

The output looks like this.  The field class part:

        static_blob: Static BLOB (Length 1)
        blob_without_len: Dynamic BLOB (no length field)
        blob_with_len: Dynamic BLOB (with length field)

The field part:

    static_blob: Length 1:
      fe
    blob_without_len: Length 2048:
      46 72 6f 6d 20 36 34 64 62 36 31 36 36 35 65 32
      38 62 62 63 39 63 62 64 32 62 64 32 62 34 39 31
      <snip>
    blob_with_len: Empty

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

2 weeks agosink.text.details: handle field classes with field locations
Simon Marchi [Fri, 4 Mar 2022 21:46:09 +0000 (16:46 -0500)] 
sink.text.details: handle field classes with field locations

Handle MIP 1 variant, option and dynamic array field classes.  They
have field locations instead of field paths.

The format used by write_field_location is based on write_field_path.

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

2 weeks agolib: make variant field class option name optional with MIP > 0
Philippe Proulx [Tue, 17 May 2022 17:46:52 +0000 (13:46 -0400)] 
lib: make variant field class option name optional with MIP > 0

CTF2-SPEC-2.0 [1] calls for optionally named variant field class
option, therefore libbabeltrace2 should support this.

Before this patch, having a variant field class option name is a
precondition. This patch relaxes said precondition when the MIP version
is greater than zero.

Note that a structure field member class must still have a name.

[1]: https://diamon.org/ctf/CTF2-SPEC-2.0.html

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

2 weeks agolib: add namespace property to event classes
Simon Marchi [Tue, 7 May 2024 20:01:42 +0000 (16:01 -0400)] 
lib: add namespace property to event classes

Add the namespace property to event classes, with the intent to support
namespace properties on event record classes in CTF2‑SPEC‑2.0 [1].

Copy everything from the existing name property, and rename it to
"namespace."

Both new public functions have a `MIP >= 1` pre-condition check.

Philippe updated the documentation.

[1] https://diamon.org/ctf/CTF2-SPEC-2.0.html

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

This page took 0.059486 seconds and 4 git commands to generate.