~lttng/babeltrace/trunk

  • Committer: Philippe Proulx
  • Author(s): Simon Marchi
  • Date: 2023-11-22 16:55:42 UTC
  • Revision ID: git-v1:0121936a17b5964dd23e8dc291b1371d59de399f
lib: validate iterator message sequence

Validate that the sequence of messages produced by iterators respects
the sequence defined by the Message Interchange Protocol (MIP) [1].

    Without packets
        SB (E | DE)* SE

    With packets
        SB ((PB (E | DE)* PE) | DE | DP)* SE

Validate that when an iterator returns
BT_MESSAGE_ITERATOR_CLASS_NEXT_METHOD_STATUS_END, all streams are
properly ended (we have received a stream end message for all streams).

Add an expected_msg_types field to the iterator's per_stream_state
structure, which holds a bit mask of the message types the iterator is
allowed to emit next.

Use the cur_packet field that is maintained by
message_packet_is_valid when processing a discarded events message.  We
need to know if we are in a packet or not to determine the following
valid message types (DE appears twice in the "With packets" sequence
above, once within a packet and once outside a packet).

It doesn't matter in which order the two assertions are placed, since
the "sequence is as expected" assertion doesn't use the cur_packet field
when handling the "packet beginning" and "packet end" messages.
However, I think that it is more useful to have the "sequence is as
expected" first.  Some mistakes, like the following sequence where a
packet beginning message is forgotten:

    ... PB E E PE E E PE ...

... would cause both assertions to fail.  But the "sequence is as
expected" assertion points closer to the root cause of the problem than
the "packet is expected" one, which points more to a symptom.  So, if
both assertions would fail, I prefer that we show the "sequence is
as expected" one.

Here's an example of the error message that is printed when an error is
detected.  In this case, a packet beginning message was forgotten.

    Babeltrace 2 library postcondition not satisfied.
    ------------------------------------------------------------------------
    Condition ID: `post:message-iterator-class-next-method:mip-message-sequence-is-expected`.
    Function: bt_message_iterator_class_next_method().
    ------------------------------------------------------------------------
    Error is:
    MIP message sequence is not expected: stream-addr=0x60d000001d80, stream-id=0, iterator-addr=0x611000004c80, iterator-upstream-comp-name="source.gpx.GpxSource", iterator-upstream-comp-log-level=WARNING, iterator-upstream-comp-class-type=SOURCE, iterator-upstream-comp-class-name="GpxSource", iterator-upstream-comp-class-partial-descr="", message-addr=0x607000004540, message-type=EVENT, expected-msg-types=STREAM_END|PACKET_BEGINNING
    Aborting...

[1] https://babeltrace.org/docs/v2.0/libbabeltrace2/group__api-msg.html#api-msg-seq

Change-Id: I25d3ff9b87c551dcced1ba25e0a8525f316a8050
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10450
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Filename Latest Rev Last Changed Committer Comment Size
..
doc 376 11 years ago Mathieu Desnoyers Add babeltrace.1 manpage Signed-off-by: Mathieu D Diff
include 1 13 years ago Mathieu Desnoyers Common Trace Format - initial commit Signed-off-b Diff
LICENSES 4126 3 years ago Philippe Proulx Move to kernel style SPDX license identifiers The Diff
m4 545 11 years ago Mathieu Desnoyers Babeltrace python binding The Babeltrace Python m Diff
src 3138 4 years ago Philippe Proulx Re-organize sources * Create a top-level 'src' d Diff
tests 1 13 years ago Mathieu Desnoyers Common Trace Format - initial commit Signed-off-b Diff
tools 4236 2 years ago Philippe Proulx Add `tools/format-cpp` script The new `format-cpp Diff
version 4074 3 years ago Philippe Proulx common: support custom, extra information for buil Diff
.clang-format 4270 1 year ago Philippe Proulx .clang-format: update for clang-format 13 This pa 3.3 KB Diff Download File
.editorconfig 4377 7 months ago Philippe Proulx Add .editorconfig entry for .h and .c files Chang 260 bytes Diff Download File
.gitignore 4545 1 month ago Philippe Proulx tests: normalize names of files and more The curr 1.5 KB Diff Download File
.gitreview 2989 4 years ago Francis Deslauriers Add git-review config Signed-off-by: Michael Jean 123 bytes Diff Download File
File bootstrap 4224 2 years ago Jérémie Galarneau Fix: bootstrap with autoconf >= 2.70 We want to e 491 bytes Diff Download File
ChangeLog 4079 3 years ago Jérémie Galarneau Release: Babeltrace 2.0.0 "Amqui" Released at lon 4.9 KB Diff Download File
CodingStyle 3392 4 years ago Philippe Proulx Explicitly mention `black` in CodingStyle guidelin 469 bytes Diff Download File
configure.ac 4563 1 month ago Philippe Proulx Reduce the number of Makefiles in 'src/' by one mo 32.7 KB Diff Download File
CONTRIBUTING.adoc 4551 1 month ago Philippe Proulx tools/format-cpp: add `.sh` extension to identify 56.3 KB Diff Download File
dev-requirements.txt 4507 1 month ago Simon Marchi Remove dev-requirements.txt entry for click Since 44 bytes Diff Download File
LICENSE 4506 1 month ago Philippe Proulx Add `tests/utils/python/normand.py` (Normand 0.23) 2.2 KB Diff Download File
Makefile.am 4591 15 days ago Michael Jeanson Add SPDX info for `tests/utils/python/typing/typin 675 bytes Diff Download File
pyproject.toml 4506 1 month ago Philippe Proulx Add `tests/utils/python/normand.py` (Normand 0.23) 582 bytes Diff Download File
README.adoc 4406 3 months ago Michael Jeanson Bump minimum supported automake version to 1.13 s 9.1 KB Diff Download File
setup.cfg 4531 1 month ago Philippe Proulx tests: add moultipart.py Add moultipart.py, a Pyt 565 bytes Diff Download File
std-ext-lib.txt 1 13 years ago Mathieu Desnoyers Common Trace Format - initial commit Signed-off-b 1.9 KB Diff Download File