Simon Marchi [Wed, 10 Nov 2021 15:17:41 +0000 (10:17 -0500)]
Fix: add missing cases in enum-to-string functions
Change the enum-to-string functions to not use a default case, such that
the compiler will give a -Wswitch warning if an enumerator is not
handled. Add some missing ones found by such warnings.
Put a bt_common_abort call after each switch (rather than returning
"(unknown)", because there's no way in theory that we can reach that.
Having anything else would be a bug we would want to fix in babeltrace.
Change-Id: I2cfae112386aede4844062be51dba009a1e9a056
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/6693
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Tue, 28 Sep 2021 20:43:44 +0000 (16:43 -0400)]
tests: rename BT_OS_TYPE to BT_TESTS_OS_TYPE
Follow the naming scheme used by other testsuite environment variables.
Change-Id: I26dfe20b0c06a9de4d1e4bd1418f15d17ed4477c
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/6455
Reviewed-by: Michael Jeanson <mjeanson@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
Francis Deslauriers [Thu, 9 Sep 2021 19:09:26 +0000 (15:09 -0400)]
Fix: build with `--enable-python-bindings` fails
Issue
=====
Configuring with the following option:
`./configure --disable-man-pages --enable-python-bindings`
makes the build fails with the following error:
make[4]: Entering directory '/home/frdeso/projets/babeltrace/src/bindings/python/bt2'
touch copy-static-deps.stamp
SWIG bt2/native_bt.c
/bin/bash: -MD: command not found
This error is due to the fact that the `SWIG` automake variable is empty
leading to that unexpected `-MD: command not found` error.
Currently, in the `configure.ac`, the `SWIG` variable is only set when the
`--enable-python-plugins` is enabled. This is wrong because it's the
bindings that require SWIG.
Fix
===
Define the `SWIG` variable when the bindings are enabled.
Note
====
Enabling the plugins requires also enabling the bindings.
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: Ie6eb21c5bd2ebc1fa97751148b44c8e9263dcf0c
Reviewed-on: https://review.lttng.org/c/babeltrace/+/6378
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Michael Jeanson <mjeanson@efficios.com>
Simon Marchi [Wed, 5 May 2021 14:09:23 +0000 (10:09 -0400)]
ctf: append error causes when returning errors
Change as many error paths as possible in the CTF metadata parsing code
to append error causes. This will give clearer error messages to users
when the metadata can't be parsed. The errors are already printed to
stderr, but this will make them more obvious, as they will be printed in
the error stack.
For example, a syntax error caught by the metadata-info query:
$ cat test/metadata
/* CTF 1.8 */
trace {
foo = ;
};
$ ./src/cli/babeltrace2 query src.ctf.fs metadata-info -p 'path=test'
...
ERROR: [Babeltrace CLI] (/home/simark/src/babeltrace/src/cli/babeltrace2.c:649)
Failed to query component class: unknown error: plugin-name="ctf", comp-cls-name="fs", comp-cls-type=1 object="metadata-info"
CAUSED BY [libbabeltrace2] (/home/simark/src/babeltrace/src/lib/graph/query-executor.c:231)
Component class's "query" method failed: query-exec-addr=0x60b000001430, cc-addr=0x60f000000220, cc-type=SOURCE, cc-name="fs", cc-partial-descr="Read CTF traces from the file sy",
cc-is-frozen=0, cc-so-handle-addr=0x607000000100, cc-so-handle-path="/home/simark/build/babeltrace/src/plugins/ctf/babeltrace-plugin-ctf.la", object="metadata-info", params-addr=0x606000000980,
params-type=MAP, params-element-count=1, log-level=WARNING
CAUSED BY ['source.ctf.fs'] (/home/simark/src/babeltrace/src/plugins/ctf/fs-src/query.c:121)
Cannot update metadata decoder's content: path="test".
CAUSED BY ['source.ctf.fs'] (/home/simark/src/babeltrace/src/plugins/ctf/common/metadata/decoder.c:279)
Cannot create the metadata AST out of the metadata text: mdec-addr=0x60c000003a00
CAUSED BY [CTF metadata parser] (/home/simark/src/babeltrace/src/plugins/ctf/common/metadata/parser.y:925)
At line 4 in metadata stream: syntax error, unexpected CTF_SEMICOLON: token=";"
And a semantic error caught when trying to read the trace:
$ cat test/metadata
/* CTF 1.8 */
trace {
byte_order = 2;
};
$ ./src/cli/babeltrace2 test
...
ERROR: [Babeltrace CLI] (/home/simark/src/babeltrace/src/cli/babeltrace2.c:2462)
Cannot create components.
CAUSED BY [Babeltrace CLI] (/home/simark/src/babeltrace/src/cli/babeltrace2.c:2277)
Cannot create component: plugin-name="ctf", comp-cls-name="fs", comp-cls-type=1, comp-name="auto-disc-source-ctf-fs"
CAUSED BY [libbabeltrace2] (/home/simark/src/babeltrace/src/lib/graph/graph.c:1055)
Component initialization method failed: status=ERROR, comp-addr=0x60c000004f00, comp-name="auto-disc-source-ctf-fs", comp-log-level=WARNING, comp-class-type=SOURCE, comp-class-name="fs", comp-class-partial-descr="Read CTF traces
from the file sy", comp-class-is-frozen=1, comp-class-so-handle-addr=0x607000000100, comp-class-so-handle-path="/home/simark/build/babeltrace/src/plugins/ctf/babeltrace-plugin-ctf.la", comp-input-port-count=0,
comp-output-port-count=0
CAUSED BY [auto-disc-source-ctf-fs: 'source.ctf.fs'] (/home/simark/src/babeltrace/src/plugins/ctf/fs-src/fs.c:1186)
Cannot create trace for `/home/simark/build/babeltrace/test`.
CAUSED BY [auto-disc-source-ctf-fs: 'source.ctf.fs'] (/home/simark/src/babeltrace/src/plugins/ctf/common/metadata/decoder.c:327)
Failed to visit AST node to create CTF IR objects: mdec-addr=0x60c0000052c0, ret=-22
CAUSED BY [auto-disc-source-ctf-fs: 'source.ctf.fs'] (/home/simark/src/babeltrace/src/plugins/ctf/common/metadata/visitor-generate-ir.c:4722)
At line 0 in metadata stream: Cannot set trace's native byte order: ret=-22
CAUSED BY [auto-disc-source-ctf-fs: 'source.ctf.fs'] (/home/simark/src/babeltrace/src/plugins/ctf/common/metadata/visitor-generate-ir.c:4148)
At line 4 in metadata stream: Invalid `byte_order` attribute in trace (`trace` block): expecting `le`, `be`, or `network`.
CAUSED BY [auto-disc-source-ctf-fs: 'source.ctf.fs'] (/home/simark/src/babeltrace/src/plugins/ctf/common/metadata/visitor-generate-ir.c:920)
At line 4 in metadata stream: "byte_order" attribute: expecting `be`, `le`, `network`, or `native`.
The metadata parser can be used in both component and component class
context. For logging purposes, only a component is passed through
ctf_metadata_decoder_config, when the parsing is done in the context of
a component. To be able to append error causes with the right component
class actor, add the option to pass a component class as well.
Change-Id: I8db734fa27cea5ea3b911e36800d535290c51ad9
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/5693
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Simon Marchi [Wed, 5 May 2021 19:06:18 +0000 (15:06 -0400)]
Fix: ctf: free all scopes of ctf_scanner
When parsing using a ctf_scanner does not complete, because an error is
encountered, ctf_scanner_free does not properly free all the scopes
allocated by and held by ctf_scanner.
This can be observed on an ASan-enabled build of Babeltrace. Create a
test/metadata file with:
/* CTF 1.8 */
trace {}
and run:
$ LIBBABELTRACE2_NO_DLCLOSE=1 ./src/cli/babeltrace2 query src.ctf.fs metadata-info -p 'path=test'
I get:
Direct leak of 16 byte(s) in 1 object(s) allocated from:
#0 0x7ffff7677459 in __interceptor_malloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cpp:145
#1 0x7ffff35605b9 in push_scope /home/simark/src/babeltrace/src/plugins/ctf/common/metadata/parser.y:296
#2 0x7ffff356726f in yyparse /home/simark/src/babeltrace/src/plugins/ctf/common/metadata/parser.y:1478
#3 0x7ffff3563297 in ctf_scanner_append_ast /home/simark/src/babeltrace/src/plugins/ctf/common/metadata/parser.y:958
#4 0x7ffff3598a6a in ctf_metadata_decoder_append_content /home/simark/src/babeltrace/src/plugins/ctf/common/metadata/decoder.c:277
#5 0x7ffff3626fff in metadata_info_query /home/simark/src/babeltrace/src/plugins/ctf/fs-src/query.c:118
#6 0x7ffff3625ac1 in ctf_fs_query /home/simark/src/babeltrace/src/plugins/ctf/fs-src/fs.c:2454
#7 0x7ffff74a616d in bt_query_executor_query /home/simark/src/babeltrace/src/lib/graph/query-executor.c:219
#8 0x5555555a09e2 in cli_query /home/simark/src/babeltrace/src/cli/babeltrace2-query.c:62
#9 0x555555574fb3 in query /home/simark/src/babeltrace/src/cli/babeltrace2.c:113
#10 0x5555555775c6 in cmd_query /home/simark/src/babeltrace/src/cli/babeltrace2.c:645
#11 0x555555582ae7 in main /home/simark/src/babeltrace/src/cli/babeltrace2.c:2682
#12 0x7ffff70ebb24 in __libc_start_main (/usr/lib/libc.so.6+0x27b24)
What happens is: while parsing, push_scope is called to allocate a new
scope and make it current (ctf_scanner::cs). The previous current scope
becomes the parent of the new scope. When everything goes right,
pop_scope is called as many times as push_scope is called, freeing all
the scopes created during parsing. ctf_scanner_free doesn't need to
free any scopes in that case. However, if parsing ends early to due to
an error, ctf_scanner_free is called on a scanner that may have some
scopes that were pushed and not popped. If so, it needs to free them.
Change it to start freeing ctf_scanner::cs (the innermost scope) and
then go up the chain. The last scope in that chain is
ctf_scanner::root_scope. This one doesn't need free'ing, as its storage
is allocate within the ctf_scanner structure, but it still needs
finalizing.
Change-Id: I3a1b83af8128cd1b8a3ee235311dd41e45e29ea2
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/5692
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Simon Marchi [Wed, 5 May 2021 14:19:19 +0000 (10:19 -0400)]
Fix: ctf: set `ret` on error paths
The error paths touched by this patch currently don't set the `ret`
variable, resulting in the error not being communicated to the caller.
Fix that.
Change-Id: If044e4ff28a98bda408610c1c2f85d7fe13ea1c1
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/5691
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Simon Marchi [Wed, 5 May 2021 14:08:35 +0000 (10:08 -0400)]
lib: make auto-seek skip over packet messages without clock snapshots
Trying to use a CTF trace with packets that don't have beginning clock
snapshots [1] with a trimmer component invokes the "auto-seek" seeking
mechanism provided by the lib, and leads to:
$ ./src/cli/babeltrace2 nvctf --timerange="05:50:53,05:50:55"
...
Babeltrace 2 library postcondition not satisfied.
------------------------------------------------------------------------
Condition ID: `post:message-iterator-class-next-method:packet-message-has-default-clock-snapshot`.
Function: bt_message_iterator_class_next_method().
------------------------------------------------------------------------
Error is:
Packet message has no default clock snapshot: addr=0x607000001fa0, type=PACKET_BEGINNING, is-frozen=0, graph-addr=0x612000001840, packet-is-frozen=1, packet-context-field-addr=(nil), packet-stream-addr=0x60d000001cb0, packet-stream-id=0, packet-stream-name="/home/simark/build/babeltrace/nvctf/channel0", packet-trace-class-addr=0x60d000001be0
The problem is with the auto_seek_handle_message function assuming that
all packet beginning messages have a clock snapshot. Fix it by making
it check the relevant property in the stream class, and skip the message
if it doesn't have a clock snapshot.
Change it as well for packet end, discarded event and discarded packet
messages, although I did not test these cases.
[1] Like the trace from
https://lists.lttng.org/pipermail/lttng-dev/2021-May/029955.html
Change-Id: I6be0ab013285c2a01125dbf27161d31e227250a8
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/5690
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Simon Marchi [Wed, 5 May 2021 14:07:56 +0000 (10:07 -0400)]
trimmer: don't get clock snapshots from messages that don't have them
When using a trace with packets that don't have beginning clock
snapshots [1] with a trimmer component, we hit:
$ ./src/cli/babeltrace2 nvctf --timerange="05:50:53,05:50:55"
...
Condition ID: `pre:message-packet-beginning-borrow-default-clock-snapshot-const:msg-stream-class-packets-have-beginning-default-clock-snapshot`.
Function: bt_message_packet_beginning_borrow_default_clock_snapshot_const().
------------------------------------------------------------------------
Error is:
Message's stream class packets don't have beginning default clock snapshot.
The problem is with the trimmer's get_msg_ns_from_origin function
assuming that that packet begnning messages have a clock snapshot if the
stream class has a clock class (which I suppose was true in early
development stages).
Fix that by making get_msg_ns_from_origin skip over messages
that don't have clock snapshots. In addition to packet beginning
messages, I found (just by inspection, not tested) that packet end,
discarded events and discarded packets messages are in the same
situation.
Note that the trimmer component currently requires packet messages to
have clock snapshots in order to work. However, the check for this
happens later, during the TRIM state. get_msg_ns_from_origin is called
early, during the SET_BOUNDS_NS_FROM_ORIGIN state. So in
get_msg_ns_from_origin, we can't assume that messages we encounter have
them.
[1] Like the trace from
https://lists.lttng.org/pipermail/lttng-dev/2021-May/029955.html
Change-Id: Ie56b3250829197eadb823b7ac5d23efc46d12b3c
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/5689
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Simon Marchi [Wed, 5 May 2021 13:52:13 +0000 (09:52 -0400)]
lib: enforce preconditions when getting packet message clock snapshots
The functions:
- bt_message_packet_beginning_borrow_default_clock_snapshot_const
- bt_message_packet_end_borrow_default_clock_snapshot_const
respectively have the preconditions:
- The packets of the stream class of message have a beginning default
clock snapshot.
- The packets of the stream class of message have an end default clock
snapshot.
These preconditions are currently not enforced by the code. A user of
these functions violating these preconditions in a dev build currently
gets NULL back, which is not an expected return value. Add some checks
for this.
This helps for example when using the trimmer component on a trace
without packet beginning/end default clock snapshots, like the one here
[1]. Without this patch, we hit a precondition failure when we pass the
unexpected NULL value to another function:
$ ./src/cli/babeltrace2 nvctf --timerange="05:50:53,05:50:55"
05-05 10:02:15.110
3642287 3642287 F LIB/ASSERT-COND bt_lib_assert_cond_failed@assert-cond.c:64 Babeltrace 2 library precondition not satisfied.
05-05 10:02:15.110
3642287 3642287 F LIB/ASSERT-COND bt_lib_assert_cond_failed@assert-cond.c:66 ------------------------------------------------------------------------
05-05 10:02:15.110
3642287 3642287 F LIB/ASSERT-COND bt_lib_assert_cond_failed@assert-cond.c:67 Condition ID: `pre:clock-snapshot-get-ns-from-origin:not-null:clock-snapshot`.
05-05 10:02:15.110
3642287 3642287 F LIB/ASSERT-COND bt_lib_assert_cond_failed@assert-cond.c:69 Function: bt_clock_snapshot_get_ns_from_origin().
05-05 10:02:15.110
3642287 3642287 F LIB/ASSERT-COND bt_lib_assert_cond_failed@assert-cond.c:70 ------------------------------------------------------------------------
05-05 10:02:15.110
3642287 3642287 F LIB/ASSERT-COND bt_lib_assert_cond_failed@assert-cond.c:71 Error is:
05-05 10:02:15.110
3642287 3642287 F LIB/ASSERT-COND bt_lib_assert_cond_failed@assert-cond.c:73 Clock snapshot is NULL.
05-05 10:02:15.110
3642287 3642287 F LIB/ASSERT-COND bt_lib_assert_cond_failed@assert-cond.c:76 Aborting...
With this patch, the problem is caught a little bit earlier, so closer
to the root of the problem:
$ ./src/cli/babeltrace2 nvctf --timerange="05:50:53,05:50:55"
05-05 10:02:30.784
3647078 3647078 F LIB/ASSERT-COND bt_lib_assert_cond_failed@assert-cond.c:64 Babeltrace 2 library precondition not satisfied.
05-05 10:02:30.784
3647078 3647078 F LIB/ASSERT-COND bt_lib_assert_cond_failed@assert-cond.c:66 ------------------------------------------------------------------------
05-05 10:02:30.784
3647078 3647078 F LIB/ASSERT-COND bt_lib_assert_cond_failed@assert-cond.c:67 Condition ID: `pre:message-packet-beginning-borrow-default-clock-snapshot-const:msg-stream-class-packets-have-beginning-default-clock-snapshot`.
05-05 10:02:30.784
3647078 3647078 F LIB/ASSERT-COND bt_lib_assert_cond_failed@assert-cond.c:69 Function: bt_message_packet_beginning_borrow_default_clock_snapshot_const().
05-05 10:02:30.784
3647078 3647078 F LIB/ASSERT-COND bt_lib_assert_cond_failed@assert-cond.c:70 ------------------------------------------------------------------------
05-05 10:02:30.784
3647078 3647078 F LIB/ASSERT-COND bt_lib_assert_cond_failed@assert-cond.c:71 Error is:
05-05 10:02:30.784
3647078 3647078 F LIB/ASSERT-COND bt_lib_assert_cond_failed@assert-cond.c:73 Message's stream class packets don't have beginning default clock snapshot.
05-05 10:02:30.784
3647078 3647078 F LIB/ASSERT-COND bt_lib_assert_cond_failed@assert-cond.c:76 Aborting...
[1] https://lists.lttng.org/pipermail/lttng-dev/2021-May/029955.html
Change-Id: I420bb71ab3a5139ff15b524f09c818a1c2aafa81
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/5688
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Simon Marchi [Fri, 10 Sep 2021 03:25:19 +0000 (23:25 -0400)]
common: move bt_component_class_type_string here, use it more
I spotted some messages in the CLI code that could print the component
class type as a string rather than an integer.
bt_component_class_type_string is not accessible to the CLI code,
because it's in a lib header. Move it to common/common.h, and rename it
accordingly.
Adjust all existing callers, and use it in cli/babeltrace2.c.
Before:
$ ./src/cli/babeltrace2 query src.ctf.fs foo
...
Failed to query component class: unknown query object: plugin-name="ctf", comp-cls-name="fs", comp-cls-type=1 object="foo"
After:
$ ./src/cli/babeltrace2 query src.ctf.fs foo
...
Failed to query component class: unknown query object: plugin-name="ctf", comp-cls-name="fs", comp-cls-type=SOURCE object="foo"
Change-Id: I88f01ac7cae9723ce11dbf2ec0843a06d761abb6
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/6273
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Philippe Proulx [Thu, 17 Dec 2020 02:22:43 +0000 (21:22 -0500)]
src/common/uuid.h: wrap code in C++ guards
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ia87b11fe0a7015085325259446f15393dc1f1e19
Reviewed-on: https://review.lttng.org/c/babeltrace/+/4600
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Philippe Proulx [Tue, 15 Dec 2020 15:36:15 +0000 (10:36 -0500)]
Add `tools/format-cpp` script
The new `format-cpp` script uses `clang-format -i` to inline-format all
the C++ files except `src/cpp-common/optional/optional.hpp` and
`src/cpp-common/string_view/string_view.hpp`.
You can run it from any directory: it always runs `clang-format -i` for
the whole project.
By default, the script runs `clang-format -i`; you can override this
with the `FORMATTER` environment variable, for example:
$ FORMATTER='clang-format-10 -i' ./tools/format-cpp
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I1049eabf8da71ce5c1d8443e1e2cdc9a73f4b4d5
Reviewed-on: https://review.lttng.org/c/babeltrace/+/4592
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Philippe Proulx [Mon, 14 Dec 2020 18:07:40 +0000 (13:07 -0500)]
src/common/common.h: do not use `void *` in arithmetic
This avoids a G++ warning:
> common.h:445:22: warning: pointer of type ‘void *’ used in arithmetic
> [-Wpointer-arith]
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I71bad4b54a0aa3baa806e5c29e060d0047c007f2
Reviewed-on: https://review.lttng.org/c/babeltrace/+/4566
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Philippe Proulx [Fri, 11 Dec 2020 00:19:35 +0000 (19:19 -0500)]
src/common/{common,safe}.h: wrap code in C++ guards
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ifcb907d159b67e6f27a5191553824fe2ed25ef5d
Reviewed-on: https://review.lttng.org/c/babeltrace/+/4534
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Simon Marchi [Mon, 9 Aug 2021 15:55:58 +0000 (11:55 -0400)]
cli: make config cli args functions return a status enum
The retcode returned by functions that create a bt_config from CLI args
is not very intuitive. Replace that by a proper status enum. Change
those functions to return the status as their return value, and return
the bt_config through an out parameter (only if the returned status is
BT_CONFIG_CLI_ARGS_STATUS_OK).
Change-Id: I2f273a6e28bcd0322a1b7ddd303639a696043872
Reviewed-on: https://review.lttng.org/c/babeltrace/+/6278
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Simon Marchi [Mon, 9 Aug 2021 14:06:32 +0000 (10:06 -0400)]
Fix: cli: use correct argument index in subcommand error messages
Because command implementation are not aware that there may have been
arguments before the ones they receive, the argument number in
argument-parsing-related error messages is off:
$ ./src/cli/babeltrace2 --omit-home-plugin-path convert --foo
ERROR: [Babeltrace CLI] (/home/simark/src/babeltrace/src/cli/babeltrace2.c:2644)
Command-line error: retcode=1
CAUSED BY [Babeltrace CLI] (/home/simark/src/babeltrace/src/cli/babeltrace2-cfg-cli-args.c:1423)
While parsing `convert` command's command-line arguments: While parsing argument #1 (`--foo`): Unknown option `--foo`
The `argument #1` message referring to `--foo` is erroneous, from the
point of view of the user.
Fix that by passing down an offset to apply to argument indices when
error messages are generated.
Change-Id: Ib3254094ed5e3de858f5a69cd1dc02f840a92939
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/5929
Simon Marchi [Fri, 21 May 2021 03:12:58 +0000 (23:12 -0400)]
cli: sync argpar - adjust to iterator API
Sync with commit
1c88181255c1 ("argpar/argpar.h: update API
documentation").
The main change in this version is the API that changed from
parse-all-at-once (the `argpar_parse` function) to something based on an
iterator, where we need to call `argpar_iter_next` to obtain the next
item.
Update the top-level option parsing. As before, we stop as soon as we
encounter an unknown option or a non-option argument.
Update all commands to use the new `parse_next_item` function, which
factors out a bit of otherwise repetitive code.
Another change in this argpar version is that argpar does not provide a
format error string anymore. It provides an `argpar_error` object
contaning all the raw information needed to create such string. The
new `format_arg_error` function formats the errors using the exact same
syntax as argpar did, such that no changes in the tests are necessary.
Change-Id: Ied9080953a0bb1b81f9880263a3f9dd1724eba07
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/5928
Tested-by: jenkins <jenkins@lttng.org>
Philippe Proulx [Wed, 9 Dec 2020 16:41:14 +0000 (11:41 -0500)]
Fix: clear_string_field(): set first character to 0
The API documentation of bt_field_string_clear() says:
> Clears the string field `field`, making its value an empty string.
clear_string_field(), called by bt_field_string_clear(), sets the string
field's buffer's length to 0 without setting its first character to 0 to
make the string field empty from bt_field_string_get_value()'s point of
view.
This patch makes clear_string_field() also set the string field's
buffer's first character to 0.
Reported by Brice Videau (@Kerilk) in
<https://github.com/efficios/babeltrace/pull/116>.
Reported-by: Brice Videau <bvideau@anl.gov>
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I964599ecfbea33a7cb583dcf7cf25e6cffbc30b6
Reviewed-on: https://review.lttng.org/c/babeltrace/+/4528
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Philippe Proulx [Wed, 9 Dec 2020 16:33:49 +0000 (11:33 -0500)]
API doc: use minus sign (U+2212) where appropriate instead of `-`
The minus sign is usually rendered larger than `-` and therefore
visually more interesting for mathematical expressions.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I9f9dc8cde4ecce1b40e9fb08ac2e188221fffe3b
Reviewed-on: https://review.lttng.org/c/babeltrace/+/4527
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Philippe Proulx [Wed, 9 Dec 2020 16:22:35 +0000 (11:22 -0500)]
Fix: doc: field-class.h: signed integer field class value range
Reported by Brice Videau (@Kerilk) in
<https://github.com/efficios/babeltrace/pull/116>.
Reported-by: Brice Videau <bvideau@anl.gov>
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ic180e9e3f26214e9d9cb5e44d805694d37850199
Reviewed-on: https://review.lttng.org/c/babeltrace/+/4526
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Francis Deslauriers [Wed, 4 Aug 2021 15:19:14 +0000 (11:19 -0400)]
Fix: src.ctf.fs: Not resolving event common ctx
Issue
=====
An assertion fails when creating the trace class with a sequence in the
event common context with the following callstack:
#0 0x00007ffff7bf118b in raise () from /lib/x86_64-linux-gnu/libc.so.6
#1 0x00007ffff7bd0859 in abort () from /lib/x86_64-linux-gnu/libc.so.6
#2 0x00007ffff73e2d86 in bt_common_abort () at common.c:2111
#3 0x00007ffff73ddec4 in bt_common_assert_failed (file=0x7ffff73ec268 "ctf-meta-update-value-storing-indexes.c", line=57, func=0x7ffff73ec300 <__func__.16976> "update_field_class_stored_value_index", assertion=0x7ffff73ec260 "tgt_fc") at assert.c:40
#4 0x00007ffff738a396 in update_field_class_stored_value_index (fc=0x5555555d9c00, tc=0x555555598000, sc=0x555555598690, ec=0x0) at ctf-meta-update-value-storing-indexes.c:57
#5 0x00007ffff738a4a0 in update_field_class_stored_value_index (fc=0x5555555d8ee0, tc=0x555555598000, sc=0x555555598690, ec=0x0) at ctf-meta-update-value-storing-indexes.c:81
#6 0x00007ffff738a63b in ctf_trace_class_update_value_storing_indexes (ctf_tc=0x555555598000) at ctf-meta-update-value-storing-indexes.c:148
#7 0x00007ffff73a0e95 in ctf_visitor_generate_ir_visit_node (visitor=0x55555559ce60, node=0x5555555ad100) at visitor-generate-ir.c:4900
#8 0x00007ffff738e583 in ctf_metadata_decoder_append_content (mdec=0x55555559f380, fp=0x5555555aba00) at decoder.c:316
#9 0x00007ffff73c9fda in ctf_fs_metadata_set_trace_class (self_comp=0x5555555a21b0, ctf_fs_trace=0x5555555981d0, config=0x55555559ee08) at metadata.c:107
#10 0x00007ffff73c5e2f in ctf_fs_trace_create (self_comp=0x5555555a21b0, self_comp_class=0x0, path=0x555555597d40 "/home/frdeso/lttng-traces/auto-
20210804-093702/kernel", name=0x0, metadata_config=0x55555559ee08, log_level=BT_LOGGING_LEVEL_WARNING) at fs.c:1072
#11 0x00007ffff73c65cc in ctf_fs_component_create_ctf_fs_trace_one_path (ctf_fs=0x55555559edf0, path_param=0x5555555a1e50 "/home/frdeso/lttng-traces/auto-
20210804-093702/kernel", trace_name=0x0, traces=0x555555597a80, self_comp=0x5555555a21b0, self_comp_class=0x0) at fs.c:1183
#12 0x00007ffff73c8a4d in ctf_fs_component_create_ctf_fs_trace (ctf_fs=0x55555559edf0, paths_value=0x5555555ac4d0, trace_name_value=0x0, self_comp=0x5555555a21b0, self_comp_class=0x0) at fs.c:2097
#13 0x00007ffff73c9a97 in ctf_fs_create (params=0x5555555abf70, self_comp_src=0x5555555a21b0) at fs.c:2397
#14 0x00007ffff73c9b52 in ctf_fs_init (self_comp_src=0x5555555a21b0, config=0x0, params=0x5555555abf70, init_method_data=0x0) at fs.c:2431
#15 0x00007ffff7f20b60 in add_component_with_init_method_data (graph=0x5555555a20a0, comp_cls=0x5555555a9580, init_method=0x7ffff73c9b1c <ctf_fs_init>, name=0x5555555abf40 "auto-disc-source-ctf-fs", params=0x5555555abf70, init_method_data=0x0, log_level=BT_LOGGING_LEVEL_WARNING, user_component=0x7fffffffe308, api_func=0x7ffff7f63880 <__func__.17336> "bt_graph_add_source_component", init_method_name=0x7ffff7f633a8 "bt_component_class_source_initialize_method") at graph.c:1048
#16 0x00007ffff7f20e3d in add_source_component_with_initialize_method_data (graph=0x5555555a20a0, comp_cls=0x5555555a9580, name=0x5555555abf40 "auto-disc-source-ctf-fs", params=0x5555555abf70, init_method_data=0x0, log_level=BT_LOGGING_LEVEL_WARNING, component=0x7fffffffe308, api_func=0x7ffff7f63880 <__func__.17336> "bt_graph_add_source_component") at graph.c:1127
#17 0x00007ffff7f20eec in bt_graph_add_source_component (graph=0x5555555a20a0, comp_cls=0x5555555a9580, name=0x5555555abf40 "auto-disc-source-ctf-fs", params=0x5555555abf70, log_level=BT_LOGGING_LEVEL_WARNING, component=0x7fffffffe308) at graph.c:1152
#18 0x000055555556251a in cmd_run_ctx_create_components_from_config_components (ctx=0x7fffffffe390, cfg_components=0x5555555ab0c0) at babeltrace2.c:2252
#19 0x00005555555628ec in cmd_run_ctx_create_components (ctx=0x7fffffffe390) at babeltrace2.c:2347
#20 0x0000555555562cb5 in cmd_run (cfg=0x5555555a1b80) at babeltrace2.c:2461
#21 0x00005555555635ef in main (argc=2, argv=0x7fffffffe508) at babeltrace2.c:2673
This is due to the fact that the event context field class containing a
sequence is never resolved by calling `resolve_root_class()`. This leads
to the `ctf_field_class_sequence::length_fc` field never being
initialized.
Looking at the `resolve_stream_class_field_classes()` function, it looks
like there is a typo where the `CTF_SCOPE_EVENT_SPECIFIC_CONTEXT` enum
label was used where the intention was to use
`CTF_SCOPE_EVENT_COMMON_CONTEXT` according to the surrounding code.
Fix
===
Replace `CTF_SCOPE_EVENT_SPECIFIC_CONTEXT` by `CTF_SCOPE_EVENT_COMMON_CONTEXT`.
Test
====
This commit adds a minimal testcase with a sequence in the event and
packet contexts.
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I370a620855f2dcdf51d02db80b9df22b0f043f3a
Reviewed-on: https://review.lttng.org/c/babeltrace/+/6257
CI-Build: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Bernhard Rosenkränzer [Wed, 26 May 2021 03:06:55 +0000 (05:06 +0200)]
Fix: ctf-writer: list of reserved keywords
The missing comma between "void" and "_Bool" causes the compiler to
treat it as one string ("void_Bool"), missing both "void" and "_Bool"
as real reserved keywords.
Signed-off-by: Bernhard Rosenkränzer <bero@lindev.ch>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I3da1b1f579d5fa1248501a8c2d9804ddbf467bc1
Reviewed-on: https://review.lttng.org/c/babeltrace/+/5964
Tested-by: jenkins <jenkins@lttng.org>
Mathieu Desnoyers [Thu, 25 Mar 2021 18:32:40 +0000 (14:32 -0400)]
compiler warning cleanup: is_signed_type: compare -1 to 1
Comparing -1 to 0 triggers compiler warnings (gcc -Wtype-limits and
-Wbool-compare) and Coverity warning "Macro compares unsigned to 0".
Comparing -1 to 1 instead takes care of silencing those warnings while
keeping the same behavior.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I7d3a2d5a813838cef0e7b42d8c80ccf46f27ac62
Reviewed-on: https://review.lttng.org/c/babeltrace/+/5188
CI-Build: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Michael Jeanson [Wed, 17 Feb 2021 17:27:20 +0000 (12:27 -0500)]
Fix: bootstrap with autoconf >= 2.70
We want to enable all warnings and treat them as errors when running
autoreconf but we have to disable 'obsolete' because of
AM_PATH_GLIB_2_0. Turns out that autoconf >= 2.70 will drop all other
warnings categories when 'all' is used. So the only way to enable all
categories but 'obsolete' is to list them all.
Change-Id: I6fae9c86130d79a1bc9d3bb7d0610a24d734532a
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Philippe Duplessis-Guindon [Fri, 16 Oct 2020 18:29:05 +0000 (14:29 -0400)]
Fix: lib: assert if an error occurs in `bt_message_iterator_class_finalize_method`
I tried to append an error with `BT_COMP_LOGE_APPEND_CAUSE_ERRNO`
in `bt_message_iterator_class_finalize_method` from a plugin, and
there was no error. The expected behavior would be for the plugin
to fail if there is an error on the current thread after returning.
This patch adds `BT_ASSERT_POST_NO_ERROR` and the assert fails if
there is an error on the current thread after returning
With this patch, here is the following output, which is the expected behavior:
10-16 14:18:05.890 51873 51873 F LIB/ASSERT-COND bt_lib_assert_cond_failed@assert-cond.c:64 Babeltrace 2 library postcondition not satisfied.
10-16 14:18:05.890 51873 51873 F LIB/ASSERT-COND bt_lib_assert_cond_failed@assert-cond.c:66 ------------------------------------------------------------------------
10-16 14:18:05.890 51873 51873 F LIB/ASSERT-COND bt_lib_assert_cond_failed@assert-cond.c:67 Condition ID: `post:message-iterator-class-finalize-method:no-error`.
10-16 14:18:05.890 51873 51873 F LIB/ASSERT-COND bt_lib_assert_cond_failed@assert-cond.c:69 Function: bt_message_iterator_class_finalize_method().
10-16 14:18:05.890 51873 51873 F LIB/ASSERT-COND bt_lib_assert_cond_failed@assert-cond.c:70 ------------------------------------------------------------------------
10-16 14:18:05.890 51873 51873 F LIB/ASSERT-COND bt_lib_assert_cond_failed@assert-cond.c:71 Error is:
10-16 14:18:05.890 51873 51873 F LIB/ASSERT-COND bt_lib_assert_cond_failed@assert-cond.c:73 Current thread has an error
10-16 14:18:05.890 51873 51873 F LIB/ASSERT-COND bt_lib_assert_cond_failed@assert-cond.c:76 Aborting...
Add `BT_ASSERT_POST_NO_ERROR` after calling the method.
Signed-off-by: Philippe Duplessis-Guindon <pduplessis@efficios.com>
Change-Id: I6cf6118661cbe615c1f6ddc77c8b3555dca3b526
Reviewed-on: https://review.lttng.org/c/babeltrace/+/4201
CI-Build: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Simon Marchi [Tue, 26 Jan 2021 21:28:12 +0000 (16:28 -0500)]
Fix: macro name for "get supported mip versions method" attribute descriptor
I tried to use BT_PLUGIN_SINK_COMPONENT_CLASS_GET_SUPPORTED_MIP_VERSIONS_METHOD, I got:
In file included from /home/simark/src/babeltrace/include/babeltrace2/babeltrace.h:67,
from /home/simark/src/babeltrace/src/cpp-common/bt2/plugin-dev.hpp:10,
from /home/simark/src/babeltrace/tests/cpp-common/plugin-dev/plugin.cpp:7:
/home/simark/src/babeltrace/include/babeltrace2/plugin/plugin-dev.h:2214:91: error: ‘BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_GET_SUPPORTED_MIP_VERSIONS’ was not declared in this scope; did you mean ‘BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_GET_SUPPORTED_MIP_VERSIONS_METHOD’?
2214 | __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(sink_get_supported_mip_versions_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_GET_SUPPORTED_MIP_VERSIONS, _plugin_id, _component_class_id, sink, _method)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/simark/src/babeltrace/include/babeltrace2/plugin/plugin-dev.h:2641:11: note: in definition of macro ‘__BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE’
2641 | .type = _attr_type, \
| ^~~~~~~~~~
/home/simark/src/babeltrace/include/babeltrace2/plugin/plugin-dev.h:2224:2: note: in expansion of macro ‘BT_PLUGIN_SINK_COMPONENT_CLASS_GET_SUPPORTED_MIP_VERSIONS_METHOD_WITH_ID’
2224 | BT_PLUGIN_SINK_COMPONENT_CLASS_GET_SUPPORTED_MIP_VERSIONS_METHOD_WITH_ID(auto, _name, _method)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/simark/src/babeltrace/src/cpp-common/bt2/plugin-dev.hpp:110:5: note: in expansion of macro ‘BT_PLUGIN_SINK_COMPONENT_CLASS_GET_SUPPORTED_MIP_VERSIONS_METHOD’
110 | BT_PLUGIN_SINK_COMPONENT_CLASS_GET_SUPPORTED_MIP_VERSIONS_METHOD( \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/simark/src/babeltrace/tests/cpp-common/plugin-dev/plugin.cpp:19:1: note: in expansion of macro ‘BT_CPP_PLUGIN_SINK_COMPONENT_CLASS_GET_SUPPORTED_MIP_VERSIONS_METHOD’
19 | BT_CPP_PLUGIN_SINK_COMPONENT_CLASS_GET_SUPPORTED_MIP_VERSIONS_METHOD(the_sink, TheSink);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I think it should be
BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_GET_SUPPORTED_MIP_VERSIONS_METHOD
instead of
BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_GET_SUPPORTED_MIP_VERSIONS
Change-Id: I397da2945e3eedcedefe713fbb9a469633c57f7a
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/4750
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Michael Jeanson [Tue, 26 Jan 2021 20:14:09 +0000 (15:14 -0500)]
Fix: disable deprecation warnings for SWIG generated code
There is nothing we can do about deprecations in SWIG generated code so
silence this warning.
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ia3188e6e8fcb52a635d6793f4a40808479860252
Simon Marchi [Tue, 26 Jan 2021 16:42:30 +0000 (11:42 -0500)]
Fix: configure: support Autoconf 2.70
This patch is stolen and adapted from lttng-tools' patch:
https://git.lttng.org/?p=lttng-tools.git;a=commit;h=
faa88ea855741f5c356d223011ff4b347576c7d2
The newly-released autoconf 2.70 introduces a number of breaking
changes [1] and is being rolled-out by some distros.
Amongst those changes, the AC_PROG_CC_STDC macro is marked as obsolete
and was merged into AC_PROG_CC, which we already use. On 2.70, this
results in a warning which we handle as an error.
A version check is added to invoke the AC_PROG_CC_STDC macro only when
running a pre-2.70 version of autoconf, fixing the issue.
The AC_PROG_LEX now takes an argument, and the argument-less version is
marked as obsolete. The macro is invoked with the `noyywrap` option, as
recommended in the documentation.
Also, the AX_PTHREAD macro makes use of the $as_echo built-in shell
variable which no longer exists in 2.70. A patch was submitted to the
GNU Autoconf archive in March, but there have been no signs of life
given since then [2].
As such, our local copy is updated to the latest version and the patch
(which looks fairly straight-forward / safe) is applied. This should
minimize changes once we go back to an "official" version of the macro.
Some issues with glib2 remain:
configure.ac:264: warning: The macro `AC_TRY_RUN' is obsolete.
configure.ac:264: You should run autoupdate.
./lib/autoconf/general.m4:2996: AC_TRY_RUN is expanded from...
/usr/share/aclocal/glib-2.0.m4:11: AM_PATH_GLIB_2_0 is expanded from...
configure.ac:264: the top level
configure.ac:264: warning: The macro `AC_TRY_LINK' is obsolete.
configure.ac:264: You should run autoupdate.
./lib/autoconf/general.m4:2919: AC_TRY_LINK is expanded from...
/usr/share/aclocal/glib-2.0.m4:11: AM_PATH_GLIB_2_0 is expanded from...
configure.ac:264: the top level
Those have been fixed upstream:
https://gitlab.gnome.org/GNOME/glib/-/commit/
6f26637e83727b05f865389937bb07c761c13c12
so it's always possible to get the modifications from there for local
development.
[1] https://lwn.net/Articles/839395/
[2] https://savannah.gnu.org/patch/?9906
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-by: Michael Jeanson <michael.jeanson@efficios.com>
Change-Id: Ia9f5ac6721a556238e84bee64d57e04bf378fee9
Reviewed-on: https://review.lttng.org/c/babeltrace/+/4743
Reviewed-by: Michael Jeanson <mjeanson@efficios.com>
Philippe Proulx [Thu, 10 Sep 2020 14:51:07 +0000 (10:51 -0400)]
Add `dev-requirements.txt` for pip
`dev-requirements.txt` contains which specific version of Black and
Flake8 to use for development and by a CI so that both parties agree.
Use specific versions as such:
$ virtualenv -p python3 yo
$ . yo/bin/activate
$ pip install -r dev-requirements.txt
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Id29e7f61c4038b55bed613e00f76f7c180699fa9
Reviewed-on: https://review.lttng.org/c/babeltrace/+/4057
CI-Build: Michael Jeanson <mjeanson@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Michael Jeanson <mjeanson@efficios.com>
Reviewed-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Fabrice Fontaine [Sat, 26 Sep 2020 20:03:10 +0000 (22:03 +0200)]
tests/lib/test_trace_ir_ref.c: rename user structure
Rename user structure to bt_user to avoid the following build failure
with uclibc:
test_trace_ir_ref.c:41:8: error: redefinition of 'struct user'
struct user {
^
In file included from /home/naourr/work/instance-0/output-1/per-package/babeltrace2/host/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/include/sys/procfs.h:33,
from /home/naourr/work/instance-0/output-1/per-package/babeltrace2/host/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/include/sys/ucontext.h:25,
from /home/naourr/work/instance-0/output-1/per-package/babeltrace2/host/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/include/signal.h:329,
from /home/naourr/work/instance-0/output-1/per-package/babeltrace2/host/bin/../arm-buildroot-linux-uclibcgnueabi/sysroot/usr/include/glib-2.0/glib/gbacktrace.h:36,
from /home/naourr/work/instance-0/output-1/per-package/babeltrace2/host/bin/../arm-buildroot-linux-uclibcgnueabi/sysroot/usr/include/glib-2.0/glib.h:34,
from ../../src/common/assert.h:28,
from ../../src/lib/object.h:28,
from test_trace_ir_ref.c:25:
/home/naourr/work/instance-0/output-1/per-package/babeltrace2/host/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/include/sys/user.h:48:8: note: originally defined here
struct user
^~~~
Fixes:
- http://autobuild.buildroot.org/results/
e4229e2b9c892b419a9d2eaa6929b80ea62dd130
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Change-Id: I1a9d912545f781d61d6e3c62b31998285d2a237c
Reviewed-on: https://review.lttng.org/c/babeltrace/+/4522
CI-Build: Simon Marchi <simon.marchi@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Philippe Proulx [Mon, 7 Dec 2020 19:21:47 +0000 (14:21 -0500)]
src/common/{assert,macros}.h: wrap code in C++ guards
Not strictly needed for `macros.h`, but adding it just in case.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I6d13ab5a062c6c5b1ecaa996c119a149d2487f0b
Reviewed-on: https://review.lttng.org/c/babeltrace/+/4504
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
Philippe Proulx [Thu, 19 Nov 2020 18:21:00 +0000 (13:21 -0500)]
CONTRIBUTING.adoc: document C++ usage
This patch adds a C++ usage section to `CONTRIBUTING.adoc` as a baseline
of rules and recommended practices to write C++ code for Babeltrace 2.
The reminders at the end of the document are some points I could
initially think of, but we'll add more and probably categorize them as
we write C++ code for this project.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I482fd5d4c3870f90bc8f9b7d7122f19bac0e2757
Reviewed-on: https://review.lttng.org/c/babeltrace/+/4424
Philippe Proulx [Thu, 19 Nov 2020 18:03:56 +0000 (13:03 -0500)]
Add `.clang-format` file for C++ source files
This patch adds the `.clang-format` file which contains a style to be
applied automatically by the clang-format [1] tool to the project's C++
files.
To apply the style to all the project's C++ files, run:
$ find -iname '*.cpp' -o -iname '*.hpp' -exec clang-format -i '{}' ';'
As of this patch, the project has no C++ files. This patch is part of an
effort to lay the ground for the introduction of C++ sources in
Babeltrace 2.
I chose to set the `PointerAlignment` style setting to `Left` as
clang-format also uses it for references:
const char* str
const std::string& str
[1]: https://clang.llvm.org/docs/ClangFormat.html
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I1def3ec2bf309819878aacef80bd5681d4c44e73
Reviewed-on: https://review.lttng.org/c/babeltrace/+/4423
Philippe Proulx [Thu, 19 Nov 2020 16:26:01 +0000 (11:26 -0500)]
CONTRIBUTING.adoc: follow EfficiOS AsciiDoc conventions
This patch:
* Removes the version, only keeping the date.
* Sets the `bt2` attribute with a non-breaking space to avoid
redundancy.
* Keeps only one empty line above a heading.
* Do not repeat full heading title in internal links.
This is in line with the style of other EfficiOS AsciiDoc documents.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: If991b9ac6161a436911f4dd3bc3e80f2eea3fd78
Reviewed-on: https://review.lttng.org/c/babeltrace/+/4422
Simon Marchi [Wed, 2 Dec 2020 22:36:05 +0000 (17:36 -0500)]
Fix: sink.ctf.fs: fix logic of make_unique_stream_file_name
The logic in make_unique_stream_file_name is wrong. It tries names as
long as the candidate exists _and_ is named "metadata". The intent here
is that we keep trying names as long as the candidate name names an
already existing file _or_ is named "metadata". So the && should be a
||.
The impact of this bug is that if two streams have the same name,
they'll write to the same file, with troubling consequences (see bug
1279 [1]).
Add a test where `sink.ctf.fs` writes a trace with two streams with the
same name, and one stream named "metadata".
[1] https://bugs.lttng.org/issues/1279
Change-Id: Ifaa30459574229aa5e607095f65033d2caae188f
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/4483
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Simon Marchi [Wed, 2 Dec 2020 21:04:19 +0000 (16:04 -0500)]
Fix: sink.ctf.fs: remove spurious directory level when using assume-single-trace
The behavior of `sink.ctf.fs` with the `assume-single-trace=true`
parameter does not match the documentation nor the comments in the code.
The man page says:
If the assume-single-trace parameter is true, then the output trace
path to use for the single input trace is the directory specified by
the path parameter.
What I understand from this is that if you pass `path=/tmp/yo`, that
should produce the `/tmp/yo/metadata` file and the data files alongside
it.
The documentation on the `fs_sink_comp::assume_single_trace` says:
/*
* True if the component assumes that it will only write a
* single CTF trace (which can contain one or more data
* streams). This makes the component write the stream files
* directly in the output directory (`output_dir_path` above).
*/
bool assume_single_trace;
The `output_dir_path` would contain `/tmp/yo`, in the previous example,
so that confirms the previous assumption.
The actual behavior is that the sink puts the trace in an extra `trace`
directory, in `/tmp/yo/trace`.
We end up with the `trace` relative trace path (relative to the base
output directory) because `make_trace_path_rel` returns an empty string
when `assume_single_trace` is true and `sanitize_trace_path` replaces it
with `trace`.
When using `assume-single-trace=true`, we should not deal with a
relative trace path, as the trace is output directly in the base output
directory. We also don't want to run the path in
`make_unique_trace_path`, as the trace should be output in the base
directory specified by the user, not another directory. Anyway, if the
user specifies an existing directory, `sink.ctf.fs` will initially
error out with:
Single trace mode, but output path exists: output-path="/tmp/yo"
Although that's a TOCTOU bug, two babeltrace instances could both check
at the same time that the same output directory does not exist, and both
write in the same directory. That would not be good.
Change-Id: Ib2415420eabbc096a920d113863993161105e90a
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/4480
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Michael Jeanson [Wed, 18 Nov 2020 16:22:56 +0000 (11:22 -0500)]
Add C++11 support to the build system
Add C++11 support in preparation to the addition of C++ sources in the
plugins.
Automake uses the following variables for C++ files:
* AM_CPPFLAGS / CPPFLAGS: Preprocessor flags
* AM_CXXFLAGS / CXXFLAGS: C++ compiler flags
* AM_LDFLAGS / LDFLAGS: Linker flags
Change-Id: Ib9d1ce4b7853981c441e1c31460fd24579fa97ea
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/4413
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Michael Jeanson [Thu, 29 Oct 2020 14:29:55 +0000 (10:29 -0400)]
fix: merge of AE_FEATURE and FreeBSD disable debug-info
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Change-Id: Ieda416eedaf449d4a3d4a1cb1c5f63450c16611b
Reviewed-on: https://review.lttng.org/c/babeltrace/+/4287
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Michael Jeanson [Wed, 16 Sep 2020 18:46:55 +0000 (14:46 -0400)]
Fix: elfutils detection fallback for sles12
Turns out SLES12 doesn't bother shipping .pc files for elfutils, add a
fallback compile test that will work even in cross-compilation.
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ia31b9add4831a9c4a67a440e7b1777d5f12d94d9
Michael Jeanson [Thu, 10 Sep 2020 19:20:03 +0000 (15:20 -0400)]
Rename AM_CHECK_PYTHON_SPHINX to AE_CHECK_PYTHON_SPHINX
The AM prefix is reserved for upstream automake macros, use our own AE
prefix which stands for "Autotools EfficiOS".
This is part of an effort to standardize our custom macros across all
our autotools based projects.
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I5e03597945c38710ccad84fa1959834dabeab60d
Michael Jeanson [Thu, 10 Sep 2020 19:04:43 +0000 (15:04 -0400)]
Rename AM_PATH_PYTHON_MODULES to AE_PATH_PYTHON_MODULES
The AM prefix is reserved for upstream automake macros, use our own AE
prefix which stands for "Autotools EfficiOS".
This is part of an effort to standardize our custom macros across all
our autotools based projects.
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: If5e94c7fa6df2d368c3cb9ae14c080caf2c27837
Michael Jeanson [Thu, 10 Sep 2020 15:06:28 +0000 (11:06 -0400)]
Introduce AE_FEATURE to manage configure features
The new AE_FEATURE set of macros are wrappers over autoconf's
AC_ARG_ENABLE. The main objective is to make the m4sh code more readable
to the less seasoned autotools enthusiast among us and reduce the
duplication of code with it's associated bugs.
The AE prefix was chosen to mean "Autotools EfficiOS" and is part of an
effort to standardize our custom macros across all our autotools based
projects.
Change-Id: I7f802cb026ab4a386e05b27aaed56a5f189d0391
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Michael Jeanson [Mon, 19 Oct 2020 22:13:35 +0000 (18:13 -0400)]
port: 'ls --ignore=' is a GNU extension
Use grep -v instead to filter README.adoc.
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I9b58120ee94dc4caa7b1e69bb4a4807f2af6f98c
Michael Jeanson [Mon, 19 Oct 2020 16:26:36 +0000 (12:26 -0400)]
port: add 'notext' keyword linker support
Check if the linker support the 'notext' keyword to allow relocations
against read-only segments. GNU ld defaults to notext but LLVM's ld does
not, both linkers support the keyword.
This is required for the plugins section symbols.
Change-Id: I2b5f5c77865267e35c529dd17a0298cd4405303d
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Michael Jeanson [Mon, 19 Oct 2020 17:04:17 +0000 (13:04 -0400)]
port: fix compat/endian.h on FreeBSD
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Iad3591f6f2172d8640abc13c9608aa393db5f199
Michael Jeanson [Mon, 19 Oct 2020 17:03:50 +0000 (13:03 -0400)]
Fix: tests: use the test suite configured python binary
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I4cd7e1389503fe0914abf965f56e9d2143cbe9fa
Michael Jeanson [Mon, 19 Oct 2020 16:44:32 +0000 (12:44 -0400)]
port: tests: Add sys/wait.h include for FreeBSD
Required for WIFEXITED and WEXITSTATUS.
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Iaf3b95bfe048eab43b8ecb6c8837bc5a5242828d
Michael Jeanson [Mon, 19 Oct 2020 16:37:53 +0000 (12:37 -0400)]
port: namespace align.h with BT_ prefix
ALIGN is defined in FreeBSD system includes with an incompatible
signature, namespace our internal version.
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ib5b24a7194a0ddbe6eab9aa4f789c612886594f5
Michael Jeanson [Mon, 19 Oct 2020 16:29:53 +0000 (12:29 -0400)]
port: Add sys/param.h include to compat/limits.h for FreeBSD
Required for MAXHOSTNAMELEN.
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Iea97849212c736dc93e4b2ce07b23107764e367b
Michael Jeanson [Mon, 19 Oct 2020 16:18:07 +0000 (12:18 -0400)]
port: disable debug-info by default on FreeBSD
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I25909ef56f33a0832c7aa5b4eece4e04c4b2e75a
Michael Jeanson [Wed, 9 Sep 2020 18:50:04 +0000 (14:50 -0400)]
Update minimum autotools versions in README.adoc
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Change-Id: Ife8e4be34eca414fac7e818f1d58179f258cd418
Reviewed-on: https://review.lttng.org/c/babeltrace/+/4058
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Philippe Proulx [Thu, 10 Sep 2020 15:35:58 +0000 (11:35 -0400)]
Reformat Python files with Black v20.8b1
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I50a663f02800456ce2370383bbdaefa8e0ebabc1
Reviewed-on: https://review.lttng.org/c/babeltrace/+/4062
Tested-by: jenkins <jenkins@lttng.org>
Philippe Proulx [Thu, 10 Sep 2020 20:47:52 +0000 (16:47 -0400)]
Fix: bt2: _trim_docstring(): docstring can have 0 or 1 line
It is possible that a user component class's docstring has no lines or a
single one, for example:
# no line
class MySink(bt2._UserSinkComponent):
""""""
def _user_consume(self):
pass
# single line
class MySink(bt2._UserSinkComponent):
"""The single line"""
def _user_consume(self):
pass
The previous version of _trim_docstring() expects this format:
class MySink(bt2._UserSinkComponent):
"""
My sink's description
Dolore officia ex et aliquip eiusmod enim pariatur reprehenderit
ad adipisicing non occaecat ullamco aliquip laborum duis
proident ex duis.
Irure commodo proident esse non pariatur in aute cillum id aute.
"""
def _user_consume(self):
pass
In _trim_docstring(), accept no lines or a single one.
Adding new tests to `test_component_class.py` to validate this
behaviour. The
# fmt: off
"""
"""
# fmt: on
docstring has off/on formatting markers as Black 20.8b1 transforms this
into the non-equivalent
""""""
(which is another test now).
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ia12b0e9bfd4d1e1aaa86f0c8c207c3c1535f5c3e
Reviewed-on: https://review.lttng.org/c/babeltrace/+/4072
Philippe Proulx [Tue, 21 Jul 2020 17:57:10 +0000 (13:57 -0400)]
Fix: `ctf` plugin: use element FC's alignment as array/seq. FC alignment
Observed issue
==============
When reading some CTF trace with an empty array/sequence field,
Babeltrace 2 can fail.
More specifically, for the trace `tests/data/ctf-traces/succeed/array-align-elem`
(added by this patch):
The CLI's output is:
07-21 14:00:24.636 73959 73959 E PLUGIN/CTF/MSG-ITER request_medium_bytes@msg-iter.c:535 [auto-disc-source-ctf-fs] User function returned EOF, but message iterator is in an unexpected state: state=DSCOPE_EVENT_PAYLOAD_CONTINUE, cur-packet-size=-1, cur=24, packet-cur=24, last-eh-at=16
07-21 14:00:24.636 73959 73959 E PLUGIN/CTF/MSG-ITER read_dscope_continue_state@msg-iter.c:632 [auto-disc-source-ctf-fs] Cannot ensure that buffer has at least one byte: msg-addr=0x55d3b4e051f0, status=ERROR
07-21 14:00:24.636 73959 73959 E PLUGIN/CTF/MSG-ITER ctf_msg_iter_get_next_message@msg-iter.c:2881 [auto-disc-source-ctf-fs] Cannot handle state: msg-it-addr=0x55d3b4e051f0, state=DSCOPE_EVENT_PAYLOAD_CONTINUE
07-21 14:00:24.636 73959 73959 E PLUGIN/SRC.CTF.FS ctf_fs_iterator_next_one@fs.c:90 [auto-disc-source-ctf-fs] Failed to get next message from CTF message iterator.
07-21 14:00:24.636 73959 73959 W LIB/MSG-ITER bt_message_iterator_next@iterator.c:865 Component input port message iterator's "next" method failed: iter-addr=0x55d3b4e05000, iter-upstream-comp-name="auto-disc-source-ctf-fs", iter-upstream-comp-log-level=WARNING, iter-upstream-comp-class-type=SOURCE, iter-upstream-comp-class-name="fs", iter-upstream-comp-class-partial-descr="Read CTF traces from the file sy", iter-upstream-port-type=OUTPUT, iter-upstream-port-name="array-align-elem | 0 | array-align-elem/stream", status=ERROR
07-21 14:00:24.636 73959 73959 E PLUGIN/FLT.UTILS.MUXER muxer_upstream_msg_iter_next@muxer.c:446 [muxer] Upstream iterator's next method returned an error: status=ERROR
07-21 14:00:24.636 73959 73959 E PLUGIN/FLT.UTILS.MUXER validate_muxer_upstream_msg_iters@muxer.c:989 [muxer] Cannot validate muxer's upstream message iterator wrapper: muxer-msg-iter-addr=0x55d3b4dcb830, muxer-upstream-msg-iter-wrap-addr=0x55d3b4e055c0
ev: { a = 1, b = [ ], c = 2 }
07-21 14:00:24.636 73959 73959 E PLUGIN/FLT.UTILS.MUXER muxer_msg_iter_next@muxer.c:1417 [muxer] Cannot get next message: comp-addr=0x55d3b4dcae70, muxer-comp-addr=0x55d3b4dcaef0, muxer-msg-iter-addr=0x55d3b4dcb830, msg-iter-addr=0x55d3b4dcb750, status=ERROR
07-21 14:00:24.636 73959 73959 W LIB/MSG-ITER bt_message_iterator_next@iterator.c:865 Component input port message iterator's "next" method failed: iter-addr=0x55d3b4dcb750, iter-upstream-comp-name="muxer", iter-upstream-comp-log-level=WARNING, iter-upstream-comp-class-type=FILTER, iter-upstream-comp-class-name="muxer", iter-upstream-comp-class-partial-descr="Sort messages from multiple inpu", iter-upstream-port-type=OUTPUT, iter-upstream-port-name="out", status=ERROR
07-21 14:00:24.636 73959 73959 W LIB/GRAPH consume_graph_sink@graph.c:462 Component's "consume" method failed: status=ERROR, comp-addr=0x55d3b4dcb070, comp-name="pretty", comp-log-level=WARNING, comp-class-type=SINK, comp-class-name="pretty", comp-class-partial-descr="Pretty-print messages (`text` fo", comp-class-is-frozen=1, comp-class-so-handle-addr=0x55d3b4dc7c50, comp-class-so-handle-path="/home/eepp/dev/babeltrace/install/lib/babeltrace2/plugins/babeltrace-plugin-text.la", comp-input-port-count=1, comp-output-port-count=0
07-21 14:00:24.636 73959 73959 E CLI cmd_run@babeltrace2.c:2529 Graph failed to complete successfully
ERROR: [Babeltrace CLI] (babeltrace2.c:2529)
Graph failed to complete successfully
CAUSED BY [libbabeltrace2] (graph.c:462)
Component's "consume" method failed: status=ERROR, comp-addr=0x55d3b4dcb070, comp-name="pretty", comp-log-level=WARNING, comp-class-type=SINK,
comp-class-name="pretty", comp-class-partial-descr="Pretty-print messages (`text` fo", comp-class-is-frozen=1, comp-class-so-handle-addr=0x55d3b4dc7c50,
comp-class-so-handle-path="/home/eepp/dev/babeltrace/install/lib/babeltrace2/plugins/babeltrace-plugin-text.la", comp-input-port-count=1,
comp-output-port-count=0
CAUSED BY [libbabeltrace2] (iterator.c:865)
Component input port message iterator's "next" method failed: iter-addr=0x55d3b4dcb750, iter-upstream-comp-name="muxer",
iter-upstream-comp-log-level=WARNING, iter-upstream-comp-class-type=FILTER, iter-upstream-comp-class-name="muxer",
iter-upstream-comp-class-partial-descr="Sort messages from multiple inpu", iter-upstream-port-type=OUTPUT, iter-upstream-port-name="out", status=ERROR
CAUSED BY [muxer: 'filter.utils.muxer'] (muxer.c:1417)
Cannot get next message: comp-addr=0x55d3b4dcae70, muxer-comp-addr=0x55d3b4dcaef0, muxer-msg-iter-addr=0x55d3b4dcb830, msg-iter-addr=0x55d3b4dcb750,
status=ERROR
CAUSED BY [muxer: 'filter.utils.muxer'] (muxer.c:989)
Cannot validate muxer's upstream message iterator wrapper: muxer-msg-iter-addr=0x55d3b4dcb830, muxer-upstream-msg-iter-wrap-addr=0x55d3b4e055c0
CAUSED BY [muxer: 'filter.utils.muxer'] (muxer.c:446)
Upstream iterator's next method returned an error: status=ERROR
CAUSED BY [libbabeltrace2] (iterator.c:865)
Component input port message iterator's "next" method failed: iter-addr=0x55d3b4e05000, iter-upstream-c
Cause
=====
The internal CTF IR array and sequence field classes do not have an
alignment which is equal to their element FC's alignment, although
CTF 1.8.3 requires it [1]:
> Arrays are always aligned on their element alignment requirement.
Solution
========
In `bfcr.c`, align_class_state() is already called for array/sequence
fields.
Add a CTF IR trace class visitor to set any array/sequence FC's
alignment to its element FC's alignment, recursively (postorder).
Also update, postorder, structure FC alignments since some of the
alignments of the field types of their members can change.
Note
====
This patch adds two minimalist CTF traces to test the fix as well as two
new corresponding tests in
`tests/plugins/src.ctf.fs/succeed/test_succeed`:
`array-align-elem`:
Metadata:
struct {
integer { size = 8; } a;
integer { size = 8; align = 16; } b[0];
integer { size = 8; } c;
};
Taking the aligment of `b` into account, there's one byte of padding
between `a` and `c`:
a # c
^---- alignment of `b`
`struct-array-align-elem`:
Metadata:
struct {
integer { size = 8; } x;
struct {
integer { size = 8; } a;
integer { size = 8; align = 32; } b[0];
} y;
integer { size = 8; } z;
};
Taking the alignment of `y.b` into account, the `y` structure itself
is 32-bit-aligned, making the outer structure also 32-bit-aligned.
Therefore, there are three bytes of padding between `x` and `a`, and
three other bytes of padding between `a` and `z`:
x # # # a # # # z
^ ^-------- alignment of `b`
'---------------- alignment of `y`
References
==========
[1]: https://diamon.org/ctf/v1.8.3/#spec4.2.3
Fixes: https://bugs.lttng.org/issues/1276
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: If1ccfe374976e9faef590f2fe7ff6bac2f335df8
Reviewed-on: https://review.lttng.org/c/babeltrace/+/3805
Michael Jeanson [Thu, 23 Jul 2020 20:51:59 +0000 (16:51 -0400)]
Enable autotools warnings as errors
Enable all autotools warnings and error out to help catch all the
wonderful, shall we say, pecularities of M4sh.
* Bump the minimum autoconf version to 2.69, we already require
automake 1.12 released in 2012, use an autoconf of the same vintage.
* Minor syntax tweaks by running 'autoupdate'.
* Use AS_ESCAPE to escape bt_version_description C string
* Rename obsolete AC_HELP_STRING to AS_HELP_STRING.
* Use pkg-config to detect elfutils instead of our custom macro using
AC_RUN_IFELSE which won't work when cross-compiling.
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Change-Id: Ic4de35dc6a51db3fd82b145e8a4ce4bb80e6b27b
Reviewed-on: https://review.lttng.org/c/babeltrace/+/3812
CI-Build: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Simon Marchi [Mon, 10 Aug 2020 14:55:37 +0000 (10:55 -0400)]
sink.ctf.fs: append error causes where relevant
The `sink.ctf.fs` component class doesn't append error causes when it
encounters errors. This makes the error reporting very vague. For
example, both when the user fails to pass the required `path` parameter
and when they pass a path to a directory they don't have write
permissions on, they get:
ERROR: [Babeltrace CLI] (/home/simark/src/babeltrace/src/cli/babeltrace2.c:2462)
Cannot create components.
CAUSED BY [Babeltrace CLI] (/home/simark/src/babeltrace/src/cli/babeltrace2.c:2277)
Cannot create component: plugin-name="ctf", comp-cls-name="fs", comp-cls-type=4, comp-name="sink.ctf.fs"
CAUSED BY [libbabeltrace2] (/home/simark/src/babeltrace/src/lib/graph/graph.c:1055)
Component initialization method failed: status=ERROR, comp-addr=0x60c000011d40, comp-name="sink.ctf.fs", comp-log-level=WARNING, comp-class-type=SINK, comp-class-name="fs",
comp-class-partial-descr="Write CTF traces to the file sys", comp-class-is-frozen=1, comp-class-so-handle-addr=0x607000000100,
comp-class-so-handle-path="/home/simark/build/babeltrace/src/plugins/ctf/babeltrace-plugin-ctf.la", comp-input-port-count=0, comp-output-port-count=0
Add calls to append error causes where relevant. It becomes much easier
to distinguish the errors:
ERROR: [Babeltrace CLI] (/home/simark/src/babeltrace/src/cli/babeltrace2.c:2462)
Cannot create components.
CAUSED BY [Babeltrace CLI] (/home/simark/src/babeltrace/src/cli/babeltrace2.c:2277)
Cannot create component: plugin-name="ctf", comp-cls-name="fs", comp-cls-type=4, comp-name="sink.ctf.fs"
CAUSED BY [libbabeltrace2] (/home/simark/src/babeltrace/src/lib/graph/graph.c:1055)
Component initialization method failed: status=ERROR, comp-addr=0x60c000011d40, comp-name="sink.ctf.fs", comp-log-level=WARNING, comp-class-type=SINK, comp-class-name="fs",
comp-class-partial-descr="Write CTF traces to the file sys", comp-class-is-frozen=1, comp-class-so-handle-addr=0x607000000100,
comp-class-so-handle-path="/home/simark/build/babeltrace/src/plugins/ctf/babeltrace-plugin-ctf.la", comp-input-port-count=0, comp-output-port-count=0
CAUSED BY [sink.ctf.fs: 'sink.ctf.fs'] (/home/simark/src/babeltrace/src/plugins/ctf/fs-sink/fs-sink.c:74)
Error validating parameters: missing mandatory entry `path`
and
ERROR: [Babeltrace CLI] (/home/simark/src/babeltrace/src/cli/babeltrace2.c:2462)
Cannot create components.
CAUSED BY [Babeltrace CLI] (/home/simark/src/babeltrace/src/cli/babeltrace2.c:2277)
Cannot create component: plugin-name="ctf", comp-cls-name="fs", comp-cls-type=4, comp-name="sink.ctf.fs"
CAUSED BY [libbabeltrace2] (/home/simark/src/babeltrace/src/lib/graph/graph.c:1055)
Component initialization method failed: status=ERROR, comp-addr=0x60c000011e00, comp-name="sink.ctf.fs", comp-log-level=WARNING, comp-class-type=SINK, comp-class-name="fs",
comp-class-partial-descr="Write CTF traces to the file sys", comp-class-is-frozen=1, comp-class-so-handle-addr=0x607000000100,
comp-class-so-handle-path="/home/simark/build/babeltrace/src/plugins/ctf/babeltrace-plugin-ctf.la", comp-input-port-count=0, comp-output-port-count=0
CAUSED BY [sink.ctf.fs: 'sink.ctf.fs'] (/home/simark/src/babeltrace/src/plugins/ctf/fs-sink/fs-sink.c:40)
Cannot create directories for output directory: Permission denied: output-dir-path="/tmp/pouet/yo"
Change-Id: I384e88a1d2629ac75495518c8bce2a2cba2f9741
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/3907
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Mon, 10 Aug 2020 15:02:18 +0000 (11:02 -0400)]
sink.ctf.fs: remove unreachable error cases
Just before this switch, we already check if `next_status` is negative
and bail out. It's therefore not possible for the `ERROR` and
`MEMORY_ERROR` cases to be reached.
Change-Id: I6afa4d2f57e0b3574bbbef0e60c6dc5ebb746fb3
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/3906
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Geneviève Bastien [Tue, 25 Feb 2020 20:33:49 +0000 (15:33 -0500)]
sink.text.pretty: add optional `print-enum-flags` parameter
`print-enum-flags` parameter
============================
This new parameter tells the component to try to print enum values as
ORed bit flags if it applies.
When printing the value of an enum field that has no corresponding mapping,
the value is divided into its bit values and if each bit has a corresponding
mapping, consider that those mappings are ORed bit flags.
If any of the bits has no mapping, then the value is printed as <unknown>.
Example Babeltrace output of such a field (block_rq* kernel events):
[13:15:49.
024354958] (+0.
000003868) wilbrod block_rq_complete: { cpu_id = 4 },
{ dev =
8388624, sector =
375490176, nr_sector = 360, error = 0,
rwbs = ( "RWBS_FLAG_READ" | "RWBS_FLAG_RAHEAD" : container = 12 ) }
This parameter defaults to `false` as it may trigger unexpected behavior
if a trace contains a bit flag that is not described in the metadata as
is, but can be expressed as a binary OR of two existing values.
This can happen if an application changes the possible values of an
enumeration but forgets to update the metadata associated with
that recorded field. Such value must be printed as <unknown>.
Print all labels matching value
===============================
With this commit, a `sink.text.pretty` component will print all matching
labels inside curly brackets separated by commas. See
`print_enum_value_label_array()`.
So if an enum value matches two labels it will be printed as:
enum_field = ( { "bit0", "range1to3" } : container = 1 )
Change-Id: I26a17307243d5612c70c0e5b04e6b9567b0720d3
Signed-off-by: Geneviève Bastien <gbastien@versatic.net>
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/3045
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Geneviève Bastien [Wed, 26 Feb 2020 20:49:57 +0000 (15:49 -0500)]
Tests: sink.text.pretty: Add unit tests for enum fields printing
Adds a Python component class who creates an event class with an enum
field that contains the enumeration described by the test caller. The
script iterator has a single event with a value also sent in parameter.
The tests themselves are run from a bash script, for signed/unsigned
values.
This commit also renames the existing `test_pretty` test file to
`test_pretty_python` to control all future Python tests for the
`sink.text.pretty` component class.
Change-Id: I3f631224dd3bdf21dbb2ef2d233c9f2dc8da43fa
Signed-off-by: Geneviève Bastien <gbastien@versatic.net>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/3149
CI-Build: Francis Deslauriers <francis.deslauriers@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Simon Marchi [Wed, 5 Aug 2020 19:54:20 +0000 (15:54 -0400)]
bt2: update comment about bt2._UserMessageIterator
The comment modified by this patch contains a few stale informations.
Update it to reflect the current reality.
Change-Id: I565eed51728c74ed5d8ba1e07d32b5b538a0c554
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/3882
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Wed, 5 Aug 2020 18:48:34 +0000 (14:48 -0400)]
bt2: remove comment reference to "output port message iterator"
Output port message iterators is a concept that existed in preliminary
versions of Babeltrace 2, but did not exist in the final release. This
comment is stale.
Change-Id: I012e640eb33fe1dbf84b3863ae21a313f6de57f3
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/3881
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Philippe Proulx [Thu, 23 Jul 2020 18:16:29 +0000 (14:16 -0400)]
babeltrace2-source.ctf.fs(7): add a "CTF compliance" description section
This new section states that `src.ctf.fs` complies with CTF 1.8.3. It
also lists a few exceptions/limitations.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I45dc9d6c63fc17f1660ddf9359e83da9e1967df3
Reviewed-on: https://review.lttng.org/c/babeltrace/+/3809
Reviewed-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Francis Deslauriers [Mon, 13 Jul 2020 17:43:59 +0000 (13:43 -0400)]
Fix: src.ctf.lttng-live: overwrite of error status trips `BT_ASSERT()`
Issue
=====
While tracking a bug in the LTTng Consumer daemon we witness an
assertion failure of Babeltrace:
# Test ust streaming live clear with viewer
# Parameters: tracing_active=1, clear_twice=1, buffer_type=uid
ok 253 - Create session Yi7ksFEZ76dwwd4m with uri:net://localhost and opts: --live
ok 254 - Enable channel chan for session Yi7ksFEZ76dwwd4m
ok 255 - Enable ust event tp:tptest for session Yi7ksFEZ76dwwd4m
ok 256 - Start tracing for session Yi7ksFEZ76dwwd4m
# Waiting for live trace at url: net://localhost
ok 257 - Waiting for live trace at url: net://localhost
# Waiting for live viewers on url: net://localhost
ok 258 - Waiting for live viewers on url: net://localhost
07-10 15:14:20.932 13745 13745 E PLUGIN/SRC.CTF.LTTNG-LIVE/VIEWER lttng_live_get_stream_bytes@viewer-connection.c:1601 [lttng-live] Received get_data_packet response: unknown
(╯°□°)╯︵ ┻━┻ msg-iter.c:491: request_medium_bytes(): Assertion `buffer_sz != 0` failed
The issue is that even when the `lttng_live_get_stream_bytes()`
function fails miserably because of an unknown status code, it could
return a `CTF_MSG_ITER_MEDIUM_STATUS_OK`. This happens because we are
calling the `viewer_status_to_ctf_msg_iter_medium_status()` function in
the `error:` label even when the `status` variable was already set.
Solution
========
Add another label to specifically convert status from `enum lttng_live_viewer_status` to
`enum ctf_msg_iter_medium_status`.
Notes
=====
- This commit adds the printing of the value of the unknown status
received by the Relay
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I6c740dd28ee0b336cf06dbdbf60d6333cf79d168
Reviewed-on: https://review.lttng.org/c/babeltrace/+/3758
Reviewed-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
Jérémie Galarneau [Thu, 16 Jul 2020 20:09:53 +0000 (16:09 -0400)]
Fix: source.ctf.lttng-live: muxing failure on clear (unit conversion)
This commit is a follow-up fix for
8ec4d5ff (see original message).
The original fix included a bogus comparison of:
`stream_iter->last_inactivity_ts > curr_msg_ts_ns`
While the idea behind the fix is valid, this statement compares
nanoseconds since Unix Epoch (former) to clock cycles (latter).
A conversion of the `last_inactivity_ts` to nanoseconds since Unix epoch
is performed using the stream's default clock class allowing a
comparison in a common time base to take place.
The diff looks more intimidating than it really is as it shifts the
indentation of a lot of code at once. This is because we only want to
perform the timestamp conversion when necessary (very rarely) on this
fairly hot path.
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ibdc365fec4685da88ae141383d5e5ef0af169a87
Simon Marchi [Wed, 15 Jul 2020 16:17:24 +0000 (12:17 -0400)]
configure: enable -Wstrict-prototypes unconditionally
I noticed that -Wstrict-prototypes would not get enabled, because the
autoconf test program generates a warning of this type. Enable it
unconditionally, like we already do for -Wold-style-definition.
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I145ceedb977d1d60a094f598ecae56930c742c4c
Francis Deslauriers [Mon, 13 Jul 2020 20:20:14 +0000 (16:20 -0400)]
Cleanup: flt.lttng-utils.debug-info: indentation fixes
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: If177e044acc85672b18fb88d06af3296516057e4
Francis Deslauriers [Mon, 13 Jul 2020 17:41:38 +0000 (13:41 -0400)]
Cleanup: src.ctf.lttng-live: missing space in debug statement
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I2bb8477aaad8ce6ee8d17b9c315fc34bc05ce577
Francis Deslauriers [Mon, 29 Jun 2020 20:27:46 +0000 (16:27 -0400)]
Cleanup: flt.lttng-utils.debug-info: remove usage of `bt_bool` inside the component class
Also, cleanup an extra whitespace.
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I7916ededcde363e6d3c7ae2eec417eedb7c1851a
Michael Jeanson [Mon, 13 Jul 2020 18:56:57 +0000 (14:56 -0400)]
tests: return the proper TAP exit code
The C TAP library provides the 'exit_status()' function that will return
the proper exit code according to the number of tests that succeeded or
failed.
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ia76ed7d1510bb23bf3848f85ac9022c66e752311
Michael Jeanson [Thu, 25 Jun 2020 16:28:08 +0000 (12:28 -0400)]
Port: No syslimits.h on GNU Hurd
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Change-Id: I72c7d35ee121abd0dd95ceb11127c6de90a20187
Michael Jeanson [Thu, 25 Jun 2020 16:30:27 +0000 (12:30 -0400)]
Port: Add logging thread id support on GNU Hurd
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I8db78267136ba172964f3c8c1f40115e28ac6446
Michael Jeanson [Thu, 25 Jun 2020 16:19:45 +0000 (12:19 -0400)]
Port: Set PATH_MAX on GNU Hurd
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I1490391b47ad9fe905482a362f589d26f5a13a3c
Simon Marchi [Mon, 8 Jun 2020 16:48:29 +0000 (12:48 -0400)]
configure: remove unused configuration macros
The `PYTHON_PLUGINS` and `ENABLE_DEBUG_INFO` configuration macros aren't
effectively used, remove them.
Change-Id: If965795f24f20aa1e275c829d44c5f9587a8e5fb
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/3622
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Jérémie Galarneau [Wed, 27 May 2020 16:15:54 +0000 (12:15 -0400)]
Fix: src.ctf.lttng-live: incomplete metadata packet is an error
Observed issue
==============
While investigating the issue described in [1], I noticed that
babeltrace2 falls into a retry loop when the src.ctf.lttng-live
component encounters unparseable metadata.
The src.ctf.lttng-live reports parsing errors on every subsequent
reception of a metadata packet. The relay daemon eventually sends
binary data which fails to be decoded, ending the graph's execution
with a binary decoding error, which is not the "real" issue.
Cause
=====
Due to a (now fixed) bug in LTTng [1], unparseable (incomplete)
metadata can be made visible to live clients. This bug fix doesn't
involve the clients; it resulted in an illegal state in the lttng-live
protocol.
When the relay daemon notifies the live client that new metadata is
available, lttng_live_metadata_update() receives all the metadata made
available by the relay daemon in a memory stream and then uses the
ctf_metadata_decoder to append the new content to the existing trace
class.
However, if the decoder returns
`CTF_METADATA_DECODER_STATUS_INCOMPLETE`,
`LTTNG_LIVE_ITERATOR_STATUS_AGAIN` is returned to the caller,
resulting in the graph retrying to invoke the live iterator's `next`
method until another error eventually prevents the successful
completion of the graph.
I am assuming that the use of the `AGAIN` status code may have been a
failed attempt at fixing [1] in the live component rather than
adressing the underlying problem.
Solution
========
To my knowledge there are no provisions made for incomplete metadata
in the lttng-live protocol as of the current version. This may have
been done in anticipation of a future change (?), but it currently
obscures the error reported when a corrupted/incomplete/unparseable
metadata packet is received by the src.ctf.lttng-live component.
The current approach doesn't work anyhow as
lttng_live_metadata_update() creates a "fresh" memory stream on each
invocation. If the intention was to accumulate partial metadata until
it can be successfully parsed, the accumulated metadata would have to
be preserved from one invocation to the next.
The conversion of the status code from `INCOMPLETE` to `AGAIN` is
removed to fail immediately during the current invocation of the
iterator's `next` method.
Drawbacks
=========
None.
References
==========
[1] https://github.com/lttng/lttng-tools/commit/
f5ba75b4f0c0b44092c76bc931b25b24a2e62718
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I8a379ea5d838786a6731199dd5f03bbf70ec13f5
Reviewed-on: https://review.lttng.org/c/babeltrace/+/3586
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Francis Deslauriers [Thu, 4 Jun 2020 19:13:34 +0000 (15:13 -0400)]
Cleanup: debug-info: move all `_FIELD_NAME` defines to the same file
The `VPID_FIELD_NAME` and `IP_FIELD_NAME` are currently defined in both
`debug_info.c` and `debug-info.h`.
This commit regroups all `_FIELD_NAME` defines to the same file for
consistency.
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I5afd805506beb91512cb855566c475d03ed333f6
Reviewed-on: https://review.lttng.org/c/babeltrace/+/3615
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Francis Deslauriers [Thu, 4 Jun 2020 18:58:55 +0000 (14:58 -0400)]
Cleanup: debug-info: remove include indirection
- Include `babeltrace.h` to use the `bt_field_class` definition directly
instead of relying on `trace-ir-mapping.h`'s inclusion.
- Include `debug-info.h` to use `IP_FIELD_NAME` and `VPID_FIELD_NAME`
defines.
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I16d9614f6bdb405e02c2d9f4ee18e02013d1c919
Reviewed-on: https://review.lttng.org/c/babeltrace/+/3614
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Jérémie Galarneau [Tue, 2 Jun 2020 15:11:14 +0000 (11:11 -0400)]
Tests: src.ctf.lttng-live: add discarded packets inactivity test
Add a test to ensure that inactivity beacon sent during the
period of a `Discarded packets` message does not violate the
monotonicity guarantees of the graph.
A new indexed trace is added to the test traces. It was generated
by the following source:
import bt2
bt2.register_plugin(__name__, "builder")
class SourceIter(bt2._UserMessageIterator):
def __init__(self, config, output_port):
ec = output_port.user_data
sc = ec.stream_class
tc = sc.trace_class
trace = tc()
stream = trace.create_stream(sc)
pkt1 = stream.create_packet()
pkt8 = stream.create_packet()
self._msgs = [
self._create_stream_beginning_message(stream),
self._create_packet_beginning_message(pkt1, default_clock_snapshot=0),
self._create_event_message(ec, pkt1, default_clock_snapshot=10),
self._create_packet_end_message(pkt1, default_clock_snapshot=20),
self._create_discarded_packets_message(stream, 7, 20, 121),
self._create_packet_beginning_message(pkt8, default_clock_snapshot=121),
self._create_event_message(ec, pkt8, default_clock_snapshot=133),
self._create_packet_end_message(pkt8, default_clock_snapshot=140),
self._create_stream_end_message(stream),
]
def __next__(self):
if len(self._msgs) > 0:
return self._msgs.pop(0)
else:
raise StopIteration
@bt2.plugin_component_class
class Source(bt2._UserSourceComponent, message_iterator_class=SourceIter):
def __init__(self, config, params, obj):
tc = self._create_trace_class()
cc = self._create_clock_class()
sc = tc.create_stream_class(
default_clock_class=cc,
supports_packets=True,
packets_have_beginning_default_clock_snapshot=True,
packets_have_end_default_clock_snapshot=True,
supports_discarded_packets=True,
discarded_packets_have_default_clock_snapshots=True,
)
ec = sc.create_event_class(name="my-event")
self._add_output_port("some-name", ec)
The index was generated manually.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Iebb34b9cf003d94e4c0a4ee4a530f7d7957d8b0d
Reviewed-on: https://review.lttng.org/c/babeltrace/+/3613
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Jérémie Galarneau [Fri, 5 Jun 2020 19:55:54 +0000 (15:55 -0400)]
Tests: src.ctf.lttng-live: add support for beacon injections
Add a 'beacons' field to the sessions configuration accepted
by lttng_live_server.py. 'beacons' is expected to be a list
of clock snapshots (in cycles) at which live inactivity beacons
should be sent to a live client.
From a protocol standpoint, an inactivity beacon is a "special" type
of index entry. They are inserted in the index list (_entries)
so that they can simply be sent in response to a
LttngLiveViewerGetNextDataStreamIndexEntryCommand in the same
way typical index entries are processed.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I1f86cf369a5115af6787e9a9d52469d16f1ab3aa
Reviewed-on: https://review.lttng.org/c/babeltrace/+/3618
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Jérémie Galarneau [Thu, 4 Jun 2020 22:32:32 +0000 (18:32 -0400)]
Fix: source.ctf.lttng-live: muxing failure on clear
Observed issue
==============
The lttng-tools port builds regularly fail on the CI with the following
error:
```
05-28 16:13:52.864 11219 11219 E PLUGIN/SRC.CTF.LTTNG-LIVE next_stream_iterator_for_trace@lttng-live.c:1067 [lttng-live] Message's timestamp is less than lttng-live's message iterator's last returned timestamp: lttng-live-msg-iter-addr=0xd810220dd30, ts=
1590696831733594090, last-msg-ts=
1590696832514058899
05-28 16:13:52.864 11219 11219 E PLUGIN/SRC.CTF.LTTNG-LIVE lttng_live_msg_iter_next@lttng-live.c:1502 [lttng-live] Error preparing the next batch of messages: live-iter-status=LTTNG_LIVE_ITERATOR_STATUS_ERROR
05-28 16:13:52.864 11219 11219 W LIB/MSG-ITER bt_message_iterator_next@iterator.c:868 Component input port message iterator's "next" method failed: iter-addr=0xd810221c7c0, iter-upstream-comp-name="lttng-live", iter-upstream-comp-log-level=WARNING, iter-upstream-comp-class-type=SOURCE, iter-upstream-comp-class-name="lttng-live", iter-upstream-comp-class-partial-descr="Connect to an LTTng relay daemon", iter-upstream-port-type=OUTPUT, iter-upstream-port-name="out", status=ERROR
05-28 16:13:52.864 11219 11219 W LIB/GRAPH consume_graph_sink@graph.c:466 Component's "consume" method failed: status=ERROR, comp-addr=0xd81022373a0, comp-name="sink.text.details", comp-log-level=WARNING, comp-class-type=SINK, comp-class-name="details", comp-class-partial-descr="Print messages with details.", comp-class-is-frozen=0, comp-class-so-handle-addr=0xd8102233ca0, comp-class-so-handle-path="/tmp/debug_jgalar/build/usr/lib/babeltrace2/plugins/babeltrace-plugin-text.so", comp-input-port-count=1, comp-output-port-count=0
05-28 16:13:52.865 11219 11219 E CLI cmd_run@babeltrace2.c:2530 Graph failed to complete successfully
ERROR: [Babeltrace CLI] (babeltrace2.c:2530)
Graph failed to complete successfully
CAUSED BY [libbabeltrace2] (graph.c:466)
Component's "consume" method failed: status=ERROR, comp-addr=0xd81022373a0,
comp-name="sink.text.details", comp-log-level=WARNING, comp-class-type=SINK,
comp-class-name="details", comp-class-partial-descr="Print messages with
details.", comp-class-is-frozen=0, comp-class-so-handle-addr=0xd8102233ca0,
comp-class-so-handle-path="/tmp/debug_jgalar/build/usr/lib/babeltrace2/plugins/babeltrace-plugin-text.so",
comp-input-port-count=1, comp-output-port-count=0
CAUSED BY [libbabeltrace2] (iterator.c:868)
Component input port message iterator's "next" method failed:
iter-addr=0xd810221c7c0, iter-upstream-comp-name="lttng-live",
iter-upstream-comp-log-level=WARNING, iter-upstream-comp-class-type=SOURCE,
iter-upstream-comp-class-name="lttng-live",
iter-upstream-comp-class-partial-descr="Connect to an LTTng relay daemon",
iter-upstream-port-type=OUTPUT, iter-upstream-port-name="out", status=ERROR
CAUSED BY [lttng-live: 'source.ctf.lttng-live'] (lttng-live.c:1502)
Error preparing the next batch of messages:
live-iter-status=LTTNG_LIVE_ITERATOR_STATUS_ERROR
CAUSED BY [lttng-live: 'source.ctf.lttng-live'] (lttng-live.c:1067)
Message's timestamp is less than lttng-live's message iterator's last returned
timestamp: lttng-live-msg-iter-addr=0xd810220dd30, ts=
1590696831733594090,
last-msg-ts=
1590696832514058899
```
The test that ends up with this error performs a session `clear`
while tracing an application as part of a "live" session.
Cause
=====
Given the following trace,
| pkt seq:0 |<-------discarded packets------>| pkt seq:8 |
0 20 121 140
a CTF source is expected to introduce a "Discarded Packets" message
between packets 0 and 8. The begin and end timestamps of such a message
are synthesized from the timestamps of the last known packet (seq:0)
and the newly decoded packet (seq:8).
For instance, here the Discarded Packets message would have the bounds
[pkt0.end_ts, pkt8.begin_ts].
In the context of a live source, the tracer could report an inactivity
period during the interval of the "Discarded packets" message.
Those live protocol messages eventually translate into an "Iterator
Inactivity" message with a timestamp set at the end of the inactivity
period.
If the tracer reports an inactivity period that ends at a point
between pkt0 and pkt8 (resulting in an "Iterator Inactivity" message),
the live source will send a "Discarded Packets" message that starts
before the preceding "Iterator Inactivity" message, breaking the
monotonicity constraint of the graph.
This happens regularly when `clear` is used on an LTTng live session as
it effectively discards packets, something that would otherwise not
happen (before LTTng 2.12) as most users set their tracing channels in
"discard" mode (the default for that session type).
However, the same problem as described above applies to "Discarded
Events" messages and could occur with older LTTng versions.
Solution
========
"Discarded Events" and Discarded Packets" messages are intercepted
in the lttng-live source's "muxer" and are _adjusted_ so that
they honor the monotonicity guarantee of the graph.
In effect, whenever such a message is seen to have a begin timestamp
that is _before_ the last inactivity timestamp, its begin timestamp
is adjusted to the last inactivity timestamp's value.
From a correctness standpoint, this is okay. If the tracer notified the
relay daemon of an inactivity period on a stream, we can rely on the
fact that no data was produced during that time to affirm that no
packets where lost during that time either.
A test reproducing the "Discarded Packets" scenatio described in
this message is added in a follow-up patch.
Known drawbacks
===============
None.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ia8f32ba6717b33203637bf8d5aa34ff2a78c3e7f
Reviewed-on: https://review.lttng.org/c/babeltrace/+/3616
Tested-by: jenkins <jenkins@lttng.org>
Jérémie Galarneau [Mon, 1 Jun 2020 22:53:45 +0000 (18:53 -0400)]
Fix: source.ctf.fs: 0-length packet index length causes SIGFPE
A corrupted index can present a 0-length packet index length
which will result in a division by 0 when computing the index
entry count.
Program terminated with signal SIGFPE, Arithmetic exception.
#0 0x00007f6ecbd44978 in build_index_from_idx_file (ds_file=0x561ade51ca00, file_info=0x561ade51d000,
msg_iter=0x561ade51cd00) at data-stream-file.c:640
640 file_entry_count = (filesize - sizeof(*header)) / file_index_entry_size;
The index packet length is checked against the smallest valid size:
the size of an index entry as of the 1.0 CTF index version.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I83c705575d55f3b56ae413d1ce5ae0fc60121f2c
Reviewed-on: https://review.lttng.org/c/babeltrace/+/3606
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Jérémie Galarneau [Tue, 2 Jun 2020 19:35:55 +0000 (15:35 -0400)]
Tests: src.ctf.lttng-live: use JSON description for sessions
In preparation for a follow-up commit introducing live beacons
to insert within a stream's indexes, transition from the current session
description string format to a JSON-based description.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I08642f95888550de94bd7bddcf4b1e2e875b1a25
Reviewed-on: https://review.lttng.org/c/babeltrace/+/3605
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Jérémie Galarneau [Tue, 2 Jun 2020 16:23:41 +0000 (12:23 -0400)]
Tests: whitespace fix in src.ctf.lttng-live/test_live
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I6ca6c61013421b4c8456413db14bbd7971a0edb1
Reviewed-on: https://review.lttng.org/c/babeltrace/+/3604
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Simon Marchi [Wed, 22 Apr 2020 21:13:08 +0000 (17:13 -0400)]
Fix: lib: use appropriate format specifier to print message iterator class
Running
babeltrace2 --debug /some/trace
... results in the following crash:
==31705==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7f5b9c25ae22 bp 0x7ffc64114490 sp 0x7ffc64113ba8 T0)
==31705==The signal is caused by a READ memory access.
==31705==Hint: address points to the zero page.
#0 0x7f5b9c25ae21 (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xfce21)
#1 0x7f5b9c1d231f (/usr/lib/x86_64-linux-gnu/libasan.so.4+0x7431f)
#2 0x7f5b9c1fef4d in __interceptor_vsnprintf (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xa0f4d)
#3 0x7f5b9c1ff286 in snprintf (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xa1286)
#4 0x7f5b9bdf61c3 in format_component_class /home/smarchi/src/babeltrace/src/lib/lib-logging.c:1061
#5 0x7f5b9bdfad46 in handle_conversion_specifier_bt /home/smarchi/src/babeltrace/src/lib/lib-logging.c:1451
#6 0x7f5b9bead260 in bt_common_custom_vsnprintf /home/smarchi/src/babeltrace/src/common/common.c:1727
#7 0x7f5b9bdfb10b in bt_lib_log /home/smarchi/src/babeltrace/src/lib/lib-logging.c:1496
#8 0x7f5b9be32965 in bt_message_iterator_class_set_seek_beginning_methods /home/smarchi/src/babeltrace/src/lib/graph/message-iterator-class.c:138
...
This is due to an object being printed with the wrong format specifier.
`C` is for component class objects, use `I` instead, since we are
printing a message iterator object.
Change-Id: Ie3985d8b7c4e02ac7d09aee84bfe46ea4bab87e9
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/3450
Reviewed-by: Geneviève Bastien <gbastien@versatic.net>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Philippe Proulx [Wed, 22 Apr 2020 21:18:38 +0000 (17:18 -0400)]
Fix: lib: BT_ASSERT_PRE_NON_NULL_FROM_FUNC(): change `: ` -> `.` in msg.
This changes, for example,
...
Error is:
Value object is NULL:
Aborting...
to
...
Error is:
Value object is NULL.
Aborting...
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ic122d50f5cb88dd72978d5dd8e2e4b22ee965a3e
Reviewed-on: https://review.lttng.org/c/babeltrace/+/3451
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
Philippe Proulx [Tue, 14 Apr 2020 01:38:22 +0000 (21:38 -0400)]
tests: add libbabeltrace2 pre/postcondition testing infrastructure
This patch adds a basic libbabeltrace2 pre/postcondition testing
infrastructure to the project.
When a libbabeltrace2 public function precondition or postcondition is
not satisfied, the function logs a FATAL-level message which indicates
what's wrong and then aborts. Slow path functions check such conditions
unconditionally, while fast path functions check them only in developer
mode.
Testing that a libbabeltrace2 function catches an unsatisfied
pre/postcondition and reports it is not straightforward: the library
aborts the program, so we can't use the usual approach because the test
program itself would abort.
The solution brought by this patch is the following process in
`tests/lib/conds`:
1. The `conds-triggers.c` program contains all the pre/postcondition
failure triggering instructions to test, one condition per function.
Each triggering function triggers a single pre/postcondition check.
It is expected that the function actually aborts.
main() calls ppc_main(), an internal utility, with its command-line
arguments and an array of condition trigger descriptors.
Each condition trigger descriptor has:
* A condition type: precondition or postcondition.
* The ID of the condition to trigger.
* A name suffix.
* A condition triggering function.
Each condition trigger descriptor has a unique name: its condition ID
and an optional name suffix.
As of this patch, the PPC_TRIGGER_*_RUN_IN_COMP_CLS_INIT() macros
create condition trigger descriptors of which the function runs
within a component class initialization function (accepts a
`bt_self_component *` parameter). This is often needed as many
libbabeltrace2 functions are only accessible through a self component
(all the trace IR API, for example).
ppc_main() handles two command-line subcommands:
`list`:
Prints a JSON array of objects which represent the triggering
descriptors, for example (output for this patch):
[
{
"cond-id": "pre:field-class-integer-set-field-value-range:valid-n",
"name": "pre:field-class-integer-set-field-value-range:valid-n-0"
},
{
"cond-id": "pre:field-class-integer-set-field-value-range:valid-n",
"name": "pre:field-class-integer-set-field-value-range:valid-n-gt-64"
},
{
"cond-id": "pre:field-class-integer-set-field-value-range:not-null:field-class",
"name": "pre:field-class-integer-set-field-value-range:not-null:field-class"
}
]
`run INDEX`:
Runs the condition triggering function for the descriptor at
index `INDEX` in the `list` array.
It is expected that this command aborts.
2. `test_conds` is a Bash script which only does this:
reldir=lib/conds
export BT_TESTS_LIB_CONDS_TRIGGER_BIN="$BT_TESTS_BUILDDIR/$reldir/conds-triggers"
if [ "$BT_OS_TYPE" = "mingw" ]; then
BT_TESTS_LIB_CONDS_TRIGGER_BIN="$BT_TESTS_LIB_CONDS_TRIGGER_BIN.exe"
fi
run_python_bt2_test "$BT_TESTS_SRCDIR/$reldir" test.py
In other words, it runs the Python TAP test runner to discover and
run tests in `test.py`.
This script is part of the `make check` test set.
3. In `test.py`, a function:
a) Runs `conds-triggers list` and decodes the output to get the list
of available condition trigger descriptors.
This step also validates the regular expressions and checks that
there are no duplicate descriptor names.
b) For each condition trigger descriptor, creates and adds a test to
its single test case class which:
I. Executes `conds-triggers run INDEX` as a subprocess,
where `INDEX` is the descriptor's index.
II. Reads the complete process's standard error.
III. Asserts that the process aborts (`SIGABRT` signal).
This seems to be only possible on a POSIX system with the
`subprocess.Popen` API.
IV. Asserts that the standard error (II) contains the
descriptor's condition ID.
All this is only enabled if, at configuration time:
* Python 3 is available.
* The Babeltrace 2 developer mode is enabled (`BABELTRACE_DEV_MODE=1`).
This patch's `conds-triggers.c` includes two precondition triggering
functions to confirm that everything works as expected:
trigger_fc_int_set_field_value_range_n_0():
When calling bt_field_class_integer_set_field_value_range(), the
parameter `N` cannot be greater than 64.
trigger_fc_int_set_field_value_range_n_gt_64():
When calling bt_field_class_integer_set_field_value_range(), the
parameter `N` cannot be 0.
trigger_fc_int_set_field_value_range_null():
When calling bt_field_class_integer_set_field_value_range(), the
field class cannot be `NULL`.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I70713d690f7dbfeac5804e6cfcec989242823611
Reviewed-on: https://review.lttng.org/c/babeltrace/+/3401
Philippe Proulx [Tue, 21 Apr 2020 15:15:42 +0000 (11:15 -0400)]
lib: assign a unique ID to each pre/postcond. and report it on failure
This patch changes the libbabeltrace2 pre/postcondition assertion macros
so that each precondition and postcondion has a unique ID within the
library.
The macros report (log with a FATAL level) the condition ID on assertion
failure as such (logging prefixes removed):
Babeltrace 2 library precondition not satisfied.
------------------------------------------------------------------------
Condition ID: `pre:field-class-integer-set-field-value-range:valid-n`.
Function: bt_field_class_integer_set_field_value_range().
------------------------------------------------------------------------
Error is:
Unsupported size for integer field class's field value range
(minimum is 1, maximum is 64): size=65
Aborting...
The main goal of this change is to make it easier to test library
precondition and postcondition assertions: now you only need to confirm
that the log indicates the expected condition ID, making the details
("Unsupported size for [...]" in the example above) unimportant.
The condition IDs could also exist in the documentation so as to make it
easier to search for libbabeltrace2 pre/postcondition documentation when
failing to satisfy one.
The general condition ID format is:
TYPE:FUNC:SUFFIX
with
`TYPE`:
`pre` or `post`.
`FUNC`:
Name of the API function (precondition) or user function type
(postcondition) without the `bt_` prefix and with `_` replaced with
`-`.
`SUFFIX`:
With the scope of the function: unique, specific precondition or
postcondition ID.
The BT_ASSERT_PRE_FROM_FUNC() macro (and its developer mode counterpart)
accepts a function name and an ID suffix.
The BT_ASSERT_PRE() macro (and its developer mode counterpart) only
accepts an ID suffix: it uses BT_ASSERT_PRE_FROM_FUNC() with `__func__`
as the function name.
All the other precondition assertion macros follow the same scheme:
`_FROM_FUNC` suffix for a specific function, no suffix for the current
function.
Many precondition assertion macros in `assert-cond.h` build a complete
ID suffix based on a part of it. For example, BT_ASSERT_PRE_NON_NULL()
accepts an object ID, so that
BT_ASSERT_PRE_NON_NULL("description", descr, "Description");
has the condition ID, when used from the hypothetical public function
bt_do_xyz(), `pre:do-xyz:not-null:description`.
It is imperative that the used API function name is always the one the
user called. Knowing this, internal, static functions _cannot_ use
BT_ASSERT_PRE() because the reported function name would be the internal
one. Not only is this confusing for the library user, it could also
change in the future.
This patch uses two strategies to deal with this constraint depending
on the intended execution path of the public function:
Slow path:
The common (internal) function accepts an `api_func` parameter which
is the ultimate public API function name.
The common function only uses precondition assertion macros which
end with `_FROM_FUNC`.
A public function which calls this common function passes `__func__`
as its `api_func` parameter.
Fast path:
We define (locally) a new macro which uses the required precondition
assertion macros (the variants without `_FROM_FUNC`).
A public function which calls the common function uses the custom
macro.
Postconditions are checked when a user function returns. Therefore, the
function name in that case is the user function type name.
BT_ASSERT_POST() accepts a function name and an ID suffix.
_BT_ASSERT_COND() calls the internal bt_lib_assert_cond_failed() which
formats the condition ID, prints it and the function name, prints the
details, and aborts.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I8bfab8c90cd1c18215fc0738f0b9504130f48b45
Reviewed-on: https://review.lttng.org/c/babeltrace/+/3435
Philippe Proulx [Tue, 21 Apr 2020 14:56:20 +0000 (10:56 -0400)]
lib: add bt_lib_log_v()
This is a `va_list` (vprintf() style) version of bt_lib_log().
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I41dc0e247c79e8f22cc930b27ec4f13a2dd6d573
Reviewed-on: https://review.lttng.org/c/babeltrace/+/3441
Philippe Proulx [Tue, 21 Apr 2020 14:42:13 +0000 (10:42 -0400)]
lib: rename BT_ASSERT_PRE_BEGIN_LE_END() -> BT_..._MSG_CS_BEGIN_LE_END()
This adds a namespace as BT_ASSERT_PRE_MSG_CS_BEGIN_LE_END() is now part
of the common `assert-cond.h` header.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I5f3197a41b240f58fb7da5518053c792aab5da9d
Reviewed-on: https://review.lttng.org/c/babeltrace/+/3440
Philippe Proulx [Thu, 16 Apr 2020 17:13:11 +0000 (13:13 -0400)]
lib: use common precond. assert. macros from `assert-cond.h` thru lib
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Iad421161d61079f8777c4d75232e523a59f9120c
Reviewed-on: https://review.lttng.org/c/babeltrace/+/3434
Philippe Proulx [Tue, 21 Apr 2020 14:27:48 +0000 (10:27 -0400)]
lib: rename *_IS_TYPE() and *_HAS_ID() macros -> *_HAS_TYPE()
This is to normalize this type of macro.
Since those macros check that a given object _has_ a given type, I
believe "has" makes more sense than "is" (you pass the instance, not the
type).
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I8b77443c3675d94ffc796b97eca2f773b71832db
Reviewed-on: https://review.lttng.org/c/babeltrace/+/3439
Philippe Proulx [Thu, 16 Apr 2020 17:12:55 +0000 (13:12 -0400)]
lib: commonize some precondition assertion macros
1. Rename `assert-cond.h` to `assert-cond-base.h`.
2. Move common specialized pre/postcondition macros from
`assert-cond-base.h` to `assert-cond.h`.
Now `assert-cond-base.h` only contains the very basic
pre/postcondition assertion macros.
3. Move common specialized macros from various internal header files to
`assert-cond.h`.
4. Add new common specialized macros to `assert-cond.h`, mostly "non
null" precondition assertion macros.
The goal of this patch is to make it easy to change code for many sites
at the same time when those sites use the same macro.
This patch introduces the common precondition assertion macros, but
does not use them in source files (future patch).
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I2456e459bab9d942e4e11953b4afc5a6f4d30620
Reviewed-on: https://review.lttng.org/c/babeltrace/+/3433
Philippe Proulx [Thu, 16 Apr 2020 14:00:55 +0000 (10:00 -0400)]
lib: move bt_graph_configure() to `graph.c` (only used there)
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I097f61f1e64d9e83d929980f5224b429e6202eb5
Reviewed-on: https://review.lttng.org/c/babeltrace/+/3432
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Philippe Proulx [Thu, 16 Apr 2020 13:58:08 +0000 (09:58 -0400)]
Fix: lib: bt_component_class_sink_simple_borrow() is internal
My guess is that at some point the intention was to have the user borrow
the simple sink component class and call bt_graph_add_sink_component()
herself but that's not how it works now:
bt_graph_add_simple_sink_component() calls
bt_component_class_sink_simple_borrow() internally.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I77e10d43a2d90ea4b99c7c7fc09606cbf2ffbe41
Reviewed-on: https://review.lttng.org/c/babeltrace/+/3431
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
Philippe Proulx [Thu, 16 Apr 2020 13:53:01 +0000 (09:53 -0400)]
lib: object.h: convert precondition assertions to internal assertions
The `object.h` API is completely internal.
We used to have only two public reference counting modification
functions (to get and put references), but since
c5b9b4417 ("lib: make
public reference count functions have strict types"), each shared object
type has its own reference counting modification functions. Therefore
it's impossible that bt_object_get_ref() or bt_object_put_ref() be
called with a unique object without at least getting a compiler warning.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I80286144f3f29af933694d5e824473abd7ec9103
Reviewed-on: https://review.lttng.org/c/babeltrace/+/3430
Philippe Proulx [Thu, 16 Apr 2020 12:55:56 +0000 (08:55 -0400)]
lib: move code only used by create_event() to `message/event.c`
Those functions, bt_event_set_packet() and bt_event_set_stream(), used
to exist in the Babeltrace 1 to 2 transition. But now it seems like
they're internal and only used by the also internal create_event().
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Id9087e802af3aca76de6dd89abf73b3d75c848ea
Reviewed-on: https://review.lttng.org/c/babeltrace/+/3429
Philippe Proulx [Wed, 15 Apr 2020 20:47:18 +0000 (16:47 -0400)]
lib: merge `assert-pre.h` and `assert-post.h` into `assert-cond.h`
Merge both files into a single one to make it possible to reuse code.
Specific `BT_ASSERT_PRE*` and `BT_ASSERT_POST*` macros which were
identical are merged into a single one with the `BT_ASSERT_COND*` prefix
now.
No functional changes intended.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I019bcc73d5c644012238775c16b6498d07931a9a
Reviewed-on: https://review.lttng.org/c/babeltrace/+/3428
Simon Marchi [Wed, 15 Apr 2020 01:23:52 +0000 (21:23 -0400)]
Fix: sink.text.pretty: assign status at the end of pretty_consume
The compiler on SLES 12 reports:
pretty.c:200:2: warning: 'status' may be used uninitialized in this function [-Wmaybe-uninitialized]
return status;
^
We are indeed missing an assignment of status at the end, if everything
went well. In practice, status has the right value (_OK) from the last
call of handle_message. But if, for some reason,
bt_message_iterator_next returns OK with 0 messages, then it would stay
unset. So assigning it explicitly at the end doesn't hurt.
Change-Id: Ic3bf018388f006c919173f9e8942a8ab2384c0f1
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/3427
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Simon Marchi [Tue, 14 Apr 2020 18:28:23 +0000 (14:28 -0400)]
sink.text.pretty: append error causes where applicable
Change-Id: I34a01f4647538ec09b26588335a708ff0e739fa8
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/3407
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
Simon Marchi [Tue, 14 Apr 2020 18:33:24 +0000 (14:33 -0400)]
sink.text.pretty: simplify error handling in pretty_consume
Replace the switch with a simple condition. On _END, it is not
necessary to put the message iterator, that will be done in
pretty_finalize.
Change-Id: Ia0bd20e0d119cae155c03cc5d7656a5c4619ebb8
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/3406
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Simon Marchi [Tue, 14 Apr 2020 17:02:00 +0000 (13:02 -0400)]
sink.text.pretty: update logging macros
Change the logging macros to be more in sync with how it's done in other
component classes of the project
Add the `self_comp` and `log_level` fields to the pretty_component
structure, and change the BT_COMP_LOG_SELF_COMP and BT_LOG_OUTPUT_LEVEL
to assume there's always a pointer to such a structure named `pretty`.
Change-Id: I6292f3c9b6b7f238e335cfcc90259a1f0047313d
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/3405
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Tested-by: jenkins <jenkins@lttng.org>
This page took 0.057964 seconds and 4 git commands to generate.