deliverable/lttng-tools.git
2 years agoVERSION SPOOFING: tests: spoof the version for the live unit test.
Jonathan Rajotte [Thu, 26 May 2022 14:11:54 +0000 (10:11 -0400)] 
VERSION SPOOFING: tests: spoof the version for the live unit test.

Otherwise since that the default trace format is now CTF2 the attach
session fail and lead to an abort since the code expect success only in
continuation.

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

2 years agoWIP: Events can be defined with no fields yielding no " { } " field text
Jonathan Rajotte [Fri, 12 Aug 2022 19:19:52 +0000 (15:19 -0400)] 
WIP: Events can be defined with no fields yielding no " { } " field text

The current lttng-modules ctf2 implementation produce the following
"no field" event record:

{
"type": "event-record-class",
"id": 0,
"name": "syscall_entry_gettid"
"data-stream-class-id": 0,
}

Which is valid and simply result in an output without payload.

In ctf1 the same "event record" is:

event {
        name = "syscall_entry_gettid";
        id = 0;
        stream_id = 0;
        fields := struct {
        };
};

Resulting in an empty but present payload -> " { } "

The tests looked for the presence of a payload ("{.*}"),

For now I decided to modify the regex since I have no feedback from eepp
for the last 5 hours... And ultimately I'm not sure what we should
prioritize in term of preventing "regression".

A ctf2 event record yielding the same output would be:
{
"type": "event-record-class",
"id": 0,
"name": "syscall_entry_gettid"
"data-stream-class-id": 0,
"payload-field-class": {
  "type": "structure"
}
}

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

2 years agoTests: use jq for extracting info from ctf2 traces
Jonathan Rajotte [Wed, 10 Aug 2022 22:38:55 +0000 (18:38 -0400)] 
Tests: use jq for extracting info from ctf2 traces

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

2 years agoTests: ctf2: ust clock override: adapt validation for ctf2
Jonathan Rajotte [Wed, 3 Aug 2022 21:06:52 +0000 (17:06 -0400)] 
Tests: ctf2: ust clock override: adapt validation for ctf2

IMPORTANT: this introduce a dependency on jq for data extraction of the
clock-class.

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

2 years agoUse LTTNG_TEST_TRACE_FORMAT from env to chose the session trace format
Jonathan Rajotte [Wed, 27 Jul 2022 18:44:41 +0000 (14:44 -0400)] 
Use LTTNG_TEST_TRACE_FORMAT from env to chose the session trace format

This is a temporary solution for testing.

The plan is to review all tests and produce ctf1/ctf2 only when
pertinent. For now we want to cover as much ground as possible.

Change-Id: Ic5823c15689061f230a6ebd6e0ce3591a2e48ef7
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
2 years agotests: force the trace format to ctf1
Jonathan Rajotte [Thu, 18 Aug 2022 14:09:25 +0000 (10:09 -0400)] 
tests: force the trace format to ctf1

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

2 years agoUpdate python bindings for session and trace format descriptor
Jonathan Rajotte [Thu, 18 Aug 2022 14:07:35 +0000 (10:07 -0400)] 
Update python bindings for session and trace format descriptor

TODO: this is the bare minimum change. It would be interesting to maybe
adopt a bindings style ala bt2 instead of exposing the C api as-is.

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

2 years agoPropagate trace format to relayd on session creation
Jonathan Rajotte [Fri, 20 May 2022 18:54:39 +0000 (14:54 -0400)] 
Propagate trace format to relayd on session creation

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

2 years agoSave/load: support session trace format
Jonathan Rajotte [Tue, 26 Apr 2022 20:49:38 +0000 (16:49 -0400)] 
Save/load: support session trace format

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

2 years agoCLI: Add trace format mi to session mi
Jonathan Rajotte [Mon, 25 Apr 2022 17:44:34 +0000 (13:44 -0400)] 
CLI: Add trace format mi to session mi

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

2 years agoCLI: Add trace format output to listing
Jonathan Rajotte [Mon, 25 Apr 2022 17:44:15 +0000 (13:44 -0400)] 
CLI: Add trace format output to listing

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

2 years agoCLI: Add lttng_trace_format_descriptor to lttng_session_extended
Jonathan Rajotte [Mon, 25 Apr 2022 17:43:45 +0000 (13:43 -0400)] 
CLI: Add lttng_trace_format_descriptor to lttng_session_extended

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

2 years agoCLI: Add `--trace-format` option to `create` command
Jonathan Rajotte [Thu, 14 Apr 2022 21:50:02 +0000 (17:50 -0400)] 
CLI: Add `--trace-format` option to `create` command

TODO: doc

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

2 years agoAPI: get/set trace format descriptor for session descriptor
Jonathan Rajotte [Fri, 22 Jul 2022 18:19:28 +0000 (14:19 -0400)] 
API: get/set trace format descriptor for session descriptor

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

2 years agoLive: viewer: check trace format support based on protocol.
Jonathan Rajotte [Fri, 20 May 2022 19:49:37 +0000 (15:49 -0400)] 
Live: viewer: check trace format support based on protocol.

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

2 years agoCTF2: add to relayd supported trace format
Jonathan Rajotte [Tue, 26 Jul 2022 15:56:24 +0000 (11:56 -0400)] 
CTF2: add to relayd supported trace format

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

2 years agoAdd `--disallow-ctf2` to lttng-relayd
Jonathan Rajotte [Fri, 6 May 2022 20:39:45 +0000 (16:39 -0400)] 
Add `--disallow-ctf2` to lttng-relayd

FIXME: do we want to limit this to live?
TODO: Doc

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

2 years agorelayd: Extend relayd get configuration command to check for trace format support
Jonathan Rajotte [Fri, 6 May 2022 19:01:30 +0000 (15:01 -0400)] 
relayd: Extend relayd get configuration command to check for trace format support

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

2 years agoRefactor: pass ltt_session directly
Jonathan Rajotte [Thu, 28 Apr 2022 19:51:19 +0000 (15:51 -0400)] 
Refactor: pass ltt_session directly

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

2 years agoRefactor: split relayd socket creation and sending to consumer
Jonathan Rajotte [Thu, 28 Apr 2022 18:22:27 +0000 (14:22 -0400)] 
Refactor: split relayd socket creation and sending to consumer

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

2 years agoUse the trace format type for ust metadata generation
Jonathan Rajotte [Tue, 26 Jul 2022 20:36:34 +0000 (16:36 -0400)] 
Use the trace format type for ust metadata generation

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

2 years agoConsumer: strip ring buffer header when consuming ctf2 ring buffer packet
Jonathan Rajotte [Fri, 17 Jun 2022 21:34:46 +0000 (17:34 -0400)] 
Consumer: strip ring buffer header when consuming ctf2 ring buffer packet

On the kernel tracer side, providing a header free packet would be quite
intrusive in term of ABI/API modification. Thus for now, the kernel
tracers keeps the notion of header. On the consumer side, we can drop
the header as necessary based on the format we expect or we could even
inspect the header if necessary. For now, we chose to trust the
configured format for the session since we have access to the
information.

On the userspace side, historically the usage of a "ring buffer" for the
metadata was somewhat driven by the ctf1 "requirement" of providing
header for a given metadata packet. Essentially in ctf1 the ring buffer
packet "metadata" leaks into the actual ctf1 spec. It also happened that
the same machinery could then be reused for both the kernelspace and
userspace metadata ingestions.

CTF2 drop all this so could lttng-tools! But, considering that ctf1
still need to be supported for a while and that we still need to have
all the machinery for consuming from the kernelspace metadata
ringbuffer, keeping the current data path for both userspace and
kernelspace for metadata is probably a safer bet.

The only "drawback" here is that headers for the userspace metadata
ringbuffer contain version fields that will be equivalent to 1.8 despite
the fact that it contains ctf2 metadata. This is because the version is
currently hard coded by lttng-ust into the metadata packet headers.

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

2 years agoPropagate trace format all the way to the consumer
Jonathan Rajotte [Thu, 18 Aug 2022 20:39:37 +0000 (16:39 -0400)] 
Propagate trace format all the way to the consumer

TODO: currently we end up propagating and exposing the trace format as a
vulgar integer on lttng-consumerd side. This is one of the frontier we
discussed IRL.

TODO: use the trace format serialize and pass a complete trace format
object on the pipe

Note that this is necessary to later decide if the consumerd strips the
ringbuffer header or not based on the ctf version. As discussed IRL, ust
could be modified to expose an API allowing us to set the ctf version thus
propagating the ctf version inside the ringbuffer header and perofming
introspection at the consumer level and split based on the value. This
was simply easier to do since we have all the data available at hand.

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

2 years agoPropagate trace format to ust_app_session object
Jonathan Rajotte [Thu, 18 Aug 2022 20:38:50 +0000 (16:38 -0400)] 
Propagate trace format to ust_app_session object

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

2 years agoConvert ust_app_session to c++
Jonathan Rajotte [Thu, 18 Aug 2022 20:29:25 +0000 (16:29 -0400)] 
Convert ust_app_session to c++

This is a minimal patch to move the ust_app_session struct to c++ style.
This will allow us to add complex type in the struct later on (such
as unique_ptr/shared_ptr etc).

Use default member initialization when possible.

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

2 years agoPropagate trace format to ltt_kernel_session object
Jonathan Rajotte [Thu, 18 Aug 2022 20:32:53 +0000 (16:32 -0400)] 
Propagate trace format to ltt_kernel_session object

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

2 years agoConvert ltt_kernel_session to c++
Jonathan Rajotte [Thu, 18 Aug 2022 18:46:02 +0000 (14:46 -0400)] 
Convert ltt_kernel_session to c++

This is a minimal patch to move the ltt_kernel_session struct to c++ style.
This will allow us to add complex type in the struct later on (such
as unique_ptr/shared_ptr etc).

Use default member initialization when possible.

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

2 years agoPropagate trace format to kernel tracer
Jonathan Rajotte [Tue, 7 Jun 2022 19:50:39 +0000 (15:50 -0400)] 
Propagate trace format to kernel tracer

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

2 years agoKernel: add feature check for ctf2 based on lttng-modules ABI
Jonathan Rajotte [Wed, 27 Apr 2022 19:17:57 +0000 (15:17 -0400)] 
Kernel: add feature check for ctf2 based on lttng-modules ABI

TODO: change the actual value when actually upstreaming

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

2 years agoPropagate trace format to ltt_ust_session
Jonathan Rajotte [Thu, 14 Apr 2022 20:02:34 +0000 (16:02 -0400)] 
Propagate trace format to ltt_ust_session

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

2 years agoAdd lttng_trace_format::sptr to ltt_session
Jonathan Rajotte [Thu, 14 Apr 2022 19:57:30 +0000 (15:57 -0400)] 
Add lttng_trace_format::sptr to ltt_session

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

2 years agoAdd trace format descriptor to session descriptor
Jonathan Rajotte [Wed, 13 Apr 2022 17:49:00 +0000 (13:49 -0400)] 
Add trace format descriptor to session descriptor

Default to ctf1 for now.

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

2 years agoBase lttng_trace_format_descriptor
Jonathan Rajotte [Thu, 7 Apr 2022 17:45:34 +0000 (13:45 -0400)] 
Base lttng_trace_format_descriptor

Implements an internal lttng::trace_format_descriptor c++ based object
as the backing object for lttng_trace_format_descriptor (C API).

TODO: MI might be better off using a visitor? Config also?
      Same for serialize?

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

2 years agoConvert ltt_ust_session to c++
Jonathan Rajotte [Thu, 14 Apr 2022 20:01:25 +0000 (16:01 -0400)] 
Convert ltt_ust_session to c++

This is a minimal patch to move the ltt_ust_session struct to c++ style.
This will allow us to add complex type in the struct later on (such
as unique_ptr/shared_ptr etc).

Use default member initialization when possible.

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

2 years agoConvert ltt_session to c++
Jonathan Rajotte [Thu, 14 Apr 2022 20:01:25 +0000 (16:01 -0400)] 
Convert ltt_session to c++

This is a minimal patch to move the ltt_ust_session struct to c++ style.
This will allow us to add complex type in the struct later on (such
as unique_ptr/shared_ptr etc).

Use default member initialization when possible.

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

2 years agoBasic serialization/deserialization for lttng_session
Jonathan Rajotte [Wed, 20 Apr 2022 21:03:52 +0000 (17:03 -0400)] 
Basic serialization/deserialization for lttng_session

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

2 years agoLoad: use session descriptor for session creation
Jonathan Rajotte [Tue, 26 Apr 2022 18:40:21 +0000 (14:40 -0400)] 
Load: use session descriptor for session creation

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

2 years agoFix: missing variant choice name
Jonathan Rajotte [Wed, 3 Aug 2022 20:50:47 +0000 (16:50 -0400)] 
Fix: missing variant choice name

While running ust clock override tests:

ok 19 - Start tracing for session clock_override
ok 20 - Application done
ok 21 - Stop lttng tracing for session clock_override
ok 22 - Destroy session clock_override
08-03 16:28:19.082 996505 996505 E PLUGIN/CTF/META/PARSER yyerror@parser.ypp:927 At line 52 in metadata stream: syntax error, unexpected CTF_RBRAC: token="}"
08-03 16:28:19.082 996505 996505 E PLUGIN/CTF/CTF-1-META-STREAM-PARSER [fs] Cannot create the metadata stream AST from TSDL text: ret=1
08-03 16:28:19.083 996505 996505 E PLUGIN/SRC.CTF.FS [fs] Failed to exectute query: object=babeltrace.support-info
08-03 16:28:19.083 996505 996505 W LIB/QUERY-EXECUTOR bt_query_executor_query@query-executor.c:231 Component class's "query" method failed: query-exec-addr=0x5614fe4204a0, cc-addr=0x5614fe41b690, cc-type=SOURCE, cc-name="fs", cc-partial-descr="Read CTF traces from the file sy", cc-is-frozen=0, cc-so-handle-addr=0x5614fe4188d0, cc-so-handle-path="/usr/local/lib/babeltrace2/plugins/babeltrace-plugin-ctf.la", object="babeltrace.support-info", params-addr=0x5614fe4218b0, params-type=MAP, params-element-count=2, log-level=WARNING
08-03 16:28:19.083 996505 996505 E CLI-CFG-SRC-AUTO-DISC support_info_query_all_sources@autodisc.c:493 babeltrace.support-info query failed.
08-03 16:28:19.083 996505 996505 E CLI main@babeltrace2.c:2653 Command-line error: retcode=1

ERROR:    [Babeltrace CLI] (babeltrace2.c:2653)
  Command-line error: retcode=1
CAUSED BY [Source auto-discovery] (autodisc.c:493)
  babeltrace.support-info query failed.
CAUSED BY [libbabeltrace2] (query-executor.c:231)
  Component class's "query" method failed: query-exec-addr=0x5614fe4204a0,
  cc-addr=0x5614fe41b690, cc-type=SOURCE, cc-name="fs", cc-partial-descr="Read
  CTF traces from the file sy", cc-is-frozen=0,
  cc-so-handle-addr=0x5614fe4188d0,
  cc-so-handle-path="/usr/local/lib/babeltrace2/plugins/babeltrace-plugin-ctf.la",
  object="babeltrace.support-info", params-addr=0x5614fe4218b0, params-type=MAP,
  params-element-count=2, log-level=WARNING
CAUSED BY ['source.ctf.fs'] (fs.cpp:1598)
  Failed to exectute query: object=babeltrace.support-info
CAUSED BY ['source.ctf.fs'] (ctf-1-metadata-stream-parser.cpp:462)
  Cannot create the metadata stream AST from TSDL text: ret=1
CAUSED BY [CTF metadata parser] (parser.ypp:927)
  At line 52 in metadata stream: syntax error, unexpected CTF_RBRAC: token="}"

Cause
=====

The name of the variant choice is missing.

Solution
========

Output the field name followed by ";" as defined by the spec.

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

2 years agoFix: wrong visitor called
Jonathan Rajotte [Wed, 3 Aug 2022 14:16:30 +0000 (10:16 -0400)] 
Fix: wrong visitor called

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

2 years agoTo backpropagate: use tsdl visitor for now
Jonathan Rajotte [Wed, 17 Aug 2022 21:29:35 +0000 (17:29 -0400)] 
To backpropagate: use tsdl visitor for now

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

2 years agoUse the parsed URI instead of raw string for override
Jonathan Rajotte [Tue, 26 Apr 2022 18:33:52 +0000 (14:33 -0400)] 
Use the parsed URI instead of raw string for override

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

2 years agoJGALAR CTF2 HEAD
Jonathan Rajotte [Tue, 26 Jul 2022 21:10:57 +0000 (17:10 -0400)] 
JGALAR CTF2 HEAD

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

2 years agosessiond: add a CTF 2-generating trace class visitor
Jérémie Galarneau [Mon, 4 Jul 2022 19:19:00 +0000 (15:19 -0400)] 
sessiond: add a CTF 2-generating trace class visitor

The enumeration_type class is modified to guarantee that a mapping is
present. Implicit (or auto) mappings provided by the tracer are
converted to an explicit mapping.

This results in a slightly more verbose TSDL output which can be fixed
later.

Change-Id: I4372ad528384c1b7d9321dd5183525e3bd60ded4
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agosessiond: add variant selector intervals
Jérémie Galarneau [Tue, 26 Jul 2022 21:06:30 +0000 (17:06 -0400)] 
sessiond: add variant selector intervals

In CTF 2, variant options are chosen using a set of ranges. This differs
from CTF 1.8 (and the current API) which assumed that a variant had
options that perfectly matched the selector enumeration's mappings.

Add integer mappings to variants and also carry a choice name that
becomes the name used by the TSDL producer.

Change-Id: Ib31cf9cc211dad36759bd73dc722c49d634c666b
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agosessiond: validate existence of field reference received from LTTng-UST
Jérémie Galarneau [Tue, 26 Jul 2022 22:34:44 +0000 (18:34 -0400)] 
sessiond: validate existence of field reference received from LTTng-UST

Some field descriptions received from traced applications refer to
other fields (a sequence's length field, a variant's selector field,
etc.)

Validate that those references are valid.

Change-Id: I73f5b464b007810beb228128d5bc3243e3b05157
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agosessiond: express field references as locations instead of names
Jérémie Galarneau [Tue, 26 Jul 2022 19:17:20 +0000 (15:17 -0400)] 
sessiond: express field references as locations instead of names

CTF2 requires type references (a sequence's length, a variant's
selector) to be expressed as absolute field locations.

The `field` API currently expresses these references as names directly
since those are provided by the tracer.

This change introduces the notion of a field location and adapts
the tsdl visitor to serialize those as expected.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I56f603062d6748051adf3fa31bc08422c47c144d

2 years agosessiond: return raw pointer to packet header
Jérémie Galarneau [Thu, 21 Jul 2022 19:41:43 +0000 (15:41 -0400)] 
sessiond: return raw pointer to packet header

There is no benefit to transfering the ownership of a new packet header
everytime it is serialized. Packet headers don't change after the
creation of a session; prefer allocating it once and provide a
raw (const) pointer to the session's instance.

While LTTng always produces one, a trace doesn't absolutely need a
packet header so a pointer is preferred over a reference.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I66b8f9ad74e332edcc8273c076137a7fff0d4d5e

2 years agosessiond: tsdl: remove useless std::move
Jérémie Galarneau [Wed, 13 Jul 2022 21:14:01 +0000 (17:14 -0400)] 
sessiond: tsdl: remove useless std::move

append_metadata_fragment accepts the string by reference and it is
passed as such all the way; there is no need for an ownership transfer.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I49baab00c333b97f0dde49bad34fee43e7e40a2b

2 years agosessiond: generate packet header, packet context and event header dynamically
Jérémie Galarneau [Thu, 7 Jul 2022 16:20:33 +0000 (12:20 -0400)] 
sessiond: generate packet header, packet context and event header dynamically

Instead of hardcoding event header and packet header/context layouts,
their layout is expressed using the lttng::sessiond::trace::field/type
API and serialized to TSDL using the visitor.

This reduces the duplication of code in the CTF2 visitor.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I9a4255889e36e6861a59536ce70b1e708da06ac5

2 years agoFix: sessiond: tsdl: don't prepend underscore for stream_id
Jérémie Galarneau [Mon, 11 Jul 2022 19:48:49 +0000 (15:48 -0400)] 
Fix: sessiond: tsdl: don't prepend underscore for stream_id

Although the CTF v1.8 specification recommends ignoring any leading
underscore, Some readers, such as Babeltrace 1.x, expect special
identifiers without a prepended underscore.

This causes problems in a follow-up patch since packet header, context,
and event headers become dynamically generated.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I0aeb24ab2e1c0ee1ea70d2fb9bb0eabbb2e9e035

2 years agosessiond: field: add field roles and blob types
Jérémie Galarneau [Mon, 4 Jul 2022 19:00:25 +0000 (15:00 -0400)] 
sessiond: field: add field roles and blob types

Extend the field/field type to include the blob field types that
are used to express the trace class uuid in CTF2.

Roles defined by the CTF2 specification are also added to allow a trace
class to define the layout of some scopes (e.g. packet header and
context) instead of hard-coding the serialized version of the layout
description.

The TSDL trace class visitor takes the new types into account by
converting them into arrays of "bytes" (uint8_t).

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ic9d976416ed765b157e951bf9b8b299abbe20e5b

2 years agoAdd nlohmann/json 3.10.5 to vendor libraries
Jérémie Galarneau [Mon, 13 Jun 2022 18:43:22 +0000 (14:43 -0400)] 
Add nlohmann/json 3.10.5 to vendor libraries

JSON is released under the MIT license. The MIT license text is already
under LICENCES.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I1aab2c0af7e71248a8ce8b10240daf191d057e09

2 years agoTests: size-based rotation: implement a trace size cutoff protection
Jérémie Galarneau [Tue, 5 Jul 2022 20:43:26 +0000 (16:43 -0400)] 
Tests: size-based rotation: implement a trace size cutoff protection

Stop waiting for rotations when the trace exceeds a certain size cutoff.
This prevents those tests from filling a hard drive when they fail.

However, this check is racy since it is possible for an arbitrary number
of apps to run before the session daemon gets a chance to perform the
scheduled rotations.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I465462e6f1d5c17ada2b3aceb68662d8663254eb

2 years agoFix: sessiond: handle empty scheduled rotations
Jérémie Galarneau [Wed, 6 Jul 2022 16:09:41 +0000 (12:09 -0400)] 
Fix: sessiond: handle empty scheduled rotations

A number of error codes were added to cmd_rotate_session since the
implementation of size-based rotations. The rotation thread doesn't
expect LTTNG_ERR_ROTATION_MULTIPLE_AFTER_STOP and
LTTNG_ERR_ROTATION_AFTER_STOP_CLEAR which are not fatal failures.

These rotations would simply result in an empty trace archive and are,
therefore, not produced. In both cases, it is safe to wait for the next
size cycle.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ib90526b586de17c0b14d16970c862d9f981ed464

2 years agoClean-up: sessiond: remove left-over code
Jérémie Galarneau [Tue, 5 Jul 2022 22:31:15 +0000 (18:31 -0400)] 
Clean-up: sessiond: remove left-over code

ust_metadata_channel_statedump no longer exists and _metadata_dumped
is unused.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I2fa3f3bcb8d1c5a779ab1cfa0375174b479ed21f

2 years agoTests: rotation: add a kernel size-based rotation test
Jérémie Galarneau [Wed, 22 Jun 2022 19:05:55 +0000 (15:05 -0400)] 
Tests: rotation: add a kernel size-based rotation test

Change-Id: I035814dcbe5e74227f907bae300eacffd132d80f
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agoTests: rotation: add a per-pid size-based rotation test
Jérémie Galarneau [Wed, 22 Jun 2022 17:52:43 +0000 (13:52 -0400)] 
Tests: rotation: add a per-pid size-based rotation test

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I8f6875567d52dd7d28000ff34fff47f992cdab3f

2 years agoTests: add a local size-based rotation test in per-uid buffering mode
Jérémie Galarneau [Tue, 21 Jun 2022 04:42:34 +0000 (00:42 -0400)] 
Tests: add a local size-based rotation test in per-uid buffering mode

This test runs an application up until we observe four archived traces.
Unfortunately, we can't validate their size since they are approximative.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Iecdbf3ee33ed02745a99e7af22c0645b4375413e

2 years agoFix: sessiond: report client list allocation failure as a fatal error
Jérémie Galarneau [Thu, 30 Jun 2022 16:03:23 +0000 (12:03 -0400)] 
Fix: sessiond: report client list allocation failure as a fatal error

Report the failure to allocate a notification client list as a fatal
notification thread error.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I8f2654020d0d890cc9275d445fdeccde940d2ae0

2 years agoFix: leak of channel-bound trigger list element
Jérémie Galarneau [Wed, 29 Jun 2022 20:37:54 +0000 (16:37 -0400)] 
Fix: leak of channel-bound trigger list element

The list element is never free'd when a channel-bound trigger
is unregistered.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I32c4ee4512c460363e3384c2e3aac9feff4343b1

2 years agoFix: sessiond: size-based rotation threshold exceeded in per-pid tracing (2/2)
Jérémie Galarneau [Tue, 28 Jun 2022 03:36:22 +0000 (23:36 -0400)] 
Fix: sessiond: size-based rotation threshold exceeded in per-pid tracing (2/2)

For a complete description of the original problem, refer to the previous
commit.

This change implements the second part of the fix.

Buffer statistic samples are augmented to include the channel's session
id. Since a session can outlive its channels (on the session daemon
side), the consumed size conditions are now bound to the session.

This means that the "total consumed" state is now part of the
session_info structure exclusively which, overall, is cleaner.

A side-effect of this change is that consumed size conditions are now
also evaluated when a trigger is registered or when a client subscribes
to it via a notification channel instead of waiting until the next
monitoring sample.

The buffer statistics sample also expresses a "consumed size" that is
relative to the last sample that was successfully sent.

Finally, the consumer daemon sends a final buffer statistics sample when
a channel is torn down. As explained in more detail in the previous
commit, this makes the accounting of per-pid sessions more reliable when
short-live applications are traced.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I322b9f20977e59c63cf2a4254c97c4ee657e933e

2 years agoFix: sessiond: size-based rotation threshold exceeded in per-pid tracing (1/2)
Jérémie Galarneau [Mon, 27 Jun 2022 16:01:48 +0000 (12:01 -0400)] 
Fix: sessiond: size-based rotation threshold exceeded in per-pid tracing (1/2)

Issue observed
--------------

When tracing short-lived applications with buffers configured in per-pid
mode, the size-based rotation threshold is often greatly exceeded. In
the CI, this occasionally causes the size-based rotation tests to
timeout for the per-pid case.

Cause
-----

There is a scenario where a session's consumed size is miscalculated.

When an application exits during per-pid tracing, both the session and
consumer daemons notice it. The session daemon sees the application's
command pipe hanging-up, while the consumer daemon sees the
application's data-ready pipe hanging-up.

Upon handling these events, both daemons tear down their representation of
the channels.

In an ideal world, we'd want to sample the streams' "consumed_size" at
the last possible moment to get the size of all consumed data for this
stream. However, this is problematic in the following scenario:
  - the sessiond destroys the channel before the consumer daemon,
  - the consumer daemon sends a final buffer stats sample on tear down,
  - the sessiond can do nothing with the sample as it doesn't know that
    channel anymore.

(Note that the session daemon gracefully handles the case where it
doesn't know a channel.)

When applications have a short lifetime and are traced in per-PID
buffering mode, there is a high likelihood that the last buffer
statistics sample sent for a given channel will target a channel that
the session daemon has already torn down.

Solution
--------

Consumed-size conditions are somewhat special: they are bound to a
session, but they are evaluated through a per-channel event (buffer
statistics samples taken by the channels' monitoring timer).

To work around the problem of lifetime of channels, we can rely
on the fact that sessions outlive channels to perform the accounting
of the consumed size.

This patch is the first step to implement this fix: new
notification-thread commands are introduced to announce the creation and
destruction of an `ltt_session`. Currently, the notification thread
implies the existence of a session by tracking its channels' creation
and destruction.

With this change, it no longer needs to do so; session are explicitly
created and destroyed. Their unique ID is also kept stored.

The key of `sessions_ht` becomes the `id` of the session to allow
efficient look-ups on the reception of a buffer statistics sample.

The existing callsites that make use of the session's name to perform a
look-up are modified to look-up the id by name (see
sample_session_id_by_name()).

The add/remove channel commands and rotation ongoing/completed commands
are modified to refer to sessions by ID since they can assume the
notification thread knows about the session.

Note
----

In a follow-up patch, buffer statistics samples are modified to include
the session's ID and the consumed size is modified to become a "delta"
relative to the previous sample associated with a given channel.

This makes it possible to perform the accounting of a session's consumed
size beyond the lifetime of its channels.

The follow-up patch is the "core" of the fix, but it requires these
prior changes.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I865e9ac5e1a63e62123209be63957dad28c588a8

2 years agoconsumerd: send a buffer static sample on flush command
Jérémie Galarneau [Tue, 21 Jun 2022 20:56:23 +0000 (16:56 -0400)] 
consumerd: send a buffer static sample on flush command

When application exits during per-pid tracing, both the session and
consumer daemons notice it. The session daemon sees the application's
command pipe hanging-up, while the consumer daemon sees the
application's data-ready pipe hanging-up.

Upon handling this event, both daemons tear down their representation of
the channels.

In an ideal world, we'd want to sample the streams' "consumed_size" at the
last possible moment to get the size of all consumed data for this
stream. However, this is problematic in the following scenario:
  - the sessiond destroys the channel before the consumer daemon,
  - the consumer daemon sends a final buffer stats sample on tear down,
  - the sessiond can do nothing with the sample as it doesn't know that
    channel anymore.

Note that the session daemon handles the case where it doesn't know a
channel gracefully.

When an application being traced in per-pid mode is torn down, the
session requests a flush of its buffers to the consumer daemon. We can
use this opportunity to emit a buffer stats sample.

This is still racy since the tear down of the channel could complete on
the session daemon's end before that last sample can be processed. In
practice, though, it markedly improves the precision of size-based
rotations in per-pid tracing mode.

On my work machine, I see the size-based rotation tests pass with
archive sizes within ~10% of the size threshold. Before this, we lost a
lot of samples from short-lived buffers and it would not be rare to see
archives end-up multiple times (5x-10x) larger than the size-threshold.

Another problem is that the consumed_size returned by the consumer
daemon will not include the packets that have yet to be consumed.

Whether or not this is a fix is debatable since it arguably just
improves the precision of size-based rotations.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I8a72328ba1733ac2f50c77a1ff81d7a6aaac095c

2 years agoconsumerd: rename `data_read` to `has_data_left_to_be_read_before_teardown`
Jérémie Galarneau [Tue, 21 Jun 2022 20:46:29 +0000 (16:46 -0400)] 
consumerd: rename `data_read` to `has_data_left_to_be_read_before_teardown`

Document the sequence of events after a stream hangs up and rename
the `data_read` stream attribute to give it a more specific name.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Id7d26fa04fc0d2f0875dced18b6a3f6a7fe7d139

2 years agoFix: ust-consumerd: set `hangup_flush_done` in a locked context
Jérémie Galarneau [Tue, 21 Jun 2022 20:21:17 +0000 (16:21 -0400)] 
Fix: ust-consumerd: set `hangup_flush_done` in a locked context

hangup_flush_done is updated after releasing the stream lock. This
doesn't appear to be a problem right now since this attribute is
apparently always accessed by the same thread, but it is conceptually
sus.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I191cb01b02c3d96e19034e0d0e80cb7f8dff2140

2 years agoFix: sessiond: size-based rotations never trigger
Jérémie Galarneau [Fri, 17 Jun 2022 20:53:53 +0000 (16:53 -0400)] 
Fix: sessiond: size-based rotations never trigger

Issue observed
==============

Size-based scheduled rotations have no effect.

Cause
=====

Since c08136a3f, the rotation thread's handle_condition() checks that
the notification received matches the trigger that was registered.

As part of the equality check, the triggers' credentials are compared.

This checks fails systematically since the group id of a trigger's
credentials is not transported by the serialize/create_from functions.
The trigger that is received through the notification thus has an unset
group id, while the rotation trigger of the `ltt_session` has a group id
set; it was not stripped by the communication layer.

The check also fails since the trigger registered for the size-based
rotation is "hidden". This internal attribute is not propagated through
the communication layer, which causes the comparison to fail.

Solution
========

Since triggers only use the 'uid' part of lttng_credentials, we ensure
that lttng_trigger_set_credentials only sets this part of the structure.

Also, the `is_hidden` attribute of a trigger is now propagated through
the communication layer. This has no effect for external applications
since this attribute is not exposed through the API. However, it is
useful for internal triggers which use the same communication
facilities.

This allows the equality check in rotation-thread.cpp to go through as
expected.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I216f5cb9297ecd1a867dc292c10b8da595efce34

2 years agoBump URCU dependency to 0.14
Michael Jeanson [Tue, 12 Apr 2022 20:55:50 +0000 (16:55 -0400)] 
Bump URCU dependency to 0.14

Complete C++ support was introduced in Userspace-RCU 0.14, using earlier
versions results in a build failure, this should be reflected in the
configure check.

Change-Id: I1b708bd9b04784deb9f2c8768a331911c3ebb891
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agoBuild fix: missing initializer for member 'payload'
Jérémie Galarneau [Thu, 16 Jun 2022 21:36:41 +0000 (17:36 -0400)] 
Build fix: missing initializer for member 'payload'

gcc 5.4.0 complains that:
channel.cpp:584:2: warning: missing initializer for member 'lttng_notification_channel_message::payload' [-Wmissing-field-initializers]

The structure's members are initialized one by one.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ia5a5f37f6fe6977169771e4a298d1ce73ab74ea4

2 years agoBuild fix: missing initializer for member 'override_name'
Jérémie Galarneau [Thu, 16 Jun 2022 21:36:41 +0000 (17:36 -0400)] 
Build fix: missing initializer for member 'override_name'

gcc 5.4.0 complains that:
relayd/relayd.cpp:1353:2: warning: missing initializer for member 'lttcomm_relayd_create_trace_chunk::override_name' [-Wmissing-field-initializers]

The structure's members are initialized one by one.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I6607c46e4aa98017183f41fc8be9b0226b70cf29

2 years agoBuild fix: missing initializer for member 'rotate_positions'
Jérémie Galarneau [Thu, 16 Jun 2022 21:36:41 +0000 (17:36 -0400)] 
Build fix: missing initializer for member 'rotate_positions'

gcc 5.4.0 complains that:
relayd/relayd.cpp:1221:2: warning: missing initializer for member 'lttcomm_relayd_rotate_streams::rotation_positions' [-Wmissing-field-initializers]

The structure's members are initialized one by one.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: If0ecd9c9b2c5a0861463e93a2a52b0d2b3a36712

2 years agoBuild fix: missing initializer for member 'payload'
Jérémie Galarneau [Thu, 16 Jun 2022 21:36:41 +0000 (17:36 -0400)] 
Build fix: missing initializer for member 'payload'

gcc 5.4.0 complains that:
notification.cpp:43:57: warning: missing initializer for member 'lttng_notification_comm::payload' [-Wmissing-field-initializers]

The structure's members are initialized one by one.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Iebb2f14df21f6db9dceaf708af6ef12efda1b929

2 years agoBuild fix: missing initializer for member 'payload'
Jérémie Galarneau [Thu, 16 Jun 2022 21:36:41 +0000 (17:36 -0400)] 
Build fix: missing initializer for member 'payload'

gcc 5.4.0 complains that:
event.cpp:1238:53: warning: missing initializer for member 'lttng_event_context_comm::payload' [-Wmissing-field-initializers]

The structure's members are initialized one by one.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Id7c01cd19cbf884efd16734239cae8476b798c20

2 years agoBuild fix: missing initializer for member 'payload'
Jérémie Galarneau [Thu, 16 Jun 2022 21:36:41 +0000 (17:36 -0400)] 
Build fix: missing initializer for member 'payload'

gcc 5.4.0 complains that:
event.cpp:769:3: warning: missing initializer for member 'lttng_event_exclusion_comm::payload' [-Wmissing-field-initializers]

The structure's members are initialized one by one.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I22ccd0c84669951f6e0a13663e47b1d2a204d3a8

2 years agoBuild fix: missing initializer for member 'payload'
Jérémie Galarneau [Thu, 16 Jun 2022 21:36:41 +0000 (17:36 -0400)] 
Build fix: missing initializer for member 'payload'

gcc 5.4.0 complains that:
event.cpp:769:3: warning: missing initializer for member 'lttng_event_exclusion_comm::payload' [-Wmissing-field-initializers]

The structure's members are initialized one by one.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Iac3eedff2d79843c910b4da5edec4d7f10fa062a

2 years agoBuild fix: missing initializer for member 'payload'
Jérémie Galarneau [Thu, 16 Jun 2022 21:36:41 +0000 (17:36 -0400)] 
Build fix: missing initializer for member 'payload'

gcc 5.4.0 complains that:
error-query.cpp:777:2: warning: missing initializer for member '{anonymous}::lttng_error_query_comm::payload' [-Wmissing-field-initializers]

The structure's members are initialized one by one.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I1264bc2da7e8ff6ec6c740341a381b33bae643d1

2 years agoBuild fix: missing initializer for member 'payload'
Jérémie Galarneau [Thu, 16 Jun 2022 21:36:41 +0000 (17:36 -0400)] 
Build fix: missing initializer for member 'payload'

gcc 5.4.0 complains that:
error-query.cpp:570:2: warning: missing initializer for member '{anonymous}::lttng_error_query_results_comm::payload' [-Wmissing-field-initializers]

The structure's members are initialized one by one.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ib1a297eaf2fd75b908573ac252b433a14423add5

2 years agoBuild fix: missing initializer for member 'payload'
Jérémie Galarneau [Thu, 16 Jun 2022 21:36:41 +0000 (17:36 -0400)] 
Build fix: missing initializer for member 'payload'

gcc 5.4.0 complains that:
error-query.cpp:318:2: warning: missing initializer for member '{anonymous}::lttng_error_query_result_comm::payload' [-Wmissing-field-initializers]

The structure's members are initialized one by one.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ie194864415bc3bc32bda6b2ac17150bd3f163394

2 years agoBuild fix: missing initializer for member 'payload'
Jérémie Galarneau [Thu, 16 Jun 2022 21:36:41 +0000 (17:36 -0400)] 
Build fix: missing initializer for member 'payload'

gcc 5.4.0 complains that:
evaluation.cpp:30:2: warning: missing initializer for member 'lttng_evaluation_comm::payload' [-Wmissing-field-initializers]

The structure's members are initialized one by one.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I2784138b00af34b2bc47ed28097ab32afaa379d2

2 years agoBuild fix: missing initializer for member 'indexes'
Jérémie Galarneau [Thu, 16 Jun 2022 21:36:41 +0000 (17:36 -0400)] 
Build fix: missing initializer for member 'indexes'

gcc 5.4.0 complains that:
actions/path.cpp:191:7: warning: missing initializer for member '{anonymous}::lttng_action_path_comm::indexes' [-Wmissing-field-initializers]

The structure's members are initialized one by one.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I3b365e89c6a11cf65f609a4e14ae972faa2a518d

2 years agoBuild fix: missing initializer for member 'payload'
Jérémie Galarneau [Thu, 16 Jun 2022 21:36:41 +0000 (17:36 -0400)] 
Build fix: missing initializer for member 'payload'

gcc 5.4.0 complains that:
notification-thread-events.cpp:3755:2: warning: missing initializer for member 'lttng_notification_channel_message::payload' [-Wmissing-field-initializers]

The structure's members are initialized one by one.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I4e3f32da956764cd9beba6f4c72cfc48251b8203

2 years agoBuild fix: missing initializer for member 'rotation_positions'
Jérémie Galarneau [Thu, 16 Jun 2022 21:31:20 +0000 (17:31 -0400)] 
Build fix: missing initializer for member 'rotation_positions'

gcc 5.4.0 complains that:
  main.cpp: In function 'ssize_t relay_unpack_rotate_streams_header(const lttng_buffer_view*, lttcomm_relayd_rotate_streams*)':
  main.cpp:2547:2: warning: missing initializer for member 'lttcomm_relayd_rotate_streams::rotation_positions' [-Wmissing-field-initializers]

The structure's members are initialized one by one.

At the same time, the use of the address of a packed
member (stream_count) is eliminated, which fixes another unrelated
warning emited by clang.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I5fd90d75cc6e0ba17350fc8092929f476e93757e

2 years agoBuild fix: specialization of template in different namespace
Jonathan Rajotte [Wed, 15 Jun 2022 19:09:03 +0000 (15:09 -0400)] 
Build fix: specialization of template in different namespace

Observed issue
==============

On older g++, such as gcc (Ubuntu 5.3.1-14ubuntu2) 5.3.1 20160413:

make[3]: Entering directory '/tmp/virtenv/src/lttng-tools/src/bin/lttng-sessiond'
  CXX      utils.lo
In file included from ust-app.hpp:15:0,
                 from lttng-sessiond.hpp:22,
                 from utils.cpp:17:
../../../src/common/format.hpp:17:24: warning: unknown option after '#pragma GCC diagnostic' kind [-Wpragmas]
 DIAGNOSTIC_IGNORE_DUPLICATED_BRANCHES
                        ^
In file included from ust-app.hpp:15:0,
                 from lttng-sessiond.hpp:22,
                 from utils.cpp:17:
../../../src/common/format.hpp:23:13: error: specialization of 'template<class T, class Char, class Enable> struct fmt::v8::formatter' in different namespace [-fpermissive]
 struct fmt::formatter<std::type_info> : fmt::formatter<std::string> {
             ^
In file included from ../../../src/common/format.hpp:19:0,
                 from ust-app.hpp:15,
                 from lttng-sessiond.hpp:22,
                 from utils.cpp:17:
../../../src/vendor/fmt/core.h:707:8: error:   from definition of 'template<class T, class Char, class Enable> struct fmt::v8::formatter' [-fpermissive]
 struct formatter {
        ^
In file included from ust-registry.hpp:20:0,
                 from ust-app.hpp:19,
                 from lttng-sessiond.hpp:22,
                 from utils.cpp:17:
ust-registry-event.hpp:66:13: error: specialization of 'template<class T, class Char, class Enable> struct fmt::v8::formatter' in different namespace [-fpermissive]
 struct fmt::formatter<lttng::sessiond::ust::registry_event> : fmt::formatter<std::string> {
             ^
In file included from ../../../src/common/format.hpp:19:0,
                 from ust-app.hpp:15,
                 from lttng-sessiond.hpp:22,
                 from utils.cpp:17:
../../../src/vendor/fmt/core.h:707:8: error:   from definition of 'template<class T, class Char, class Enable> struct fmt::v8::formatter' [-fpermissive]
 struct formatter {
        ^
In file included from ust-app.hpp:19:0,
                 from lttng-sessiond.hpp:22,
                 from utils.cpp:17:
ust-registry.hpp: In constructor 'lttng::sessiond::ust::registry_typed_enum<MappingIntegerType>::registry_typed_enum(const char*, const lttng_ust_ctl_enum_entry*, size_t)':
ust-registry.hpp:111:45: error: 'lttng::sessiond::trace::integer_type::signedness' is not a class, namespace, or enumeration
       lttng::sessiond::trace::integer_type::signedness::SIGNED :
                                             ^
ust-registry.hpp:112:51: error: 'lttng::sessiond::trace::integer_type::signedness' is not a class, namespace, or enumeration
             lttng::sessiond::trace::integer_type::signedness::UNSIGNED),
                                                   ^
In file included from lttng-sessiond.hpp:22:0,
                 from utils.cpp:17:
ust-app.hpp: At global scope:
ust-app.hpp:330:13: error: specialization of 'template<class T, class Char, class Enable> struct fmt::v8::formatter' in different namespace [-fpermissive]
 struct fmt::formatter<ust_app> : fmt::formatter<std::string> {
             ^
In file included from ../../../src/common/format.hpp:19:0,
                 from ust-app.hpp:15,
                 from lttng-sessiond.hpp:22,
                 from utils.cpp:17:
../../../src/vendor/fmt/core.h:707:8: error:   from definition of 'template<class T, class Char, class Enable> struct fmt::v8::formatter' [-fpermissive]
 struct formatter {
        ^
cc1plus: warning: unrecognized command line option '-Wno-gnu-folding-constant'
cc1plus: warning: unrecognized command line option '-Wno-incomplete-setjmp-declaration'
Makefile:855: recipe for target 'utils.lo' failed
make[3]: *** [utils.lo] Error 1

This also applies to the following specializations:
  void lst::signed_enumeration_type::accept(type_visitor& visitor) const
  void lst::unsigned_enumeration_type::accept(type_visitor& visitor) const

Problem
=======

This is due to a now-fixed gcc bug:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=42018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480

Solution
========

Put the template specializations inside the proper namespace.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I6b931065b37e6e9ba97f87c754c15808506c2ba8

2 years agoBuild fix: old gcc does not recognize hidden/shadowed enumeration as valid
Jérémie Galarneau [Wed, 15 Jun 2022 20:09:05 +0000 (16:09 -0400)] 
Build fix: old gcc does not recognize hidden/shadowed enumeration as valid

The build fails on GCC < 6 with:

ust-registry.hpp: In constructor 'lttng::sessiond::ust::registry_typed_enum<MappingIntegerType>::registry_typed_enum(const char*, const lttng_ust_ctl_enum_entry*, size_t)':
ust-registry.hpp:111:45: error: 'lttng::sessiond::trace::integer_type::signedness' is not a class, namespace, or enumeration
       lttng::sessiond::trace::integer_type::signedness::SIGNED :

The same error occurs for stream_class::header_type.

This is due to a bug fixed in gcc 6:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60994

In both cases, the member is suffixed to disambiguate the reference to
the inner-enumeration.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Id0f2f98a147be589b9c70740660c7fb911dfc22c

2 years agoBuild fix: unknown warning -Wduplicated-branches
Jérémie Galarneau [Wed, 15 Jun 2022 19:00:35 +0000 (15:00 -0400)] 
Build fix: unknown warning -Wduplicated-branches

-Wduplicated-branches was introduced in GCC 7. Only define
DIAGNOSTIC_IGNORE_DUPLICATED_BRANCHES for those more recent versions.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I3b50a671867a74629519375801bf2b4f3c597cd8

2 years agoFix: pthread::mutex unlock must not throw
Jérémie Galarneau [Tue, 14 Jun 2022 16:11:54 +0000 (12:11 -0400)] 
Fix: pthread::mutex unlock must not throw

unlock() is often called by destructors (e.g. lock guard); it must not
throw. We don't expect unlock to fail given our current usage anyhow.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I5dfd856f8a2dd29fd7c480c6ab6289b5b91c4391

2 years agoClean-up: common: uuid: uninitialized output parameter on error
Jérémie Galarneau [Tue, 14 Jun 2022 16:04:07 +0000 (12:04 -0400)] 
Clean-up: common: uuid: uninitialized output parameter on error

1490018 Uninitialized scalar variable
The variable will contain an arbitrary value left from earlier
computations.

In lttng_uuid_from_str(char const *, std::​array<unsigned char, 16ul> &):
Use of an uninitialized variable (CWE-457)

Callers should not use the return parameter anyhow on error.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Idd863d219da840a0c291478733f7b931967a5e56

2 years agoFix: sessiond: registry_channel: initialize _rcu_head and _node
Jérémie Galarneau [Tue, 14 Jun 2022 16:01:22 +0000 (12:01 -0400)] 
Fix: sessiond: registry_channel: initialize _rcu_head and _node

1490020 Uninitialized pointer field
The pointer field will point to an arbitrary memory location, any
attempt to write may cause corruption.

In lttng::​sessiond::​ust::​registry_channel::​registry_channel(unsigned int, std::​function<void (lttng::​sessiond::​ust::​registry_channel const &)>, std::​function<void (lttng::​sessiond::​ust::​registry_channel const &, lttng::​sessiond::​ust::​registry_event const &)>): A pointer field is not initialized in the constructor (CWE-457)

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ie043af750941a02a65ba69e70fe2620349989398

2 years agosessiond: registry_event: remove lttng_ht_node_u64 wrapper
Jérémie Galarneau [Tue, 14 Jun 2022 15:56:51 +0000 (11:56 -0400)] 
sessiond: registry_event: remove lttng_ht_node_u64 wrapper

Use rcu_head and cds_lfht_node directly since the lttng_ht_node_u64
utils is unused anyhow: its key is never initialized.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Id8b8d4b2f9ca9137b859844bc70e9d02e9fa2975

2 years agoTests: test_uuid: unchecked return value
Jérémie Galarneau [Tue, 14 Jun 2022 14:56:35 +0000 (10:56 -0400)] 
Tests: test_uuid: unchecked return value

1490026 Unchecked return value
If the function returns an error value, the error value may be mistaken
for a normal value.

In run_test_lttng_uuid_is_equal(): Value returned from a function is not
checked for errors before being used (CWE-252)

Reported-by: Coverity Scan
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Id9558a07ebcc47f5630deed32f5a457ba002bfe6

2 years agoFix: common: uninitialized lttng::ctl:error field
Jérémie Galarneau [Tue, 14 Jun 2022 14:54:09 +0000 (10:54 -0400)] 
Fix: common: uninitialized lttng::ctl:error field

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I456d1811c3827472533d0531af7148ee6e7eb34b

2 years agocommon: replace container_of with a C++ safe implementation
Jérémie Galarneau [Fri, 10 Jun 2022 19:10:32 +0000 (15:10 -0400)] 
common: replace container_of with a C++ safe implementation

As more code moves to a more idiomatic C++ style, structures like
typically end up becoming classes that use different access controls,
virtual functions, etc. This, in turn, makes them adopt a non standard
layout and causes GCC and clang to emit the following warning when
container_of is used:

error: 'offsetof' within non-standard-layout type 'foo' is conditionally-supported [-Werror=invalid-offsetof]

This new implementation of container_of makes use of a pointer to a data
member to find the parent's address.

The use of ptr_to_member against the null dummy_parent makes me uneasy
as it seems equivalent to performing arithmetic on a null pointer, which
I understand is undefined behavior (C++11 Standard 5.7.5).

However, Boost.Instrusive uses an approach that seems roughly equivalent
to lttng::utils::container_of() [1].

It seems like a reasonable compromise that works on all mainstream
compilers.

[1] https://github.com/boostorg/intrusive/blob/3c5c8cec3f0356a028a4b56ba6cac2256340dab1/include/boost/intrusive/detail/parent_from_member.hpp#L92

Change-Id: Ia6287e1648bce85dfe6de936f17ec5df46ea648d
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agosessiond: registry_session: mark functions as noexcept
Jérémie Galarneau [Thu, 9 Jun 2022 16:16:39 +0000 (12:16 -0400)] 
sessiond: registry_session: mark functions as noexcept

Mark functions destroy_channel and _destroy_enum as noexcept as they are
used by the registry_session destructor (which must not throw).

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ie7bbbf349f14f5691b52873fe8ba6556be143d93

2 years agoClean-up: sessiond: move registry_session free functions under class
Jérémie Galarneau [Wed, 8 Jun 2022 19:50:07 +0000 (15:50 -0400)] 
Clean-up: sessiond: move registry_session free functions under class

Move a number of registry_session methods implemented as c-style
free functions under the `registry_session` class. This makes it
possible to make a large number of attributes private.

This leaves only the metadata storage and locking facilities
publicly accessible. Making them private requires a bit more
refactoring.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I6bdd4cc8918e5d7025fc3d735fadbf1ce2e9b7c8

2 years agoClean-up: sessiond: move ust_registry_session under lttng::sessiond::ust
Jérémie Galarneau [Wed, 8 Jun 2022 17:10:26 +0000 (13:10 -0400)] 
Clean-up: sessiond: move ust_registry_session under lttng::sessiond::ust

The ust_registry_session* class hierarchy is namespaced under
lttng::sessiond::ust.

The registry session classes are also moved to their own headers.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I3be5aa3239bbff9b385ab942f749748b4d6cb352

2 years agosessiond: transition from lttng-ust to tracer agnostic API
Jérémie Galarneau [Mon, 13 Jun 2022 16:01:21 +0000 (12:01 -0400)] 
sessiond: transition from lttng-ust to tracer agnostic API

Refactor the session daemon's user space tracer management to use the
tracer-agnostic trace hierarchy description API. Since the API
introduced under lttng::sessiond::trace is closer to idiomatic C++,
some changes are needed to make use of it.

The biggest changes make the ust_registry* structures inherit from the
trace descriptions classes (trace_class, stream_class, event_class,
clock_class). This effectively isolates the members of the
`ust_registry` structures that describe their corresponding CTF class
to a base class and leaves only the implementation guts in the
`ust_registry` objects (moved under lttng::sessiond::ust).

Since the generation of TSDL metadata directly used the lttng_ust_ctl
API, it is replaced by a new implementation that is based around a trace
class visitor that serializes the tracer agnostic trace description
objects.

The TSDL environment visitor is moved under the TSDL implementation
of the trace class visitor.

Some little changes are also made to the existing code to make it
exception-safe, as needed.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I6562ef12e85afa91780337e8c6fdbb13568d9ece

2 years agosessiond: add tracer-agnostic trace hierarchy classes
Jérémie Galarneau [Thu, 12 May 2022 18:34:30 +0000 (14:34 -0400)] 
sessiond: add tracer-agnostic trace hierarchy classes

The session daemon receives the fields present in events from the
instrumented applications in the form of an array of lttng_ust_ctl_field
structures and uses them directly in a number of code paths.

This makes it impossible to extend the structures which makes a number of
features harder to implement than they should be.

The session daemon also implements various CTF concepts (clock, trace,
event, stream classes) as part of various structures defined under
`ust_registry*`. This makes it hard to isolate which attributes are
"internal" and which are visible to the external world through the
traces.

Tracer-agnostic trace hierachy classes are introduced under the
lttng::sessiond::trace namespace. Those classes don't cover the full
functionality of CTF: they expose what the tracers can currently
express.

The top-level elements of the trace hierarchy -- trace, event, stream,
clock classes -- are visited using the trace_class_visitor interface.

Seperate field and type visitor interfaces are used to make it easier to
visit this subset of the trace hierarchy. This will be useful to
implement the listing of event fields through liblttng-ctl, for example.

In the short term, these classes will be used to implement the
serialization of the layout descriptions of CTF 1.8 and 2.

Change-Id: I6d99f0ec93082259bf64434c440a720ed9a49bf8
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
2 years agocommon: macros: missing include of pthread.h
Jérémie Galarneau [Thu, 2 Jun 2022 15:01:23 +0000 (11:01 -0400)] 
common: macros: missing include of pthread.h

A number of macros in this file make use of pthread APIs. However, the
header is not included.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: If13df2434bd08269984c9589ff60a2bae4484ab3

2 years agocommon: uuid: add `uuid_to_str` which returns an std::string
Jérémie Galarneau [Thu, 2 Jun 2022 15:00:40 +0000 (11:00 -0400)] 
common: uuid: add `uuid_to_str` which returns an std::string

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Id915ba7dbe8128d492d92faa05bbf12770a49f8d

2 years agosessiond: session registry: use pthread::lock_guard instead of raw lock
Jérémie Galarneau [Thu, 12 May 2022 19:22:50 +0000 (15:22 -0400)] 
sessiond: session registry: use pthread::lock_guard instead of raw lock

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I3f5227782701a82257b710232fc02bd3c61a2e20

2 years agoTests fix: metadata event: print expected and actual event match count
Jérémie Galarneau [Mon, 16 May 2022 22:49:05 +0000 (18:49 -0400)] 
Tests fix: metadata event: print expected and actual event match count

The validate_metadata_event() function prints the actual event match
count twice when a test fails. Printing the expected vs actual counts
was probably the intention of the original author.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ideac2593a5d4d239ee24f98f954dddf2b5be91fa

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