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

Validate that messages coming out of iterators have sensible packet
values.  This applies to event and packet end messages: their packet
must match the packet of the previous packet beginning message.

Add a hash table to hold per-stream state, inside the
bt_message_iterator structure.  Since this state will only be used for
dev assertions, for the moment, only create it if BT_DEV_MODE is

Discard the per-stream state when the iterator seeks (after which the
iterator is expected to produce a new message sequence, starting from

If the iterator uses auto-seek to implement "seek ns from origin", we
need to discard the per-stream state twice: once after seeking the
beginning, and once after consuming messages until the desired point.

When a wrong packet is detected, print an error logging message with
some details, before the failed assertion message:

    Babeltrace 2 library postcondition not satisfied.
    Condition ID: `post:message-iterator-class-next-method:message-packet-is-expected`.
    Function: bt_message_iterator_class_next_method().
    Error is:
    Message's packet 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, received-packet-addr=0x607000004310, expected-packet-addr=(nil)

The particular structure of the code is explained by the following
patch, which adds verification that the message sequence is as expected.
Both assertions (packet is expected, and message sequence is as
expected) need to know about the current packet (this state is
maintained by message_packet_is_valid), so must be in the same "for all
messages" loop.  Alternatively, they could both track the current packet
independently, but that would be redundant.

But this form also allows putting more info about the problematic
message in the abort notice, which I think is nice.

Change-Id: I176417d9ae7b04a9c16ff975e008e208b173e3d2
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10448
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Filename Latest Rev Last Changed Committer Comment Size
doc 376 12 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 4 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 4 years ago Philippe Proulx common: support custom, extra information for buil Diff
.clang-format 4270 2 years ago Philippe Proulx .clang-format: update for clang-format 13 This pa 3.3 KB Diff Download File
.editorconfig 4377 11 months ago Philippe Proulx Add .editorconfig entry for .h and .c files Chang 260 bytes Diff Download File
.gitignore 4545 5 months 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 3 years ago Jérémie Galarneau Fix: bootstrap with autoconf >= 2.70 We want to e 491 bytes Diff Download File
ChangeLog 4079 4 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 5 months ago Philippe Proulx Reduce the number of Makefiles in 'src/' by one mo 32.7 KB Diff Download File
CONTRIBUTING.adoc 4551 5 months ago Philippe Proulx tools/format-cpp: add `.sh` extension to identify 56.3 KB Diff Download File
dev-requirements.txt 4507 6 months ago Simon Marchi Remove dev-requirements.txt entry for click Since 44 bytes Diff Download File
LICENSE 4506 6 months ago Philippe Proulx Add `tests/utils/python/normand.py` (Normand 0.23) 2.2 KB Diff Download File
Makefile.am 4591 4 months ago Michael Jeanson Add SPDX info for `tests/utils/python/typing/typin 675 bytes Diff Download File
pyproject.toml 4506 6 months ago Philippe Proulx Add `tests/utils/python/normand.py` (Normand 0.23) 582 bytes Diff Download File
README.adoc 4406 7 months ago Michael Jeanson Bump minimum supported automake version to 1.13 s 9.1 KB Diff Download File
setup.cfg 4531 5 months 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